@postonus/cli 0.1.50 → 0.1.52

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,6 +8513,8 @@ 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);
@@ -8575,6 +8578,8 @@ var ScheduleDraftInputSchema = object({
8575
8578
  // Required when the draft was saved with no channels; replaces them otherwise.
8576
8579
  selectedIntegrations: array(string2()).min(1).optional(),
8577
8580
  platforms: array(PlatformSchema).min(1).optional(),
8581
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional(),
8582
+ integrationDelivery: record(string2(), _enum(SCHEDULE_DELIVERY_VALUES)).optional(),
8578
8583
  dryRun: DryRunField
8579
8584
  }).refine((data) => !(data.selectedIntegrations && data.platforms), {
8580
8585
  message: "Name channels by `selectedIntegrations` or `platforms`, not both",
@@ -8663,6 +8668,7 @@ var PostScheduleSchema = object({
8663
8668
  userId: string2(),
8664
8669
  integrationId: string2(),
8665
8670
  status: _enum(SCHEDULE_STATUS_VALUES),
8671
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
8666
8672
  scheduledAt: Timestamp.nullable(),
8667
8673
  publishedAt: Timestamp.nullable(),
8668
8674
  failureReason: string2().nullable(),
@@ -8739,7 +8745,8 @@ var PostScheduleStateSchema = object({
8739
8745
  platform: PlatformSchema,
8740
8746
  channelName: string2(),
8741
8747
  scheduledAt: Timestamp.nullable(),
8742
- status: _enum(SCHEDULE_STATUS_VALUES)
8748
+ status: _enum(SCHEDULE_STATUS_VALUES),
8749
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES)
8743
8750
  });
8744
8751
  var PostStateSchema = object({
8745
8752
  postId: string2(),
@@ -8806,6 +8813,11 @@ var postDomainErrors = {
8806
8813
  AI_CREDITS_EXHAUSTED: {
8807
8814
  status: 402,
8808
8815
  message: "AI credits exhausted. Upgrade your plan or wait for your credits to renew."
8816
+ },
8817
+ SCHEDULE_NOT_READY: { status: 400, message: "Only ready schedules can be marked as posted." },
8818
+ BROWSER_DELIVERY_NOT_ALLOWED: {
8819
+ status: 400,
8820
+ message: "Tap to post is available for X (Twitter) only and cannot include threads or first comments."
8809
8821
  }
8810
8822
  };
8811
8823
  var tagged13 = base.route({ tags: ["Posts"] });
@@ -8842,6 +8854,11 @@ var postsContract = {
8842
8854
  path: "/posts/schedules/{scheduleId}/reschedule",
8843
8855
  summary: "Move a schedule to a new time"
8844
8856
  }).errors({ ...writableErrors, ...postDomainErrors }).input(RescheduleInputSchema).output(PostStateSchema),
8857
+ markPosted: idempotent.route({
8858
+ method: "POST",
8859
+ path: "/posts/schedules/{scheduleId}/mark-posted",
8860
+ summary: "Mark a ready schedule as posted"
8861
+ }).errors({ ...writableErrors, ...postDomainErrors }).input(object({ scheduleId: Uuid })).output(PostStateSchema),
8845
8862
  bulkScheduleInWindows: internal7.route({
8846
8863
  method: "POST",
8847
8864
  path: "/posts/schedules/bulk-schedule-windows",
@@ -9112,7 +9129,7 @@ var AcquisitionMethodSchema = _enum(["api", "url", "csv", "extension"]);
9112
9129
  var WorkflowStatusSchema = _enum(["DRAFT", "RUNNING", "PAUSED", "COMPLETED", "FAILED"]);
9113
9130
  var WorkflowRunStatusSchema = _enum(["SUCCESS", "PARTIAL", "FAILED", "RATE_LIMITED"]);
9114
9131
  var ScheduleSpreadSchema = _enum(["IMMEDIATE", "SPREAD_DAYS", "SPREAD_WEEKS"]);
9115
- var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED"]);
9132
+ var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED", "READY"]);
9116
9133
  var quotaErrors = {
9117
9134
  REPURPOSE_QUOTA_EXCEEDED: {
9118
9135
  status: 403,
@@ -9595,6 +9612,7 @@ var ScheduleListItemSchema = object({
9595
9612
  organizationId: string2(),
9596
9613
  integrationId: string2(),
9597
9614
  status: _enum(SCHEDULE_STATUS_VALUES),
9615
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9598
9616
  scheduledAt: Timestamp.nullable(),
9599
9617
  publishedAt: Timestamp.nullable(),
9600
9618
  originRecycleEventId: string2().nullable(),
@@ -9664,6 +9682,7 @@ var ScheduleWithIntegrationSchema = object({
9664
9682
  organizationId: string2(),
9665
9683
  integrationId: string2(),
9666
9684
  status: _enum(SCHEDULE_STATUS_VALUES),
9685
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9667
9686
  scheduledAt: Timestamp.nullable(),
9668
9687
  publishedAt: Timestamp.nullable(),
9669
9688
  originRecycleEventId: string2().nullable(),
@@ -12946,7 +12965,7 @@ function formatTable(headers, rows, isTty = process.stdout.isTTY) {
12946
12965
  }
12947
12966
 
12948
12967
  // src/version.ts
12949
- var CLI_VERSION = "0.1.50";
12968
+ var CLI_VERSION = "0.1.52";
12950
12969
 
12951
12970
  // src/client.ts
12952
12971
  var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
@@ -13980,6 +13999,14 @@ function readXLinkHandling(value2) {
13980
13999
  }
13981
14000
  return failUsage("--x-link-handling must be 'first_reply', 'plain_text', or 'keep_live'.");
13982
14001
  }
14002
+ function parseDelivery(value2) {
14003
+ if (!value2) return void 0;
14004
+ const upper = value2.toUpperCase();
14005
+ if (upper === "API" || upper === "BROWSER") {
14006
+ return upper;
14007
+ }
14008
+ return failUsage("--delivery must be 'api' or 'browser'.");
14009
+ }
13983
14010
  function readTiming(options) {
13984
14011
  const chosen = [options.at, options.optimal, options.now, options.draft].filter(Boolean);
13985
14012
  if (chosen.length > 1) failUsage("Use one of --at, --optimal, --now or --draft.");
@@ -14025,6 +14052,7 @@ async function post(text, options) {
14025
14052
  const project = await readProjectConfig();
14026
14053
  const targets = readTargets(options, project?.defaultPlatforms);
14027
14054
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14055
+ const delivery = parseDelivery(options.delivery);
14028
14056
  if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
14029
14057
  failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
14030
14058
  }
@@ -14041,6 +14069,7 @@ async function post(text, options) {
14041
14069
  ],
14042
14070
  shared: {
14043
14071
  ...targets,
14072
+ delivery,
14044
14073
  thread,
14045
14074
  integrationContent: readCopy(options.copy),
14046
14075
  xLinkHandling,
@@ -14072,9 +14101,10 @@ async function editPost(postId, text, options) {
14072
14101
  const integrationContent = readCopy(options.copy);
14073
14102
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14074
14103
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14075
- if (!thread && content === void 0 && !targets.platforms && !targets.selectedIntegrations && !integrationContent && !scheduledAt && !options.media?.length && !options.subreddit && !xLinkHandling) {
14104
+ const delivery = parseDelivery(options.delivery);
14105
+ if (!thread && content === void 0 && !targets.platforms && !targets.selectedIntegrations && !integrationContent && !scheduledAt && !options.media?.length && !options.subreddit && !xLinkHandling && !delivery) {
14076
14106
  failUsage(
14077
- "Nothing to change. Pass new text, --thread-file, --at, --to, --channel, --copy, --subreddit, --x-link-handling or --media."
14107
+ "Nothing to change. Pass new text, --thread-file, --at, --to, --channel, --copy, --subreddit, --x-link-handling, --delivery or --media."
14078
14108
  );
14079
14109
  }
14080
14110
  const { api } = await getApi();
@@ -14085,6 +14115,7 @@ async function editPost(postId, text, options) {
14085
14115
  content,
14086
14116
  thread,
14087
14117
  scheduledAt,
14118
+ delivery,
14088
14119
  ...targets,
14089
14120
  integrationContent,
14090
14121
  subreddit: options.subreddit,
@@ -14262,6 +14293,11 @@ async function scheduleDraft(postId, options) {
14262
14293
  if (Boolean(options.at) === Boolean(options.optimal)) failUsage("Say when to post: --at <time> or --optimal.");
14263
14294
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14264
14295
  const channelIds = options.channels?.split(",").map((id) => id.trim()).filter(Boolean);
14296
+ const deliveryUpper = options.delivery ? options.delivery.toUpperCase() : void 0;
14297
+ if (deliveryUpper && deliveryUpper !== "API" && deliveryUpper !== "BROWSER") {
14298
+ failUsage("--delivery must be 'api' or 'browser'.");
14299
+ }
14300
+ const delivery = deliveryUpper;
14265
14301
  const { api } = await getApi();
14266
14302
  try {
14267
14303
  const state = await api.posts.scheduleDraft({
@@ -14269,6 +14305,7 @@ async function scheduleDraft(postId, options) {
14269
14305
  scheduledAt,
14270
14306
  useOptimalTime: options.optimal,
14271
14307
  selectedIntegrations: channelIds?.length ? channelIds : void 0,
14308
+ delivery,
14272
14309
  dryRun: options.dryRun
14273
14310
  });
14274
14311
  if (isJsonMode()) {
@@ -14384,15 +14421,15 @@ var collect = (value2, previous = []) => [...previous, value2];
14384
14421
  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
14422
  "--x-link-handling <handling>",
14386
14423
  "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);
14424
+ ).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);
14425
+ 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
14426
  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
14427
  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
14428
  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
14429
  program.command("workspaces").alias("workspace").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
14393
14430
  var queue = program.command("queue").description("inspect and adjust scheduled posts");
14394
14431
  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(
14432
+ 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
14433
  "-c, --channels <ids>",
14397
14434
  "comma-separated channel ids from `postonus channels list`; needed if the draft has none"
14398
14435
  ).action(scheduleDraft);