coss-cli 0.7.0 → 0.8.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
@@ -10,19 +10,18 @@ coss listen --forward-to localhost:3000/webhooks
10
10
  coss trigger email.bounced # in another terminal: a test event, forwarded by coss listen
11
11
  ```
12
12
 
13
- Published from [cosscom/coss](https://github.com/cosscom/coss) by CI, with
14
- [provenance](https://docs.npmjs.com/generating-provenance-statements). Full guide:
13
+ Published by coss.com's CI. Full guide:
15
14
  [coss.com/docs/cli](https://coss.com/docs/cli).
16
15
 
17
16
  ## Install without Node.js
18
17
 
19
- Each release's [GitHub release](https://github.com/cosscom/coss/releases) (`coss-cli@<version>`)
18
+ Each release on [cosscom/coss-cli](https://github.com/cosscom/coss-cli/releases) (`coss-cli@<version>`)
20
19
  also has standalone executables (Bun's runtime built in) for macOS, Linux (glibc and musl) and
21
20
  Windows, arm64 and x64, with a `SHA256SUMS`:
22
21
 
23
22
  ```sh
24
23
  brew install cosscom/tap/coss # macOS and Linux; completions included
25
- curl -fsSL https://raw.githubusercontent.com/cosscom/coss/main/packages/cli/install.sh | sh
24
+ curl -fsSL https://raw.githubusercontent.com/cosscom/coss-cli/main/install.sh | sh
26
25
  ```
27
26
 
28
27
  `install.sh` picks the archive for the machine, checks it against `SHA256SUMS` and installs `coss`
@@ -101,6 +100,8 @@ ID and notarized by Apple (since 0.3.0), so one downloaded with a browser runs w
101
100
  | `coss scheduling event-types create <title>`, `coss scheduling event-types update <event-type>` | What can be booked (`--minutes`, `--uid`, `--host`, `--kind`, `--status`, `--requires-approval`, `--no-approval`, `--data`). |
102
101
  | `coss scheduling slots <event-type>`, `coss scheduling slots explain <event-type>`, `coss scheduling booking <booking>`, `coss scheduling booking-events <booking>`, `coss scheduling cancel <booking>`, `coss scheduling calendars <host>` | Bookable starts (`--start`, `--end`), one booking, cancelling it, and a host's calendar connections. |
103
102
  | `coss scheduling reminders`, `coss scheduling notifications <booking>`, `coss scheduling no-show <booking>` | What goes out around a booking (`--event-type`), what was queued for one and why anything wasn't sent, and marking it a no-show. |
103
+ | `coss scheduling candidates <booking>`, `coss scheduling reassign <booking>`, `coss scheduling ooo` | Who a booking could go to, [giving it to them](https://coss.com/docs/scheduling/reassigning) (`--to`, `--auto`), and [time hosts are away](https://coss.com/docs/scheduling/out-of-office). |
104
+ | `coss scheduling reassign-many`, `coss scheduling reassignments`, `coss scheduling reassignment <id>` | [Moving many bookings](https://coss.com/docs/scheduling/reassigning#many-at-once) (`--from`, `--ooo`, `--to`, `--preferred`, `--dry-run`), its runs, and one run (`--cancel`, `--undo`). |
104
105
  | `coss scheduling diagnose <event-type>` | Why there are no slots, each finding certain, likely or possible (`--start`, `--end`, `--host`). |
105
106
  | `coss scheduling book <event-type>`, `coss scheduling reschedule <booking>`, `coss scheduling approve <booking>`, `coss scheduling decline <booking>` | Books a slot (`--start`, `--time-zone`, `--name`, `--email`, `--phone`, `--uid`, `--host`, `--minutes`, `--attribute`, `--answer`, `--metadata`, `--data`) and moves or decides one. They tell the attendee, so a live key asks first (`--yes` off a terminal). |
106
107
  | `coss forms list`, `coss forms get <form>`, `coss forms create <name>`, `coss forms update <form>`, `coss forms remove <form>` | The environment's [forms](https://coss.com/docs/forms) and their endpoints (`update`: `--name`, `--enabled`, `--disabled`, `--origin`, `--redirect`, `--data`). `remove` can't be undone, so a live key asks first (`--yes` off a terminal). |
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-kad9znCz.js";
2
+ import { c as flushOutput, l as nodeIo, n as run } from "./run-C9XeqRPx.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-kad9znCz.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-C9XeqRPx.js";
@@ -349,6 +349,8 @@ var Output = class {
349
349
  }
350
350
  };
351
351
  const API_KEY_FORMAT = /^coss_(live|test)_[A-Za-z]{64}$/;
352
+ /** How long GitHub Actions' token endpoint may take to hand over an ID token. */
353
+ const ID_TOKEN_TIMEOUT_MS = 3e4;
352
354
  function createContext(io, flags) {
353
355
  return {
354
356
  io,
@@ -384,6 +386,7 @@ async function resolveCredentials(context) {
384
386
  const fromEnv = io.env.COSS_API_KEY?.trim();
385
387
  if (fromEnv) return {
386
388
  apiKey: fromEnv,
389
+ oidc: null,
387
390
  source: "env",
388
391
  profileName: name,
389
392
  profile: null,
@@ -391,10 +394,35 @@ async function resolveCredentials(context) {
391
394
  baseUrl: apiBaseUrl(io, null),
392
395
  dashboardUrl: dashboardBaseUrl(io, null)
393
396
  };
397
+ const credentialId = io.env.COSS_OIDC_CREDENTIAL_ID?.trim();
398
+ if (credentialId) {
399
+ const baseUrl = apiBaseUrl(io, null);
400
+ const first = await requireOidcIdToken(io, io.signal);
401
+ let reuse = first;
402
+ const idToken = async () => {
403
+ const token = reuse ?? await requireOidcIdToken(io, null);
404
+ reuse = null;
405
+ return token;
406
+ };
407
+ return {
408
+ apiKey: await exchangeOidcToken(io, credentialId, first, baseUrl),
409
+ oidc: {
410
+ credentialId,
411
+ idToken
412
+ },
413
+ source: "oidc",
414
+ profileName: name,
415
+ profile: null,
416
+ config,
417
+ baseUrl,
418
+ dashboardUrl: dashboardBaseUrl(io, null)
419
+ };
420
+ }
394
421
  const profile = config.profiles[name];
395
422
  if (!profile) throw new CliError(name === "default" && !flags.profile && !io.env.COSS_PROFILE ? "Not signed in. Run `coss login`, or set COSS_API_KEY." : `No profile named "${name}". Run \`coss login --profile ${name}\`.`);
396
423
  return {
397
424
  apiKey: profile.api_key,
425
+ oidc: null,
398
426
  source: "profile",
399
427
  profileName: name,
400
428
  profile,
@@ -403,10 +431,76 @@ async function resolveCredentials(context) {
403
431
  dashboardUrl: dashboardBaseUrl(io, profile)
404
432
  };
405
433
  }
434
+ /**
435
+ * The job's OIDC ID token: `COSS_OIDC_TOKEN` (any provider, e.g. GitLab's `id_tokens`), GitHub
436
+ * Actions' token endpoint (with `COSS_OIDC_AUDIENCE`, default `https://coss.com`), Vercel's or
437
+ * CircleCI's. Mirrors the SDK's `detectIdToken`, on the CLI's own env and `fetch`. Bounded by
438
+ * `ID_TOKEN_TIMEOUT_MS`, and stopped by `signal` (Ctrl-C) when there is one.
439
+ */
440
+ async function oidcIdToken(io, signal) {
441
+ const env = (name) => io.env[name]?.trim() || void 0;
442
+ const explicit = env("COSS_OIDC_TOKEN");
443
+ if (explicit) return explicit;
444
+ const requestUrl = env("ACTIONS_ID_TOKEN_REQUEST_URL");
445
+ const requestToken = env("ACTIONS_ID_TOKEN_REQUEST_TOKEN");
446
+ if (requestUrl && requestToken) {
447
+ const url = new URL(requestUrl);
448
+ url.searchParams.set("audience", oidcAudience(io));
449
+ const timeout = AbortSignal.timeout(ID_TOKEN_TIMEOUT_MS);
450
+ let response;
451
+ let body;
452
+ try {
453
+ response = await io.fetch(url.href, {
454
+ headers: {
455
+ Authorization: `bearer ${requestToken}`,
456
+ Accept: "application/json"
457
+ },
458
+ signal: signal ? AbortSignal.any([signal, timeout]) : timeout
459
+ });
460
+ body = response.ok ? await response.json() : {};
461
+ } catch (cause) {
462
+ if (signal?.aborted) throw new CliError("Interrupted.", 130);
463
+ if (timeout.aborted) throw new CliError(`GitHub Actions didn't answer for an OIDC ID token within ${ID_TOKEN_TIMEOUT_MS / 1e3}s.`);
464
+ throw cause;
465
+ }
466
+ if (!response.ok) throw new CliError(`GitHub Actions answered ${response.status} for an OIDC ID token. Does the job have \`permissions: id-token: write\`?`);
467
+ return typeof body.value === "string" ? body.value : null;
468
+ }
469
+ return env("VERCEL_OIDC_TOKEN") ?? env("CIRCLE_OIDC_TOKEN_V2") ?? env("CIRCLE_OIDC_TOKEN") ?? null;
470
+ }
471
+ function oidcAudience(io) {
472
+ return io.env.COSS_OIDC_AUDIENCE?.trim() || "https://coss.com";
473
+ }
474
+ async function requireOidcIdToken(io, signal) {
475
+ const token = await oidcIdToken(io, signal);
476
+ if (!token) throw new CliError("COSS_OIDC_CREDENTIAL_ID is set, but there is no OIDC ID token here. Set COSS_OIDC_TOKEN, or run in GitHub Actions (with `permissions: id-token: write`), Vercel or CircleCI.");
477
+ return token;
478
+ }
479
+ async function exchangeOidcToken(io, credentialId, token, baseUrl) {
480
+ const { data, error } = await new Coss({
481
+ oidc: {
482
+ credentialId,
483
+ token
484
+ },
485
+ baseUrl,
486
+ fetch: io.fetch
487
+ }).oidc.exchangeToken({
488
+ credential_id: credentialId,
489
+ token
490
+ }, { signal: io.signal });
491
+ if (io.signal.aborted) throw new CliError("Interrupted.", 130);
492
+ if (error) throw new CliError(error.code === "invalid_oidc_token" ? `The OIDC ID token wasn't accepted for ${credentialId}. The environment's logs in the dashboard say why.` : `Couldn't exchange the OIDC ID token: ${error.message}`);
493
+ return data.access_token;
494
+ }
406
495
  /** An SDK client for these credentials, on the CLI's `fetch` (never the SDK's env fallbacks). */
407
496
  function clientFor(io, credentials, options = {}) {
497
+ const { oidc } = credentials;
408
498
  return new Coss({
409
- apiKey: credentials.apiKey,
499
+ ...oidc ? { oidc: {
500
+ credentialId: oidc.credentialId,
501
+ token: oidc.idToken,
502
+ audience: oidcAudience(io)
503
+ } } : { apiKey: credentials.apiKey },
410
504
  baseUrl: credentials.baseUrl,
411
505
  fetch: io.fetch,
412
506
  timeout: options.timeout,
@@ -4669,7 +4763,7 @@ async function ignoredByGit(io, dir, file) {
4669
4763
  //#endregion
4670
4764
  //#region src/version.ts
4671
4765
  /** The package version (`coss --version`, the forwarded requests' user agent). */
4672
- const VERSION = "0.7.0";
4766
+ const VERSION = "0.8.0";
4673
4767
  //#endregion
4674
4768
  //#region src/listen/forward.ts
4675
4769
  /** Posting an event to the local URL, as coss.com would post it to an endpoint. */
@@ -6897,9 +6991,13 @@ const ENVIRONMENT_PAGES = {
6897
6991
  forms: "/forms",
6898
6992
  scheduling: "/scheduling",
6899
6993
  "scheduling-hosts": "/scheduling/hosts",
6994
+ "scheduling-out-of-office": "/scheduling/out-of-office",
6995
+ "scheduling-holidays": "/scheduling/holidays",
6996
+ "scheduling-reassignments": "/scheduling/reassignments",
6900
6997
  "scheduling-event-types": "/scheduling/event-types",
6901
6998
  "scheduling-reminders": "/scheduling/reminders",
6902
6999
  "scheduling-calendar-delegation": "/scheduling/calendar-delegation",
7000
+ "scheduling-oauth-apps": "/scheduling/oauth-apps",
6903
7001
  "scheduling-settings": "/scheduling/settings",
6904
7002
  hooks: "/hooks",
6905
7003
  "hooks-event-types": "/hooks/event-types",
@@ -7986,6 +8084,14 @@ const STATUSES$4 = [
7986
8084
  "cancelled",
7987
8085
  "declined"
7988
8086
  ];
8087
+ const REASSIGN_REASONS = [
8088
+ "host_unavailable",
8089
+ "out_of_office",
8090
+ "workload",
8091
+ "customer_request",
8092
+ "offboarding",
8093
+ "other"
8094
+ ];
7989
8095
  const LIMIT = {
7990
8096
  type: "string",
7991
8097
  value: "<n>",
@@ -8314,6 +8420,74 @@ const cancel$2 = defineCommand({
8314
8420
  return 0;
8315
8421
  }
8316
8422
  });
8423
+ const REASSIGN_FLAGS = {
8424
+ to: {
8425
+ type: "string",
8426
+ value: "<host>",
8427
+ description: "The new host's id or uid"
8428
+ },
8429
+ auto: {
8430
+ type: "boolean",
8431
+ description: "Let coss.com pick the fairest who's free"
8432
+ },
8433
+ from: {
8434
+ type: "string",
8435
+ value: "<host>",
8436
+ description: "Who's leaving, if it has several hosts"
8437
+ },
8438
+ reason: {
8439
+ type: "string",
8440
+ value: "<code>",
8441
+ description: `Why: ${REASSIGN_REASONS.join(", ")} (default other)`
8442
+ },
8443
+ note: {
8444
+ type: "string",
8445
+ value: "<text>",
8446
+ description: "Why, in your words"
8447
+ },
8448
+ "any-host": {
8449
+ type: "boolean",
8450
+ description: "Allow a host who doesn't take this event type"
8451
+ },
8452
+ override: {
8453
+ type: "string",
8454
+ value: "<reason>",
8455
+ description: "Go past this reason they can't, such as outside_availability. Needs --note"
8456
+ },
8457
+ "no-notify": {
8458
+ type: "boolean",
8459
+ description: "Don't tell the attendee"
8460
+ },
8461
+ json: BOOKING_FLAGS.json
8462
+ };
8463
+ const reassign = defineCommand({
8464
+ name: "scheduling reassign",
8465
+ summary: "Give a booking to another host",
8466
+ usage: "<booking> (--to <host> | --auto)",
8467
+ description: "Keeps the booking's id and time. Whoever's leaving and joining are told, and the attendee unless --no-notify. A group session moves as a whole.",
8468
+ flags: REASSIGN_FLAGS,
8469
+ positionals: true,
8470
+ run: async ({ positionals, values, context }) => {
8471
+ const [id] = requireArgs(positionals, 1, "scheduling reassign <booking>");
8472
+ if (Boolean(values.to) === Boolean(values.auto)) throw new UsageError("Pass one of --to <host> and --auto.");
8473
+ const reason = values.reason ?? "other";
8474
+ if (!REASSIGN_REASONS.includes(reason)) throw new UsageError(`--reason takes one of ${REASSIGN_REASONS.join(", ")}.`);
8475
+ const overrides = [...values["any-host"] ? ["any_host"] : [], ...values.override ? [values.override] : []];
8476
+ const { data, error } = await (await client$1(context)).scheduling.bookings.reassign(id, {
8477
+ changes: [{
8478
+ ...values.to ? { to_host: values.to } : { auto: true },
8479
+ ...values.from ? { from_host: values.from } : {}
8480
+ }],
8481
+ reason_code: reason,
8482
+ ...values.note ? { note: values.note } : {},
8483
+ ...overrides.length > 0 ? { overrides } : {},
8484
+ ...values["no-notify"] ? { notify: { attendee: false } } : {}
8485
+ });
8486
+ if (error) throw apiError("Couldn't reassign the booking", error);
8487
+ printBooking(context, data);
8488
+ return 0;
8489
+ }
8490
+ });
8317
8491
  const noShow = defineCommand({
8318
8492
  name: "scheduling no-show",
8319
8493
  summary: "Mark a booking as a no-show",
@@ -8329,6 +8503,310 @@ const noShow = defineCommand({
8329
8503
  return 0;
8330
8504
  }
8331
8505
  });
8506
+ const candidates = defineCommand({
8507
+ name: "scheduling candidates",
8508
+ summary: "List who a booking could go to",
8509
+ usage: "<booking>",
8510
+ description: "Members of the event type first, each saying whether they're free and why not.",
8511
+ flags: { json: {
8512
+ type: "boolean",
8513
+ description: "One candidate per line, as JSON"
8514
+ } },
8515
+ positionals: true,
8516
+ run: async ({ positionals, context }) => {
8517
+ const [id] = requireArgs(positionals, 1, "scheduling candidates <booking>");
8518
+ const { data, error } = await (await client$1(context)).scheduling.bookings.reassignCandidates(id);
8519
+ if (error) throw apiError("Couldn't list the candidates", error);
8520
+ const { out } = context;
8521
+ if (out.json) {
8522
+ for (const item of data.data) out.data(item);
8523
+ return 0;
8524
+ }
8525
+ if (data.data.length === 0) {
8526
+ out.info("Nobody else in this environment.");
8527
+ return 0;
8528
+ }
8529
+ const lines = table([[
8530
+ "HOST",
8531
+ "NAME",
8532
+ "FREE",
8533
+ "WHY NOT",
8534
+ "MEMBER"
8535
+ ], ...data.data.map((row) => [
8536
+ row.uid ? printable(row.uid) : row.host,
8537
+ printable(row.name),
8538
+ row.available ? "yes" : "no",
8539
+ row.reason ?? "",
8540
+ row.member ? "yes" : "no"
8541
+ ])]);
8542
+ for (const line of lines) out.line(line);
8543
+ return 0;
8544
+ }
8545
+ });
8546
+ const reassignMany = defineCommand({
8547
+ name: "scheduling reassign-many",
8548
+ summary: "Move many bookings to other hosts",
8549
+ usage: "(--from <host> | --ooo <id>)",
8550
+ description: "Moves them in the background. Each host hears once, and attendees per booking unless --no-notify. A booking nobody can take stays where it is. Start with --dry-run to see who they'd go to.",
8551
+ flags: {
8552
+ from: {
8553
+ type: "string",
8554
+ value: "<host>",
8555
+ description: "Whose bookings, by id or uid"
8556
+ },
8557
+ ooo: {
8558
+ type: "string",
8559
+ value: "<id>",
8560
+ description: "The bookings in this out of office entry"
8561
+ },
8562
+ to: {
8563
+ type: "string",
8564
+ value: "<host>",
8565
+ description: "Give them all to this host"
8566
+ },
8567
+ preferred: {
8568
+ type: "string",
8569
+ value: "<hosts>",
8570
+ description: "Try these first, comma-separated"
8571
+ },
8572
+ "leave-rest": {
8573
+ type: "boolean",
8574
+ description: "After --preferred, keep the rest where they are"
8575
+ },
8576
+ after: {
8577
+ type: "string",
8578
+ value: "<time>",
8579
+ description: "Only bookings ending after this"
8580
+ },
8581
+ before: {
8582
+ type: "string",
8583
+ value: "<time>",
8584
+ description: "Only bookings starting before this"
8585
+ },
8586
+ reason: REASSIGN_FLAGS.reason,
8587
+ note: REASSIGN_FLAGS.note,
8588
+ "no-notify": {
8589
+ type: "boolean",
8590
+ description: "Don't tell attendees"
8591
+ },
8592
+ "dry-run": {
8593
+ type: "boolean",
8594
+ description: "Show who they'd go to, and move nothing"
8595
+ },
8596
+ json: {
8597
+ type: "boolean",
8598
+ description: "One item per line, as JSON"
8599
+ }
8600
+ },
8601
+ run: async ({ values, context }) => {
8602
+ if (Boolean(values.from) === Boolean(values.ooo)) throw new UsageError("Pass one of --from <host> and --ooo <id>.");
8603
+ if (values.to && values.preferred) throw new UsageError("Pass one of --to and --preferred.");
8604
+ const reason = values.reason ?? "other";
8605
+ if (!REASSIGN_REASONS.includes(reason)) throw new UsageError(`--reason takes one of ${REASSIGN_REASONS.join(", ")}.`);
8606
+ const selection = {
8607
+ ...values.from ? { host: values.from } : {},
8608
+ ...values.ooo ? { out_of_office: values.ooo } : {},
8609
+ ...values.after ? { start_after: values.after } : {},
8610
+ ...values.before ? { start_before: values.before } : {}
8611
+ };
8612
+ const strategy = {
8613
+ ...values.to ? { to_host: values.to } : {},
8614
+ ...values.preferred ? { preferred_hosts: values.preferred.split(",") } : {},
8615
+ ...values["leave-rest"] ? { otherwise: "leave" } : {}
8616
+ };
8617
+ const coss = await client$1(context);
8618
+ const { out } = context;
8619
+ if (values["dry-run"]) {
8620
+ const { data, error } = await coss.scheduling.reassignments.preview({
8621
+ selection,
8622
+ strategy
8623
+ });
8624
+ if (error) throw apiError("Couldn't preview that", error);
8625
+ if (out.json) {
8626
+ for (const item of data.items) out.data(item);
8627
+ return 0;
8628
+ }
8629
+ if (data.items.length === 0) {
8630
+ out.info("Nothing to move.");
8631
+ return 0;
8632
+ }
8633
+ const lines = table([[
8634
+ "BOOKING",
8635
+ "START",
8636
+ "FROM",
8637
+ "TO",
8638
+ "WHY NOT"
8639
+ ], ...data.items.map((item) => [
8640
+ item.booking,
8641
+ when(item.start),
8642
+ item.from_host ?? "",
8643
+ item.to_host ?? "stays",
8644
+ item.reason ?? ""
8645
+ ])]);
8646
+ for (const line of lines) out.line(line);
8647
+ if (data.truncated) out.info("That's the first 500.");
8648
+ return 0;
8649
+ }
8650
+ const { data, error } = await coss.scheduling.reassignments.create({
8651
+ selection,
8652
+ strategy,
8653
+ reason_code: reason,
8654
+ ...values.note ? { note: values.note } : {},
8655
+ ...values["no-notify"] ? { notify: { attendees: false } } : {}
8656
+ });
8657
+ if (error) throw apiError("Couldn't start that", error);
8658
+ if (out.json) {
8659
+ out.data(data);
8660
+ return 0;
8661
+ }
8662
+ out.line(data.id);
8663
+ out.info(`Follow it with: coss scheduling reassignment ${data.id}`);
8664
+ return 0;
8665
+ }
8666
+ });
8667
+ const REASSIGNMENTS_FLAGS = {
8668
+ limit: LIMIT,
8669
+ json: {
8670
+ type: "boolean",
8671
+ description: "One run per line, as JSON"
8672
+ }
8673
+ };
8674
+ const countsLine = (counts) => `${counts.reassigned} of ${counts.total} moved, ${counts.no_candidate} stayed, ${counts.skipped} skipped, ${counts.failed} failed`;
8675
+ const reassignments = defineCommand({
8676
+ name: "scheduling reassignments",
8677
+ summary: "List bulk reassignments",
8678
+ description: "The environment's runs, newest first, with how each went.",
8679
+ flags: REASSIGNMENTS_FLAGS,
8680
+ run: async ({ values, context }) => {
8681
+ const coss = await client$1(context);
8682
+ const limit = limitOf(values.limit);
8683
+ const { data, error } = await coss.scheduling.reassignments.list(limit ? { limit } : {});
8684
+ if (error) throw apiError("Couldn't list reassignments", error);
8685
+ const { out } = context;
8686
+ if (out.json) {
8687
+ for (const item of data.data) out.data(item);
8688
+ return 0;
8689
+ }
8690
+ if (data.data.length === 0) {
8691
+ out.info("No reassignments yet.");
8692
+ return 0;
8693
+ }
8694
+ const lines = table([[
8695
+ "ID",
8696
+ "STATUS",
8697
+ "CREATED",
8698
+ "PROGRESS"
8699
+ ], ...data.data.map((row) => [
8700
+ row.id,
8701
+ row.status,
8702
+ when(row.created_at),
8703
+ countsLine(row.counts)
8704
+ ])]);
8705
+ for (const line of lines) out.line(line);
8706
+ return 0;
8707
+ }
8708
+ });
8709
+ const reassignment = defineCommand({
8710
+ name: "scheduling reassignment",
8711
+ summary: "Show, cancel or undo a bulk reassignment",
8712
+ usage: "<id> [--cancel | --undo]",
8713
+ description: "How a run went, and what happened to each booking that didn't move.",
8714
+ flags: {
8715
+ cancel: {
8716
+ type: "boolean",
8717
+ description: "Stop what hasn't happened yet"
8718
+ },
8719
+ undo: {
8720
+ type: "boolean",
8721
+ description: "Give back what it moved, as a new run"
8722
+ },
8723
+ json: {
8724
+ type: "boolean",
8725
+ description: "As JSON"
8726
+ }
8727
+ },
8728
+ positionals: true,
8729
+ run: async ({ positionals, values, context }) => {
8730
+ const [id] = requireArgs(positionals, 1, "scheduling reassignment <id>");
8731
+ if (values.cancel && values.undo) throw new UsageError("Pass one of --cancel and --undo.");
8732
+ const coss = await client$1(context);
8733
+ const { out } = context;
8734
+ const { data, error } = values.cancel ? await coss.scheduling.reassignments.cancel(id) : values.undo ? await coss.scheduling.reassignments.undo(id) : await coss.scheduling.reassignments.get(id);
8735
+ if (error) throw apiError("Couldn't do that", error);
8736
+ if (out.json) {
8737
+ out.data(data);
8738
+ return 0;
8739
+ }
8740
+ out.line(`${data.id} ${data.status}`);
8741
+ out.line(countsLine(data.counts));
8742
+ if (values.undo) return 0;
8743
+ const items = await coss.scheduling.reassignments.items(id, { limit: 100 });
8744
+ if (items.error) throw apiError("Couldn't list what happened", items.error);
8745
+ const unmoved = items.data.data.filter((item) => item.outcome !== "reassigned");
8746
+ if (unmoved.length === 0) return 0;
8747
+ const lines = table([[
8748
+ "BOOKING",
8749
+ "OUTCOME",
8750
+ "CODE"
8751
+ ], ...unmoved.map((item) => [
8752
+ item.booking,
8753
+ item.outcome,
8754
+ item.error_code ?? ""
8755
+ ])]);
8756
+ for (const line of lines) out.line(line);
8757
+ return 0;
8758
+ }
8759
+ });
8760
+ const outOfOffice = defineCommand({
8761
+ name: "scheduling ooo",
8762
+ summary: "List time hosts are away",
8763
+ description: "The environment's out of office entries, newest first.",
8764
+ flags: {
8765
+ host: {
8766
+ type: "string",
8767
+ value: "<host>",
8768
+ description: "One host's entries, by id or uid"
8769
+ },
8770
+ limit: LIMIT,
8771
+ json: {
8772
+ type: "boolean",
8773
+ description: "One entry per line, as JSON"
8774
+ }
8775
+ },
8776
+ run: async ({ values, context }) => {
8777
+ const coss = await client$1(context);
8778
+ const limit = limitOf(values.limit);
8779
+ const { data, error } = await coss.scheduling.outOfOffice.list({
8780
+ ...limit ? { limit } : {},
8781
+ ...values.host ? { host: values.host } : {}
8782
+ });
8783
+ if (error) throw apiError("Couldn't list out of office entries", error);
8784
+ const { out } = context;
8785
+ if (out.json) {
8786
+ for (const item of data.data) out.data(item);
8787
+ return 0;
8788
+ }
8789
+ if (data.data.length === 0) {
8790
+ out.info("Nobody's away.");
8791
+ return 0;
8792
+ }
8793
+ const lines = table([[
8794
+ "ID",
8795
+ "HOST",
8796
+ "START",
8797
+ "END",
8798
+ "REASON"
8799
+ ], ...data.data.map((row) => [
8800
+ row.id,
8801
+ row.host,
8802
+ when(row.start),
8803
+ when(row.end),
8804
+ printable(row.reason)
8805
+ ])]);
8806
+ for (const line of lines) out.line(line);
8807
+ return 0;
8808
+ }
8809
+ });
8332
8810
  const notifications = defineCommand({
8333
8811
  name: "scheduling notifications",
8334
8812
  summary: "List what was queued for a booking",
@@ -9177,6 +9655,12 @@ const SCHEDULING_COMMANDS = [
9177
9655
  approve,
9178
9656
  decline,
9179
9657
  cancel$2,
9658
+ reassign,
9659
+ candidates,
9660
+ reassignMany,
9661
+ reassignments,
9662
+ reassignment,
9663
+ outOfOffice,
9180
9664
  calendars,
9181
9665
  noShow,
9182
9666
  notifications,
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "coss-cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "The coss.com command line: sign in, tail your log, forward webhooks to localhost with `coss listen`, and use email, marketing, inboxes, SMS, Verify, Sign, Forms, Scheduling, Hooks and Risk.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://coss.com/docs/cli",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/cosscom/coss.git",
10
- "directory": "packages/cli"
9
+ "url": "git+https://github.com/cosscom/coss-cli.git"
11
10
  },
12
- "bugs": "https://github.com/cosscom/coss/issues",
11
+ "bugs": "https://coss.com/contact",
13
12
  "keywords": [
14
13
  "coss",
15
14
  "cli",
@@ -51,7 +50,7 @@
51
50
  "test": "bun test"
52
51
  },
53
52
  "dependencies": {
54
- "coss": "^0.12.0"
53
+ "coss": "^0.13.0"
55
54
  },
56
55
  "devDependencies": {
57
56
  "@arethetypeswrong/core": "0.18.5",
@@ -62,7 +61,6 @@
62
61
  "typescript": "7.0.2"
63
62
  },
64
63
  "publishConfig": {
65
- "access": "public",
66
- "provenance": true
64
+ "access": "public"
67
65
  }
68
66
  }