@pubnio/sdk 0.3.0 → 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/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 });
@@ -2785,23 +2789,20 @@ var postText = Schema18.Trim.check(Schema18.isMaxLength(postTextLimit)).pipe(Sch
2785
2789
  description: `At most ${postTextLimit} characters after trimming.`
2786
2790
  }));
2787
2791
  var postTargets = Schema18.Array(PublishTarget).check(Schema18.isMaxLength(50));
2788
- var postContent = {
2792
+ var PostContent = Schema18.Struct({
2789
2793
  text: Schema18.optionalKey(postText),
2790
2794
  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,
2795
+ media: Schema18.optionalKey(MediaInputs),
2798
2796
  scheduledAt: Schema18.optionalKey(ScheduledAt)
2799
- }).annotate({ identifier: "PostPreflight" });
2800
- var CreatePost = Schema18.Struct({
2801
- text: Schema18.optionalKey(postText),
2797
+ }).annotate({ identifier: "PostContent" });
2798
+ var destinationSelectors = {
2802
2799
  platforms: Schema18.optionalKey(Schema18.Array(Provider).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2803
2800
  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))),
2801
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit)))
2802
+ };
2803
+ var CreatePost = Schema18.Struct({
2804
+ text: Schema18.optionalKey(postText),
2805
+ ...destinationSelectors,
2805
2806
  media: Schema18.optionalKey(MediaInputs),
2806
2807
  scheduledAt: Schema18.optionalKey(ScheduledAt),
2807
2808
  publishNow: Schema18.optionalKey(Schema18.Boolean),
@@ -2809,12 +2810,18 @@ var CreatePost = Schema18.Struct({
2809
2810
  description: "Save the post as a draft without submitting it. Defaults to false."
2810
2811
  })
2811
2812
  }).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."
2813
+ 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
2814
  });
2814
2815
  var UpdatePost = Schema18.Struct({
2815
- ...postContent,
2816
+ text: Schema18.optionalKey(postText),
2817
+ media: Schema18.optionalKey(MediaInputs),
2818
+ scheduledAt: Schema18.optionalKey(ScheduleOverride),
2819
+ ...destinationSelectors,
2820
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMaxLength(publishTargetLimit))),
2816
2821
  expectedRevision: Schema18.optionalKey(revision)
2817
- }).annotate({ identifier: "UpdatePost" });
2822
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2823
+ 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."
2824
+ });
2818
2825
  var Post = Schema18.Struct({
2819
2826
  postId: PostId,
2820
2827
  isDraft: Schema18.Boolean,
@@ -2822,6 +2829,9 @@ var Post = Schema18.Struct({
2822
2829
  text: postText,
2823
2830
  media: MediaInputs,
2824
2831
  targets: postTargets,
2832
+ scheduledAt: Schema18.NullOr(ScheduledAt).annotate({
2833
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2834
+ }),
2825
2835
  deliveries: Schema18.Array(DeliveryStatus),
2826
2836
  status: PostState,
2827
2837
  createdAt: Schema18.String,
@@ -5421,6 +5431,17 @@ class DestinationAlreadySubmitted extends HttpApiError.Problem()("DestinationAlr
5421
5431
  }) {
5422
5432
  }
5423
5433
 
5434
+ class PostSubmitted extends HttpApiError.Problem()("PostSubmitted", {
5435
+ type: "urn:pubnio:problem:post-submitted",
5436
+ status: 409,
5437
+ title: "Post already submitted"
5438
+ }, {
5439
+ code: Schema28.Literal("post_submitted"),
5440
+ targetIds: Schema28.Array(TargetId),
5441
+ nextAction: Schema28.String
5442
+ }) {
5443
+ }
5444
+
5424
5445
  class DeliveryNotRetryable extends HttpApiError.Problem()("DeliveryNotRetryable", {
5425
5446
  type: "urn:pubnio:problem:delivery-not-retryable",
5426
5447
  status: 409,
@@ -5926,6 +5947,7 @@ var PublishProblems = [
5926
5947
  AttemptChanged,
5927
5948
  IdempotencyConflict,
5928
5949
  DestinationAlreadySubmitted,
5950
+ PostSubmitted,
5929
5951
  DeliveryNotRetryable,
5930
5952
  DeliveryNotReconcilable,
5931
5953
  DeliveryScheduleLocked,
@@ -6384,7 +6406,7 @@ import { ProblemDetails } from "effect/http";
6384
6406
  // package.json
6385
6407
  var package_default = {
6386
6408
  name: "@pubnio/sdk",
6387
- version: "0.3.0",
6409
+ version: "0.4.0",
6388
6410
  description: "JavaScript and TypeScript client for the PubNio API",
6389
6411
  type: "module",
6390
6412
  exports: {
@@ -8912,7 +8934,7 @@ function createPubNioClient({
8912
8934
  return withIdempotencyKey(idempotencyKey, async () => {
8913
8935
  const body = post;
8914
8936
  if (post.isDraft) {
8915
- return decode(Post, postsCreate({
8937
+ return decode(PostCreated, postsCreate({
8916
8938
  client,
8917
8939
  query: { workspaceId },
8918
8940
  headers: { "idempotency-key": idempotencyKey },
@@ -9606,7 +9628,7 @@ function createPubNioClient({
9606
9628
  ...transport()
9607
9629
  }));
9608
9630
  },
9609
- publish: (postId, input) => {
9631
+ publish: (postId, input = {}) => {
9610
9632
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9611
9633
  return withIdempotencyKey(idempotencyKey, async () => {
9612
9634
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9617,7 +9639,7 @@ function createPubNioClient({
9617
9639
  body: {
9618
9640
  expectedRevision: publish.expectedRevision,
9619
9641
  scheduledAt: publish.scheduledAt,
9620
- accountIds: publish.accountIds && [...publish.accountIds],
9642
+ accounts: publish.accounts && [...publish.accounts],
9621
9643
  targets: publish.targets && [...publish.targets]
9622
9644
  },
9623
9645
  ...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 });
@@ -2983,23 +2987,20 @@ var postText = import_effect18.Schema.Trim.check(import_effect18.Schema.isMaxLen
2983
2987
  description: `At most ${postTextLimit} characters after trimming.`
2984
2988
  }));
2985
2989
  var postTargets = import_effect18.Schema.Array(PublishTarget).check(import_effect18.Schema.isMaxLength(50));
2986
- var postContent = {
2990
+ var PostContent = import_effect18.Schema.Struct({
2987
2991
  text: import_effect18.Schema.optionalKey(postText),
2988
2992
  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,
2993
+ media: import_effect18.Schema.optionalKey(MediaInputs),
2996
2994
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt)
2997
- }).annotate({ identifier: "PostPreflight" });
2998
- var CreatePost = import_effect18.Schema.Struct({
2999
- text: import_effect18.Schema.optionalKey(postText),
2995
+ }).annotate({ identifier: "PostContent" });
2996
+ var destinationSelectors = {
3000
2997
  platforms: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(Provider).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit))),
3001
2998
  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))),
2999
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMinLength(1), import_effect18.Schema.isMaxLength(publishTargetLimit)))
3000
+ };
3001
+ var CreatePost = import_effect18.Schema.Struct({
3002
+ text: import_effect18.Schema.optionalKey(postText),
3003
+ ...destinationSelectors,
3003
3004
  media: import_effect18.Schema.optionalKey(MediaInputs),
3004
3005
  scheduledAt: import_effect18.Schema.optionalKey(ScheduledAt),
3005
3006
  publishNow: import_effect18.Schema.optionalKey(import_effect18.Schema.Boolean),
@@ -3007,12 +3008,18 @@ var CreatePost = import_effect18.Schema.Struct({
3007
3008
  description: "Save the post as a draft without submitting it. Defaults to false."
3008
3009
  })
3009
3010
  }).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."
3011
+ 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
3012
  });
3012
3013
  var UpdatePost = import_effect18.Schema.Struct({
3013
- ...postContent,
3014
+ text: import_effect18.Schema.optionalKey(postText),
3015
+ media: import_effect18.Schema.optionalKey(MediaInputs),
3016
+ scheduledAt: import_effect18.Schema.optionalKey(ScheduleOverride),
3017
+ ...destinationSelectors,
3018
+ targets: import_effect18.Schema.optionalKey(import_effect18.Schema.Array(CreatePostTarget).check(import_effect18.Schema.isMaxLength(publishTargetLimit))),
3014
3019
  expectedRevision: import_effect18.Schema.optionalKey(revision)
3015
- }).annotate({ identifier: "UpdatePost" });
3020
+ }).annotate({ identifier: "UpdatePost" }).annotate({
3021
+ 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."
3022
+ });
3016
3023
  var Post = import_effect18.Schema.Struct({
3017
3024
  postId: PostId,
3018
3025
  isDraft: import_effect18.Schema.Boolean,
@@ -3020,6 +3027,9 @@ var Post = import_effect18.Schema.Struct({
3020
3027
  text: postText,
3021
3028
  media: MediaInputs,
3022
3029
  targets: postTargets,
3030
+ scheduledAt: import_effect18.Schema.NullOr(ScheduledAt).annotate({
3031
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
3032
+ }),
3023
3033
  deliveries: import_effect18.Schema.Array(DeliveryStatus),
3024
3034
  status: PostState,
3025
3035
  createdAt: import_effect18.Schema.String,
@@ -5619,6 +5629,17 @@ class DestinationAlreadySubmitted extends import_http_api.HttpApiError.Problem()
5619
5629
  }) {
5620
5630
  }
5621
5631
 
5632
+ class PostSubmitted extends import_http_api.HttpApiError.Problem()("PostSubmitted", {
5633
+ type: "urn:pubnio:problem:post-submitted",
5634
+ status: 409,
5635
+ title: "Post already submitted"
5636
+ }, {
5637
+ code: import_effect28.Schema.Literal("post_submitted"),
5638
+ targetIds: import_effect28.Schema.Array(TargetId),
5639
+ nextAction: import_effect28.Schema.String
5640
+ }) {
5641
+ }
5642
+
5622
5643
  class DeliveryNotRetryable extends import_http_api.HttpApiError.Problem()("DeliveryNotRetryable", {
5623
5644
  type: "urn:pubnio:problem:delivery-not-retryable",
5624
5645
  status: 409,
@@ -6124,6 +6145,7 @@ var PublishProblems = [
6124
6145
  AttemptChanged,
6125
6146
  IdempotencyConflict,
6126
6147
  DestinationAlreadySubmitted,
6148
+ PostSubmitted,
6127
6149
  DeliveryNotRetryable,
6128
6150
  DeliveryNotReconcilable,
6129
6151
  DeliveryScheduleLocked,
@@ -6582,7 +6604,7 @@ var import_http = require("effect/http");
6582
6604
  // package.json
6583
6605
  var package_default = {
6584
6606
  name: "@pubnio/sdk",
6585
- version: "0.3.0",
6607
+ version: "0.4.0",
6586
6608
  description: "JavaScript and TypeScript client for the PubNio API",
6587
6609
  type: "module",
6588
6610
  exports: {
@@ -9110,7 +9132,7 @@ function createPubNioClient({
9110
9132
  return withIdempotencyKey(idempotencyKey, async () => {
9111
9133
  const body = post;
9112
9134
  if (post.isDraft) {
9113
- return decode(Post, postsCreate({
9135
+ return decode(PostCreated, postsCreate({
9114
9136
  client,
9115
9137
  query: { workspaceId },
9116
9138
  headers: { "idempotency-key": idempotencyKey },
@@ -9804,7 +9826,7 @@ function createPubNioClient({
9804
9826
  ...transport()
9805
9827
  }));
9806
9828
  },
9807
- publish: (postId, input) => {
9829
+ publish: (postId, input = {}) => {
9808
9830
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9809
9831
  return withIdempotencyKey(idempotencyKey, async () => {
9810
9832
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9815,7 +9837,7 @@ function createPubNioClient({
9815
9837
  body: {
9816
9838
  expectedRevision: publish.expectedRevision,
9817
9839
  scheduledAt: publish.scheduledAt,
9818
- accountIds: publish.accountIds && [...publish.accountIds],
9840
+ accounts: publish.accounts && [...publish.accounts],
9819
9841
  targets: publish.targets && [...publish.targets]
9820
9842
  },
9821
9843
  ...transport()