@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/internal.js CHANGED
@@ -465,18 +465,22 @@ var PublishPlacement = Schema8.Literals([
465
465
  var ScheduleOverride = Schema8.Union([ScheduledAt, Schema8.Null]);
466
466
  var DestinationSelection = Schema8.Struct({
467
467
  accountId: AccountId,
468
- placement: PublishPlacement,
468
+ placement: Schema8.optionalKey(PublishPlacement).annotate({
469
+ description: "Omit to select the draft's only destination for this account."
470
+ }),
469
471
  scheduledAt: Schema8.optionalKey(ScheduleOverride),
470
472
  queueId: Schema8.optionalKey(uuid2)
471
473
  }).annotate({ identifier: "DestinationSelection" });
472
474
  var PublishInput = Schema8.Struct({
473
- expectedRevision: PublishRevision,
475
+ expectedRevision: Schema8.optionalKey(PublishRevision).annotate({
476
+ description: "Publish only if the draft is still at this revision. Omit to publish the saved draft as it is."
477
+ }),
474
478
  scheduledAt: Schema8.optionalKey(ScheduledAt),
475
- accountIds: Schema8.optionalKey(Schema8.Array(AccountId).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
479
+ accounts: Schema8.optionalKey(Schema8.Array(AccountId).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
476
480
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
477
481
  })),
478
482
  targets: Schema8.optionalKey(Schema8.Array(DestinationSelection).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
479
- description: "Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."
483
+ description: "Select exact draft destinations and optionally override each schedule. Omit accounts when using targets."
480
484
  }))
481
485
  });
482
486
  var PostRef = Schema8.Struct({ postId: PostId });
@@ -703,7 +707,9 @@ var BillingPlan = Schema9.Struct({
703
707
  includedXReadMicros: Schema9.NullOr(Schema9.Int),
704
708
  seatsLimit: Schema9.NullOr(Schema9.Int),
705
709
  analyticsRetentionDays: Schema9.Int,
706
- whiteLabelOAuth: Schema9.Boolean,
710
+ whiteLabelOAuth: Schema9.Boolean.annotate({
711
+ description: "Reserved for branded connect pages and your own provider apps. Neither is available yet."
712
+ }),
707
713
  ssoSaml: Schema9.Boolean,
708
714
  priorityQueue: Schema9.Boolean,
709
715
  adsInsights: Schema9.Boolean,
@@ -2785,23 +2791,20 @@ var postText = Schema18.Trim.check(Schema18.isMaxLength(postTextLimit)).pipe(Sch
2785
2791
  description: `At most ${postTextLimit} characters after trimming.`
2786
2792
  }));
2787
2793
  var postTargets = Schema18.Array(PublishTarget).check(Schema18.isMaxLength(50));
2788
- var postContent = {
2794
+ var PostContent = Schema18.Struct({
2789
2795
  text: Schema18.optionalKey(postText),
2790
2796
  targets: Schema18.optionalKey(postTargets),
2791
- media: Schema18.optionalKey(MediaInputs)
2792
- };
2793
- var PostContent = Schema18.Struct(postContent).annotate({
2794
- identifier: "PostContent"
2795
- });
2796
- var PostPreflight = Schema18.Struct({
2797
- ...postContent,
2797
+ media: Schema18.optionalKey(MediaInputs),
2798
2798
  scheduledAt: Schema18.optionalKey(ScheduledAt)
2799
- }).annotate({ identifier: "PostPreflight" });
2800
- var CreatePost = Schema18.Struct({
2801
- text: Schema18.optionalKey(postText),
2799
+ }).annotate({ identifier: "PostContent" });
2800
+ var destinationSelectors = {
2802
2801
  platforms: Schema18.optionalKey(Schema18.Array(Provider).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2803
2802
  accounts: Schema18.optionalKey(Schema18.Array(AccountId).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2804
- targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2803
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit)))
2804
+ };
2805
+ var CreatePost = Schema18.Struct({
2806
+ text: Schema18.optionalKey(postText),
2807
+ ...destinationSelectors,
2805
2808
  media: Schema18.optionalKey(MediaInputs),
2806
2809
  scheduledAt: Schema18.optionalKey(ScheduledAt),
2807
2810
  publishNow: Schema18.optionalKey(Schema18.Boolean),
@@ -2809,12 +2812,18 @@ var CreatePost = Schema18.Struct({
2809
2812
  description: "Save the post as a draft without submitting it. Defaults to false."
2810
2813
  })
2811
2814
  }).annotate({ identifier: "CreatePost" }).annotate({
2812
- 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."
2815
+ 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."
2813
2816
  });
2814
2817
  var UpdatePost = Schema18.Struct({
2815
- ...postContent,
2818
+ text: Schema18.optionalKey(postText),
2819
+ media: Schema18.optionalKey(MediaInputs),
2820
+ scheduledAt: Schema18.optionalKey(ScheduleOverride),
2821
+ ...destinationSelectors,
2822
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMaxLength(publishTargetLimit))),
2816
2823
  expectedRevision: Schema18.optionalKey(revision)
2817
- }).annotate({ identifier: "UpdatePost" });
2824
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2825
+ 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."
2826
+ });
2818
2827
  var Post = Schema18.Struct({
2819
2828
  postId: PostId,
2820
2829
  isDraft: Schema18.Boolean,
@@ -2822,6 +2831,9 @@ var Post = Schema18.Struct({
2822
2831
  text: postText,
2823
2832
  media: MediaInputs,
2824
2833
  targets: postTargets,
2834
+ scheduledAt: Schema18.NullOr(ScheduledAt).annotate({
2835
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2836
+ }),
2825
2837
  deliveries: Schema18.Array(DeliveryStatus),
2826
2838
  status: PostState,
2827
2839
  createdAt: Schema18.String,
@@ -5421,6 +5433,17 @@ class DestinationAlreadySubmitted extends HttpApiError.Problem()("DestinationAlr
5421
5433
  }) {
5422
5434
  }
5423
5435
 
5436
+ class PostSubmitted extends HttpApiError.Problem()("PostSubmitted", {
5437
+ type: "urn:pubnio:problem:post-submitted",
5438
+ status: 409,
5439
+ title: "Post already submitted"
5440
+ }, {
5441
+ code: Schema28.Literal("post_submitted"),
5442
+ targetIds: Schema28.Array(TargetId),
5443
+ nextAction: Schema28.String
5444
+ }) {
5445
+ }
5446
+
5424
5447
  class DeliveryNotRetryable extends HttpApiError.Problem()("DeliveryNotRetryable", {
5425
5448
  type: "urn:pubnio:problem:delivery-not-retryable",
5426
5449
  status: 409,
@@ -5926,6 +5949,7 @@ var PublishProblems = [
5926
5949
  AttemptChanged,
5927
5950
  IdempotencyConflict,
5928
5951
  DestinationAlreadySubmitted,
5952
+ PostSubmitted,
5929
5953
  DeliveryNotRetryable,
5930
5954
  DeliveryNotReconcilable,
5931
5955
  DeliveryScheduleLocked,
@@ -6384,7 +6408,7 @@ import { ProblemDetails } from "effect/http";
6384
6408
  // package.json
6385
6409
  var package_default = {
6386
6410
  name: "@pubnio/sdk",
6387
- version: "0.3.0",
6411
+ version: "0.5.0",
6388
6412
  description: "JavaScript and TypeScript client for the PubNio API",
6389
6413
  type: "module",
6390
6414
  exports: {
@@ -8912,7 +8936,7 @@ function createPubNioClient({
8912
8936
  return withIdempotencyKey(idempotencyKey, async () => {
8913
8937
  const body = post;
8914
8938
  if (post.isDraft) {
8915
- return decode(Post, postsCreate({
8939
+ return decode(PostCreated, postsCreate({
8916
8940
  client,
8917
8941
  query: { workspaceId },
8918
8942
  headers: { "idempotency-key": idempotencyKey },
@@ -9606,7 +9630,7 @@ function createPubNioClient({
9606
9630
  ...transport()
9607
9631
  }));
9608
9632
  },
9609
- publish: (postId, input) => {
9633
+ publish: (postId, input = {}) => {
9610
9634
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9611
9635
  return withIdempotencyKey(idempotencyKey, async () => {
9612
9636
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9617,7 +9641,7 @@ function createPubNioClient({
9617
9641
  body: {
9618
9642
  expectedRevision: publish.expectedRevision,
9619
9643
  scheduledAt: publish.scheduledAt,
9620
- accountIds: publish.accountIds && [...publish.accountIds],
9644
+ accounts: publish.accounts && [...publish.accounts],
9621
9645
  targets: publish.targets && [...publish.targets]
9622
9646
  },
9623
9647
  ...transport()
package/dist/solid.cjs CHANGED
@@ -663,18 +663,22 @@ var PublishPlacement = import_effect8.Schema.Literals([
663
663
  var ScheduleOverride = import_effect8.Schema.Union([ScheduledAt, import_effect8.Schema.Null]);
664
664
  var DestinationSelection = import_effect8.Schema.Struct({
665
665
  accountId: AccountId,
666
- placement: PublishPlacement,
666
+ placement: import_effect8.Schema.optionalKey(PublishPlacement).annotate({
667
+ description: "Omit to select the draft's only destination for this account."
668
+ }),
667
669
  scheduledAt: import_effect8.Schema.optionalKey(ScheduleOverride),
668
670
  queueId: import_effect8.Schema.optionalKey(uuid2)
669
671
  }).annotate({ identifier: "DestinationSelection" });
670
672
  var PublishInput = import_effect8.Schema.Struct({
671
- expectedRevision: PublishRevision,
673
+ expectedRevision: import_effect8.Schema.optionalKey(PublishRevision).annotate({
674
+ description: "Publish only if the draft is still at this revision. Omit to publish the saved draft as it is."
675
+ }),
672
676
  scheduledAt: import_effect8.Schema.optionalKey(ScheduledAt),
673
- accountIds: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
677
+ accounts: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
674
678
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
675
679
  })),
676
680
  targets: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(DestinationSelection).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
677
- description: "Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."
681
+ description: "Select exact draft destinations and optionally override each schedule. Omit accounts when using targets."
678
682
  }))
679
683
  });
680
684
  var PostRef = import_effect8.Schema.Struct({ postId: PostId });
@@ -901,7 +905,9 @@ var BillingPlan = import_effect9.Schema.Struct({
901
905
  includedXReadMicros: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
902
906
  seatsLimit: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
903
907
  analyticsRetentionDays: import_effect9.Schema.Int,
904
- whiteLabelOAuth: import_effect9.Schema.Boolean,
908
+ whiteLabelOAuth: import_effect9.Schema.Boolean.annotate({
909
+ description: "Reserved for branded connect pages and your own provider apps. Neither is available yet."
910
+ }),
905
911
  ssoSaml: import_effect9.Schema.Boolean,
906
912
  priorityQueue: import_effect9.Schema.Boolean,
907
913
  adsInsights: import_effect9.Schema.Boolean,
@@ -2983,23 +2989,20 @@ var postText = import_effect18.Schema.Trim.check(import_effect18.Schema.isMaxLen
2983
2989
  description: `At most ${postTextLimit} characters after trimming.`
2984
2990
  }));
2985
2991
  var postTargets = import_effect18.Schema.Array(PublishTarget).check(import_effect18.Schema.isMaxLength(50));
2986
- var postContent = {
2992
+ var PostContent = import_effect18.Schema.Struct({
2987
2993
  text: import_effect18.Schema.optionalKey(postText),
2988
2994
  targets: import_effect18.Schema.optionalKey(postTargets),
2989
- media: import_effect18.Schema.optionalKey(MediaInputs)
2990
- };
2991
- var PostContent = import_effect18.Schema.Struct(postContent).annotate({
2992
- identifier: "PostContent"
2993
- });
2994
- var PostPreflight = import_effect18.Schema.Struct({
2995
- ...postContent,
2995
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2996
2996
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt)
2997
- }).annotate({ identifier: "PostPreflight" });
2998
- var CreatePost = import_effect18.Schema.Struct({
2999
- text: import_effect18.Schema.optionalKey(postText),
2997
+ }).annotate({ identifier: "PostContent" });
2998
+ var destinationSelectors = {
3000
2999
  platforms: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(Provider).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
3001
3000
  accounts: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(AccountId).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
3002
- targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
3001
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit)))
3002
+ };
3003
+ var CreatePost = import_effect18.Schema.Struct({
3004
+ text: import_effect18.Schema.optionalKey(postText),
3005
+ ...destinationSelectors,
3003
3006
  media: import_effect18.Schema.optionalKey(MediaInputs),
3004
3007
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt),
3005
3008
  publishNow: import_effect18.Schema.optionalKey(import_effect18.Schema.Boolean),
@@ -3007,12 +3010,18 @@ var CreatePost = import_effect18.Schema.Struct({
3007
3010
  description: "Save the post as a draft without submitting it. Defaults to false."
3008
3011
  })
3009
3012
  }).annotate({ identifier: "CreatePost" }).annotate({
3010
- 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."
3013
+ 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."
3011
3014
  });
3012
3015
  var UpdatePost = import_effect18.Schema.Struct({
3013
- ...postContent,
3016
+ text: import_effect18.Schema.optionalKey(postText),
3017
+ media: import_effect18.Schema.optionalKey(MediaInputs),
3018
+ scheduledAt: import_effect18.Schema.optionalKey(ScheduleOverride),
3019
+ ...destinationSelectors,
3020
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMaxLength(publishTargetLimit))),
3014
3021
  expectedRevision: import_effect18.Schema.optionalKey(revision)
3015
- }).annotate({ identifier: "UpdatePost" });
3022
+ }).annotate({ identifier: "UpdatePost" }).annotate({
3023
+ 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."
3024
+ });
3016
3025
  var Post = import_effect18.Schema.Struct({
3017
3026
  postId: PostId,
3018
3027
  isDraft: import_effect18.Schema.Boolean,
@@ -3020,6 +3029,9 @@ var Post = import_effect18.Schema.Struct({
3020
3029
  text: postText,
3021
3030
  media: MediaInputs,
3022
3031
  targets: postTargets,
3032
+ scheduledAt: import_effect18.Schema.NullOr(ScheduledAt).annotate({
3033
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
3034
+ }),
3023
3035
  deliveries: import_effect18.Schema.Array(DeliveryStatus),
3024
3036
  status: PostState,
3025
3037
  createdAt: import_effect18.Schema.String,
@@ -5619,6 +5631,17 @@ class DestinationAlreadySubmitted extends import_http_api.HttpApiError.Problem()
5619
5631
  }) {
5620
5632
  }
5621
5633
 
5634
+ class PostSubmitted extends import_http_api.HttpApiError.Problem()("PostSubmitted", {
5635
+ type: "urn:pubnio:problem:post-submitted",
5636
+ status: 409,
5637
+ title: "Post already submitted"
5638
+ }, {
5639
+ code: import_effect28.Schema.Literal("post_submitted"),
5640
+ targetIds: import_effect28.Schema.Array(TargetId),
5641
+ nextAction: import_effect28.Schema.String
5642
+ }) {
5643
+ }
5644
+
5622
5645
  class DeliveryNotRetryable extends import_http_api.HttpApiError.Problem()("DeliveryNotRetryable", {
5623
5646
  type: "urn:pubnio:problem:delivery-not-retryable",
5624
5647
  status: 409,
@@ -6124,6 +6147,7 @@ var PublishProblems = [
6124
6147
  AttemptChanged,
6125
6148
  IdempotencyConflict,
6126
6149
  DestinationAlreadySubmitted,
6150
+ PostSubmitted,
6127
6151
  DeliveryNotRetryable,
6128
6152
  DeliveryNotReconcilable,
6129
6153
  DeliveryScheduleLocked,
@@ -6582,7 +6606,7 @@ var import_http = require("effect/http");
6582
6606
  // package.json
6583
6607
  var package_default = {
6584
6608
  name: "@pubnio/sdk",
6585
- version: "0.3.0",
6609
+ version: "0.5.0",
6586
6610
  description: "JavaScript and TypeScript client for the PubNio API",
6587
6611
  type: "module",
6588
6612
  exports: {
@@ -9110,7 +9134,7 @@ function createPubNioClient({
9110
9134
  return withIdempotencyKey(idempotencyKey, async () => {
9111
9135
  const body = post;
9112
9136
  if (post.isDraft) {
9113
- return decode(Post, postsCreate({
9137
+ return decode(PostCreated, postsCreate({
9114
9138
  client,
9115
9139
  query: { workspaceId },
9116
9140
  headers: { "idempotency-key": idempotencyKey },
@@ -9804,7 +9828,7 @@ function createPubNioClient({
9804
9828
  ...transport()
9805
9829
  }));
9806
9830
  },
9807
- publish: (postId, input) => {
9831
+ publish: (postId, input = {}) => {
9808
9832
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9809
9833
  return withIdempotencyKey(idempotencyKey, async () => {
9810
9834
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9815,7 +9839,7 @@ function createPubNioClient({
9815
9839
  body: {
9816
9840
  expectedRevision: publish.expectedRevision,
9817
9841
  scheduledAt: publish.scheduledAt,
9818
- accountIds: publish.accountIds && [...publish.accountIds],
9842
+ accounts: publish.accounts && [...publish.accounts],
9819
9843
  targets: publish.targets && [...publish.targets]
9820
9844
  },
9821
9845
  ...transport()