shipmail-cli 0.4.6 → 0.4.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +68 -2
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  } from "shipmail";
15
15
 
16
16
  // src/version.ts
17
- var VERSION = "0.4.6";
17
+ var VERSION = "0.4.7";
18
18
 
19
19
  // src/cli.ts
20
20
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -185,6 +185,19 @@ function parseStylingMode(options) {
185
185
  if (value === "styled" || value === "plain") return value;
186
186
  throw new CliUsageError("--styling-mode must be styled or plain.");
187
187
  }
188
+ async function automationDefinition(value) {
189
+ const parsed = await readJsonInput(value);
190
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
191
+ throw new CliUsageError("--definition must be a JSON automation definition object.");
192
+ }
193
+ return parsed;
194
+ }
195
+ function automationStatus(options) {
196
+ const value = getString(options, "status");
197
+ if (value === void 0) return void 0;
198
+ if (value === "active" || value === "paused" || value === "disabled") return value;
199
+ throw new CliUsageError("--status must be active, paused, or disabled.");
200
+ }
188
201
  async function newsletterCreateParams(options) {
189
202
  const audience_id = getRequiredString(options, "audience-id");
190
203
  const sender_identity_id = getRequiredString(options, "sender-identity-id");
@@ -324,6 +337,11 @@ Usage:
324
337
  shipmail status
325
338
  shipmail capabilities
326
339
  shipmail api <METHOD> <PATH> [--data JSON|@file] [--output file]
340
+ shipmail automations list
341
+ shipmail automations create --name "Daily brief" --definition JSON|@file [--idempotency-key key]
342
+ shipmail automations get <id>
343
+ shipmail automations update <id> [--name "..."] [--definition JSON|@file] [--status active|paused|disabled] [--idempotency-key key]
344
+ shipmail automations run <id> [--idempotency-key key]
327
345
  shipmail domains list [--limit 25] [--cursor cur]
328
346
  shipmail domains search <keyword>
329
347
  shipmail domains create <name>
@@ -1839,6 +1857,53 @@ async function runBookingPages(client, parsed, out) {
1839
1857
  }
1840
1858
  throw new CliUsageError("Unknown booking-pages command.");
1841
1859
  }
1860
+ async function runAutomations(client, parsed, out) {
1861
+ const subcommand = parsed.positional[1];
1862
+ const idempotencyKey = getString(parsed.options, "idempotency-key");
1863
+ const options = idempotencyKey ? { idempotencyKey } : void 0;
1864
+ if (subcommand === "list") {
1865
+ writeJson(out, await client.automations.list());
1866
+ return;
1867
+ }
1868
+ if (subcommand === "create") {
1869
+ writeJson(
1870
+ out,
1871
+ await client.automations.create(
1872
+ {
1873
+ name: getRequiredString(parsed.options, "name"),
1874
+ definition: await automationDefinition(getRequiredString(parsed.options, "definition"))
1875
+ },
1876
+ options
1877
+ )
1878
+ );
1879
+ return;
1880
+ }
1881
+ const id = requirePositional(parsed.positional, 2, "automation id");
1882
+ if (subcommand === "get") {
1883
+ writeJson(out, await client.automations.get(id));
1884
+ return;
1885
+ }
1886
+ if (subcommand === "update") {
1887
+ const name = getString(parsed.options, "name");
1888
+ const definitionInput = getString(parsed.options, "definition");
1889
+ const status = automationStatus(parsed.options);
1890
+ const params = {
1891
+ ...name !== void 0 ? { name } : {},
1892
+ ...definitionInput !== void 0 ? { definition: await automationDefinition(definitionInput) } : {},
1893
+ ...status !== void 0 ? { status } : {}
1894
+ };
1895
+ if (Object.keys(params).length === 0) {
1896
+ throw new CliUsageError("Provide --name, --definition, or --status.");
1897
+ }
1898
+ writeJson(out, await client.automations.update(id, params, options));
1899
+ return;
1900
+ }
1901
+ if (subcommand === "run") {
1902
+ writeJson(out, await client.automations.run(id, options));
1903
+ return;
1904
+ }
1905
+ throw new CliUsageError("Unknown automations command.");
1906
+ }
1842
1907
  async function runPartner(client, parsed, out) {
1843
1908
  const group = parsed.positional[1];
1844
1909
  if (group === "usage") {
@@ -1994,7 +2059,8 @@ async function runCli(argv, options = {}) {
1994
2059
  return 0;
1995
2060
  }
1996
2061
  const client = createClient(parsed, options);
1997
- if (command === "domains") await runDomains(client, parsed, out);
2062
+ if (command === "automations") await runAutomations(client, parsed, out);
2063
+ else if (command === "domains") await runDomains(client, parsed, out);
1998
2064
  else if (command === "mailboxes") await runMailboxes(client, parsed, out);
1999
2065
  else if (command === "inbox") await runInbox(client, parsed, out);
2000
2066
  else if (command === "messages") await runMessages(client, parsed, out);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shipmail-cli",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Official CLI for the Shipmail API",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "shipmail": "0.4.13"
44
+ "shipmail": "0.4.14"
45
45
  },
46
46
  "devDependencies": {
47
47
  "tsup": "^8.4.0",