autark-cli 0.3.1 → 0.4.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 (2) hide show
  1. package/autark.mjs +37 -2
  2. package/package.json +1 -1
package/autark.mjs CHANGED
@@ -856,10 +856,35 @@ async function mail(command, rest) {
856
856
  if (command === 'raw') return mailRaw(rest)
857
857
  if (command === 'attachment') return mailAttachment(rest)
858
858
  if (command === 'request') return mailRequest(rest)
859
+ if (command === 'suppress') return mailSuppress(rest)
860
+ if (command === 'unsuppress') return mailUnsuppress(rest)
861
+ if (command === 'suppressed') return mailSuppressed(rest)
859
862
  mailUsage()
860
863
  process.exit(1)
861
864
  }
862
865
 
866
+ async function mailSuppress(rest) {
867
+ const opts = parseArgs(rest)
868
+ const entry = required(opts.email || opts._[0], 'email')
869
+ const reason = opts.reason || 'manual'
870
+ const result = await api('POST', '/v1/suppression', { entry, reason })
871
+ printJson(result)
872
+ }
873
+
874
+ async function mailUnsuppress(rest) {
875
+ const opts = parseArgs(rest)
876
+ const entry = required(opts.email || opts._[0], 'email')
877
+ const result = await api('DELETE', `/v1/suppression/${encodeURIComponent(entry)}`)
878
+ printJson(result)
879
+ }
880
+
881
+ async function mailSuppressed(rest) {
882
+ const opts = parseArgs(rest)
883
+ const limit = opts.limit ? Number(opts.limit) : 100
884
+ const result = await api('GET', `/v1/suppression?limit=${limit}`)
885
+ printJson(result)
886
+ }
887
+
863
888
  async function mailSetup(rest) {
864
889
  const opts = parseArgs(rest)
865
890
  const existing = loadCredentials() || {}
@@ -891,6 +916,11 @@ async function mailSend(rest) {
891
916
  rejectUnsendableAddress(to)
892
917
  const subject = opts.subject || ''
893
918
  const body = mailBody(opts, { to, subject })
919
+ const dryRun = opts['dry-run'] === true || opts.dry_run === true
920
+ if (dryRun) {
921
+ printJson({ dry_run: true, would_send: { inbox: creds.inboxId, to, subject, body } })
922
+ return
923
+ }
894
924
  const result = await agentmailRequest('POST', `/inboxes/${encodeURIComponent(creds.inboxId)}/messages/send`, body)
895
925
  const action = await maybeLogMailAction(opts, {
896
926
  kind: 'send',
@@ -1299,7 +1329,7 @@ function mailUsage() {
1299
1329
  console.log(`autark mail
1300
1330
 
1301
1331
  setup --prefix <name> [--force]
1302
- send --to <email[,email]> --subject <s> --text @body.txt [--run-id <id>]
1332
+ send --to <email[,email]> --subject <s> --text @body.txt [--run-id <id>] [--dry-run]
1303
1333
  reply --message-id <id> --text @reply.txt [--run-id <id>]
1304
1334
  reply-all --message-id <id> --text @reply.txt [--run-id <id>]
1305
1335
  forward --message-id <id> --to <email> [--text @body.txt] [--run-id <id>]
@@ -1310,8 +1340,13 @@ function mailUsage() {
1310
1340
  raw <message_id>
1311
1341
  attachment --message-id <id> --attachment-id <id> [--out file]
1312
1342
  request <METHOD> <path> [--body @json] [--raw]
1343
+ suppress <email> [--reason "<text>"] add to org-wide send-block list
1344
+ unsuppress <email> remove from send-block list
1345
+ suppressed [--limit N] list blocked addresses
1313
1346
 
1314
- Mail uses the inbox-scoped token in ~/.autark/credentials.json.`)
1347
+ Mail uses the inbox-scoped token in ~/.autark/credentials.json. Suppression
1348
+ verbs proxy through the autark worker (org-scoped). --dry-run prints the
1349
+ payload without hitting SES.`)
1315
1350
  }
1316
1351
 
1317
1352
  function usage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autark-cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "CLI for autark \u2014 hypothesis-driven product runbooks. Track products, hypotheses, runs, and actions from the terminal.",
5
5
  "type": "module",
6
6
  "license": "MIT",