@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/solid.js CHANGED
@@ -472,18 +472,22 @@ var PublishPlacement = Schema8.Literals([
472
472
  var ScheduleOverride = Schema8.Union([ScheduledAt, Schema8.Null]);
473
473
  var DestinationSelection = Schema8.Struct({
474
474
  accountId: AccountId,
475
- placement: PublishPlacement,
475
+ placement: Schema8.optionalKey(PublishPlacement).annotate({
476
+ description: "Omit to select the draft's only destination for this account."
477
+ }),
476
478
  scheduledAt: Schema8.optionalKey(ScheduleOverride),
477
479
  queueId: Schema8.optionalKey(uuid2)
478
480
  }).annotate({ identifier: "DestinationSelection" });
479
481
  var PublishInput = Schema8.Struct({
480
- 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
+ }),
481
485
  scheduledAt: Schema8.optionalKey(ScheduledAt),
482
- 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({
483
487
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
484
488
  })),
485
489
  targets: Schema8.optionalKey(Schema8.Array(DestinationSelection).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
486
- 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."
487
491
  }))
488
492
  });
489
493
  var PostRef = Schema8.Struct({ postId: PostId });
@@ -2792,23 +2796,20 @@ var postText = Schema18.Trim.check(Schema18.isMaxLength(postTextLimit)).pipe(Sch
2792
2796
  description: `At most ${postTextLimit} characters after trimming.`
2793
2797
  }));
2794
2798
  var postTargets = Schema18.Array(PublishTarget).check(Schema18.isMaxLength(50));
2795
- var postContent = {
2799
+ var PostContent = Schema18.Struct({
2796
2800
  text: Schema18.optionalKey(postText),
2797
2801
  targets: Schema18.optionalKey(postTargets),
2798
- media: Schema18.optionalKey(MediaInputs)
2799
- };
2800
- var PostContent = Schema18.Struct(postContent).annotate({
2801
- identifier: "PostContent"
2802
- });
2803
- var PostPreflight = Schema18.Struct({
2804
- ...postContent,
2802
+ media: Schema18.optionalKey(MediaInputs),
2805
2803
  scheduledAt: Schema18.optionalKey(ScheduledAt)
2806
- }).annotate({ identifier: "PostPreflight" });
2807
- var CreatePost = Schema18.Struct({
2808
- text: Schema18.optionalKey(postText),
2804
+ }).annotate({ identifier: "PostContent" });
2805
+ var destinationSelectors = {
2809
2806
  platforms: Schema18.optionalKey(Schema18.Array(Provider).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2810
2807
  accounts: Schema18.optionalKey(Schema18.Array(AccountId).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2811
- 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,
2812
2813
  media: Schema18.optionalKey(MediaInputs),
2813
2814
  scheduledAt: Schema18.optionalKey(ScheduledAt),
2814
2815
  publishNow: Schema18.optionalKey(Schema18.Boolean),
@@ -2816,12 +2817,18 @@ var CreatePost = Schema18.Struct({
2816
2817
  description: "Save the post as a draft without submitting it. Defaults to false."
2817
2818
  })
2818
2819
  }).annotate({ identifier: "CreatePost" }).annotate({
2819
- 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."
2820
2821
  });
2821
2822
  var UpdatePost = Schema18.Struct({
2822
- ...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))),
2823
2828
  expectedRevision: Schema18.optionalKey(revision)
2824
- }).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
+ });
2825
2832
  var Post = Schema18.Struct({
2826
2833
  postId: PostId,
2827
2834
  isDraft: Schema18.Boolean,
@@ -2829,6 +2836,9 @@ var Post = Schema18.Struct({
2829
2836
  text: postText,
2830
2837
  media: MediaInputs,
2831
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
+ }),
2832
2842
  deliveries: Schema18.Array(DeliveryStatus),
2833
2843
  status: PostState,
2834
2844
  createdAt: Schema18.String,
@@ -5428,6 +5438,17 @@ class DestinationAlreadySubmitted extends HttpApiError.Problem()("DestinationAlr
5428
5438
  }) {
5429
5439
  }
5430
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
+
5431
5452
  class DeliveryNotRetryable extends HttpApiError.Problem()("DeliveryNotRetryable", {
5432
5453
  type: "urn:pubnio:problem:delivery-not-retryable",
5433
5454
  status: 409,
@@ -5933,6 +5954,7 @@ var PublishProblems = [
5933
5954
  AttemptChanged,
5934
5955
  IdempotencyConflict,
5935
5956
  DestinationAlreadySubmitted,
5957
+ PostSubmitted,
5936
5958
  DeliveryNotRetryable,
5937
5959
  DeliveryNotReconcilable,
5938
5960
  DeliveryScheduleLocked,
@@ -6391,7 +6413,7 @@ import { ProblemDetails } from "effect/http";
6391
6413
  // package.json
6392
6414
  var package_default = {
6393
6415
  name: "@pubnio/sdk",
6394
- version: "0.3.0",
6416
+ version: "0.4.0",
6395
6417
  description: "JavaScript and TypeScript client for the PubNio API",
6396
6418
  type: "module",
6397
6419
  exports: {
@@ -8919,7 +8941,7 @@ function createPubNioClient({
8919
8941
  return withIdempotencyKey(idempotencyKey, async () => {
8920
8942
  const body = post;
8921
8943
  if (post.isDraft) {
8922
- return decode(Post, postsCreate({
8944
+ return decode(PostCreated, postsCreate({
8923
8945
  client,
8924
8946
  query: { workspaceId },
8925
8947
  headers: { "idempotency-key": idempotencyKey },
@@ -9613,7 +9635,7 @@ function createPubNioClient({
9613
9635
  ...transport()
9614
9636
  }));
9615
9637
  },
9616
- publish: (postId, input) => {
9638
+ publish: (postId, input = {}) => {
9617
9639
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9618
9640
  return withIdempotencyKey(idempotencyKey, async () => {
9619
9641
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9624,7 +9646,7 @@ function createPubNioClient({
9624
9646
  body: {
9625
9647
  expectedRevision: publish.expectedRevision,
9626
9648
  scheduledAt: publish.scheduledAt,
9627
- accountIds: publish.accountIds && [...publish.accountIds],
9649
+ accounts: publish.accounts && [...publish.accounts],
9628
9650
  targets: publish.targets && [...publish.targets]
9629
9651
  },
9630
9652
  ...transport()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubnio/sdk",
3
- "version": "0.3.0",
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": [