shipmail-cli 0.4.1 → 0.4.2

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/README.md +3 -0
  2. package/dist/cli.js +58 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -159,6 +159,9 @@ Use repeatable `--header "Name: value"` flags for request headers. Use `--output
159
159
  - `mailboxes sandbox-inbound`
160
160
  - `webhooks list|create|test|deliveries|replay-delivery`
161
161
  - `suppressions list|remove`
162
+ - `audiences list|create|get|update|delete`
163
+ - `audiences feed get|update|rotate|revoke`
164
+ - `audiences subscribers add|list|get|by-email|update|unsubscribe|resubscribe|remove`
162
165
  - `newsletter-domains list`
163
166
  - `newsletters create|update|preview|preflight|test-send|schedule|cancel|resume`
164
167
  - `newsletter-assets list|upload|register-url`
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.1";
17
+ var VERSION = "0.4.2";
18
18
 
19
19
  // src/cli.ts
20
20
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -404,6 +404,10 @@ Usage:
404
404
  shipmail audiences get <id>
405
405
  shipmail audiences update <id> [--name "..."] [--description "..."]
406
406
  shipmail audiences delete <id>
407
+ shipmail audiences feed get <audience-id>
408
+ shipmail audiences feed update <audience-id> [--enabled true|false] [--title "..."] [--subtitle "..."] [--site-url https://...] [--author-name "..."] [--icon-url https://...] [--idempotency-key key]
409
+ shipmail audiences feed rotate <audience-id> [--idempotency-key key]
410
+ shipmail audiences feed revoke <audience-id> [--idempotency-key key]
407
411
  shipmail audiences subscribers add <audience-id> <email> [--name "Jane"] [--consent-source "..."]
408
412
  shipmail audiences subscribers list <audience-id> [--status subscribed] [--email jane@x.com] [--limit 25]
409
413
  shipmail audiences subscribers get <audience-id> <subscriber-id>
@@ -1326,12 +1330,65 @@ async function runSubscribers(client, parsed, out) {
1326
1330
  }
1327
1331
  throw new CliUsageError("Unknown audiences subscribers command.");
1328
1332
  }
1333
+ function audienceFeedUpdateParams(options) {
1334
+ const enabled = getBoolean(options, "enabled");
1335
+ const title = getString(options, "title");
1336
+ const subtitle = getString(options, "subtitle");
1337
+ const siteUrl = getString(options, "site-url");
1338
+ const authorName = getString(options, "author-name");
1339
+ const iconUrl = getString(options, "icon-url");
1340
+ if (enabled === void 0 && title === void 0 && subtitle === void 0 && siteUrl === void 0 && authorName === void 0 && iconUrl === void 0) {
1341
+ throw new CliUsageError("Provide at least one feed setting to update.");
1342
+ }
1343
+ return {
1344
+ ...enabled !== void 0 ? { enabled } : {},
1345
+ ...title !== void 0 ? { title } : {},
1346
+ ...subtitle !== void 0 ? { subtitle } : {},
1347
+ ...siteUrl !== void 0 ? { site_url: siteUrl } : {},
1348
+ ...authorName !== void 0 ? { author_name: authorName } : {},
1349
+ ...iconUrl !== void 0 ? { icon_url: iconUrl } : {}
1350
+ };
1351
+ }
1352
+ async function runAudienceFeed(client, parsed, out) {
1353
+ const action = parsed.positional[2];
1354
+ const audienceId = requirePositional(parsed.positional, 3, "audience id");
1355
+ if (action === "get") {
1356
+ writeJson(out, await client.audiences.feeds.get(audienceId));
1357
+ return;
1358
+ }
1359
+ const idempotencyKey = getString(parsed.options, "idempotency-key");
1360
+ const methodOptions = idempotencyKey ? { idempotencyKey } : void 0;
1361
+ if (action === "update") {
1362
+ writeJson(
1363
+ out,
1364
+ await client.audiences.feeds.update(
1365
+ audienceId,
1366
+ audienceFeedUpdateParams(parsed.options),
1367
+ methodOptions
1368
+ )
1369
+ );
1370
+ return;
1371
+ }
1372
+ if (action === "rotate") {
1373
+ writeJson(out, await client.audiences.feeds.rotate(audienceId, methodOptions));
1374
+ return;
1375
+ }
1376
+ if (action === "revoke") {
1377
+ writeJson(out, await client.audiences.feeds.revoke(audienceId, methodOptions));
1378
+ return;
1379
+ }
1380
+ throw new CliUsageError("Unknown audiences feed command.");
1381
+ }
1329
1382
  async function runAudiences(client, parsed, out) {
1330
1383
  const subcommand = parsed.positional[1];
1331
1384
  if (subcommand === "subscribers") {
1332
1385
  await runSubscribers(client, parsed, out);
1333
1386
  return;
1334
1387
  }
1388
+ if (subcommand === "feed") {
1389
+ await runAudienceFeed(client, parsed, out);
1390
+ return;
1391
+ }
1335
1392
  if (subcommand === "list") {
1336
1393
  writeJson(
1337
1394
  out,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shipmail-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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.4"
44
+ "shipmail": "0.4.6"
45
45
  },
46
46
  "devDependencies": {
47
47
  "tsup": "^8.4.0",