@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/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 });
@@ -710,7 +714,9 @@ var BillingPlan = Schema9.Struct({
710
714
  includedXReadMicros: Schema9.NullOr(Schema9.Int),
711
715
  seatsLimit: Schema9.NullOr(Schema9.Int),
712
716
  analyticsRetentionDays: Schema9.Int,
713
- whiteLabelOAuth: Schema9.Boolean,
717
+ whiteLabelOAuth: Schema9.Boolean.annotate({
718
+ description: "Reserved for branded connect pages and your own provider apps. Neither is available yet."
719
+ }),
714
720
  ssoSaml: Schema9.Boolean,
715
721
  priorityQueue: Schema9.Boolean,
716
722
  adsInsights: Schema9.Boolean,
@@ -2792,23 +2798,20 @@ var postText = Schema18.Trim.check(Schema18.isMaxLength(postTextLimit)).pipe(Sch
2792
2798
  description: `At most ${postTextLimit} characters after trimming.`
2793
2799
  }));
2794
2800
  var postTargets = Schema18.Array(PublishTarget).check(Schema18.isMaxLength(50));
2795
- var postContent = {
2801
+ var PostContent = Schema18.Struct({
2796
2802
  text: Schema18.optionalKey(postText),
2797
2803
  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,
2804
+ media: Schema18.optionalKey(MediaInputs),
2805
2805
  scheduledAt: Schema18.optionalKey(ScheduledAt)
2806
- }).annotate({ identifier: "PostPreflight" });
2807
- var CreatePost = Schema18.Struct({
2808
- text: Schema18.optionalKey(postText),
2806
+ }).annotate({ identifier: "PostContent" });
2807
+ var destinationSelectors = {
2809
2808
  platforms: Schema18.optionalKey(Schema18.Array(Provider).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2810
2809
  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))),
2810
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit)))
2811
+ };
2812
+ var CreatePost = Schema18.Struct({
2813
+ text: Schema18.optionalKey(postText),
2814
+ ...destinationSelectors,
2812
2815
  media: Schema18.optionalKey(MediaInputs),
2813
2816
  scheduledAt: Schema18.optionalKey(ScheduledAt),
2814
2817
  publishNow: Schema18.optionalKey(Schema18.Boolean),
@@ -2816,12 +2819,18 @@ var CreatePost = Schema18.Struct({
2816
2819
  description: "Save the post as a draft without submitting it. Defaults to false."
2817
2820
  })
2818
2821
  }).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."
2822
+ 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
2823
  });
2821
2824
  var UpdatePost = Schema18.Struct({
2822
- ...postContent,
2825
+ text: Schema18.optionalKey(postText),
2826
+ media: Schema18.optionalKey(MediaInputs),
2827
+ scheduledAt: Schema18.optionalKey(ScheduleOverride),
2828
+ ...destinationSelectors,
2829
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMaxLength(publishTargetLimit))),
2823
2830
  expectedRevision: Schema18.optionalKey(revision)
2824
- }).annotate({ identifier: "UpdatePost" });
2831
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2832
+ 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."
2833
+ });
2825
2834
  var Post = Schema18.Struct({
2826
2835
  postId: PostId,
2827
2836
  isDraft: Schema18.Boolean,
@@ -2829,6 +2838,9 @@ var Post = Schema18.Struct({
2829
2838
  text: postText,
2830
2839
  media: MediaInputs,
2831
2840
  targets: postTargets,
2841
+ scheduledAt: Schema18.NullOr(ScheduledAt).annotate({
2842
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2843
+ }),
2832
2844
  deliveries: Schema18.Array(DeliveryStatus),
2833
2845
  status: PostState,
2834
2846
  createdAt: Schema18.String,
@@ -5428,6 +5440,17 @@ class DestinationAlreadySubmitted extends HttpApiError.Problem()("DestinationAlr
5428
5440
  }) {
5429
5441
  }
5430
5442
 
5443
+ class PostSubmitted extends HttpApiError.Problem()("PostSubmitted", {
5444
+ type: "urn:pubnio:problem:post-submitted",
5445
+ status: 409,
5446
+ title: "Post already submitted"
5447
+ }, {
5448
+ code: Schema28.Literal("post_submitted"),
5449
+ targetIds: Schema28.Array(TargetId),
5450
+ nextAction: Schema28.String
5451
+ }) {
5452
+ }
5453
+
5431
5454
  class DeliveryNotRetryable extends HttpApiError.Problem()("DeliveryNotRetryable", {
5432
5455
  type: "urn:pubnio:problem:delivery-not-retryable",
5433
5456
  status: 409,
@@ -5933,6 +5956,7 @@ var PublishProblems = [
5933
5956
  AttemptChanged,
5934
5957
  IdempotencyConflict,
5935
5958
  DestinationAlreadySubmitted,
5959
+ PostSubmitted,
5936
5960
  DeliveryNotRetryable,
5937
5961
  DeliveryNotReconcilable,
5938
5962
  DeliveryScheduleLocked,
@@ -6391,7 +6415,7 @@ import { ProblemDetails } from "effect/http";
6391
6415
  // package.json
6392
6416
  var package_default = {
6393
6417
  name: "@pubnio/sdk",
6394
- version: "0.3.0",
6418
+ version: "0.5.0",
6395
6419
  description: "JavaScript and TypeScript client for the PubNio API",
6396
6420
  type: "module",
6397
6421
  exports: {
@@ -8919,7 +8943,7 @@ function createPubNioClient({
8919
8943
  return withIdempotencyKey(idempotencyKey, async () => {
8920
8944
  const body = post;
8921
8945
  if (post.isDraft) {
8922
- return decode(Post, postsCreate({
8946
+ return decode(PostCreated, postsCreate({
8923
8947
  client,
8924
8948
  query: { workspaceId },
8925
8949
  headers: { "idempotency-key": idempotencyKey },
@@ -9613,7 +9637,7 @@ function createPubNioClient({
9613
9637
  ...transport()
9614
9638
  }));
9615
9639
  },
9616
- publish: (postId, input) => {
9640
+ publish: (postId, input = {}) => {
9617
9641
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9618
9642
  return withIdempotencyKey(idempotencyKey, async () => {
9619
9643
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9624,7 +9648,7 @@ function createPubNioClient({
9624
9648
  body: {
9625
9649
  expectedRevision: publish.expectedRevision,
9626
9650
  scheduledAt: publish.scheduledAt,
9627
- accountIds: publish.accountIds && [...publish.accountIds],
9651
+ accounts: publish.accounts && [...publish.accounts],
9628
9652
  targets: publish.targets && [...publish.targets]
9629
9653
  },
9630
9654
  ...transport()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubnio/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "JavaScript and TypeScript client for the PubNio API",
5
5
  "homepage": "https://pubnio.com",
6
6
  "keywords": [