@pubnio/sdk 0.3.0 → 0.5.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
@@ -505,18 +505,22 @@ var PublishPlacement = import_effect8.Schema.Literals([
505
505
  var ScheduleOverride = import_effect8.Schema.Union([ScheduledAt, import_effect8.Schema.Null]);
506
506
  var DestinationSelection = import_effect8.Schema.Struct({
507
507
  accountId: AccountId,
508
- placement: PublishPlacement,
508
+ placement: import_effect8.Schema.optionalKey(PublishPlacement).annotate({
509
+ description: "Omit to select the draft's only destination for this account."
510
+ }),
509
511
  scheduledAt: import_effect8.Schema.optionalKey(ScheduleOverride),
510
512
  queueId: import_effect8.Schema.optionalKey(uuid2)
511
513
  }).annotate({ identifier: "DestinationSelection" });
512
514
  var PublishInput = import_effect8.Schema.Struct({
513
- expectedRevision: PublishRevision,
515
+ expectedRevision: import_effect8.Schema.optionalKey(PublishRevision).annotate({
516
+ description: "Publish only if the draft is still at this revision. Omit to publish the saved draft as it is."
517
+ }),
514
518
  scheduledAt: import_effect8.Schema.optionalKey(ScheduledAt),
515
- accountIds: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
519
+ accounts: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
516
520
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
517
521
  })),
518
522
  targets: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(DestinationSelection).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
519
- description: "Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."
523
+ description: "Select exact draft destinations and optionally override each schedule. Omit accounts when using targets."
520
524
  }))
521
525
  });
522
526
  var PostRef = import_effect8.Schema.Struct({ postId: PostId });
@@ -743,7 +747,9 @@ var BillingPlan = import_effect9.Schema.Struct({
743
747
  includedXReadMicros: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
744
748
  seatsLimit: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
745
749
  analyticsRetentionDays: import_effect9.Schema.Int,
746
- whiteLabelOAuth: import_effect9.Schema.Boolean,
750
+ whiteLabelOAuth: import_effect9.Schema.Boolean.annotate({
751
+ description: "Reserved for branded connect pages and your own provider apps. Neither is available yet."
752
+ }),
747
753
  ssoSaml: import_effect9.Schema.Boolean,
748
754
  priorityQueue: import_effect9.Schema.Boolean,
749
755
  adsInsights: import_effect9.Schema.Boolean,
@@ -2825,23 +2831,20 @@ var postText = import_effect18.Schema.Trim.check(import_effect18.Schema.isMaxLen
2825
2831
  description: `At most ${postTextLimit} characters after trimming.`
2826
2832
  }));
2827
2833
  var postTargets = import_effect18.Schema.Array(PublishTarget).check(import_effect18.Schema.isMaxLength(50));
2828
- var postContent = {
2834
+ var PostContent = import_effect18.Schema.Struct({
2829
2835
  text: import_effect18.Schema.optionalKey(postText),
2830
2836
  targets: import_effect18.Schema.optionalKey(postTargets),
2831
- media: import_effect18.Schema.optionalKey(MediaInputs)
2832
- };
2833
- var PostContent = import_effect18.Schema.Struct(postContent).annotate({
2834
- identifier: "PostContent"
2835
- });
2836
- var PostPreflight = import_effect18.Schema.Struct({
2837
- ...postContent,
2837
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2838
2838
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt)
2839
- }).annotate({ identifier: "PostPreflight" });
2840
- var CreatePost = import_effect18.Schema.Struct({
2841
- text: import_effect18.Schema.optionalKey(postText),
2839
+ }).annotate({ identifier: "PostContent" });
2840
+ var destinationSelectors = {
2842
2841
  platforms: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(Provider).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2843
2842
  accounts: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(AccountId).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2844
- targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2843
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit)))
2844
+ };
2845
+ var CreatePost = import_effect18.Schema.Struct({
2846
+ text: import_effect18.Schema.optionalKey(postText),
2847
+ ...destinationSelectors,
2845
2848
  media: import_effect18.Schema.optionalKey(MediaInputs),
2846
2849
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt),
2847
2850
  publishNow: import_effect18.Schema.optionalKey(import_effect18.Schema.Boolean),
@@ -2849,12 +2852,18 @@ var CreatePost = import_effect18.Schema.Struct({
2849
2852
  description: "Save the post as a draft without submitting it. Defaults to false."
2850
2853
  })
2851
2854
  }).annotate({ identifier: "CreatePost" }).annotate({
2852
- 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."
2855
+ 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."
2853
2856
  });
2854
2857
  var UpdatePost = import_effect18.Schema.Struct({
2855
- ...postContent,
2858
+ text: import_effect18.Schema.optionalKey(postText),
2859
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2860
+ scheduledAt: import_effect18.Schema.optionalKey(ScheduleOverride),
2861
+ ...destinationSelectors,
2862
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMaxLength(publishTargetLimit))),
2856
2863
  expectedRevision: import_effect18.Schema.optionalKey(revision)
2857
- }).annotate({ identifier: "UpdatePost" });
2864
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2865
+ 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."
2866
+ });
2858
2867
  var Post = import_effect18.Schema.Struct({
2859
2868
  postId: PostId,
2860
2869
  isDraft: import_effect18.Schema.Boolean,
@@ -2862,6 +2871,9 @@ var Post = import_effect18.Schema.Struct({
2862
2871
  text: postText,
2863
2872
  media: MediaInputs,
2864
2873
  targets: postTargets,
2874
+ scheduledAt: import_effect18.Schema.NullOr(ScheduledAt).annotate({
2875
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2876
+ }),
2865
2877
  deliveries: import_effect18.Schema.Array(DeliveryStatus),
2866
2878
  status: PostState,
2867
2879
  createdAt: import_effect18.Schema.String,
@@ -5461,6 +5473,17 @@ class DestinationAlreadySubmitted extends import_http_api.HttpApiError.Problem()
5461
5473
  }) {
5462
5474
  }
5463
5475
 
5476
+ class PostSubmitted extends import_http_api.HttpApiError.Problem()("PostSubmitted", {
5477
+ type: "urn:pubnio:problem:post-submitted",
5478
+ status: 409,
5479
+ title: "Post already submitted"
5480
+ }, {
5481
+ code: import_effect28.Schema.Literal("post_submitted"),
5482
+ targetIds: import_effect28.Schema.Array(TargetId),
5483
+ nextAction: import_effect28.Schema.String
5484
+ }) {
5485
+ }
5486
+
5464
5487
  class DeliveryNotRetryable extends import_http_api.HttpApiError.Problem()("DeliveryNotRetryable", {
5465
5488
  type: "urn:pubnio:problem:delivery-not-retryable",
5466
5489
  status: 409,
@@ -5966,6 +5989,7 @@ var PublishProblems = [
5966
5989
  AttemptChanged,
5967
5990
  IdempotencyConflict,
5968
5991
  DestinationAlreadySubmitted,
5992
+ PostSubmitted,
5969
5993
  DeliveryNotRetryable,
5970
5994
  DeliveryNotReconcilable,
5971
5995
  DeliveryScheduleLocked,
@@ -6424,7 +6448,7 @@ var import_http = require("effect/http");
6424
6448
  // package.json
6425
6449
  var package_default = {
6426
6450
  name: "@pubnio/sdk",
6427
- version: "0.3.0",
6451
+ version: "0.5.0",
6428
6452
  description: "JavaScript and TypeScript client for the PubNio API",
6429
6453
  type: "module",
6430
6454
  exports: {
@@ -8952,7 +8976,7 @@ function createPubNioClient({
8952
8976
  return withIdempotencyKey(idempotencyKey, async () => {
8953
8977
  const body = post;
8954
8978
  if (post.isDraft) {
8955
- return decode(Post, postsCreate({
8979
+ return decode(PostCreated, postsCreate({
8956
8980
  client,
8957
8981
  query: { workspaceId },
8958
8982
  headers: { "idempotency-key": idempotencyKey },
@@ -9646,7 +9670,7 @@ function createPubNioClient({
9646
9670
  ...transport()
9647
9671
  }));
9648
9672
  },
9649
- publish: (postId, input) => {
9673
+ publish: (postId, input = {}) => {
9650
9674
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9651
9675
  return withIdempotencyKey(idempotencyKey, async () => {
9652
9676
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9657,7 +9681,7 @@ function createPubNioClient({
9657
9681
  body: {
9658
9682
  expectedRevision: publish.expectedRevision,
9659
9683
  scheduledAt: publish.scheduledAt,
9660
- accountIds: publish.accountIds && [...publish.accountIds],
9684
+ accounts: publish.accounts && [...publish.accounts],
9661
9685
  targets: publish.targets && [...publish.targets]
9662
9686
  },
9663
9687
  ...transport()