shipmail-cli 0.6.2 → 0.6.3

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 +6 -2
  2. package/dist/cli.js +49 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -137,7 +137,11 @@ shipmail newsletter-assets register-url https://cdn.shipmail.to/newsletter-image
137
137
  # Manage webhooks
138
138
  shipmail webhooks create \
139
139
  --url https://example.com/shipmail/webhook \
140
- --events message.received,message.bounced
140
+ --events message.received,message.bounced \
141
+ --authorization "Bearer your-endpoint-key"
142
+ shipmail webhooks update whk_123 --clear-authorization
143
+ shipmail webhooks update whk_123 --standard-webhooks-secret "whsec_..."
144
+ shipmail webhooks update whk_123 --clear-standard-webhooks-secret
141
145
  shipmail webhooks deliveries whk_123 --status failed
142
146
  shipmail webhooks replay-delivery whk_123 dlv_123 --idempotency-key replay-123
143
147
  ```
@@ -173,7 +177,7 @@ Use repeatable `--header "Name: value"` flags for request headers. Use `--output
173
177
  - `messages send|list|analytics|get|reply` (test keys also support `--sandbox-outcome`)
174
178
  - `scheduled-messages list|get|update|cancel`
175
179
  - `mailboxes sandbox-inbound`
176
- - `webhooks list|create|test|deliveries|replay-delivery`
180
+ - `webhooks list|create|update|test|deliveries|replay-delivery`
177
181
  - `suppressions list|remove`
178
182
  - `audiences list|create|get|update|delete`
179
183
  - `audiences feed get|update|rotate|revoke`
package/dist/cli.js CHANGED
@@ -649,7 +649,7 @@ async function login(options) {
649
649
  }
650
650
 
651
651
  // src/version.ts
652
- var VERSION = "0.6.2";
652
+ var VERSION = "0.6.3";
653
653
 
654
654
  // src/cli.ts
655
655
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
@@ -1227,7 +1227,8 @@ Usage:
1227
1227
  shipmail reply-scans status <scan-id>
1228
1228
  shipmail reply-scans results <scan-id> [--limit 25] [--cursor cur]
1229
1229
  shipmail webhooks list
1230
- shipmail webhooks create --url https://example.com/hook --events message.received,message.bounced
1230
+ shipmail webhooks create --url https://example.com/hook --events message.received,message.bounced [--authorization "Bearer key"] [--standard-webhooks-secret whsec_...]
1231
+ shipmail webhooks update <webhook-id> [--url https://example.com/hook] [--events message.received] [--description text] [--active true|false] [--authorization "Bearer key" | --clear-authorization] [--standard-webhooks-secret whsec_... | --clear-standard-webhooks-secret]
1231
1232
  shipmail webhooks replay-delivery <webhook-id> <delivery-id> [--idempotency-key key]
1232
1233
  shipmail suppressions list
1233
1234
  shipmail suppressions remove <email>
@@ -1380,6 +1381,39 @@ function webhookEvents(options) {
1380
1381
  }
1381
1382
  return events;
1382
1383
  }
1384
+ function webhookWriteOnlyOption(options, name) {
1385
+ const value = optionValue(options, name);
1386
+ if (value === void 0) return void 0;
1387
+ if (typeof value === "boolean") throw new CliUsageError(`Missing value for --${name}.`);
1388
+ return getString(options, name);
1389
+ }
1390
+ function webhookWriteOnlyUpdate(options, name) {
1391
+ const value = webhookWriteOnlyOption(options, name);
1392
+ const clear = getBoolean(options, `clear-${name}`) === true;
1393
+ if (value !== void 0 && clear) {
1394
+ throw new CliUsageError(`Use --${name} or --clear-${name}, not both.`);
1395
+ }
1396
+ return clear ? null : value;
1397
+ }
1398
+ function webhookUpdateParams(options) {
1399
+ const authorization = webhookWriteOnlyUpdate(options, "authorization");
1400
+ const standardWebhooksSecret = webhookWriteOnlyUpdate(options, "standard-webhooks-secret");
1401
+ const url = getString(options, "url");
1402
+ const description = getString(options, "description");
1403
+ const active = getBoolean(options, "active");
1404
+ const params = {
1405
+ ...url !== void 0 ? { url } : {},
1406
+ ...optionValue(options, "events") !== void 0 ? { events: webhookEvents(options) } : {},
1407
+ ...description !== void 0 ? { description } : {},
1408
+ ...active !== void 0 ? { active } : {},
1409
+ ...authorization !== void 0 ? { authorization } : {},
1410
+ ...standardWebhooksSecret !== void 0 ? { standard_webhooks_secret: standardWebhooksSecret } : {}
1411
+ };
1412
+ if (Object.keys(params).length === 0) {
1413
+ throw new CliUsageError("Nothing to update. Pass at least one webhook option.");
1414
+ }
1415
+ return params;
1416
+ }
1383
1417
  function webhookDeliveryParams(options) {
1384
1418
  const status = getString(options, "status");
1385
1419
  const eventType = getString(options, "event-type");
@@ -2170,16 +2204,28 @@ async function runWebhooks(client, parsed, out) {
2170
2204
  }
2171
2205
  if (subcommand === "create") {
2172
2206
  const description = getString(parsed.options, "description");
2207
+ const authorization = webhookWriteOnlyOption(parsed.options, "authorization");
2208
+ const standardWebhooksSecret = webhookWriteOnlyOption(
2209
+ parsed.options,
2210
+ "standard-webhooks-secret"
2211
+ );
2173
2212
  writeJson(
2174
2213
  out,
2175
2214
  await client.webhooks.create({
2176
2215
  url: getRequiredString(parsed.options, "url"),
2177
2216
  events: webhookEvents(parsed.options),
2178
- ...description ? { description } : {}
2217
+ ...description ? { description } : {},
2218
+ ...authorization !== void 0 ? { authorization } : {},
2219
+ ...standardWebhooksSecret !== void 0 ? { standard_webhooks_secret: standardWebhooksSecret } : {}
2179
2220
  })
2180
2221
  );
2181
2222
  return;
2182
2223
  }
2224
+ if (subcommand === "update") {
2225
+ const webhookId = requirePositional(parsed.positional, 2, "webhook id");
2226
+ writeJson(out, await client.webhooks.update(webhookId, webhookUpdateParams(parsed.options)));
2227
+ return;
2228
+ }
2183
2229
  if (subcommand === "test") {
2184
2230
  writeJson(
2185
2231
  out,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shipmail-cli",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
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.6.3",
44
+ "shipmail": "0.6.4",
45
45
  "zod": "^4.6.5"
46
46
  },
47
47
  "devDependencies": {