shipmail-cli 0.4.5 → 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 (3) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cli.js +73 -7
  3. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 ShipMail
3
+ Copyright (c) 2025 Shipmail
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/cli.js CHANGED
@@ -8,13 +8,13 @@ import { env as processEnv, exit, stderr, stdout } from "process";
8
8
  import { fileURLToPath } from "url";
9
9
  import {
10
10
  CONFERENCING_PROVIDER_IDS,
11
- ShipMailClient,
12
- ShipMailError,
11
+ ShipmailClient,
12
+ ShipmailError,
13
13
  WEBHOOK_EVENT_TYPES
14
14
  } from "shipmail";
15
15
 
16
16
  // src/version.ts
17
- var VERSION = "0.4.5";
17
+ var VERSION = "0.4.7";
18
18
 
19
19
  // src/cli.ts
20
20
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -143,7 +143,7 @@ function createClient(parsed, options) {
143
143
  organizationId: organizationId(parsed, env),
144
144
  ...options.fetch ? { fetch: options.fetch } : {}
145
145
  };
146
- return new ShipMailClient(config);
146
+ return new ShipmailClient(config);
147
147
  }
148
148
  function writeJson(out, value) {
149
149
  out.write(`${JSON.stringify(value, null, 2)}
@@ -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");
@@ -278,7 +291,7 @@ async function rawApiRequest(parsed, runOptions, method, path, body, authRequire
278
291
  }
279
292
  const targetOrganizationId = organizationId(parsed, env);
280
293
  if (targetOrganizationId) {
281
- headers["X-ShipMail-Organization-Id"] = targetOrganizationId;
294
+ headers["X-Shipmail-Organization-Id"] = targetOrganizationId;
282
295
  }
283
296
  let requestBody;
284
297
  if (body !== void 0) {
@@ -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") {
@@ -1942,7 +2007,7 @@ ${JSON.stringify(err.body, null, 2)}
1942
2007
  `);
1943
2008
  return;
1944
2009
  }
1945
- if (err instanceof ShipMailError) {
2010
+ if (err instanceof ShipmailError) {
1946
2011
  const shipmailError = err;
1947
2012
  const status = shipmailError.status !== void 0 ? ` (HTTP ${shipmailError.status})` : "";
1948
2013
  const requestId = shipmailError.requestId ? ` request_id=${shipmailError.requestId}` : "";
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "shipmail-cli",
3
- "version": "0.4.5",
4
- "description": "Official CLI for the ShipMail API",
3
+ "version": "0.4.7",
4
+ "description": "Official CLI for the Shipmail API",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "shipmail": "dist/cli.js"
@@ -26,7 +26,7 @@
26
26
  "domain",
27
27
  "terminal"
28
28
  ],
29
- "author": "ShipMail",
29
+ "author": "Shipmail",
30
30
  "license": "MIT",
31
31
  "homepage": "https://shipmail.to/docs/cli",
32
32
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "shipmail": "0.4.10"
44
+ "shipmail": "0.4.14"
45
45
  },
46
46
  "devDependencies": {
47
47
  "tsup": "^8.4.0",