@postonus/cli 0.1.50 → 0.1.51

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
@@ -8461,7 +8461,8 @@ var THUMBNAIL_SOURCE_VALUES = ["FRAME_CAPTURE", "UPLOADED"];
8461
8461
  var INTEGRATION_TOKEN_STATUS_VALUES = ["VALID", "EXPIRED", "UNKNOWN"];
8462
8462
  var SHARE_AUDIENCE_VALUES = ["anyone", "invited"];
8463
8463
  var APPROVAL_STATUS_VALUES = ["pending_review", "changes_requested", "approved", "rejected"];
8464
- var SCHEDULE_STATUS_VALUES = ["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED"];
8464
+ var SCHEDULE_STATUS_VALUES = ["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED", "READY"];
8465
+ var SCHEDULE_DELIVERY_VALUES = ["API", "BROWSER"];
8465
8466
  var ScheduleFailureDetailSchema = object({
8466
8467
  status: number2().optional(),
8467
8468
  platformMessage: string2().optional(),
@@ -8512,13 +8513,16 @@ var SharedPostFields = {
8512
8513
  */
8513
8514
  integrationMedia: record(string2(), array(string2())).optional(),
8514
8515
  integrationTimeOffsets: record(string2(), number2().int().min(-12).max(12)).optional(),
8516
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional(),
8517
+ integrationDelivery: record(string2(), _enum(SCHEDULE_DELIVERY_VALUES)).optional(),
8515
8518
  ...ThreadFields
8516
8519
  };
8517
8520
  var hasContentOrMedia = (data) => Boolean(data.content && data.content.trim().length > 0 || data.media && data.media.length > 0);
8518
8521
  var CreatePostRowSchema = object({
8519
8522
  content: ContentField,
8520
8523
  media: array(PostMediaInputSchema).optional(),
8521
- scheduledAt: InstantInput.optional()
8524
+ scheduledAt: InstantInput.optional(),
8525
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional()
8522
8526
  }).refine(hasContentOrMedia, "Add some content or media to your post");
8523
8527
  var ThreadSchema = array(string2().trim().min(1).max(DRAFT_MAX_CHARS)).min(2).max(MAX_THREAD_SEGMENTS);
8524
8528
  var DryRunField = boolean2().optional();
@@ -8575,6 +8579,8 @@ var ScheduleDraftInputSchema = object({
8575
8579
  // Required when the draft was saved with no channels; replaces them otherwise.
8576
8580
  selectedIntegrations: array(string2()).min(1).optional(),
8577
8581
  platforms: array(PlatformSchema).min(1).optional(),
8582
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional(),
8583
+ integrationDelivery: record(string2(), _enum(SCHEDULE_DELIVERY_VALUES)).optional(),
8578
8584
  dryRun: DryRunField
8579
8585
  }).refine((data) => !(data.selectedIntegrations && data.platforms), {
8580
8586
  message: "Name channels by `selectedIntegrations` or `platforms`, not both",
@@ -8663,6 +8669,7 @@ var PostScheduleSchema = object({
8663
8669
  userId: string2(),
8664
8670
  integrationId: string2(),
8665
8671
  status: _enum(SCHEDULE_STATUS_VALUES),
8672
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
8666
8673
  scheduledAt: Timestamp.nullable(),
8667
8674
  publishedAt: Timestamp.nullable(),
8668
8675
  failureReason: string2().nullable(),
@@ -8739,7 +8746,8 @@ var PostScheduleStateSchema = object({
8739
8746
  platform: PlatformSchema,
8740
8747
  channelName: string2(),
8741
8748
  scheduledAt: Timestamp.nullable(),
8742
- status: _enum(SCHEDULE_STATUS_VALUES)
8749
+ status: _enum(SCHEDULE_STATUS_VALUES),
8750
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES)
8743
8751
  });
8744
8752
  var PostStateSchema = object({
8745
8753
  postId: string2(),
@@ -8806,6 +8814,11 @@ var postDomainErrors = {
8806
8814
  AI_CREDITS_EXHAUSTED: {
8807
8815
  status: 402,
8808
8816
  message: "AI credits exhausted. Upgrade your plan or wait for your credits to renew."
8817
+ },
8818
+ SCHEDULE_NOT_READY: { status: 400, message: "Only ready schedules can be marked as posted." },
8819
+ BROWSER_DELIVERY_NOT_ALLOWED: {
8820
+ status: 400,
8821
+ message: "Tap to post is available for X (Twitter) only and cannot include threads or first comments."
8809
8822
  }
8810
8823
  };
8811
8824
  var tagged13 = base.route({ tags: ["Posts"] });
@@ -8842,6 +8855,11 @@ var postsContract = {
8842
8855
  path: "/posts/schedules/{scheduleId}/reschedule",
8843
8856
  summary: "Move a schedule to a new time"
8844
8857
  }).errors({ ...writableErrors, ...postDomainErrors }).input(RescheduleInputSchema).output(PostStateSchema),
8858
+ markPosted: idempotent.route({
8859
+ method: "POST",
8860
+ path: "/posts/schedules/{scheduleId}/mark-posted",
8861
+ summary: "Mark a ready schedule as posted"
8862
+ }).errors({ ...writableErrors, ...postDomainErrors }).input(object({ scheduleId: Uuid })).output(PostStateSchema),
8845
8863
  bulkScheduleInWindows: internal7.route({
8846
8864
  method: "POST",
8847
8865
  path: "/posts/schedules/bulk-schedule-windows",
@@ -9112,7 +9130,7 @@ var AcquisitionMethodSchema = _enum(["api", "url", "csv", "extension"]);
9112
9130
  var WorkflowStatusSchema = _enum(["DRAFT", "RUNNING", "PAUSED", "COMPLETED", "FAILED"]);
9113
9131
  var WorkflowRunStatusSchema = _enum(["SUCCESS", "PARTIAL", "FAILED", "RATE_LIMITED"]);
9114
9132
  var ScheduleSpreadSchema = _enum(["IMMEDIATE", "SPREAD_DAYS", "SPREAD_WEEKS"]);
9115
- var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED"]);
9133
+ var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED", "READY"]);
9116
9134
  var quotaErrors = {
9117
9135
  REPURPOSE_QUOTA_EXCEEDED: {
9118
9136
  status: 403,
@@ -9595,6 +9613,7 @@ var ScheduleListItemSchema = object({
9595
9613
  organizationId: string2(),
9596
9614
  integrationId: string2(),
9597
9615
  status: _enum(SCHEDULE_STATUS_VALUES),
9616
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9598
9617
  scheduledAt: Timestamp.nullable(),
9599
9618
  publishedAt: Timestamp.nullable(),
9600
9619
  originRecycleEventId: string2().nullable(),
@@ -9664,6 +9683,7 @@ var ScheduleWithIntegrationSchema = object({
9664
9683
  organizationId: string2(),
9665
9684
  integrationId: string2(),
9666
9685
  status: _enum(SCHEDULE_STATUS_VALUES),
9686
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9667
9687
  scheduledAt: Timestamp.nullable(),
9668
9688
  publishedAt: Timestamp.nullable(),
9669
9689
  originRecycleEventId: string2().nullable(),
@@ -12946,7 +12966,7 @@ function formatTable(headers, rows, isTty = process.stdout.isTTY) {
12946
12966
  }
12947
12967
 
12948
12968
  // src/version.ts
12949
- var CLI_VERSION = "0.1.50";
12969
+ var CLI_VERSION = "0.1.51";
12950
12970
 
12951
12971
  // src/client.ts
12952
12972
  var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
@@ -13980,6 +14000,14 @@ function readXLinkHandling(value2) {
13980
14000
  }
13981
14001
  return failUsage("--x-link-handling must be 'first_reply', 'plain_text', or 'keep_live'.");
13982
14002
  }
14003
+ function parseDelivery(value2) {
14004
+ if (!value2) return void 0;
14005
+ const upper = value2.toUpperCase();
14006
+ if (upper === "API" || upper === "BROWSER") {
14007
+ return upper;
14008
+ }
14009
+ return failUsage("--delivery must be 'api' or 'browser'.");
14010
+ }
13983
14011
  function readTiming(options) {
13984
14012
  const chosen = [options.at, options.optimal, options.now, options.draft].filter(Boolean);
13985
14013
  if (chosen.length > 1) failUsage("Use one of --at, --optimal, --now or --draft.");
@@ -14025,6 +14053,7 @@ async function post(text, options) {
14025
14053
  const project = await readProjectConfig();
14026
14054
  const targets = readTargets(options, project?.defaultPlatforms);
14027
14055
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14056
+ const delivery = parseDelivery(options.delivery);
14028
14057
  if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
14029
14058
  failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
14030
14059
  }
@@ -14036,7 +14065,8 @@ async function post(text, options) {
14036
14065
  {
14037
14066
  content: thread ? thread.join("\n\n") : content,
14038
14067
  scheduledAt: "scheduledAt" in timing ? timing.scheduledAt : void 0,
14039
- media: media2.map((item) => ({ url: item.url, type: item.type, id: item.mediaId, fileId: item.uploadId }))
14068
+ media: media2.map((item) => ({ url: item.url, type: item.type, id: item.mediaId, fileId: item.uploadId })),
14069
+ delivery
14040
14070
  }
14041
14071
  ],
14042
14072
  shared: {
@@ -14072,9 +14102,10 @@ async function editPost(postId, text, options) {
14072
14102
  const integrationContent = readCopy(options.copy);
14073
14103
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14074
14104
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14075
- if (!thread && content === void 0 && !targets.platforms && !targets.selectedIntegrations && !integrationContent && !scheduledAt && !options.media?.length && !options.subreddit && !xLinkHandling) {
14105
+ const delivery = parseDelivery(options.delivery);
14106
+ if (!thread && content === void 0 && !targets.platforms && !targets.selectedIntegrations && !integrationContent && !scheduledAt && !options.media?.length && !options.subreddit && !xLinkHandling && !delivery) {
14076
14107
  failUsage(
14077
- "Nothing to change. Pass new text, --thread-file, --at, --to, --channel, --copy, --subreddit, --x-link-handling or --media."
14108
+ "Nothing to change. Pass new text, --thread-file, --at, --to, --channel, --copy, --subreddit, --x-link-handling, --delivery or --media."
14078
14109
  );
14079
14110
  }
14080
14111
  const { api } = await getApi();
@@ -14085,6 +14116,7 @@ async function editPost(postId, text, options) {
14085
14116
  content,
14086
14117
  thread,
14087
14118
  scheduledAt,
14119
+ delivery,
14088
14120
  ...targets,
14089
14121
  integrationContent,
14090
14122
  subreddit: options.subreddit,
@@ -14262,6 +14294,11 @@ async function scheduleDraft(postId, options) {
14262
14294
  if (Boolean(options.at) === Boolean(options.optimal)) failUsage("Say when to post: --at <time> or --optimal.");
14263
14295
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14264
14296
  const channelIds = options.channels?.split(",").map((id) => id.trim()).filter(Boolean);
14297
+ const deliveryUpper = options.delivery ? options.delivery.toUpperCase() : void 0;
14298
+ if (deliveryUpper && deliveryUpper !== "API" && deliveryUpper !== "BROWSER") {
14299
+ failUsage("--delivery must be 'api' or 'browser'.");
14300
+ }
14301
+ const delivery = deliveryUpper;
14265
14302
  const { api } = await getApi();
14266
14303
  try {
14267
14304
  const state = await api.posts.scheduleDraft({
@@ -14269,6 +14306,7 @@ async function scheduleDraft(postId, options) {
14269
14306
  scheduledAt,
14270
14307
  useOptimalTime: options.optimal,
14271
14308
  selectedIntegrations: channelIds?.length ? channelIds : void 0,
14309
+ delivery,
14272
14310
  dryRun: options.dryRun
14273
14311
  });
14274
14312
  if (isJsonMode()) {
@@ -14384,15 +14422,15 @@ var collect = (value2, previous = []) => [...previous, value2];
14384
14422
  var postCommand = program.command("post").alias("posts").description("create a post: scheduled, now, at the next optimal time, or as a draft").argument("[text]", "post content; also accepts piped stdin").option("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-c, --channel <id>", "a channel id from `postonus channels list`; repeatable", collect).option("--channels <ids>", "channel ids; comma-separated or repeatable", collect).option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "the next recommended window").option("--now", "publish as soon as the queue picks it up").option("-d, --draft", "save as a draft without scheduling").option("-f, --file <path>", "read content from a file").option("--thread-file <path>", "read a thread: segments separated by a line of ---").option("-e, --editor", "compose in $EDITOR").option("-m, --media <path...>", "attach local image or video files").option("--copy <channelId=text>", "text that replaces the body on one channel; repeatable", collect).option("--subreddit <name>", "target subreddit for Reddit posts (e.g. programming or r/programming)").option(
14385
14423
  "--x-link-handling <handling>",
14386
14424
  "how to handle links in X posts: 'first_reply' (default), 'plain_text', or 'keep_live'"
14387
- ).option("--dry-run", "run every server check and show the result without saving").action(post);
14388
- postCommand.command("edit").description("change a post; only the flags given change").argument("<postId>", "post id from `postonus queue list`").argument("[text]", "new content").option("-t, --to <platforms>", "replace the channels with these platforms").option("-c, --channel <id>", "replace the channels with these ids; repeatable", collect).option("--channels <ids>", "alias for --channel", collect).option("-a, --at <time>", "move every channel to this RFC 3339 time").option("-f, --file <path>", "read new content from a file").option("--thread-file <path>", "replace the body with a thread file").option("-m, --media <path...>", "replace the media with these files").option("--copy <channelId=text>", "replace one channel's copy; repeatable", collect).option("--subreddit <name>", "target subreddit for Reddit posts (e.g. programming or r/programming)").option("--x-link-handling <handling>", "how to handle links in X posts: 'first_reply', 'plain_text', or 'keep_live'").option("--dry-run", "run every server check and show the result without saving").action(editPost);
14425
+ ).option("--delivery <mode>", "delivery method: 'api' (default) or 'browser' (Tap to post; costs 0 X credits)").option("--dry-run", "run every server check and show the result without saving").action(post);
14426
+ postCommand.command("edit").description("change a post; only the flags given change").argument("<postId>", "post id from `postonus queue list`").argument("[text]", "new content").option("-t, --to <platforms>", "replace the channels with these platforms").option("-c, --channel <id>", "replace the channels with these ids; repeatable", collect).option("--channels <ids>", "alias for --channel", collect).option("-a, --at <time>", "move every channel to this RFC 3339 time").option("-f, --file <path>", "read new content from a file").option("--thread-file <path>", "replace the body with a thread file").option("-m, --media <path...>", "replace the media with these files").option("--copy <channelId=text>", "replace one channel's copy; repeatable", collect).option("--subreddit <name>", "target subreddit for Reddit posts (e.g. programming or r/programming)").option("--x-link-handling <handling>", "how to handle links in X posts: 'first_reply', 'plain_text', or 'keep_live'").option("--delivery <mode>", "delivery method: 'api' or 'browser'").option("--dry-run", "run every server check and show the result without saving").action(editPost);
14389
14427
  postCommand.command("delete").alias("rm").alias("del").description("delete a post and every schedule on it").argument("<postId>", "post id from `postonus queue list`").option("--remote", "also delete published copies on their platforms").option("-y, --yes", "skip confirmation prompt").action(deletePost);
14390
14428
  postCommand.command("retry").description("queue a failed schedule to publish again").argument("<scheduleId>", "schedule id from `postonus queue list --status failed`").option("--content <text>", "replacement copy for this channel only").action(retrySchedule);
14391
14429
  program.command("best-times").description("recommended posting windows for the given platforms").requiredOption("-t, --to <platforms>", "comma-separated platforms, e.g. x,linkedin").option("-n, --limit <count>", "how many times to list (1-20)", "5").option("--count <count>", "alias for --limit (deprecated)").action(bestTimes);
14392
14430
  program.command("workspaces").alias("workspace").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
14393
14431
  var queue = program.command("queue").description("inspect and adjust scheduled posts");
14394
14432
  queue.command("list").alias("ls").description("list drafts, scheduled posts and failures").addOption(new Option("-n, --limit <count>", "how many to show (10-100)").default("20")).option("-t, --to <platforms>", "filter by comma-separated platforms").option("-s, --status <statuses>", "filter by comma-separated statuses").action(listQueue);
14395
- queue.command("schedule").description("give a draft its send time").argument("<postId>", "post id from `postonus queue list --status draft` or `postonus post --draft`").option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "next recommended window").option("--dry-run", "run every server check and show the result without saving").option(
14433
+ queue.command("schedule").description("give a draft its send time").argument("<postId>", "post id from `postonus queue list --status draft` or `postonus post --draft`").option("-a, --at <time>", "RFC 3339 time with an offset").option("-o, --optimal", "next recommended window").option("--delivery <mode>", "delivery method: 'api' (default) or 'browser' (Tap to post; costs 0 X credits)").option("--dry-run", "run every server check and show the result without saving").option(
14396
14434
  "-c, --channels <ids>",
14397
14435
  "comma-separated channel ids from `postonus channels list`; needed if the draft has none"
14398
14436
  ).action(scheduleDraft);