@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.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/internal.cjs CHANGED
@@ -513,18 +513,22 @@ var PublishPlacement = import_effect8.Schema.Literals([
513
513
  var ScheduleOverride = import_effect8.Schema.Union([ScheduledAt, import_effect8.Schema.Null]);
514
514
  var DestinationSelection = import_effect8.Schema.Struct({
515
515
  accountId: AccountId,
516
- placement: PublishPlacement,
516
+ placement: import_effect8.Schema.optionalKey(PublishPlacement).annotate({
517
+ description: "Omit to select the draft's only destination for this account."
518
+ }),
517
519
  scheduledAt: import_effect8.Schema.optionalKey(ScheduleOverride),
518
520
  queueId: import_effect8.Schema.optionalKey(uuid2)
519
521
  }).annotate({ identifier: "DestinationSelection" });
520
522
  var PublishInput = import_effect8.Schema.Struct({
521
- expectedRevision: PublishRevision,
523
+ expectedRevision: import_effect8.Schema.optionalKey(PublishRevision).annotate({
524
+ description: "Publish only if the draft is still at this revision. Omit to publish the saved draft as it is."
525
+ }),
522
526
  scheduledAt: import_effect8.Schema.optionalKey(ScheduledAt),
523
- accountIds: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
527
+ accounts: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(AccountId).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
524
528
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
525
529
  })),
526
530
  targets: import_effect8.Schema.optionalKey(import_effect8.Schema.Array(DestinationSelection).check(import_effect8.Schema.isMinLength(1), import_effect8.Schema.isMaxLength(50)).annotate({
527
- description: "Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."
531
+ description: "Select exact draft destinations and optionally override each schedule. Omit accounts when using targets."
528
532
  }))
529
533
  });
530
534
  var PostRef = import_effect8.Schema.Struct({ postId: PostId });
@@ -751,7 +755,9 @@ var BillingPlan = import_effect9.Schema.Struct({
751
755
  includedXReadMicros: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
752
756
  seatsLimit: import_effect9.Schema.NullOr(import_effect9.Schema.Int),
753
757
  analyticsRetentionDays: import_effect9.Schema.Int,
754
- whiteLabelOAuth: import_effect9.Schema.Boolean,
758
+ whiteLabelOAuth: import_effect9.Schema.Boolean.annotate({
759
+ description: "Reserved for branded connect pages and your own provider apps. Neither is available yet."
760
+ }),
755
761
  ssoSaml: import_effect9.Schema.Boolean,
756
762
  priorityQueue: import_effect9.Schema.Boolean,
757
763
  adsInsights: import_effect9.Schema.Boolean,
@@ -2833,23 +2839,20 @@ var postText = import_effect18.Schema.Trim.check(import_effect18.Schema.isMaxLen
2833
2839
  description: `At most ${postTextLimit} characters after trimming.`
2834
2840
  }));
2835
2841
  var postTargets = import_effect18.Schema.Array(PublishTarget).check(import_effect18.Schema.isMaxLength(50));
2836
- var postContent = {
2842
+ var PostContent = import_effect18.Schema.Struct({
2837
2843
  text: import_effect18.Schema.optionalKey(postText),
2838
2844
  targets: import_effect18.Schema.optionalKey(postTargets),
2839
- media: import_effect18.Schema.optionalKey(MediaInputs)
2840
- };
2841
- var PostContent = import_effect18.Schema.Struct(postContent).annotate({
2842
- identifier: "PostContent"
2843
- });
2844
- var PostPreflight = import_effect18.Schema.Struct({
2845
- ...postContent,
2845
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2846
2846
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt)
2847
- }).annotate({ identifier: "PostPreflight" });
2848
- var CreatePost = import_effect18.Schema.Struct({
2849
- text: import_effect18.Schema.optionalKey(postText),
2847
+ }).annotate({ identifier: "PostContent" });
2848
+ var destinationSelectors = {
2850
2849
  platforms: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(Provider).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2851
2850
  accounts: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(AccountId).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2852
- targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
2851
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit)))
2852
+ };
2853
+ var CreatePost = import_effect18.Schema.Struct({
2854
+ text: import_effect18.Schema.optionalKey(postText),
2855
+ ...destinationSelectors,
2853
2856
  media: import_effect18.Schema.optionalKey(MediaInputs),
2854
2857
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt),
2855
2858
  publishNow: import_effect18.Schema.optionalKey(import_effect18.Schema.Boolean),
@@ -2857,12 +2860,18 @@ var CreatePost = import_effect18.Schema.Struct({
2857
2860
  description: "Save the post as a draft without submitting it. Defaults to false."
2858
2861
  })
2859
2862
  }).annotate({ identifier: "CreatePost" }).annotate({
2860
- 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."
2863
+ 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."
2861
2864
  });
2862
2865
  var UpdatePost = import_effect18.Schema.Struct({
2863
- ...postContent,
2866
+ text: import_effect18.Schema.optionalKey(postText),
2867
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2868
+ scheduledAt: import_effect18.Schema.optionalKey(ScheduleOverride),
2869
+ ...destinationSelectors,
2870
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMaxLength(publishTargetLimit))),
2864
2871
  expectedRevision: import_effect18.Schema.optionalKey(revision)
2865
- }).annotate({ identifier: "UpdatePost" });
2872
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2873
+ 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."
2874
+ });
2866
2875
  var Post = import_effect18.Schema.Struct({
2867
2876
  postId: PostId,
2868
2877
  isDraft: import_effect18.Schema.Boolean,
@@ -2870,6 +2879,9 @@ var Post = import_effect18.Schema.Struct({
2870
2879
  text: postText,
2871
2880
  media: MediaInputs,
2872
2881
  targets: postTargets,
2882
+ scheduledAt: import_effect18.Schema.NullOr(ScheduledAt).annotate({
2883
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2884
+ }),
2873
2885
  deliveries: import_effect18.Schema.Array(DeliveryStatus),
2874
2886
  status: PostState,
2875
2887
  createdAt: import_effect18.Schema.String,
@@ -5469,6 +5481,17 @@ class DestinationAlreadySubmitted extends import_http_api.HttpApiError.Problem()
5469
5481
  }) {
5470
5482
  }
5471
5483
 
5484
+ class PostSubmitted extends import_http_api.HttpApiError.Problem()("PostSubmitted", {
5485
+ type: "urn:pubnio:problem:post-submitted",
5486
+ status: 409,
5487
+ title: "Post already submitted"
5488
+ }, {
5489
+ code: import_effect28.Schema.Literal("post_submitted"),
5490
+ targetIds: import_effect28.Schema.Array(TargetId),
5491
+ nextAction: import_effect28.Schema.String
5492
+ }) {
5493
+ }
5494
+
5472
5495
  class DeliveryNotRetryable extends import_http_api.HttpApiError.Problem()("DeliveryNotRetryable", {
5473
5496
  type: "urn:pubnio:problem:delivery-not-retryable",
5474
5497
  status: 409,
@@ -5974,6 +5997,7 @@ var PublishProblems = [
5974
5997
  AttemptChanged,
5975
5998
  IdempotencyConflict,
5976
5999
  DestinationAlreadySubmitted,
6000
+ PostSubmitted,
5977
6001
  DeliveryNotRetryable,
5978
6002
  DeliveryNotReconcilable,
5979
6003
  DeliveryScheduleLocked,
@@ -6432,7 +6456,7 @@ var import_http = require("effect/http");
6432
6456
  // package.json
6433
6457
  var package_default = {
6434
6458
  name: "@pubnio/sdk",
6435
- version: "0.3.0",
6459
+ version: "0.5.0",
6436
6460
  description: "JavaScript and TypeScript client for the PubNio API",
6437
6461
  type: "module",
6438
6462
  exports: {
@@ -8960,7 +8984,7 @@ function createPubNioClient({
8960
8984
  return withIdempotencyKey(idempotencyKey, async () => {
8961
8985
  const body = post;
8962
8986
  if (post.isDraft) {
8963
- return decode(Post, postsCreate({
8987
+ return decode(PostCreated, postsCreate({
8964
8988
  client,
8965
8989
  query: { workspaceId },
8966
8990
  headers: { "idempotency-key": idempotencyKey },
@@ -9654,7 +9678,7 @@ function createPubNioClient({
9654
9678
  ...transport()
9655
9679
  }));
9656
9680
  },
9657
- publish: (postId, input) => {
9681
+ publish: (postId, input = {}) => {
9658
9682
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9659
9683
  return withIdempotencyKey(idempotencyKey, async () => {
9660
9684
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9665,7 +9689,7 @@ function createPubNioClient({
9665
9689
  body: {
9666
9690
  expectedRevision: publish.expectedRevision,
9667
9691
  scheduledAt: publish.scheduledAt,
9668
- accountIds: publish.accountIds && [...publish.accountIds],
9692
+ accounts: publish.accounts && [...publish.accounts],
9669
9693
  targets: publish.targets && [...publish.targets]
9670
9694
  },
9671
9695
  ...transport()