groundmail-cli 0.36.0 → 0.37.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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/cli.js +60 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -74,6 +74,8 @@ groundmail workspaces use <name>
74
74
  groundmail domains list
75
75
  groundmail domains verify example.com
76
76
  groundmail webhooks list
77
+ groundmail webhooks deliveries list --webhook <webhook-id> --status failed
78
+ groundmail webhooks deliveries resend --webhook <webhook-id> --id <delivery-id>
77
79
  groundmail emails list
78
80
  groundmail batches get batch_… # status counts for an emails batch
79
81
  groundmail batches cancel batch_… # cancel the batch's emails that are still scheduled
package/dist/cli.js CHANGED
@@ -2001,6 +2001,57 @@ function parseEnabledFlag(value) {
2001
2001
  return { error: "--enabled must be true or false" };
2002
2002
  }
2003
2003
 
2004
+ // src/commands/webhooks/deliveries.ts
2005
+ var VALUE_FILTERS = {
2006
+ "--status": "status",
2007
+ "--event": "event",
2008
+ "--email-id": "email_id",
2009
+ "--q": "q",
2010
+ "--cursor": "cursor"
2011
+ };
2012
+ function listParams(args) {
2013
+ const params = {};
2014
+ for (const [flag, key] of Object.entries(VALUE_FILTERS)) {
2015
+ const value = readFlag13(args, flag);
2016
+ if (value) params[key] = value;
2017
+ }
2018
+ const limit = readFlag13(args, "--limit");
2019
+ if (limit) {
2020
+ const parsed = Number(limit);
2021
+ if (!Number.isInteger(parsed) || parsed < 1) return { error: "--limit must be a positive whole number." };
2022
+ params.limit = parsed;
2023
+ }
2024
+ const test = readFlag13(args, "--test");
2025
+ if (test) {
2026
+ if (test !== "true" && test !== "false") return { error: "--test must be true or false." };
2027
+ params.test = test === "true";
2028
+ }
2029
+ return params;
2030
+ }
2031
+ async function runDeliveriesCommand(args, env = process.env) {
2032
+ const [action, ...rest] = args;
2033
+ if (action !== "list" && action !== "get" && action !== "resend") {
2034
+ return { exitCode: 1, error: "Usage: groundmail webhooks deliveries list|get|resend --webhook <webhook-id> [--id <delivery-id>]" };
2035
+ }
2036
+ const options = parseWebhooksCommonArgs(rest);
2037
+ const apiKey = resolveApiKey6(options, env);
2038
+ if (!apiKey) return { exitCode: 1, error: "Missing API key. Set GROUNDMAIL_API_KEY or pass --api-key." };
2039
+ const webhookId = readFlag13(rest, "--webhook");
2040
+ if (!webhookId) return { exitCode: 1, error: "Missing webhook id. Pass --webhook <webhook-id>." };
2041
+ const deliveryId = readFlag13(rest, "--id");
2042
+ if (action !== "list" && !deliveryId) return { exitCode: 1, error: "Missing delivery id. Pass --id <delivery-id>." };
2043
+ const params = action === "list" ? listParams(rest) : null;
2044
+ if (params && "error" in params) return { exitCode: 1, error: params.error };
2045
+ try {
2046
+ const { webhooks } = await createWebhooksClient(apiKey, options.baseUrl);
2047
+ const result = action === "list" ? await webhooks.deliveries.list(webhookId, params ?? {}) : action === "get" ? await webhooks.deliveries.get(webhookId, deliveryId) : await webhooks.deliveries.resend(webhookId, deliveryId);
2048
+ console.log(JSON.stringify(result));
2049
+ return { exitCode: 0 };
2050
+ } catch (error) {
2051
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
2052
+ }
2053
+ }
2054
+
2004
2055
  // src/commands/keys/list.ts
2005
2056
  function readFlag16(args, flag) {
2006
2057
  const index = args.indexOf(flag);
@@ -2055,7 +2106,7 @@ function trimUrl(value) {
2055
2106
  }
2056
2107
 
2057
2108
  // package.json
2058
- var version = "0.36.0";
2109
+ var version = "0.37.0";
2059
2110
 
2060
2111
  // src/user-agent.ts
2061
2112
  function buildUserAgent(own) {
@@ -4806,6 +4857,9 @@ var USAGE_LINES = [
4806
4857
  " groundmail webhooks get --id wh_\u2026",
4807
4858
  " groundmail webhooks update --id wh_\u2026 [--url \u2026] [--event email.sent] [--enabled true|false] [--tenants a,b|all]",
4808
4859
  " groundmail webhooks delete --id <webhook-id>",
4860
+ " groundmail webhooks deliveries list --webhook <webhook-id> [--status failed] [--event email.delivered] [--email-id msg_\u2026] [--q \u2026] [--test true|false] [--limit 25] [--cursor \u2026]",
4861
+ " groundmail webhooks deliveries get --webhook <webhook-id> --id <delivery-id>",
4862
+ " groundmail webhooks deliveries resend --webhook <webhook-id> --id <delivery-id>",
4809
4863
  " groundmail validate user@example.com Groundmail validation: verdict, reasons, typo suggestion (exit 2 when invalid)",
4810
4864
  " groundmail suppressions list [--tenant <tenant>]",
4811
4865
  " groundmail suppressions add --email user@example.com [--reason \u2026] [--tenant <tenant>]",
@@ -5083,6 +5137,11 @@ async function main() {
5083
5137
  }
5084
5138
  }
5085
5139
  if (command === "webhooks") {
5140
+ if (subcommand === "deliveries") {
5141
+ const result = await runDeliveriesCommand(rest);
5142
+ if (result.error) console.error(result.error);
5143
+ process.exit(result.exitCode);
5144
+ }
5086
5145
  if (subcommand === "list") {
5087
5146
  const result = await runListCommand5(rest);
5088
5147
  if (result.error) console.error(result.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
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.38.0"
41
+ "groundmail": "0.39.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",