groundmail-cli 0.25.1 → 0.26.1

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 +8 -0
  2. package/dist/cli.js +40 -2
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -81,6 +81,14 @@ groundmail tenants resume cus_123
81
81
  `suppressions` and `keys create` (a key limited to one tenant). `webhooks create` and
82
82
  `webhooks update` take `--tenants a,b` to receive only those tenants' email events.
83
83
 
84
+ When a reader re-subscribes to a tenant's newsletter, remove their one-click opt-out so
85
+ sends in that category go through again:
86
+
87
+ ```bash
88
+ groundmail suppressions list --type category_opt_out --tenant cus_123
89
+ groundmail suppressions remove --type category_opt_out --email reader@example.com --category newsletter --tenant cus_123
90
+ ```
91
+
84
92
  ## Docs
85
93
 
86
94
  - CLI: https://docs.groundmail.dev/cli
package/dist/cli.js CHANGED
@@ -1452,7 +1452,7 @@ function trimUrl(value) {
1452
1452
  }
1453
1453
 
1454
1454
  // package.json
1455
- var version = "0.25.1";
1455
+ var version = "0.26.1";
1456
1456
 
1457
1457
  // src/user-agent.ts
1458
1458
  function buildUserAgent(own) {
@@ -2400,6 +2400,26 @@ async function runListCommand6(args, env = process.env) {
2400
2400
  const cursor = readFlag19(args, "--cursor");
2401
2401
  const email = readFlag19(args, "--email");
2402
2402
  const tenant = readFlag19(args, "--tenant");
2403
+ const type = readFlag19(args, "--type");
2404
+ if (type && type !== "suppression" && type !== "category_opt_out") {
2405
+ return { exitCode: 1, error: "--type must be suppression or category_opt_out" };
2406
+ }
2407
+ if (type === "category_opt_out") {
2408
+ const category = readFlag19(args, "--category");
2409
+ if (category && category !== "product" && category !== "newsletter") {
2410
+ return { exitCode: 1, error: "--category must be product or newsletter" };
2411
+ }
2412
+ const optOuts = await client2.suppressions.listCategoryOptOuts({
2413
+ ...limitRaw ? { limit: Number(limitRaw) } : {},
2414
+ ...cursor ? { cursor } : {},
2415
+ ...email ? { email } : {},
2416
+ ...category ? { category } : {},
2417
+ ...tenant ? { tenant } : {},
2418
+ ...args.includes("--include-tenants") ? { includeTenants: true } : {}
2419
+ });
2420
+ console.log(JSON.stringify(optOuts));
2421
+ return { exitCode: 0 };
2422
+ }
2403
2423
  const result = await client2.suppressions.list({
2404
2424
  ...limitRaw ? { limit: Number(limitRaw) } : {},
2405
2425
  ...cursor ? { cursor } : {},
@@ -2448,14 +2468,30 @@ async function runRemoveCommand(args, env = process.env) {
2448
2468
  return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
2449
2469
  }
2450
2470
  const tenant = readFlag19(args, "--tenant");
2471
+ const type = readFlag19(args, "--type");
2472
+ const category = readFlag19(args, "--category");
2473
+ if (type && type !== "suppression" && type !== "category_opt_out") {
2474
+ return { exitCode: 1, error: "--type must be suppression or category_opt_out" };
2475
+ }
2476
+ if (category && category !== "product" && category !== "newsletter") {
2477
+ return { exitCode: 1, error: "--category must be product or newsletter" };
2478
+ }
2451
2479
  const idOrEmail = readFlag19(args, "--id") || readFlag19(args, "--email") || args.find(
2452
- (a, i) => !a.startsWith("-") && a !== "remove" && a !== "delete" && !["--tenant", "--api-key", "--base-url"].includes(args[i - 1] ?? "")
2480
+ (a, i) => !a.startsWith("-") && a !== "remove" && a !== "delete" && !["--tenant", "--type", "--category", "--api-key", "--base-url"].includes(args[i - 1] ?? "")
2453
2481
  );
2454
2482
  if (!idOrEmail) {
2455
2483
  return { exitCode: 1, error: "Missing id or email. Pass --id <uuid> or --email user@example.com" };
2456
2484
  }
2457
2485
  try {
2458
2486
  const client2 = await createSuppressionsClient(apiKey, options.baseUrl);
2487
+ if (type === "category_opt_out") {
2488
+ const optOut = await client2.suppressions.removeCategoryOptOut(idOrEmail, {
2489
+ ...category ? { category } : {},
2490
+ ...tenant ? { tenant } : {}
2491
+ });
2492
+ console.log(JSON.stringify(optOut));
2493
+ return { exitCode: 0 };
2494
+ }
2459
2495
  const result = tenant ? await client2.suppressions.remove(idOrEmail, { tenant }) : await client2.suppressions.remove(idOrEmail);
2460
2496
  console.log(JSON.stringify(result));
2461
2497
  return { exitCode: 0 };
@@ -3759,6 +3795,8 @@ var USAGE_LINES = [
3759
3795
  " groundmail suppressions list [--tenant <tenant>]",
3760
3796
  " groundmail suppressions add --email user@example.com [--reason \u2026] [--tenant <tenant>]",
3761
3797
  " groundmail suppressions remove --id <id> | --email user@example.com [--tenant <tenant>]",
3798
+ " groundmail suppressions list --type category_opt_out [--category product|newsletter] [--tenant <tenant> | --include-tenants] one-click category unsubscribes",
3799
+ " groundmail suppressions remove --type category_opt_out --email user@example.com [--category newsletter] [--tenant <tenant>] re-subscribe to a category",
3762
3800
  " groundmail templates list [--status draft|published]",
3763
3801
  " groundmail templates starters",
3764
3802
  " groundmail templates from-starter password-reset",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.25.1",
3
+ "version": "0.26.1",
4
4
  "description": "Groundmail CLI — send transactional email from the terminal",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "prepublishOnly": "npm run build"
39
39
  },
40
40
  "dependencies": {
41
- "groundmail": "0.23.0"
41
+ "groundmail": "0.25.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",