@postonus/cli 0.1.49 → 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
@@ -262,6 +262,19 @@ var OUTREACH_SUPPRESSION_REASON_VALUES = [
262
262
  ];
263
263
  var OUTREACH_EVENT_KIND_VALUES = ["reply", "bounce", "unsubscribe"];
264
264
 
265
+ // ../../packages/app-config/src/clips.ts
266
+ var CLIP_JOB_FAILURE_CODES = [
267
+ "DOWNLOAD_FAILED",
268
+ "TRANSCRIBE_FAILED",
269
+ "NO_MOMENTS",
270
+ "ENCODE_FAILED",
271
+ "UPLOAD_FAILED",
272
+ "CAPTIONS_UNSUPPORTED",
273
+ "ENQUEUE_FAILED",
274
+ "STALE",
275
+ "UNKNOWN"
276
+ ];
277
+
265
278
  // src/index.ts
266
279
  import { Command, Option } from "commander";
267
280
 
@@ -7829,6 +7842,7 @@ var channelGroupsContract = {
7829
7842
  // ../../packages/api-contract/src/clips.ts
7830
7843
  var internal4 = base.meta({ internal: true });
7831
7844
  var ClipJobStatusSchema = _enum(["QUEUED", "PROCESSING", "DONE", "FAILED"]);
7845
+ var ClipJobFailureCodeSchema = _enum(CLIP_JOB_FAILURE_CODES);
7832
7846
  var ClipJobSchema = object({
7833
7847
  id: Uuid,
7834
7848
  organizationId: string2(),
@@ -7836,7 +7850,7 @@ var ClipJobSchema = object({
7836
7850
  sourceMediaId: Uuid.nullable(),
7837
7851
  youtubeUrl: string2().nullable(),
7838
7852
  status: ClipJobStatusSchema,
7839
- failureCode: string2().nullable(),
7853
+ failureCode: ClipJobFailureCodeSchema.nullable(),
7840
7854
  inputSeconds: number2().int().nullable(),
7841
7855
  creditsReserved: number2().int(),
7842
7856
  transcriptVendor: string2().nullable(),
@@ -7845,10 +7859,16 @@ var ClipJobSchema = object({
7845
7859
  createdAt: Timestamp,
7846
7860
  updatedAt: Timestamp
7847
7861
  });
7848
- var CreateClipJobInputSchema = object({
7849
- mediaId: Uuid.optional(),
7850
- youtubeUrl: string2().url().optional()
7851
- });
7862
+ var CreateClipJobInputSchema = union([
7863
+ object({
7864
+ mediaId: Uuid,
7865
+ youtubeUrl: never().optional()
7866
+ }),
7867
+ object({
7868
+ mediaId: never().optional(),
7869
+ youtubeUrl: string2().url()
7870
+ })
7871
+ ]);
7852
7872
  var ListClipsInputSchema = object({
7853
7873
  limit: coerce_exports.number().int().min(1).max(100).default(20).optional()
7854
7874
  });
@@ -8441,7 +8461,8 @@ var THUMBNAIL_SOURCE_VALUES = ["FRAME_CAPTURE", "UPLOADED"];
8441
8461
  var INTEGRATION_TOKEN_STATUS_VALUES = ["VALID", "EXPIRED", "UNKNOWN"];
8442
8462
  var SHARE_AUDIENCE_VALUES = ["anyone", "invited"];
8443
8463
  var APPROVAL_STATUS_VALUES = ["pending_review", "changes_requested", "approved", "rejected"];
8444
- 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"];
8445
8466
  var ScheduleFailureDetailSchema = object({
8446
8467
  status: number2().optional(),
8447
8468
  platformMessage: string2().optional(),
@@ -8492,13 +8513,16 @@ var SharedPostFields = {
8492
8513
  */
8493
8514
  integrationMedia: record(string2(), array(string2())).optional(),
8494
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(),
8495
8518
  ...ThreadFields
8496
8519
  };
8497
8520
  var hasContentOrMedia = (data) => Boolean(data.content && data.content.trim().length > 0 || data.media && data.media.length > 0);
8498
8521
  var CreatePostRowSchema = object({
8499
8522
  content: ContentField,
8500
8523
  media: array(PostMediaInputSchema).optional(),
8501
- scheduledAt: InstantInput.optional()
8524
+ scheduledAt: InstantInput.optional(),
8525
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional()
8502
8526
  }).refine(hasContentOrMedia, "Add some content or media to your post");
8503
8527
  var ThreadSchema = array(string2().trim().min(1).max(DRAFT_MAX_CHARS)).min(2).max(MAX_THREAD_SEGMENTS);
8504
8528
  var DryRunField = boolean2().optional();
@@ -8555,6 +8579,8 @@ var ScheduleDraftInputSchema = object({
8555
8579
  // Required when the draft was saved with no channels; replaces them otherwise.
8556
8580
  selectedIntegrations: array(string2()).min(1).optional(),
8557
8581
  platforms: array(PlatformSchema).min(1).optional(),
8582
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES).optional(),
8583
+ integrationDelivery: record(string2(), _enum(SCHEDULE_DELIVERY_VALUES)).optional(),
8558
8584
  dryRun: DryRunField
8559
8585
  }).refine((data) => !(data.selectedIntegrations && data.platforms), {
8560
8586
  message: "Name channels by `selectedIntegrations` or `platforms`, not both",
@@ -8643,6 +8669,7 @@ var PostScheduleSchema = object({
8643
8669
  userId: string2(),
8644
8670
  integrationId: string2(),
8645
8671
  status: _enum(SCHEDULE_STATUS_VALUES),
8672
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
8646
8673
  scheduledAt: Timestamp.nullable(),
8647
8674
  publishedAt: Timestamp.nullable(),
8648
8675
  failureReason: string2().nullable(),
@@ -8719,7 +8746,8 @@ var PostScheduleStateSchema = object({
8719
8746
  platform: PlatformSchema,
8720
8747
  channelName: string2(),
8721
8748
  scheduledAt: Timestamp.nullable(),
8722
- status: _enum(SCHEDULE_STATUS_VALUES)
8749
+ status: _enum(SCHEDULE_STATUS_VALUES),
8750
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES)
8723
8751
  });
8724
8752
  var PostStateSchema = object({
8725
8753
  postId: string2(),
@@ -8786,6 +8814,11 @@ var postDomainErrors = {
8786
8814
  AI_CREDITS_EXHAUSTED: {
8787
8815
  status: 402,
8788
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."
8789
8822
  }
8790
8823
  };
8791
8824
  var tagged13 = base.route({ tags: ["Posts"] });
@@ -8822,6 +8855,11 @@ var postsContract = {
8822
8855
  path: "/posts/schedules/{scheduleId}/reschedule",
8823
8856
  summary: "Move a schedule to a new time"
8824
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),
8825
8863
  bulkScheduleInWindows: internal7.route({
8826
8864
  method: "POST",
8827
8865
  path: "/posts/schedules/bulk-schedule-windows",
@@ -9092,7 +9130,7 @@ var AcquisitionMethodSchema = _enum(["api", "url", "csv", "extension"]);
9092
9130
  var WorkflowStatusSchema = _enum(["DRAFT", "RUNNING", "PAUSED", "COMPLETED", "FAILED"]);
9093
9131
  var WorkflowRunStatusSchema = _enum(["SUCCESS", "PARTIAL", "FAILED", "RATE_LIMITED"]);
9094
9132
  var ScheduleSpreadSchema = _enum(["IMMEDIATE", "SPREAD_DAYS", "SPREAD_WEEKS"]);
9095
- var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED"]);
9133
+ var ScheduleStatusSchema = _enum(["DRAFT", "SCHEDULED", "PUBLISHING", "PUBLISHED", "FAILED", "READY"]);
9096
9134
  var quotaErrors = {
9097
9135
  REPURPOSE_QUOTA_EXCEEDED: {
9098
9136
  status: 403,
@@ -9575,6 +9613,7 @@ var ScheduleListItemSchema = object({
9575
9613
  organizationId: string2(),
9576
9614
  integrationId: string2(),
9577
9615
  status: _enum(SCHEDULE_STATUS_VALUES),
9616
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9578
9617
  scheduledAt: Timestamp.nullable(),
9579
9618
  publishedAt: Timestamp.nullable(),
9580
9619
  originRecycleEventId: string2().nullable(),
@@ -9644,6 +9683,7 @@ var ScheduleWithIntegrationSchema = object({
9644
9683
  organizationId: string2(),
9645
9684
  integrationId: string2(),
9646
9685
  status: _enum(SCHEDULE_STATUS_VALUES),
9686
+ delivery: _enum(SCHEDULE_DELIVERY_VALUES),
9647
9687
  scheduledAt: Timestamp.nullable(),
9648
9688
  publishedAt: Timestamp.nullable(),
9649
9689
  originRecycleEventId: string2().nullable(),
@@ -12926,7 +12966,7 @@ function formatTable(headers, rows, isTty = process.stdout.isTTY) {
12926
12966
  }
12927
12967
 
12928
12968
  // src/version.ts
12929
- var CLI_VERSION = "0.1.49";
12969
+ var CLI_VERSION = "0.1.51";
12930
12970
 
12931
12971
  // src/client.ts
12932
12972
  var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
@@ -13960,6 +14000,14 @@ function readXLinkHandling(value2) {
13960
14000
  }
13961
14001
  return failUsage("--x-link-handling must be 'first_reply', 'plain_text', or 'keep_live'.");
13962
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
+ }
13963
14011
  function readTiming(options) {
13964
14012
  const chosen = [options.at, options.optimal, options.now, options.draft].filter(Boolean);
13965
14013
  if (chosen.length > 1) failUsage("Use one of --at, --optimal, --now or --draft.");
@@ -14005,6 +14053,7 @@ async function post(text, options) {
14005
14053
  const project = await readProjectConfig();
14006
14054
  const targets = readTargets(options, project?.defaultPlatforms);
14007
14055
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14056
+ const delivery = parseDelivery(options.delivery);
14008
14057
  if (timing.postAction !== "DRAFT" && !targets.platforms && !targets.selectedIntegrations) {
14009
14058
  failUsage("Say where to post: --to x,linkedin or --channel <id> (or use --draft).");
14010
14059
  }
@@ -14016,7 +14065,8 @@ async function post(text, options) {
14016
14065
  {
14017
14066
  content: thread ? thread.join("\n\n") : content,
14018
14067
  scheduledAt: "scheduledAt" in timing ? timing.scheduledAt : void 0,
14019
- 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
14020
14070
  }
14021
14071
  ],
14022
14072
  shared: {
@@ -14052,9 +14102,10 @@ async function editPost(postId, text, options) {
14052
14102
  const integrationContent = readCopy(options.copy);
14053
14103
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14054
14104
  const xLinkHandling = readXLinkHandling(options.xLinkHandling);
14055
- 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) {
14056
14107
  failUsage(
14057
- "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."
14058
14109
  );
14059
14110
  }
14060
14111
  const { api } = await getApi();
@@ -14065,6 +14116,7 @@ async function editPost(postId, text, options) {
14065
14116
  content,
14066
14117
  thread,
14067
14118
  scheduledAt,
14119
+ delivery,
14068
14120
  ...targets,
14069
14121
  integrationContent,
14070
14122
  subreddit: options.subreddit,
@@ -14242,6 +14294,11 @@ async function scheduleDraft(postId, options) {
14242
14294
  if (Boolean(options.at) === Boolean(options.optimal)) failUsage("Say when to post: --at <time> or --optimal.");
14243
14295
  const scheduledAt = options.at ? parseInstant(options.at, "--at") : void 0;
14244
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;
14245
14302
  const { api } = await getApi();
14246
14303
  try {
14247
14304
  const state = await api.posts.scheduleDraft({
@@ -14249,6 +14306,7 @@ async function scheduleDraft(postId, options) {
14249
14306
  scheduledAt,
14250
14307
  useOptimalTime: options.optimal,
14251
14308
  selectedIntegrations: channelIds?.length ? channelIds : void 0,
14309
+ delivery,
14252
14310
  dryRun: options.dryRun
14253
14311
  });
14254
14312
  if (isJsonMode()) {
@@ -14364,15 +14422,15 @@ var collect = (value2, previous = []) => [...previous, value2];
14364
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(
14365
14423
  "--x-link-handling <handling>",
14366
14424
  "how to handle links in X posts: 'first_reply' (default), 'plain_text', or 'keep_live'"
14367
- ).option("--dry-run", "run every server check and show the result without saving").action(post);
14368
- 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);
14369
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);
14370
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);
14371
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);
14372
14430
  program.command("workspaces").alias("workspace").description("workspaces you belong to").command("list").alias("ls").description("list workspaces and their ids").action(listWorkspaces);
14373
14431
  var queue = program.command("queue").description("inspect and adjust scheduled posts");
14374
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);
14375
- 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(
14376
14434
  "-c, --channels <ids>",
14377
14435
  "comma-separated channel ids from `postonus channels list`; needed if the draft has none"
14378
14436
  ).action(scheduleDraft);