coss-cli 0.4.0 → 0.6.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/README.md CHANGED
@@ -50,6 +50,9 @@ ID and notarized by Apple (since 0.3.0), so one downloaded with a browser runs w
50
50
  | `coss logs tail` | New lines of the environment's log as they arrive: API requests, email events, webhook attempts. Filter with `--source`, `--level`, `--type`, `--status`, `-q`; `--since 15m` starts earlier; `--interval` sets the poll interval (2000 ms). |
51
51
  | `coss inbox` | The environment's inbound domain, then each email it receives as it arrives (`--since`, `--interval`). |
52
52
  | `coss inbox get <id>` | A received email: verdicts, attachments and its text (`--html`, `--headers`); `--raw > message.eml` saves the message as received. |
53
+ | `coss inboxes list`, `coss inboxes create` | [Inboxes](https://coss.com/docs/inboxes): email addresses for agents (`--username`, `--domain`, `--name`, `--client-id`). |
54
+ | `coss inboxes threads <inbox>`, `coss inboxes thread <inbox> <thread>` | An inbox's conversations (● awaits a reply), and one read message by message (`--full` keeps the quoted text). |
55
+ | `coss inboxes reply <inbox> <message> --text <text>` | Replies in the message's thread from the inbox (`--all`: to everyone on it). |
53
56
  | `coss listen` | Receives the environment's webhook events and forwards each one to `--forward-to`, signed like coss.com signs real deliveries. Verify them with `verifyWebhook` from the `coss` SDK and the signing secret it prints (it stays the same for the profile). `--header "Name: value"` adds a header to forwarded requests. |
54
57
  | `coss trigger <event-type>` | A test event of that type, sent to the environment's subscribed endpoints and `coss listen` listeners like a real one (sandbox keys; every type but `domain.*`, `account.*`, `billing.*`). `--data '{…}'` and `-F name=value` (dotted names, JSON values) change its `data`. |
55
58
  | `coss webhooks list` | The environment's webhook endpoints: URL, state and event types. |
@@ -65,6 +68,8 @@ ID and notarized by Apple (since 0.3.0), so one downloaded with a browser runs w
65
68
  | `coss risk assess --event <event>` | Assesses an event (`--email`, `--ip`, `--user`, `--content`, `--data '{…}'`…) and prints the decision, score and reasons. Sandbox fixtures (`192.0.2.1`, `disposable.test`, `[coss-test:spam]`…) produce each decision. |
66
69
  | `coss risk assessments`, `coss risk feedback <assessment> --outcome <outcome>` | Assessments (`--review open`: the review queue), and what a user turned out to be. |
67
70
  | `coss risk lists list`, `coss risk lists add <allow\|block> <type> <value>`, `coss risk lists remove <entry>` | The allow and block lists (`--note`, `--expires 7d`). |
71
+ | `coss scheduling hosts`, `coss scheduling bookings` | The environment's [hosts and bookings](https://coss.com/docs/scheduling). |
72
+ | `coss forms list`, `coss forms submissions <form>` | The environment's [forms](https://coss.com/docs/forms) and their endpoints, and a form's submissions (`--status held`: Risk's review queue). |
68
73
  | `coss domains list` | The organization's sending domains and their status. |
69
74
  | `coss domains add <domain>` | Adds a domain and prints the DNS records to publish (`--format bind` prints zone-file lines). |
70
75
  | `coss domains get <domain>` | A domain's records and what the last DNS check saw (verified, missing, mismatch). `--format bind` too. |
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as flushOutput, l as nodeIo, n as run } from "./run-glpZgvyK.js";
2
+ import { c as flushOutput, l as nodeIo, n as run } from "./run-C97BDtxr.js";
3
3
  //#region src/cli.ts
4
4
  process.exitCode = await run(process.argv.slice(2), nodeIo());
5
5
  await flushOutput();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { u as CURSOR_FIELDS, t as HELP, r as VERSION, s as defaultConfigDir, i as generateSecret, l as nodeIo, n as run, a as sign, o as signatureHeaders } from "./run-glpZgvyK.js";
1
+ export { u as CURSOR_FIELDS, t as HELP, r as VERSION, s as defaultConfigDir, i as generateSecret, l as nodeIo, n as run, a as sign, o as signatureHeaders } from "./run-C97BDtxr.js";
@@ -204,7 +204,7 @@ function requireArgs(positionals, count, usage) {
204
204
  return positionals;
205
205
  }
206
206
  /** Repeatable flags that may also be comma-separated: `--events a,b --events c`. */
207
- function list(value) {
207
+ function list$2(value) {
208
208
  return (value === void 0 ? [] : Array.isArray(value) ? value : [value]).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
209
209
  }
210
210
  /** `name=value` flags as pairs (a usage error for anything else). */
@@ -437,7 +437,7 @@ function shorten(text, max) {
437
437
  function minute(iso) {
438
438
  return iso ? iso.slice(0, 16).replace("T", " ") : "";
439
439
  }
440
- function statusStyle$4(status) {
440
+ function statusStyle$5(status) {
441
441
  if (status === "delivered" || status === "sent" || status === "received") return "green";
442
442
  if (status === "queued" || status === "scheduled" || status === "delivery_delayed" || status === "in_progress") return "yellow";
443
443
  if (status === "canceled") return "dim";
@@ -1256,7 +1256,7 @@ function checkedFormat(format) {
1256
1256
  if (format !== void 0 && format !== "table" && format !== "bind") throw new UsageError(`--format takes table or bind; got "${format}".`);
1257
1257
  return format;
1258
1258
  }
1259
- async function client$2(context) {
1259
+ async function client$4(context) {
1260
1260
  return clientFor(context.io, await resolveCredentials(context));
1261
1261
  }
1262
1262
  const domainsListCommand = defineCommand({
@@ -1269,7 +1269,7 @@ const domainsListCommand = defineCommand({
1269
1269
  } },
1270
1270
  run: async ({ context }) => {
1271
1271
  const { out } = context;
1272
- const { data, error } = await (await client$2(context)).domains.list({ signal: context.io.signal });
1272
+ const { data, error } = await (await client$4(context)).domains.list({ signal: context.io.signal });
1273
1273
  if (error) throw apiError("Couldn't list the domains", error);
1274
1274
  if (out.json) {
1275
1275
  for (const domain of data.data) out.data(domain);
@@ -1335,7 +1335,7 @@ const domainsAddCommand = defineCommand({
1335
1335
  const { out } = context;
1336
1336
  const name = onePositional(positionals, "domain", "domains add");
1337
1337
  const format = checkedFormat(values.format);
1338
- const { data, error } = await (await client$2(context)).domains.create({ name }, { signal: context.io.signal });
1338
+ const { data, error } = await (await client$4(context)).domains.create({ name }, { signal: context.io.signal });
1339
1339
  if (error) throw apiError(`Couldn't add ${name}`, error);
1340
1340
  if (out.json || format === "bind") {
1341
1341
  printDomain(out, data, format);
@@ -1365,7 +1365,7 @@ const domainsGetCommand = defineCommand({
1365
1365
  run: async ({ values, positionals, context }) => {
1366
1366
  const ref = onePositional(positionals, "domain", "domains get");
1367
1367
  const format = checkedFormat(values.format);
1368
- const domain = await findDomain(await client$2(context), ref);
1368
+ const domain = await findDomain(await client$4(context), ref);
1369
1369
  printDomain(context.out, domain, format);
1370
1370
  return 0;
1371
1371
  }
@@ -1517,7 +1517,7 @@ async function waitForOutcome$1(context, coss, email, options) {
1517
1517
  settled: settled$1(current, options.simulate)
1518
1518
  };
1519
1519
  }
1520
- function statusStyle$3(status) {
1520
+ function statusStyle$4(status) {
1521
1521
  if (status === "delivered" || status === "sent") return "green";
1522
1522
  if (status === "queued" || status === "scheduled" || status === "delivery_delayed") return "yellow";
1523
1523
  return "red";
@@ -1686,8 +1686,8 @@ async function emailsSend({ values, context }) {
1686
1686
  events: outcome.events
1687
1687
  });
1688
1688
  else {
1689
- out.line(`${outcome.email.id} ${out.style(statusStyle$3(outcome.email.status), outcome.email.status)}`);
1690
- for (const recipient of outcome.email.recipients) out.line(` ${recipient.address} ${out.style(statusStyle$3(recipient.status), recipient.status)}`);
1689
+ out.line(`${outcome.email.id} ${out.style(statusStyle$4(outcome.email.status), outcome.email.status)}`);
1690
+ for (const recipient of outcome.email.recipients) out.line(` ${recipient.address} ${out.style(statusStyle$4(recipient.status), recipient.status)}`);
1691
1691
  if (outcome.events.length > 0) out.line();
1692
1692
  for (const event of outcome.events) out.line(` ${out.style("dim", event.occurred_at)} ${event.type}${event.recipient ? ` ${event.recipient}` : ""}`);
1693
1693
  }
@@ -1813,7 +1813,7 @@ function oneId(positionals, command) {
1813
1813
  if (id === void 0 || extra.length > 0) throw new UsageError(`Pass one email id: \`coss ${command} email_…\`.`);
1814
1814
  return id;
1815
1815
  }
1816
- async function client$1(context) {
1816
+ async function client$3(context) {
1817
1817
  return clientFor(context.io, await resolveCredentials(context));
1818
1818
  }
1819
1819
  const emailsListCommand = defineCommand({
@@ -1885,15 +1885,15 @@ async function emailsList({ values, context }) {
1885
1885
  const now = io.now();
1886
1886
  const params = {
1887
1887
  ...values.to && { to: values.to },
1888
- ...values.status && { status: checked$1(list(values.status), EMAIL_STATUSES, "status") },
1889
- ...values["recipient-status"] && { recipient_status: checked$1(list(values["recipient-status"]), RECIPIENT_STATUSES, "recipient-status") },
1888
+ ...values.status && { status: checked$1(list$2(values.status), EMAIL_STATUSES, "status") },
1889
+ ...values["recipient-status"] && { recipient_status: checked$1(list$2(values["recipient-status"]), RECIPIENT_STATUSES, "recipient-status") },
1890
1890
  ...values.query && { q: values.query },
1891
1891
  ...values.category && { category: values.category },
1892
1892
  ...values.batch && { batch_id: values.batch },
1893
1893
  created_after: time$1(values.since, "since", now),
1894
1894
  created_before: time$1(values.until, "until", now)
1895
1895
  };
1896
- const coss = await client$1(context);
1896
+ const coss = await client$3(context);
1897
1897
  const emails = [];
1898
1898
  let after;
1899
1899
  while (emails.length < limit) {
@@ -1961,7 +1961,7 @@ async function emailsGet({ values, positionals, context }) {
1961
1961
  const { io, out } = context;
1962
1962
  const id = oneId(positionals, "emails get");
1963
1963
  if (values.text && values.html) throw new UsageError("Pass --text or --html, not both.");
1964
- const { data: email, error } = await (await client$1(context)).email.get(id, { signal: io.signal });
1964
+ const { data: email, error } = await (await client$3(context)).email.get(id, { signal: io.signal });
1965
1965
  if (io.signal.aborted) return 130;
1966
1966
  if (error) throw apiError("Couldn't read the email", error);
1967
1967
  if (out.json) {
@@ -1979,7 +1979,7 @@ async function emailsGet({ values, positionals, context }) {
1979
1979
  }
1980
1980
  function printEmail(out, email) {
1981
1981
  const status = deliveryStatus(email);
1982
- out.line(`${out.style("bold", email.id)} ${out.style(statusStyle$4(status), status)}${email.sandbox ? out.style("dim", " (sandbox)") : ""}`);
1982
+ out.line(`${out.style("bold", email.id)} ${out.style(statusStyle$5(status), status)}${email.sandbox ? out.style("dim", " (sandbox)") : ""}`);
1983
1983
  field$1(out, "From", email.from);
1984
1984
  field$1(out, "Subject", email.subject);
1985
1985
  field$1(out, "Reply-To", email.reply_to.join(", "));
@@ -1991,7 +1991,7 @@ function printEmail(out, email) {
1991
1991
  field$1(out, "Sent", email.sent_at);
1992
1992
  if (email.failure) out.line(` ${out.style("dim", "Failure".padEnd(11))}${out.style("red", email.failure.code)}: ${printable(email.failure.message)}`);
1993
1993
  out.line();
1994
- for (const recipient of email.recipients) out.line(` ${recipient.type.padEnd(4)}${printable(recipient.address)} ${out.style(statusStyle$4(recipient.status), recipient.status)}`);
1994
+ for (const recipient of email.recipients) out.line(` ${recipient.type.padEnd(4)}${printable(recipient.address)} ${out.style(statusStyle$5(recipient.status), recipient.status)}`);
1995
1995
  const tracking = email.tracking;
1996
1996
  if (tracking.opens || tracking.clicks) {
1997
1997
  out.line();
@@ -2016,7 +2016,7 @@ const emailsEventsCommand = defineCommand({
2016
2016
  run: async ({ positionals, context }) => {
2017
2017
  const { io, out } = context;
2018
2018
  const id = oneId(positionals, "emails events");
2019
- const { data, error } = await (await client$1(context)).email.listEvents(id, { signal: io.signal });
2019
+ const { data, error } = await (await client$3(context)).email.listEvents(id, { signal: io.signal });
2020
2020
  if (io.signal.aborted) return 130;
2021
2021
  if (error) throw apiError("Couldn't read the email's events", error);
2022
2022
  if (data.data.length === 0 && !out.json) out.info("No events yet.");
@@ -2074,7 +2074,7 @@ function steps(out, next, indent) {
2074
2074
  async function emailsDiagnose({ values, positionals, context }) {
2075
2075
  const { io, out } = context;
2076
2076
  if (values.to !== void 0 && positionals.length > 0) throw new UsageError("Pass an email id or --to, not both.");
2077
- const coss = await client$1(context);
2077
+ const coss = await client$3(context);
2078
2078
  let id;
2079
2079
  if (values.to !== void 0) {
2080
2080
  const { data, error } = await coss.email.list({
@@ -2108,7 +2108,7 @@ async function emailsDiagnose({ values, positionals, context }) {
2108
2108
  }
2109
2109
  for (const recipient of diagnosis.recipients) {
2110
2110
  out.line();
2111
- out.line(` ${printable(recipient.address)} ${out.style(statusStyle$4(recipient.outcome), recipient.outcome)}`);
2111
+ out.line(` ${printable(recipient.address)} ${out.style(statusStyle$5(recipient.outcome), recipient.outcome)}`);
2112
2112
  out.line(` ${recipient.explanation}`);
2113
2113
  if (recipient.details) details(out, recipient.details);
2114
2114
  steps(out, recipient.next_steps, " ");
@@ -2124,13 +2124,135 @@ async function emailsDiagnose({ values, positionals, context }) {
2124
2124
  return 0;
2125
2125
  }
2126
2126
  //#endregion
2127
+ //#region src/commands/forms.ts
2128
+ const STATUSES$1 = [
2129
+ "accepted",
2130
+ "held",
2131
+ "spam",
2132
+ "pending_confirmation"
2133
+ ];
2134
+ const LIMIT$4 = {
2135
+ type: "string",
2136
+ value: "<n>",
2137
+ description: "How many to show, 1-100 (default 20)"
2138
+ };
2139
+ async function formsClient(context) {
2140
+ return clientFor(context.io, await resolveCredentials(context));
2141
+ }
2142
+ function limitOf$3(value) {
2143
+ if (value === void 0) return void 0;
2144
+ const limit = Number(value);
2145
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new UsageError("--limit takes a number from 1 to 100.");
2146
+ return limit;
2147
+ }
2148
+ function when$3(iso) {
2149
+ return iso.slice(0, 16).replace("T", " ");
2150
+ }
2151
+ function statusStyle$3(status) {
2152
+ return status === "accepted" ? "green" : status === "spam" ? "red" : "yellow";
2153
+ }
2154
+ const FORMS_COMMANDS = [defineCommand({
2155
+ name: "forms list",
2156
+ summary: "List forms",
2157
+ description: "Lists the environment's forms, newest first, with the endpoint each posts to.",
2158
+ flags: {
2159
+ limit: LIMIT$4,
2160
+ json: {
2161
+ type: "boolean",
2162
+ description: "One form per line, as JSON"
2163
+ }
2164
+ },
2165
+ run: async ({ values, context }) => {
2166
+ const { data, error } = await (await formsClient(context)).forms.list({ ...values.limit !== void 0 && { limit: limitOf$3(values.limit) } });
2167
+ if (error) throw apiError("Couldn't list the forms", error);
2168
+ const { out } = context;
2169
+ if (out.json) {
2170
+ for (const item of data.data) out.data(item);
2171
+ return 0;
2172
+ }
2173
+ if (data.data.length === 0) {
2174
+ out.info("No forms.");
2175
+ return 0;
2176
+ }
2177
+ const lines = table([[
2178
+ "ID",
2179
+ "NAME",
2180
+ "ENABLED",
2181
+ "ENDPOINT"
2182
+ ], ...data.data.map((item) => [
2183
+ item.id,
2184
+ printable(item.name),
2185
+ item.enabled && !item.disabled_by_admin ? "yes" : out.style("yellow", "no"),
2186
+ item.endpoint
2187
+ ])]);
2188
+ out.line(out.style("dim", lines[0] ?? ""));
2189
+ for (const line of lines.slice(1)) out.line(line);
2190
+ return 0;
2191
+ }
2192
+ }), defineCommand({
2193
+ name: "forms submissions",
2194
+ summary: "List a form's submissions (--status held: Risk's review queue)",
2195
+ usage: "<form> [--status <status>]",
2196
+ description: "Lists a form's submissions, newest first. Their values are what someone typed into the form.",
2197
+ flags: {
2198
+ status: {
2199
+ type: "string",
2200
+ value: "<status>",
2201
+ choices: STATUSES$1,
2202
+ description: "Only this status: accepted, held, spam or pending_confirmation"
2203
+ },
2204
+ limit: LIMIT$4,
2205
+ json: {
2206
+ type: "boolean",
2207
+ description: "One submission per line, as JSON"
2208
+ }
2209
+ },
2210
+ positionals: true,
2211
+ run: async ({ values, positionals, context }) => {
2212
+ const [formId] = requireArgs(positionals, 1, "forms submissions <form>");
2213
+ const status = values.status;
2214
+ if (status !== void 0 && !STATUSES$1.includes(status)) throw new UsageError(`--status takes ${STATUSES$1.join(", ")}; got "${status}".`);
2215
+ const { data, error } = await (await formsClient(context)).forms.submissions.list(formId, {
2216
+ ...status !== void 0 && { status: [status] },
2217
+ ...values.limit !== void 0 && { limit: limitOf$3(values.limit) }
2218
+ });
2219
+ if (error) throw apiError("Couldn't list the submissions", error);
2220
+ const { out } = context;
2221
+ if (out.json) {
2222
+ for (const item of data.data) out.data(item);
2223
+ return 0;
2224
+ }
2225
+ if (data.data.length === 0) {
2226
+ out.info("No submissions.");
2227
+ return 0;
2228
+ }
2229
+ const lines = table([[
2230
+ "ID",
2231
+ "STATUS",
2232
+ "FROM",
2233
+ "FIELDS",
2234
+ "RECEIVED"
2235
+ ], ...data.data.map((item) => [
2236
+ item.id,
2237
+ out.style(statusStyle$3(item.status), item.status),
2238
+ printable(item.submitter_email ?? ""),
2239
+ printable(Object.keys(item.data).join(", ")),
2240
+ when$3(item.created_at)
2241
+ ])]);
2242
+ out.line(out.style("dim", lines[0] ?? ""));
2243
+ for (const line of lines.slice(1)) out.line(line);
2244
+ if (data.has_more) out.info(out.style("dim", `There are more: \`coss api forms/${formId}/submissions --paginate\` lists them all.`));
2245
+ return 0;
2246
+ }
2247
+ })];
2248
+ //#endregion
2127
2249
  //#region src/commands/hooks.ts
2128
2250
  const DELIVERY_STATUSES$1 = [
2129
2251
  "pending",
2130
2252
  "succeeded",
2131
2253
  "failed"
2132
2254
  ];
2133
- const LIMIT$1 = {
2255
+ const LIMIT$3 = {
2134
2256
  type: "string",
2135
2257
  value: "<n>",
2136
2258
  description: "How many to show, 1-100 (default 50)"
@@ -2138,14 +2260,14 @@ const LIMIT$1 = {
2138
2260
  async function hooksClient(context) {
2139
2261
  return clientFor(context.io, await resolveCredentials(context));
2140
2262
  }
2141
- function limitOf$1(value) {
2263
+ function limitOf$2(value) {
2142
2264
  if (value === void 0) return void 0;
2143
2265
  const limit = Number(value);
2144
2266
  if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new UsageError("--limit takes a number from 1 to 100.");
2145
2267
  return limit;
2146
2268
  }
2147
2269
  /** `2026-10-15 12:00` */
2148
- function when$1(iso) {
2270
+ function when$2(iso) {
2149
2271
  return iso ? iso.slice(0, 16).replace("T", " ") : "";
2150
2272
  }
2151
2273
  /** One JSON object per item with --json, else a table under its headings (or `empty`). */
@@ -2180,14 +2302,14 @@ const appsList = defineCommand({
2180
2302
  summary: "List the environment's Hooks applications",
2181
2303
  description: "Lists the environment's applications (one per customer of yours, each with its own endpoints and portal), newest first.",
2182
2304
  flags: {
2183
- limit: LIMIT$1,
2305
+ limit: LIMIT$3,
2184
2306
  json: {
2185
2307
  type: "boolean",
2186
2308
  description: "One application per line, as JSON"
2187
2309
  }
2188
2310
  },
2189
2311
  run: async ({ values, context }) => {
2190
- const { data, error } = await (await hooksClient(context)).hooks.applications.list({ limit: limitOf$1(values.limit) });
2312
+ const { data, error } = await (await hooksClient(context)).hooks.applications.list({ limit: limitOf$2(values.limit) });
2191
2313
  if (error) throw apiError("Couldn't list the applications", error);
2192
2314
  printList(context.out, data, {
2193
2315
  headings: [
@@ -2200,7 +2322,7 @@ const appsList = defineCommand({
2200
2322
  app.id,
2201
2323
  app.uid ?? "",
2202
2324
  app.name,
2203
- when$1(app.created_at)
2325
+ when$2(app.created_at)
2204
2326
  ],
2205
2327
  empty: "No applications yet: `coss hooks apps create <name>` adds one.",
2206
2328
  more: "There are more: `coss api hooks/applications --paginate` lists them all."
@@ -2255,7 +2377,7 @@ const eventTypesList = defineCommand({
2255
2377
  type: "boolean",
2256
2378
  description: "Also list archived types"
2257
2379
  },
2258
- limit: LIMIT$1,
2380
+ limit: LIMIT$3,
2259
2381
  json: {
2260
2382
  type: "boolean",
2261
2383
  description: "One event type per line, as JSON"
@@ -2263,7 +2385,7 @@ const eventTypesList = defineCommand({
2263
2385
  },
2264
2386
  run: async ({ values, context }) => {
2265
2387
  const { data, error } = await (await hooksClient(context)).hooks.eventTypes.list({
2266
- limit: limitOf$1(values.limit),
2388
+ limit: limitOf$2(values.limit),
2267
2389
  ...values.archived && { include_archived: true }
2268
2390
  });
2269
2391
  if (error) throw apiError("Couldn't list the event types", error);
@@ -2356,7 +2478,7 @@ const endpointsList = defineCommand({
2356
2478
  endpoint.id,
2357
2479
  endpoint.url,
2358
2480
  endpoint.filter_types.length > 0 ? endpoint.filter_types.join(",") : "all",
2359
- !endpoint.enabled ? out.style("red", `disabled (${endpoint.disabled_reason ?? "manual"})`) : endpoint.failing_since ? out.style("yellow", `failing since ${when$1(endpoint.failing_since)}`) : out.style("green", "enabled")
2481
+ !endpoint.enabled ? out.style("red", `disabled (${endpoint.disabled_reason ?? "manual"})`) : endpoint.failing_since ? out.style("yellow", `failing since ${when$2(endpoint.failing_since)}`) : out.style("green", "enabled")
2360
2482
  ],
2361
2483
  empty: `No endpoints: \`coss hooks endpoints add ${app} --url <url>\` adds one.`
2362
2484
  });
@@ -2404,7 +2526,7 @@ const endpointsAdd = defineCommand({
2404
2526
  rateLimit = Number(values["rate-limit"]);
2405
2527
  if (!Number.isInteger(rateLimit) || rateLimit < 1 || rateLimit > 1e3) throw new UsageError("--rate-limit takes a number from 1 to 1000.");
2406
2528
  }
2407
- const types = list(values.types);
2529
+ const types = list$2(values.types);
2408
2530
  const { data, error } = await (await hooksClient(context)).hooks.endpoints.create(app, {
2409
2531
  url: values.url,
2410
2532
  ...types.length > 0 && { filter_types: types },
@@ -2507,7 +2629,7 @@ const DELIVERIES_FLAGS$1 = {
2507
2629
  choices: DELIVERY_STATUSES$1,
2508
2630
  description: "pending, succeeded or failed"
2509
2631
  },
2510
- limit: LIMIT$1,
2632
+ limit: LIMIT$3,
2511
2633
  json: {
2512
2634
  type: "boolean",
2513
2635
  description: "One delivery per line, as JSON"
@@ -2570,7 +2692,7 @@ const HOOKS_COMMANDS = [
2570
2692
  endpoint: values.endpoint,
2571
2693
  message: values.message,
2572
2694
  status: values.status,
2573
- limit: limitOf$1(values.limit)
2695
+ limit: limitOf$2(values.limit)
2574
2696
  });
2575
2697
  const { out } = context;
2576
2698
  printList(out, page, {
@@ -2590,7 +2712,7 @@ const HOOKS_COMMANDS = [
2590
2712
  delivery.last_error ?? (delivery.last_status_code === null ? "" : String(delivery.last_status_code)),
2591
2713
  delivery.endpoint_id,
2592
2714
  delivery.message_id,
2593
- when$1(delivery.created_at)
2715
+ when$2(delivery.created_at)
2594
2716
  ],
2595
2717
  empty: "No deliveries.",
2596
2718
  more: "There are more: narrow with --endpoint, --message or --status, or raise --limit."
@@ -2616,7 +2738,7 @@ const HOOKS_COMMANDS = [
2616
2738
  if (list.error) throw apiError("Couldn't list the delivery's attempts", list.error);
2617
2739
  const { out } = context;
2618
2740
  if (!out.json) {
2619
- const next = delivery.data.next_attempt_at ? `, next attempt ${when$1(delivery.data.next_attempt_at)}` : "";
2741
+ const next = delivery.data.next_attempt_at ? `, next attempt ${when$2(delivery.data.next_attempt_at)}` : "";
2620
2742
  out.line(`${delivery.data.id} ${out.style(statusStyle$2(delivery.data.status), delivery.data.status)} → ${delivery.data.endpoint_id}${out.style("dim", `${next}`)}`);
2621
2743
  }
2622
2744
  printList(out, list.data, {
@@ -2627,7 +2749,7 @@ const HOOKS_COMMANDS = [
2627
2749
  "RESPONSE"
2628
2750
  ],
2629
2751
  row: (attempt) => [
2630
- when$1(attempt.attempted_at),
2752
+ when$2(attempt.attempted_at),
2631
2753
  attempt.status_code === null ? out.style("red", printable(attempt.error ?? "no response")) : out.style(attempt.status_code < 300 ? "green" : "red", String(attempt.status_code)),
2632
2754
  `${attempt.duration_ms}ms`,
2633
2755
  printable(attempt.response_excerpt ?? "").replace(/\s+/g, " ").slice(0, 80)
@@ -2699,7 +2821,7 @@ const HOOKS_COMMANDS = [
2699
2821
  if (out.json) out.data(data);
2700
2822
  else {
2701
2823
  out.line(data.url);
2702
- out.info(out.style("dim", `Works until ${when$1(data.expires_at)} UTC${data.read_only ? ", read-only" : ""}.`));
2824
+ out.info(out.style("dim", `Works until ${when$2(data.expires_at)} UTC${data.read_only ? ", read-only" : ""}.`));
2703
2825
  }
2704
2826
  if (values.open && !await io.openBrowser(data.url)) throw new CliError("Couldn't open a browser: open the link above yourself.");
2705
2827
  return 0;
@@ -2926,6 +3048,220 @@ async function inboxGet({ values, positionals, context }) {
2926
3048
  return 0;
2927
3049
  }
2928
3050
  //#endregion
3051
+ //#region src/commands/inboxes.ts
3052
+ const LIMIT$2 = {
3053
+ type: "string",
3054
+ value: "<n>",
3055
+ description: "How many to show, 1-100 (default 20)"
3056
+ };
3057
+ async function client$2(context) {
3058
+ return clientFor(context.io, await resolveCredentials(context));
3059
+ }
3060
+ const list = defineCommand({
3061
+ name: "inboxes list",
3062
+ summary: "List the environment's inboxes",
3063
+ description: "Lists the environment's inboxes (addresses for agents), newest first.",
3064
+ flags: {
3065
+ limit: LIMIT$2,
3066
+ json: {
3067
+ type: "boolean",
3068
+ description: "One inbox per line, as JSON"
3069
+ }
3070
+ },
3071
+ run: async ({ values, context }) => {
3072
+ const { data, error } = await (await client$2(context)).inboxes.list({ limit: limitOf$2(values.limit) });
3073
+ if (error) throw apiError("Couldn't list the inboxes", error);
3074
+ printList(context.out, data, {
3075
+ headings: [
3076
+ "ID",
3077
+ "ADDRESS",
3078
+ "NAME",
3079
+ "SENDS",
3080
+ "CREATED"
3081
+ ],
3082
+ row: (inbox) => [
3083
+ inbox.id,
3084
+ inbox.address,
3085
+ inbox.display_name ?? "",
3086
+ inbox.can_send ? "yes" : "no",
3087
+ when$2(inbox.created_at)
3088
+ ],
3089
+ empty: "No inboxes yet: `coss inboxes create` makes one.",
3090
+ more: "There are more: `coss api inboxes --paginate` lists them all."
3091
+ });
3092
+ return 0;
3093
+ }
3094
+ });
3095
+ const create = defineCommand({
3096
+ name: "inboxes create",
3097
+ summary: "Create an inbox: an email address for an agent",
3098
+ description: "Creates an inbox in the environment. Mail to it is kept as threads, and each message sends an inbox.message.received webhook (`coss listen` forwards them while you develop).",
3099
+ flags: {
3100
+ username: {
3101
+ type: "string",
3102
+ value: "<name>",
3103
+ description: "The part before the @ (default: a random one)"
3104
+ },
3105
+ domain: {
3106
+ type: "string",
3107
+ value: "<hostname>",
3108
+ description: "A receiving domain of the environment (default: its coss.com inbound domain)"
3109
+ },
3110
+ name: {
3111
+ type: "string",
3112
+ value: "<name>",
3113
+ description: "The name messages are sent with"
3114
+ },
3115
+ "client-id": {
3116
+ type: "string",
3117
+ value: "<id>",
3118
+ description: "Your own id for the inbox: creating it again returns the same inbox"
3119
+ },
3120
+ json: {
3121
+ type: "boolean",
3122
+ description: "Print the inbox as JSON"
3123
+ }
3124
+ },
3125
+ run: async ({ values, context }) => {
3126
+ const { data, error } = await (await client$2(context)).inboxes.create({
3127
+ ...values.username !== void 0 && { username: values.username },
3128
+ ...values.domain !== void 0 && { domain: values.domain },
3129
+ ...values.name !== void 0 && { display_name: values.name },
3130
+ ...values["client-id"] !== void 0 && { client_id: values["client-id"] }
3131
+ });
3132
+ if (error) throw apiError("Couldn't create the inbox", error);
3133
+ const { out } = context;
3134
+ if (out.json) out.data(data);
3135
+ else {
3136
+ out.line(`${out.style("green", "✔")} ${out.style("bold", data.address)} ${out.style("dim", data.id)}`);
3137
+ if (!data.can_send) out.info("It receives only: live inboxes send from a receiving domain under a verified domain (--domain).");
3138
+ }
3139
+ return 0;
3140
+ }
3141
+ });
3142
+ const threads = defineCommand({
3143
+ name: "inboxes threads",
3144
+ summary: "List an inbox's conversations",
3145
+ usage: "<inbox> [options]",
3146
+ description: "Lists the inbox's threads, latest activity first; ● marks one whose latest message is inbound (it awaits a reply).",
3147
+ flags: {
3148
+ limit: LIMIT$2,
3149
+ json: {
3150
+ type: "boolean",
3151
+ description: "One thread per line, as JSON"
3152
+ }
3153
+ },
3154
+ positionals: true,
3155
+ run: async ({ values, positionals, context }) => {
3156
+ const [inboxId] = requireArgs(positionals, 1, "inboxes threads <inbox>");
3157
+ const { data, error } = await (await client$2(context)).inboxes.threads.list(inboxId, { limit: limitOf$2(values.limit) });
3158
+ if (error) throw apiError("Couldn't list the threads", error);
3159
+ printList(context.out, data, {
3160
+ headings: [
3161
+ "",
3162
+ "ID",
3163
+ "SUBJECT",
3164
+ "WITH",
3165
+ "MESSAGES",
3166
+ "LAST"
3167
+ ],
3168
+ row: (thread) => [
3169
+ thread.last_inbound_at === thread.last_message_at ? "●" : "",
3170
+ thread.id,
3171
+ printable(thread.subject ?? "(no subject)"),
3172
+ printable(thread.participants.join(", ")),
3173
+ String(thread.message_count),
3174
+ when$2(thread.last_message_at)
3175
+ ],
3176
+ empty: "No conversations yet.",
3177
+ more: "There are more: raise --limit, or `coss api inboxes/<inbox>/threads --paginate`."
3178
+ });
3179
+ return 0;
3180
+ }
3181
+ });
3182
+ function printMessage(out, message, full) {
3183
+ const arrow = message.direction === "inbound" ? out.style("cyan", "←") : out.style("green", "→");
3184
+ out.line(`${arrow} ${out.style("bold", printable(message.from ?? "(unknown sender)"))} ${out.style("dim", `${when$2(message.created_at)} ${message.id}`)}`);
3185
+ if (message.direction === "outbound") out.line(` ${out.style("dim", `to ${printable(message.to.join(", "))} · ${message.status}`)}`);
3186
+ for (const attachment of message.attachments) out.line(` ${out.style("dim", `📎 ${printable(attachment.filename ?? "(unnamed)")}`)}`);
3187
+ const text = full ? message.text : message.extracted_text;
3188
+ out.line();
3189
+ out.line(text === null ? out.style("dim", "(no text)") : printable(text, true));
3190
+ out.line();
3191
+ }
3192
+ const INBOXES_COMMANDS = [
3193
+ list,
3194
+ create,
3195
+ threads,
3196
+ defineCommand({
3197
+ name: "inboxes thread",
3198
+ summary: "Read a conversation",
3199
+ usage: "<inbox> <thread> [options]",
3200
+ description: "Prints the thread's latest messages, oldest first, each with its own words (without the quoted conversation, unless --full). Control characters in senders' text are left out.",
3201
+ flags: {
3202
+ full: {
3203
+ type: "boolean",
3204
+ description: "Print every message's whole text, quotes included"
3205
+ },
3206
+ json: {
3207
+ type: "boolean",
3208
+ description: "Print the thread as JSON"
3209
+ }
3210
+ },
3211
+ positionals: true,
3212
+ run: async ({ values, positionals, context }) => {
3213
+ const [inboxId, threadId] = requireArgs(positionals, 2, "inboxes thread <inbox> <thread>");
3214
+ const { data, error } = await (await client$2(context)).inboxes.threads.get(inboxId, threadId);
3215
+ if (error) throw apiError("Couldn't read the thread", error);
3216
+ const { out } = context;
3217
+ if (out.json) {
3218
+ out.data(data);
3219
+ return 0;
3220
+ }
3221
+ out.line(out.style("bold", printable(data.subject ?? "(no subject)")));
3222
+ out.line(out.style("dim", `with ${printable(data.participants.join(", "))}`));
3223
+ out.line();
3224
+ for (const message of data.messages) printMessage(out, message, values.full === true);
3225
+ return 0;
3226
+ }
3227
+ }),
3228
+ defineCommand({
3229
+ name: "inboxes reply",
3230
+ summary: "Reply to a message from its inbox",
3231
+ usage: "<inbox> <message> --text <text> [--all]",
3232
+ description: "Replies in the message's thread from the inbox's address, to its sender (--all: everyone on it), with Re: and the headers mail clients thread by.",
3233
+ flags: {
3234
+ text: {
3235
+ type: "string",
3236
+ value: "<text>",
3237
+ description: "The reply's text"
3238
+ },
3239
+ all: {
3240
+ type: "boolean",
3241
+ description: "Reply to everyone on the message, not only the sender"
3242
+ },
3243
+ json: {
3244
+ type: "boolean",
3245
+ description: "Print the reply as JSON"
3246
+ }
3247
+ },
3248
+ positionals: true,
3249
+ run: async ({ values, positionals, context }) => {
3250
+ const [inboxId, messageId] = requireArgs(positionals, 2, "inboxes reply <inbox> <message> --text <text>");
3251
+ if (!values.text) throw new UsageError("Pass the reply with --text <text>.");
3252
+ const { data, error } = await (await client$2(context)).inboxes.messages.reply(inboxId, messageId, {
3253
+ text: values.text,
3254
+ ...values.all && { reply_all: true }
3255
+ });
3256
+ if (error) throw apiError("Couldn't send the reply", error);
3257
+ const { out } = context;
3258
+ if (out.json) out.data(data);
3259
+ else out.line(`${out.style("green", "✔")} Replied to ${printable(data.to.join(", "))} ${out.style("dim", data.id)}`);
3260
+ return 0;
3261
+ }
3262
+ })
3263
+ ];
3264
+ //#endregion
2929
3265
  //#region src/env-file.ts
2930
3266
  /**
2931
3267
  * The project's env file: where `coss init` writes `COSS_API_KEY` and `coss listen` writes
@@ -3588,7 +3924,7 @@ async function ignoredByGit(io, dir, file) {
3588
3924
  //#endregion
3589
3925
  //#region src/version.ts
3590
3926
  /** The package version (`coss --version`, the forwarded requests' user agent). */
3591
- const VERSION = "0.4.0";
3927
+ const VERSION = "0.6.0";
3592
3928
  //#endregion
3593
3929
  //#region src/listen/forward.ts
3594
3930
  /** Posting an event to the local URL, as coss.com would post it to an endpoint. */
@@ -3626,8 +3962,22 @@ function describe(error) {
3626
3962
  if (error?.name === "AbortError") return "interrupted";
3627
3963
  return error instanceof Error ? error.message : String(error);
3628
3964
  }
3965
+ const TRACEPARENT = /^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$/;
3966
+ /**
3967
+ * The `traceparent` coss.com's own delivery sends for this event (its `data.traceparent`: an email
3968
+ * or text message sent with one), so a forwarded event continues the sender's trace the same way.
3969
+ */
3970
+ function traceparentOf(body) {
3971
+ try {
3972
+ const value = JSON.parse(body)?.data?.traceparent;
3973
+ return typeof value === "string" && TRACEPARENT.test(value) ? value : null;
3974
+ } catch {
3975
+ return null;
3976
+ }
3977
+ }
3629
3978
  async function forwardEvent(io, input) {
3630
3979
  const timestamp = Math.floor(io.now().getTime() / 1e3);
3980
+ const traceparent = traceparentOf(input.body);
3631
3981
  const started = performance.now();
3632
3982
  try {
3633
3983
  const response = await io.fetch(input.url, {
@@ -3635,6 +3985,7 @@ async function forwardEvent(io, input) {
3635
3985
  headers: [
3636
3986
  ["content-type", "application/json"],
3637
3987
  ["user-agent", `coss-cli/${VERSION} (coss listen)`],
3988
+ ...traceparent ? [["traceparent", traceparent]] : [],
3638
3989
  ...input.headers,
3639
3990
  ...Object.entries(signatureHeaders({
3640
3991
  secret: input.secret,
@@ -3741,7 +4092,7 @@ async function run$1(context, values) {
3741
4092
  const { io, out } = context;
3742
4093
  const target = typeof values["forward-to"] === "string" ? normalizeTarget(values["forward-to"]) : null;
3743
4094
  const headers = (values.header ?? []).map(parseHeader);
3744
- const eventTypes = list(values.events);
4095
+ const eventTypes = list$2(values.events);
3745
4096
  const credentials = await resolveCredentials(context);
3746
4097
  const coss = clientFor(io, credentials, {
3747
4098
  timeout: CLIENT_TIMEOUT_MS,
@@ -4010,13 +4361,13 @@ const logsTailCommand = defineCommand({
4010
4361
  });
4011
4362
  async function logsTail({ values, context }) {
4012
4363
  const { io, out } = context;
4013
- const sources = checked(list(values.source), SOURCES, "source");
4014
- const levels = checked(list(values.level), LEVELS, "level");
4364
+ const sources = checked(list$2(values.source), SOURCES, "source");
4365
+ const levels = checked(list$2(values.level), LEVELS, "level");
4015
4366
  const filters = {
4016
4367
  ...sources.length > 0 && { source: sources },
4017
4368
  ...levels.length > 0 && { level: levels },
4018
- ...values.type && { type: list(values.type) },
4019
- ...values.status && { status: list(values.status) },
4369
+ ...values.type && { type: list$2(values.type) },
4370
+ ...values.status && { status: list$2(values.status) },
4020
4371
  ...values.query && { q: values.query }
4021
4372
  };
4022
4373
  const intervalMs = values.interval === void 0 ? 2e3 : Number(values.interval);
@@ -4066,37 +4417,48 @@ async function logsTail({ values, context }) {
4066
4417
  //#endregion
4067
4418
  //#region src/commands/open.ts
4068
4419
  /**
4069
- * Dashboard pages by name: the environment's (under `/<org>/projects/<project>/<env>`) and the
4070
- * organization's (under `/<org>`), as in `apps/web/src/lib/navigation.ts`.
4420
+ * Dashboard pages by name: the environment's (under `/<org>/<project>/<env>`) and the
4421
+ * organization's (under `/<org>/settings`), as in `@coss/dashboard-routes`.
4071
4422
  */
4072
4423
  const ENVIRONMENT_PAGES = {
4073
4424
  overview: "",
4074
- emails: "/emails",
4075
- templates: "/templates",
4076
- received: "/received",
4077
- suppressions: "/suppressions",
4078
- tracking: "/tracking",
4079
- broadcasts: "/broadcasts",
4080
- contacts: "/contacts",
4081
- audiences: "/audiences",
4082
- segments: "/segments",
4083
- topics: "/topics",
4084
- marketing: "/marketing",
4085
- risk: "/risk",
4425
+ home: "",
4426
+ products: "/products",
4427
+ email: "/email",
4428
+ emails: "/email/messages",
4429
+ templates: "/email/templates",
4430
+ received: "/email/received",
4431
+ suppressions: "/email/suppressions",
4432
+ subaccounts: "/email/subaccounts",
4433
+ tracking: "/email/tracking",
4434
+ domains: "/email/domains",
4435
+ "dedicated-ips": "/email/dedicated-ips",
4436
+ reputation: "/email/reputation",
4437
+ broadcasts: "/marketing",
4438
+ contacts: "/marketing/contacts",
4439
+ audiences: "/marketing/audiences",
4440
+ segments: "/marketing/segments",
4441
+ topics: "/marketing/topics",
4442
+ marketing: "/marketing/settings",
4443
+ inboxes: "/inboxes",
4444
+ sms: "/sms",
4445
+ verify: "/verify",
4446
+ sign: "/sign",
4447
+ forms: "/forms",
4086
4448
  hooks: "/hooks",
4087
- "api-keys": "/api-keys",
4088
- webhooks: "/webhooks",
4089
- logs: "/logs",
4090
- "log-drains": "/log-drains"
4449
+ risk: "/risk",
4450
+ developers: "/developers",
4451
+ "api-keys": "/developers/api-keys",
4452
+ webhooks: "/developers/webhooks",
4453
+ logs: "/developers/logs",
4454
+ "log-drains": "/developers/log-drains"
4091
4455
  };
4092
4456
  const ORGANIZATION_PAGES = {
4093
- projects: "",
4094
- domains: "/domains",
4095
- "dedicated-ips": "/dedicated-ips",
4096
- members: "/members",
4097
- reputation: "/reputation",
4098
4457
  settings: "/settings",
4458
+ projects: "/settings/projects",
4459
+ members: "/settings/members",
4099
4460
  billing: "/settings/billing",
4461
+ spend: "/settings/spend",
4100
4462
  "audit-log": "/settings/audit"
4101
4463
  };
4102
4464
  const PAGES = [...Object.keys(ENVIRONMENT_PAGES), ...Object.keys(ORGANIZATION_PAGES)];
@@ -4105,7 +4467,7 @@ function dashboardPageUrl(dashboardUrl, slugs, page) {
4105
4467
  const org = `${dashboardUrl}/${encodeURIComponent(slugs.organization)}`;
4106
4468
  const organizationPage = ORGANIZATION_PAGES[page];
4107
4469
  if (organizationPage !== void 0) return `${org}${organizationPage}`;
4108
- return `${`${org}/projects/${encodeURIComponent(slugs.project)}/${encodeURIComponent(slugs.environment)}`}${ENVIRONMENT_PAGES[page] ?? ""}`;
4470
+ return `${`${org}/${encodeURIComponent(slugs.project)}/${encodeURIComponent(slugs.environment)}`}${ENVIRONMENT_PAGES[page] ?? ""}`;
4109
4471
  }
4110
4472
  /**
4111
4473
  * The environment's slugs, asked of the API (slugs can be renamed since login), or else the ones
@@ -4277,7 +4639,7 @@ const ENTRY_TYPES = [
4277
4639
  "country",
4278
4640
  "user"
4279
4641
  ];
4280
- const LIMIT = {
4642
+ const LIMIT$1 = {
4281
4643
  type: "string",
4282
4644
  value: "<n>",
4283
4645
  description: "How many to show, 1-100 (default 50)"
@@ -4290,13 +4652,13 @@ function oneOf(value, allowed, flag) {
4290
4652
  if (!allowed.includes(value)) throw new UsageError(`${flag} takes ${allowed.join(", ")}; got "${value}".`);
4291
4653
  return value;
4292
4654
  }
4293
- function limitOf(value) {
4655
+ function limitOf$1(value) {
4294
4656
  if (value === void 0) return void 0;
4295
4657
  const limit = Number(value);
4296
4658
  if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new UsageError("--limit takes a number from 1 to 100.");
4297
4659
  return limit;
4298
4660
  }
4299
- function when(iso) {
4661
+ function when$1(iso) {
4300
4662
  return iso ? iso.slice(0, 16).replace("T", " ") : "";
4301
4663
  }
4302
4664
  function decisionStyle(decision) {
@@ -4441,7 +4803,7 @@ const assessments = defineCommand({
4441
4803
  choices: ["open", "resolved"],
4442
4804
  description: "open (the review queue: reviews without feedback yet) or resolved"
4443
4805
  },
4444
- limit: LIMIT,
4806
+ limit: LIMIT$1,
4445
4807
  json: {
4446
4808
  type: "boolean",
4447
4809
  description: "One assessment per line, as JSON"
@@ -4456,7 +4818,7 @@ const assessments = defineCommand({
4456
4818
  ...event && { event },
4457
4819
  ...review && { review_status: review },
4458
4820
  ...values.user !== void 0 && { user_id: values.user },
4459
- ...values.limit !== void 0 && { limit: limitOf(values.limit) }
4821
+ ...values.limit !== void 0 && { limit: limitOf$1(values.limit) }
4460
4822
  });
4461
4823
  if (error) throw apiError("Couldn't list the assessments", error);
4462
4824
  const { out } = context;
@@ -4483,7 +4845,7 @@ const assessments = defineCommand({
4483
4845
  item.score.toFixed(2),
4484
4846
  printable(item.user.email ?? item.user.id ?? ""),
4485
4847
  item.outcome ?? (item.review_status === "open" ? out.style("yellow", "to review") : ""),
4486
- when(item.created_at)
4848
+ when$1(item.created_at)
4487
4849
  ])]);
4488
4850
  out.line(out.style("dim", lines[0] ?? ""));
4489
4851
  for (const line of lines.slice(1)) out.line(line);
@@ -4546,7 +4908,7 @@ const listsList = defineCommand({
4546
4908
  choices: ENTRY_TYPES,
4547
4909
  description: "email, domain, ip, asn, country or user"
4548
4910
  },
4549
- limit: LIMIT,
4911
+ limit: LIMIT$1,
4550
4912
  json: {
4551
4913
  type: "boolean",
4552
4914
  description: "One entry per line, as JSON"
@@ -4558,7 +4920,7 @@ const listsList = defineCommand({
4558
4920
  const { data, error } = await (await riskClient(context)).risk.lists.list({
4559
4921
  ...listName && { list: listName },
4560
4922
  ...type && { type },
4561
- ...values.limit !== void 0 && { limit: limitOf(values.limit) }
4923
+ ...values.limit !== void 0 && { limit: limitOf$1(values.limit) }
4562
4924
  });
4563
4925
  if (error) throw apiError("Couldn't list the entries", error);
4564
4926
  const { out } = context;
@@ -4582,7 +4944,7 @@ const listsList = defineCommand({
4582
4944
  out.style(entry.list === "allow" ? "green" : "red", entry.list),
4583
4945
  entry.type,
4584
4946
  printable(entry.value),
4585
- when(entry.expires_at),
4947
+ when$1(entry.expires_at),
4586
4948
  printable(entry.note ?? "")
4587
4949
  ])]);
4588
4950
  out.line(out.style("dim", lines[0] ?? ""));
@@ -4671,6 +5033,126 @@ const RISK_COMMANDS = [
4671
5033
  })
4672
5034
  ];
4673
5035
  //#endregion
5036
+ //#region src/commands/scheduling.ts
5037
+ const STATUSES = [
5038
+ "held",
5039
+ "pending_approval",
5040
+ "confirmed",
5041
+ "cancelled",
5042
+ "declined"
5043
+ ];
5044
+ const LIMIT = {
5045
+ type: "string",
5046
+ value: "<n>",
5047
+ description: "How many to show, 1-100 (default 20)"
5048
+ };
5049
+ async function client$1(context) {
5050
+ return clientFor(context.io, await resolveCredentials(context));
5051
+ }
5052
+ function limitOf(value) {
5053
+ if (value === void 0) return void 0;
5054
+ const limit = Number(value);
5055
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new UsageError("--limit takes a number from 1 to 100.");
5056
+ return limit;
5057
+ }
5058
+ const when = (iso) => iso.slice(0, 16).replace("T", " ");
5059
+ const SCHEDULING_COMMANDS = [defineCommand({
5060
+ name: "scheduling hosts",
5061
+ summary: "List the people who can be booked",
5062
+ description: "Lists the environment's scheduling hosts, newest first.",
5063
+ flags: {
5064
+ limit: LIMIT,
5065
+ json: {
5066
+ type: "boolean",
5067
+ description: "One host per line, as JSON"
5068
+ }
5069
+ },
5070
+ run: async ({ values, context }) => {
5071
+ const { data, error } = await (await client$1(context)).scheduling.hosts.list({ ...values.limit !== void 0 && { limit: limitOf(values.limit) } });
5072
+ if (error) throw apiError("Couldn't list the hosts", error);
5073
+ const { out } = context;
5074
+ if (out.json) {
5075
+ for (const item of data.data) out.data(item);
5076
+ return 0;
5077
+ }
5078
+ if (data.data.length === 0) {
5079
+ out.info("No hosts.");
5080
+ return 0;
5081
+ }
5082
+ const lines = table([[
5083
+ "ID",
5084
+ "UID",
5085
+ "NAME",
5086
+ "TIME ZONE",
5087
+ "STATUS"
5088
+ ], ...data.data.map((item) => [
5089
+ item.id,
5090
+ printable(item.uid ?? ""),
5091
+ printable(item.name),
5092
+ item.time_zone,
5093
+ item.status === "active" ? item.status : out.style("yellow", item.status)
5094
+ ])]);
5095
+ out.line(out.style("dim", lines[0] ?? ""));
5096
+ for (const line of lines.slice(1)) out.line(line);
5097
+ return 0;
5098
+ }
5099
+ }), defineCommand({
5100
+ name: "scheduling bookings",
5101
+ summary: "List bookings",
5102
+ description: "Lists the environment's bookings, newest first.",
5103
+ flags: {
5104
+ host: {
5105
+ type: "string",
5106
+ value: "<host>",
5107
+ description: "Only this host (id or uid)"
5108
+ },
5109
+ status: {
5110
+ type: "string",
5111
+ value: "<status>",
5112
+ choices: STATUSES,
5113
+ description: "Only this status: held, pending_approval, confirmed, cancelled or declined"
5114
+ },
5115
+ limit: LIMIT,
5116
+ json: {
5117
+ type: "boolean",
5118
+ description: "One booking per line, as JSON"
5119
+ }
5120
+ },
5121
+ run: async ({ values, context }) => {
5122
+ const status = values.status;
5123
+ if (status !== void 0 && !STATUSES.includes(status)) throw new UsageError(`--status takes ${STATUSES.join(", ")}; got "${status}".`);
5124
+ const { data, error } = await (await client$1(context)).scheduling.bookings.list({
5125
+ ...values.host !== void 0 && { host: values.host },
5126
+ ...status !== void 0 && { status },
5127
+ ...values.limit !== void 0 && { limit: limitOf(values.limit) }
5128
+ });
5129
+ if (error) throw apiError("Couldn't list the bookings", error);
5130
+ const { out } = context;
5131
+ if (out.json) {
5132
+ for (const item of data.data) out.data(item);
5133
+ return 0;
5134
+ }
5135
+ if (data.data.length === 0) {
5136
+ out.info("No bookings.");
5137
+ return 0;
5138
+ }
5139
+ const lines = table([[
5140
+ "ID",
5141
+ "START",
5142
+ "TITLE",
5143
+ "STATUS"
5144
+ ], ...data.data.map((item) => [
5145
+ item.id,
5146
+ when(item.start),
5147
+ printable(item.title),
5148
+ item.status === "confirmed" ? out.style("green", item.status) : out.style("yellow", item.status)
5149
+ ])]);
5150
+ out.line(out.style("dim", lines[0] ?? ""));
5151
+ for (const line of lines.slice(1)) out.line(line);
5152
+ return 0;
5153
+ }
5154
+ })];
5155
+ //#endregion
4674
5156
  //#region src/sms/simulate.ts
4675
5157
  /**
4676
5158
  * The SMS simulator: numbers whose outcome is known in advance in sandbox environments (coss.com's
@@ -5650,7 +6132,7 @@ async function addEndpoint({ values, positionals, context }) {
5650
6132
  const { io, out } = context;
5651
6133
  const [url] = requireArgs(positionals, 1, "webhooks add <url>");
5652
6134
  if (url === void 0 || !/^https?:\/\//i.test(url)) throw new UsageError("Pass an http(s) URL: `coss webhooks add https://example.com/webhooks`.");
5653
- const events = list(values.events);
6135
+ const events = list$2(values.events);
5654
6136
  const unknown = events.filter((type) => !WEBHOOK_EVENT_TYPES.includes(type));
5655
6137
  if (unknown.length > 0) throw new UsageError(`Unknown event type ${unknown.map((type) => `"${type}"`).join(", ")}. See https://coss.com/docs/webhooks.`);
5656
6138
  const coss = clientFor(io, await resolveCredentials(context));
@@ -5841,6 +6323,7 @@ const COMMANDS = [
5841
6323
  logsTailCommand,
5842
6324
  inboxCommand,
5843
6325
  inboxGetCommand,
6326
+ ...INBOXES_COMMANDS,
5844
6327
  listenCommand,
5845
6328
  triggerCommand,
5846
6329
  webhooksListCommand,
@@ -5849,6 +6332,8 @@ const COMMANDS = [
5849
6332
  webhooksRetryCommand,
5850
6333
  ...HOOKS_COMMANDS,
5851
6334
  ...RISK_COMMANDS,
6335
+ ...FORMS_COMMANDS,
6336
+ ...SCHEDULING_COMMANDS,
5852
6337
  domainsListCommand,
5853
6338
  domainsAddCommand,
5854
6339
  domainsGetCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coss-cli",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "The coss.com command line: sign in, send test emails and text messages, tail your environment's log, and forward webhook events to localhost with `coss listen`.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://coss.com/docs/cli",
@@ -43,7 +43,7 @@
43
43
  "test": "bun test"
44
44
  },
45
45
  "dependencies": {
46
- "coss": "^0.9.0"
46
+ "coss": "^0.11.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@arethetypeswrong/core": "0.18.5",