@letterstory/cli 0.175.24 → 0.175.26

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/lib/cli.mjs CHANGED
@@ -80,7 +80,7 @@ import {
80
80
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
81
81
 
82
82
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
83
- export const VERSION = "0.175.24";
83
+ export const VERSION = "0.175.26";
84
84
 
85
85
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
86
86
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -281,6 +281,8 @@ export const BOOLEAN_FLAGS = new Set([
281
281
  // `automations set --pause | --resume`.
282
282
  "pause",
283
283
  "resume",
284
+ // `automations set --unpin`: back to a pace, off its weekday.
285
+ "unpin",
284
286
  // `collection add "<headline>" --collection <id> --queue`.
285
287
  "queue",
286
288
  // `collection add ... --queue --own`: a draft you write yourself.
@@ -566,10 +568,12 @@ Reviewers:
566
568
  automations more --collection <id> New topics it doesn't cover yet
567
569
  automations dismiss <topic-id> --collection <id> Set one subject aside
568
570
  automations add topic|series|signal|best --collection <id> [--topic <id>] [--goal <target-id>]
569
- [--seer <id>] [--pace <n>] [--brief <text>] [--new-topic <name>] [--new-series <name>]
570
- Add one (refused if it says the same as another)
571
- automations set <automation-id> --collection <id> [--pace <n>] [--pause | --resume] [--goal <id>]
572
- [--brief <text>] [--remap]
571
+ [--seer <id>] [--pace <n> | --on "fri 09:00 America/New_York"] [--brief <text>]
572
+ [--new-topic <name>] [--new-series <name>]
573
+ Add one (refused if it says the same as another).
574
+ --on pins it: one post a week, on that day and time
575
+ automations set <automation-id> --collection <id> [--pace <n> | --on "<day> <HH:MM> <tz>" | --unpin]
576
+ [--pause | --resume] [--goal <id>] [--brief <text>] [--remap]
573
577
  automations remove <automation-id> --collection <id>
574
578
  automate options What an automation can be made of here: the triggers,
575
579
  whether each one's events can come yet, and templates
@@ -1120,8 +1124,6 @@ Admin (STAFF key — --staff-key / LETTERSTORY_STAFF_API_KEY; acts before an org
1120
1124
  admin billing free grant <org-id> <tokens> --why "…" [--key k] | grants [--org <org-id>] | revoke <org-id> <ref> --why "…"
1121
1125
  Give an org free tokens (a Lago org: a one-off wallet),
1122
1126
  list staff grants, take one back; posted to #billing
1123
- admin billing visitors opt-out --why "…" [--apply] Turn off identification switched on automatically on
1124
- billing-gated orgs (owners opt back in); a dry run first
1125
1127
  admin billing desk [--json] The Billing desk: switches, failed payments, the
1126
1128
  nightly reconcile, refusals, signups, grants
1127
1129
  admin billing free preflight [--json] Who the paywall stops the moment it is enforced:
@@ -5845,38 +5845,6 @@ async function cmdAdminBillingLegacyUnmark(ctx) {
5845
5845
  return 0;
5846
5846
  }
5847
5847
 
5848
- const VISITORS_USAGE = `Usage: admin billing visitors opt-out --why "…" [--apply] turn off identification switched on automatically on billing-gated orgs (owners opt back in); a dry run unless --apply`;
5849
-
5850
- /**
5851
- * admin billing visitors opt-out — identification is billed per person, so sites switched on
5852
- * automatically on an org on free tokens or billed on Lago are turned off once, as staff with who and
5853
- * why; legacy, internal, unassigned and demo orgs and every owner-set site are left alone. A dry run
5854
- * lists them unless --apply (lib/visitors/identification-opt-out.ts).
5855
- */
5856
- async function cmdAdminBillingVisitors(ctx) {
5857
- const { flags, positionals, io } = ctx;
5858
- if (positionals[1] !== "opt-out") throw new CliError(VISITORS_USAGE);
5859
- const why = flagStr(flags.why);
5860
- if (!why) throw new CliError(`Say why (--why "…").\n${VISITORS_USAGE}`);
5861
- const r = await staffPost(ctx, "/api/superadmin/billing/visitors/opt-out", { dry: !flagBool(flags.apply), why });
5862
- printResult(io, flags, r, (x) => {
5863
- const row = (s) => ` ${s.domain ?? s.siteId} ${s.orgName ?? s.orgId.slice(0, 8)} (${s.standing})`;
5864
- const lines = [
5865
- `${x.dry ? "Would turn off" : "Turned off"} ${x.changed.length} site(s):`,
5866
- ...x.changed.map(row),
5867
- ];
5868
- if (x.failed.length) lines.push(`Failed ${x.failed.length}:`, ...x.failed.map((f) => `${row(f)} ${f.error}`));
5869
- if (x.kept.length)
5870
- lines.push(
5871
- `Left on ${x.kept.length} (auto, not billing-gated or a demo):`,
5872
- ...x.kept.map((k) => `${row(k)} ${k.why}`)
5873
- );
5874
- if (x.dry) lines.push("Nothing written. Run again with --apply.");
5875
- return lines.join("\n");
5876
- });
5877
- return 0;
5878
- }
5879
-
5880
5848
  const FREE_USAGE = `Usage: admin billing free exposure [--json] who the free paywall covers, and who is unassigned
5881
5849
  admin billing free backfill --why "…" [--apply] signup grant for self-serve orgs with none; a dry run unless --apply
5882
5850
  admin billing free repair-subjects --why "…" [--apply] staff-address signup subjects fixed, refused orgs granted (R1); a dry run unless --apply
@@ -6154,7 +6122,6 @@ async function cmdAdminBilling(ctx) {
6154
6122
  if (positionals[0] === "free") return cmdAdminBillingFree(ctx);
6155
6123
  if (positionals[0] === "desk") return cmdAdminBillingDesk(ctx);
6156
6124
  if (positionals[0] === "emails") return cmdAdminBillingEmails(ctx);
6157
- if (positionals[0] === "visitors") return cmdAdminBillingVisitors(ctx);
6158
6125
  if (positionals[0] !== "lago") throw new CliError(LAGO_USAGE);
6159
6126
  const sub = positionals[1];
6160
6127
  switch (sub) {
@@ -5,6 +5,24 @@
5
5
  import { CliError } from "../client.mjs";
6
6
  import { printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
7
7
 
8
+ const WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
9
+
10
+ /**
11
+ * `--on "fri 09:00 America/New_York"` → { weekday, time, timezone } (the tool's `publish_at`).
12
+ * The weekday is a name (fri, friday) or 0-6; the timezone is an IANA name. Anything else is the
13
+ * tool's to refuse, with its own message, so only the shape is checked here.
14
+ */
15
+ export function parsePublishAt(text) {
16
+ if (text === undefined || text === true) return undefined;
17
+ const [day, time, timezone, ...extra] = String(text).trim().split(/\s+/);
18
+ if (!day || !time || !timezone || extra.length)
19
+ throw new CliError('--on takes a weekday, a time and a timezone: --on "fri 09:00 America/New_York"');
20
+ const named = WEEKDAYS.indexOf(day.slice(0, 3).toLowerCase());
21
+ const weekday = /^[0-6]$/.test(day) ? Number(day) : named;
22
+ if (weekday < 0) throw new CliError(`--on: "${day}" is not a weekday (mon, tue, … or 0-6, Sunday is 0).`);
23
+ return { weekday, time, timezone };
24
+ }
25
+
8
26
  /** See `argsFromFlags` in shared.mjs; `scripts/parity-check.ts` diffs these keys against the tool. */
9
27
  export const ARGS = {
10
28
  list_automations: {
@@ -37,6 +55,7 @@ export const ARGS = {
37
55
  target_id: { flag: "goal" },
38
56
  seer_id: { flag: "seer" },
39
57
  pace_per_week: { flag: "pace", type: "num" },
58
+ publish_at: { value: (flags) => parsePublishAt(flags.on) },
40
59
  brief: { flag: "brief" },
41
60
  new_topic: {
42
61
  value: (flags) => (typeof flags["new-topic"] === "string" ? { name: flags["new-topic"] } : undefined),
@@ -49,6 +68,7 @@ export const ARGS = {
49
68
  collection_id: { flag: "collection", required: true },
50
69
  automation_id: { positional: 0, label: "automation-id", required: true },
51
70
  pace_per_week: { flag: "pace", type: "num" },
71
+ publish_at: { value: (flags) => (flags.unpin === true ? null : parsePublishAt(flags.on)) },
52
72
  paused: {
53
73
  value: (flags) => (flags.pause === true ? true : flags.resume === true ? false : undefined),
54
74
  },
@@ -107,7 +127,7 @@ export async function cmdAutomations(ctx) {
107
127
  case "add":
108
128
  return run(rest, "create_automation", "Added.");
109
129
  case "set":
110
- refuseUnknownFlags(rest, ARGS.update_automation, ["pause", "resume", "remap"]);
130
+ refuseUnknownFlags(rest, ARGS.update_automation, ["pause", "resume", "remap", "unpin"]);
111
131
  return run(rest, "update_automation", "Changed.");
112
132
  case "remove":
113
133
  case "rm":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.175.24",
3
+ "version": "0.175.26",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",