resend-cli 1.2.1 → 1.3.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 (357) hide show
  1. package/README.md +25 -10
  2. package/dist/cli.cjs +539 -0
  3. package/package.json +31 -13
  4. package/.claude/settings.local.json +0 -5
  5. package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
  6. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
  7. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
  8. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
  9. package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
  10. package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
  11. package/.claude/worktrees/emails-list/LICENSE +0 -21
  12. package/.claude/worktrees/emails-list/README.md +0 -424
  13. package/.claude/worktrees/emails-list/biome.json +0 -36
  14. package/.claude/worktrees/emails-list/bun.lock +0 -76
  15. package/.claude/worktrees/emails-list/bunfig.toml +0 -2
  16. package/.claude/worktrees/emails-list/install.ps1 +0 -140
  17. package/.claude/worktrees/emails-list/install.sh +0 -301
  18. package/.claude/worktrees/emails-list/package.json +0 -43
  19. package/.claude/worktrees/emails-list/renovate.json +0 -6
  20. package/.claude/worktrees/emails-list/src/cli.ts +0 -74
  21. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
  22. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
  23. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
  24. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
  25. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
  26. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
  27. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
  28. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
  29. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
  30. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
  31. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
  32. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
  33. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
  34. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
  35. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
  36. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
  37. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
  38. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
  39. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
  40. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
  41. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
  42. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
  43. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
  44. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
  45. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
  46. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
  47. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
  48. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
  49. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
  50. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
  51. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
  52. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
  53. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
  54. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
  55. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
  56. package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
  57. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
  58. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
  59. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
  60. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
  61. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
  62. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
  63. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
  64. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
  65. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
  66. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
  67. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
  68. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
  69. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
  70. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
  71. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
  72. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
  73. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
  74. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
  75. package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
  76. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
  77. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
  78. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
  79. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
  80. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
  81. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
  82. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
  83. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
  84. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
  85. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
  86. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
  87. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
  88. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
  89. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
  90. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
  91. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
  92. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
  93. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
  94. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
  95. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
  96. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
  97. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
  98. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
  99. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
  100. package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
  101. package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
  102. package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
  103. package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
  104. package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
  105. package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
  106. package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
  107. package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
  108. package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
  109. package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
  110. package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
  111. package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
  112. package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
  113. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
  114. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
  115. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
  116. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
  117. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
  118. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
  119. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
  120. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
  121. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
  122. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
  123. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
  124. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
  125. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
  126. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
  127. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
  128. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
  129. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
  130. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
  131. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
  132. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
  133. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
  134. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
  135. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
  136. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
  137. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
  138. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
  139. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
  140. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
  141. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
  142. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
  143. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
  144. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
  145. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
  146. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
  147. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
  148. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
  149. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
  150. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
  151. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
  152. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
  153. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
  154. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
  155. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
  156. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
  157. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
  158. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
  159. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
  160. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
  161. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
  162. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
  163. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
  164. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
  165. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
  166. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
  167. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
  168. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
  169. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
  170. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
  171. package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
  172. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
  173. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
  174. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
  175. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
  176. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
  177. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
  178. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
  179. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
  180. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
  181. package/.claude/worktrees/emails-list/tsconfig.json +0 -14
  182. package/.github/scripts/pr-title-check.js +0 -34
  183. package/.github/workflows/ci.yml +0 -32
  184. package/.github/workflows/pr-title-check.yml +0 -13
  185. package/.github/workflows/release.yml +0 -120
  186. package/.github/workflows/test-install-windows.yml +0 -48
  187. package/CHANGELOG.md +0 -31
  188. package/biome.json +0 -36
  189. package/bun.lock +0 -76
  190. package/bunfig.toml +0 -2
  191. package/docs/agent-dx-gaps.md +0 -167
  192. package/docs/missing-commands.md +0 -58
  193. package/docs/production-readiness.md +0 -99
  194. package/docs/secure-key-storage.md +0 -174
  195. package/install.ps1 +0 -141
  196. package/install.sh +0 -301
  197. package/renovate.json +0 -4
  198. package/src/cli.ts +0 -82
  199. package/src/commands/api-keys/create.ts +0 -114
  200. package/src/commands/api-keys/delete.ts +0 -47
  201. package/src/commands/api-keys/index.ts +0 -26
  202. package/src/commands/api-keys/list.ts +0 -35
  203. package/src/commands/api-keys/utils.ts +0 -8
  204. package/src/commands/auth/index.ts +0 -20
  205. package/src/commands/auth/login.ts +0 -207
  206. package/src/commands/auth/logout.ts +0 -105
  207. package/src/commands/broadcasts/create.ts +0 -196
  208. package/src/commands/broadcasts/delete.ts +0 -46
  209. package/src/commands/broadcasts/get.ts +0 -59
  210. package/src/commands/broadcasts/index.ts +0 -43
  211. package/src/commands/broadcasts/list.ts +0 -60
  212. package/src/commands/broadcasts/send.ts +0 -56
  213. package/src/commands/broadcasts/update.ts +0 -95
  214. package/src/commands/broadcasts/utils.ts +0 -35
  215. package/src/commands/contact-properties/create.ts +0 -118
  216. package/src/commands/contact-properties/delete.ts +0 -48
  217. package/src/commands/contact-properties/get.ts +0 -46
  218. package/src/commands/contact-properties/index.ts +0 -48
  219. package/src/commands/contact-properties/list.ts +0 -68
  220. package/src/commands/contact-properties/update.ts +0 -88
  221. package/src/commands/contact-properties/utils.ts +0 -17
  222. package/src/commands/contacts/add-segment.ts +0 -78
  223. package/src/commands/contacts/create.ts +0 -122
  224. package/src/commands/contacts/delete.ts +0 -49
  225. package/src/commands/contacts/get.ts +0 -53
  226. package/src/commands/contacts/index.ts +0 -58
  227. package/src/commands/contacts/list.ts +0 -57
  228. package/src/commands/contacts/remove-segment.ts +0 -48
  229. package/src/commands/contacts/segments.ts +0 -39
  230. package/src/commands/contacts/topics.ts +0 -45
  231. package/src/commands/contacts/update-topics.ts +0 -90
  232. package/src/commands/contacts/update.ts +0 -77
  233. package/src/commands/contacts/utils.ts +0 -119
  234. package/src/commands/doctor.ts +0 -298
  235. package/src/commands/domains/create.ts +0 -83
  236. package/src/commands/domains/delete.ts +0 -42
  237. package/src/commands/domains/get.ts +0 -47
  238. package/src/commands/domains/index.ts +0 -35
  239. package/src/commands/domains/list.ts +0 -53
  240. package/src/commands/domains/update.ts +0 -75
  241. package/src/commands/domains/utils.ts +0 -44
  242. package/src/commands/domains/verify.ts +0 -38
  243. package/src/commands/emails/batch.ts +0 -140
  244. package/src/commands/emails/index.ts +0 -24
  245. package/src/commands/emails/receiving/attachment.ts +0 -55
  246. package/src/commands/emails/receiving/attachments.ts +0 -68
  247. package/src/commands/emails/receiving/get.ts +0 -58
  248. package/src/commands/emails/receiving/index.ts +0 -28
  249. package/src/commands/emails/receiving/list.ts +0 -59
  250. package/src/commands/emails/receiving/utils.ts +0 -38
  251. package/src/commands/emails/send.ts +0 -189
  252. package/src/commands/open.ts +0 -24
  253. package/src/commands/segments/create.ts +0 -50
  254. package/src/commands/segments/delete.ts +0 -47
  255. package/src/commands/segments/get.ts +0 -38
  256. package/src/commands/segments/index.ts +0 -36
  257. package/src/commands/segments/list.ts +0 -58
  258. package/src/commands/segments/utils.ts +0 -7
  259. package/src/commands/teams/index.ts +0 -10
  260. package/src/commands/teams/list.ts +0 -35
  261. package/src/commands/teams/remove.ts +0 -83
  262. package/src/commands/teams/switch.ts +0 -73
  263. package/src/commands/topics/create.ts +0 -73
  264. package/src/commands/topics/delete.ts +0 -47
  265. package/src/commands/topics/get.ts +0 -42
  266. package/src/commands/topics/index.ts +0 -42
  267. package/src/commands/topics/list.ts +0 -34
  268. package/src/commands/topics/update.ts +0 -59
  269. package/src/commands/topics/utils.ts +0 -16
  270. package/src/commands/webhooks/create.ts +0 -128
  271. package/src/commands/webhooks/delete.ts +0 -49
  272. package/src/commands/webhooks/get.ts +0 -42
  273. package/src/commands/webhooks/index.ts +0 -44
  274. package/src/commands/webhooks/list.ts +0 -55
  275. package/src/commands/webhooks/update.ts +0 -83
  276. package/src/commands/webhooks/utils.ts +0 -36
  277. package/src/commands/whoami.ts +0 -71
  278. package/src/lib/actions.ts +0 -157
  279. package/src/lib/client.ts +0 -37
  280. package/src/lib/config.ts +0 -211
  281. package/src/lib/files.ts +0 -15
  282. package/src/lib/help-text.ts +0 -38
  283. package/src/lib/output.ts +0 -54
  284. package/src/lib/pagination.ts +0 -36
  285. package/src/lib/prompts.ts +0 -149
  286. package/src/lib/spinner.ts +0 -93
  287. package/src/lib/table.ts +0 -57
  288. package/src/lib/tty.ts +0 -28
  289. package/src/lib/version.ts +0 -4
  290. package/tests/commands/api-keys/create.test.ts +0 -195
  291. package/tests/commands/api-keys/delete.test.ts +0 -156
  292. package/tests/commands/api-keys/list.test.ts +0 -133
  293. package/tests/commands/auth/login.test.ts +0 -119
  294. package/tests/commands/auth/logout.test.ts +0 -146
  295. package/tests/commands/broadcasts/create.test.ts +0 -447
  296. package/tests/commands/broadcasts/delete.test.ts +0 -182
  297. package/tests/commands/broadcasts/get.test.ts +0 -146
  298. package/tests/commands/broadcasts/list.test.ts +0 -196
  299. package/tests/commands/broadcasts/send.test.ts +0 -161
  300. package/tests/commands/broadcasts/update.test.ts +0 -283
  301. package/tests/commands/contact-properties/create.test.ts +0 -250
  302. package/tests/commands/contact-properties/delete.test.ts +0 -183
  303. package/tests/commands/contact-properties/get.test.ts +0 -144
  304. package/tests/commands/contact-properties/list.test.ts +0 -180
  305. package/tests/commands/contact-properties/update.test.ts +0 -216
  306. package/tests/commands/contacts/add-segment.test.ts +0 -188
  307. package/tests/commands/contacts/create.test.ts +0 -270
  308. package/tests/commands/contacts/delete.test.ts +0 -192
  309. package/tests/commands/contacts/get.test.ts +0 -148
  310. package/tests/commands/contacts/list.test.ts +0 -175
  311. package/tests/commands/contacts/remove-segment.test.ts +0 -166
  312. package/tests/commands/contacts/segments.test.ts +0 -167
  313. package/tests/commands/contacts/topics.test.ts +0 -163
  314. package/tests/commands/contacts/update-topics.test.ts +0 -247
  315. package/tests/commands/contacts/update.test.ts +0 -205
  316. package/tests/commands/doctor.test.ts +0 -165
  317. package/tests/commands/domains/create.test.ts +0 -192
  318. package/tests/commands/domains/delete.test.ts +0 -156
  319. package/tests/commands/domains/get.test.ts +0 -137
  320. package/tests/commands/domains/list.test.ts +0 -164
  321. package/tests/commands/domains/update.test.ts +0 -223
  322. package/tests/commands/domains/verify.test.ts +0 -117
  323. package/tests/commands/emails/batch.test.ts +0 -313
  324. package/tests/commands/emails/receiving/attachment.test.ts +0 -140
  325. package/tests/commands/emails/receiving/attachments.test.ts +0 -168
  326. package/tests/commands/emails/receiving/get.test.ts +0 -140
  327. package/tests/commands/emails/receiving/list.test.ts +0 -181
  328. package/tests/commands/emails/send.test.ts +0 -309
  329. package/tests/commands/segments/create.test.ts +0 -163
  330. package/tests/commands/segments/delete.test.ts +0 -182
  331. package/tests/commands/segments/get.test.ts +0 -137
  332. package/tests/commands/segments/list.test.ts +0 -173
  333. package/tests/commands/teams/list.test.ts +0 -63
  334. package/tests/commands/teams/remove.test.ts +0 -103
  335. package/tests/commands/teams/switch.test.ts +0 -96
  336. package/tests/commands/topics/create.test.ts +0 -191
  337. package/tests/commands/topics/delete.test.ts +0 -156
  338. package/tests/commands/topics/get.test.ts +0 -125
  339. package/tests/commands/topics/list.test.ts +0 -124
  340. package/tests/commands/topics/update.test.ts +0 -177
  341. package/tests/commands/webhooks/create.test.ts +0 -224
  342. package/tests/commands/webhooks/delete.test.ts +0 -156
  343. package/tests/commands/webhooks/get.test.ts +0 -125
  344. package/tests/commands/webhooks/list.test.ts +0 -177
  345. package/tests/commands/webhooks/update.test.ts +0 -206
  346. package/tests/commands/whoami.test.ts +0 -99
  347. package/tests/helpers.ts +0 -93
  348. package/tests/lib/client.test.ts +0 -71
  349. package/tests/lib/config.test.ts +0 -414
  350. package/tests/lib/files.test.ts +0 -65
  351. package/tests/lib/help-text.test.ts +0 -97
  352. package/tests/lib/output.test.ts +0 -127
  353. package/tests/lib/prompts.test.ts +0 -178
  354. package/tests/lib/spinner.test.ts +0 -146
  355. package/tests/lib/table.test.ts +0 -63
  356. package/tests/lib/tty.test.ts +0 -85
  357. package/tsconfig.json +0 -14
@@ -1,49 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runDelete } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const deleteContactCommand = new Command('delete')
7
- .alias('rm')
8
- .description('Delete a contact')
9
- .argument(
10
- '<id>',
11
- 'Contact UUID or email address — both are accepted by the API',
12
- )
13
- .option(
14
- '--yes',
15
- 'Skip the confirmation prompt (required in non-interactive mode)',
16
- )
17
- .addHelpText(
18
- 'after',
19
- buildHelpText({
20
- context: `The <id> argument accepts either a UUID or an email address.
21
-
22
- Non-interactive: --yes is required to confirm deletion when stdin/stdout is not a TTY.`,
23
- output: ` {"object":"contact","id":"<id>","deleted":true}`,
24
- errorCodes: ['auth_error', 'confirmation_required', 'delete_error'],
25
- examples: [
26
- 'resend contacts delete 479e3145-dd38-4932-8c0c-e58b548c9e76 --yes',
27
- 'resend contacts delete user@example.com --yes --json',
28
- ],
29
- }),
30
- )
31
- .action(async (id, opts, cmd) => {
32
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
33
- await runDelete(
34
- id,
35
- !!opts.yes,
36
- {
37
- confirmMessage: `Delete contact ${id}?\nThis cannot be undone.`,
38
- spinner: {
39
- loading: 'Deleting contact...',
40
- success: 'Contact deleted',
41
- fail: 'Failed to delete contact',
42
- },
43
- object: 'contact',
44
- successMsg: 'Contact deleted.',
45
- sdkCall: (resend) => resend.contacts.remove(id),
46
- },
47
- globalOpts,
48
- );
49
- });
@@ -1,53 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runGet } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const getContactCommand = new Command('get')
7
- .description('Retrieve a contact by ID or email address')
8
- .argument(
9
- '<id>',
10
- 'Contact UUID or email address — both are accepted by the API',
11
- )
12
- .addHelpText(
13
- 'after',
14
- buildHelpText({
15
- output: ` {\n "object": "contact",\n "id": "<uuid>",\n "email": "user@example.com",\n "first_name": "Jane",\n "last_name": "Smith",\n "created_at": "2026-01-01T00:00:00.000Z",\n "unsubscribed": false,\n "properties": {}\n }`,
16
- errorCodes: ['auth_error', 'fetch_error'],
17
- examples: [
18
- 'resend contacts get 479e3145-dd38-4932-8c0c-e58b548c9e76',
19
- 'resend contacts get user@example.com',
20
- 'resend contacts get 479e3145-dd38-4932-8c0c-e58b548c9e76 --json',
21
- ],
22
- }),
23
- )
24
- .action(async (id, _opts, cmd) => {
25
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
26
- await runGet(
27
- {
28
- spinner: {
29
- loading: 'Fetching contact...',
30
- success: 'Contact fetched',
31
- fail: 'Failed to fetch contact',
32
- },
33
- sdkCall: (resend) => resend.contacts.get(id),
34
- onInteractive: (data) => {
35
- const name = [data.first_name, data.last_name]
36
- .filter(Boolean)
37
- .join(' ');
38
- console.log(`\n${data.email}${name ? ` (${name})` : ''}`);
39
- console.log(`ID: ${data.id}`);
40
- console.log(`Created: ${data.created_at}`);
41
- console.log(`Unsubscribed: ${data.unsubscribed ? 'yes' : 'no'}`);
42
- const propEntries = Object.entries(data.properties ?? {});
43
- if (propEntries.length > 0) {
44
- console.log('Properties:');
45
- for (const [key, val] of propEntries) {
46
- console.log(` ${key}: ${val.value}`);
47
- }
48
- }
49
- },
50
- },
51
- globalOpts,
52
- );
53
- });
@@ -1,58 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { addContactSegmentCommand } from './add-segment';
4
- import { createContactCommand } from './create';
5
- import { deleteContactCommand } from './delete';
6
- import { getContactCommand } from './get';
7
- import { listContactsCommand } from './list';
8
- import { removeContactSegmentCommand } from './remove-segment';
9
- import { listContactSegmentsCommand } from './segments';
10
- import { listContactTopicsCommand } from './topics';
11
- import { updateContactCommand } from './update';
12
- import { updateContactTopicsCommand } from './update-topics';
13
-
14
- export const contactsCommand = new Command('contacts')
15
- .description('Manage contacts — the global list of people you send email to')
16
- .addHelpText(
17
- 'after',
18
- buildHelpText({
19
- context: `Contacts are global entities (not audience-scoped since the 2025 migration).
20
- Each contact is identified by a UUID or email address — both are accepted in all subcommands.
21
-
22
- Properties:
23
- Contacts carry custom key-value properties (e.g. plan, company) accessible in broadcast templates
24
- via {{{PROPERTY_NAME|fallback}}} triple-brace interpolation.
25
- firstName/lastName are convenience aliases stored as FIRST_NAME/LAST_NAME properties.
26
-
27
- Subscription:
28
- --unsubscribed is a team-wide opt-out from all broadcasts.
29
- Fine-grained control is available via topic subscriptions (see "resend contacts topics").
30
-
31
- Segments:
32
- Contacts can belong to multiple segments. Segments determine which contacts receive a broadcast.
33
- Manage membership with "resend contacts add-segment" and "resend contacts remove-segment".`,
34
- examples: [
35
- 'resend contacts list',
36
- 'resend contacts create --email jane@example.com --first-name Jane',
37
- 'resend contacts get 479e3145-dd38-4932-8c0c-e58b548c9e76',
38
- 'resend contacts get user@example.com',
39
- 'resend contacts update user@example.com --unsubscribed',
40
- 'resend contacts delete 479e3145-dd38-4932-8c0c-e58b548c9e76 --yes',
41
- 'resend contacts segments user@example.com',
42
- 'resend contacts add-segment user@example.com --segment-id 7b1e0a3d-4c5f-4e8a-9b2d-1a3c5e7f9b2d',
43
- 'resend contacts remove-segment user@example.com 7b1e0a3d-4c5f-4e8a-9b2d-1a3c5e7f9b2d',
44
- 'resend contacts topics user@example.com',
45
- `resend contacts update-topics user@example.com --topics '[{"id":"topic-uuid","subscription":"opt_in"}]'`,
46
- ],
47
- }),
48
- )
49
- .addCommand(createContactCommand)
50
- .addCommand(getContactCommand)
51
- .addCommand(listContactsCommand, { isDefault: true })
52
- .addCommand(updateContactCommand)
53
- .addCommand(deleteContactCommand)
54
- .addCommand(listContactSegmentsCommand)
55
- .addCommand(addContactSegmentCommand)
56
- .addCommand(removeContactSegmentCommand)
57
- .addCommand(listContactTopicsCommand)
58
- .addCommand(updateContactTopicsCommand);
@@ -1,57 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runList } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import {
6
- buildPaginationOpts,
7
- parseLimitOpt,
8
- printPaginationHint,
9
- } from '../../lib/pagination';
10
- import { renderContactsTable } from './utils';
11
-
12
- export const listContactsCommand = new Command('list')
13
- .alias('ls')
14
- .description('List all contacts')
15
- .option('--limit <n>', 'Maximum number of contacts to return (1-100)', '10')
16
- .option('--after <cursor>', 'Return contacts after this cursor (next page)')
17
- .option(
18
- '--before <cursor>',
19
- 'Return contacts before this cursor (previous page)',
20
- )
21
- .addHelpText(
22
- 'after',
23
- buildHelpText({
24
- context: `Contacts are global — they are not scoped to audiences or segments since the 2025 migration.
25
-
26
- Pagination: use --after or --before with a contact ID as the cursor.
27
- Only one of --after or --before may be used at a time.
28
- The response includes has_more: true when additional pages exist.`,
29
- output: ` {"object":"list","data":[{"id":"...","email":"...","first_name":"...","last_name":"...","unsubscribed":false}],"has_more":false}`,
30
- errorCodes: ['auth_error', 'invalid_limit', 'list_error'],
31
- examples: [
32
- 'resend contacts list',
33
- 'resend contacts list --limit 25 --json',
34
- 'resend contacts list --after 479e3145-dd38-4932-8c0c-e58b548c9e76 --json',
35
- ],
36
- }),
37
- )
38
- .action(async (opts, cmd) => {
39
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
40
- const limit = parseLimitOpt(opts.limit, globalOpts);
41
- const paginationOpts = buildPaginationOpts(limit, opts.after, opts.before);
42
- await runList(
43
- {
44
- spinner: {
45
- loading: 'Fetching contacts...',
46
- success: 'Contacts fetched',
47
- fail: 'Failed to list contacts',
48
- },
49
- sdkCall: (resend) => resend.contacts.list(paginationOpts),
50
- onInteractive: (list) => {
51
- console.log(renderContactsTable(list.data));
52
- printPaginationHint(list);
53
- },
54
- },
55
- globalOpts,
56
- );
57
- });
@@ -1,48 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import type { RemoveContactSegmentOptions } from 'resend';
3
- import { runWrite } from '../../lib/actions';
4
- import type { GlobalOpts } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { segmentContactIdentifier } from './utils';
7
-
8
- export const removeContactSegmentCommand = new Command('remove-segment')
9
- .description('Remove a contact from a segment')
10
- .argument('<contactId>', 'Contact UUID or email address')
11
- .argument('<segmentId>', 'Segment ID to remove the contact from')
12
- .addHelpText(
13
- 'after',
14
- buildHelpText({
15
- context: `The <contactId> argument accepts either a UUID or an email address.
16
- The <segmentId> argument must be a segment UUID (not an email).`,
17
- output: ` {"id":"<segment-id>","deleted":true}`,
18
- errorCodes: ['auth_error', 'remove_segment_error'],
19
- examples: [
20
- 'resend contacts remove-segment 479e3145-dd38-4932-8c0c-e58b548c9e76 7b1e0a3d-4c5f-4e8a-9b2d-1a3c5e7f9b2d',
21
- 'resend contacts remove-segment user@example.com 7b1e0a3d-4c5f-4e8a-9b2d-1a3c5e7f9b2d --json',
22
- ],
23
- }),
24
- )
25
- .action(async (contactId, segmentId, _opts, cmd) => {
26
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
27
-
28
- // segmentContactIdentifier resolves UUID vs email for the ContactSegmentsBaseOptions
29
- // discriminated union. The spread of that union requires an explicit cast.
30
- const payload = {
31
- ...segmentContactIdentifier(contactId),
32
- segmentId,
33
- } as RemoveContactSegmentOptions;
34
-
35
- await runWrite(
36
- {
37
- spinner: {
38
- loading: 'Removing contact from segment...',
39
- success: 'Contact removed from segment',
40
- fail: 'Failed to remove contact from segment',
41
- },
42
- sdkCall: (resend) => resend.contacts.segments.remove(payload),
43
- errorCode: 'remove_segment_error',
44
- successMsg: `Contact removed from segment: ${segmentId}`,
45
- },
46
- globalOpts,
47
- );
48
- });
@@ -1,39 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runList } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { renderSegmentsTable } from '../segments/utils';
6
- import { segmentContactIdentifier } from './utils';
7
-
8
- export const listContactSegmentsCommand = new Command('segments')
9
- .description('List the segments a contact belongs to')
10
- .argument('<id>', 'Contact UUID or email address')
11
- .addHelpText(
12
- 'after',
13
- buildHelpText({
14
- context: `The <id> argument accepts either a UUID or an email address.`,
15
- output: ` {"object":"list","data":[{"id":"<segment-uuid>","name":"Newsletter Subscribers","created_at":"..."}],"has_more":false}`,
16
- errorCodes: ['auth_error', 'list_error'],
17
- examples: [
18
- 'resend contacts segments 479e3145-dd38-4932-8c0c-e58b548c9e76',
19
- 'resend contacts segments user@example.com',
20
- 'resend contacts segments 479e3145-dd38-4932-8c0c-e58b548c9e76 --json',
21
- ],
22
- }),
23
- )
24
- .action(async (id, _opts, cmd) => {
25
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
26
- await runList(
27
- {
28
- spinner: {
29
- loading: 'Fetching segments...',
30
- success: 'Segments fetched',
31
- fail: 'Failed to list segments',
32
- },
33
- sdkCall: (resend) =>
34
- resend.contacts.segments.list(segmentContactIdentifier(id)),
35
- onInteractive: (list) => console.log(renderSegmentsTable(list.data)),
36
- },
37
- globalOpts,
38
- );
39
- });
@@ -1,45 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runList } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { contactIdentifier, renderContactTopicsTable } from './utils';
6
-
7
- export const listContactTopicsCommand = new Command('topics')
8
- .description("List a contact's topic subscriptions")
9
- .argument('<id>', 'Contact UUID or email address')
10
- .addHelpText(
11
- 'after',
12
- buildHelpText({
13
- context: `The <id> argument accepts either a UUID or an email address.
14
-
15
- Topics control which broadcast email types a contact receives.
16
- subscription values: "opt_in" (receiving) | "opt_out" (not receiving)
17
-
18
- Use "resend contacts update-topics <id>" to change subscription statuses.`,
19
- output: ` {"object":"list","data":[{"id":"...","name":"Product Updates","description":"...","subscription":"opt_in"}],"has_more":false}`,
20
- errorCodes: ['auth_error', 'list_error'],
21
- examples: [
22
- 'resend contacts topics 479e3145-dd38-4932-8c0c-e58b548c9e76',
23
- 'resend contacts topics user@example.com',
24
- 'resend contacts topics 479e3145-dd38-4932-8c0c-e58b548c9e76 --json',
25
- ],
26
- }),
27
- )
28
- .action(async (id, _opts, cmd) => {
29
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
30
- // ListContactTopicsBaseOptions uses optional { id?, email? } (not a discriminated
31
- // union), so contactIdentifier's result is directly assignable without a cast.
32
- await runList(
33
- {
34
- spinner: {
35
- loading: 'Fetching topic subscriptions...',
36
- success: 'Topic subscriptions fetched',
37
- fail: 'Failed to list topic subscriptions',
38
- },
39
- sdkCall: (resend) => resend.contacts.topics.list(contactIdentifier(id)),
40
- onInteractive: (list) =>
41
- console.log(renderContactTopicsTable(list.data)),
42
- },
43
- globalOpts,
44
- );
45
- });
@@ -1,90 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import { Command } from '@commander-js/extra-typings';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { requireClient } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { outputError, outputResult } from '../../lib/output';
7
- import { cancelAndExit } from '../../lib/prompts';
8
- import { withSpinner } from '../../lib/spinner';
9
- import { isInteractive } from '../../lib/tty';
10
- import { contactIdentifier, parseTopicsJson } from './utils';
11
-
12
- export const updateContactTopicsCommand = new Command('update-topics')
13
- .description("Update a contact's topic subscription statuses")
14
- .argument('<id>', 'Contact UUID or email address')
15
- .option(
16
- '--topics <json>',
17
- 'JSON array of topic subscriptions (required) — e.g. \'[{"id":"topic-uuid","subscription":"opt_in"}]\'',
18
- )
19
- .addHelpText(
20
- 'after',
21
- buildHelpText({
22
- context: `The <id> argument accepts either a UUID or an email address.
23
-
24
- Non-interactive: --topics is required.
25
-
26
- Topics JSON format:
27
- '[{"id":"<topic-uuid>","subscription":"opt_in"}]'
28
- subscription values: "opt_in" | "opt_out"
29
-
30
- This operation replaces all topic subscriptions for the specified topics.
31
- Topics not included in the array are left unchanged.`,
32
- output: ` {"id":"<contact-id>"}`,
33
- errorCodes: [
34
- 'auth_error',
35
- 'missing_topics',
36
- 'invalid_topics',
37
- 'update_topics_error',
38
- ],
39
- examples: [
40
- `resend contacts update-topics 479e3145-dd38-4932-8c0c-e58b548c9e76 --topics '[{"id":"topic-uuid","subscription":"opt_in"}]'`,
41
- `resend contacts update-topics user@example.com --topics '[{"id":"t1","subscription":"opt_out"},{"id":"t2","subscription":"opt_in"}]' --json`,
42
- ],
43
- }),
44
- )
45
- .action(async (id, opts, cmd) => {
46
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
47
- const resend = requireClient(globalOpts);
48
-
49
- let topicsJson = opts.topics;
50
-
51
- if (!topicsJson) {
52
- if (!isInteractive()) {
53
- outputError(
54
- { message: 'Missing --topics flag.', code: 'missing_topics' },
55
- { json: globalOpts.json },
56
- );
57
- }
58
- const result = await p.text({
59
- message:
60
- 'Topics JSON (e.g. \'[{"id":"topic-uuid","subscription":"opt_in"}]\')',
61
- placeholder: '[{"id":"topic-uuid","subscription":"opt_in"}]',
62
- validate: (v) => (!v ? 'Required' : undefined),
63
- });
64
- if (p.isCancel(result)) {
65
- cancelAndExit('Cancelled.');
66
- }
67
- topicsJson = result;
68
- }
69
-
70
- const topics = parseTopicsJson(topicsJson, globalOpts);
71
-
72
- // contactIdentifier's result is directly assignable: UpdateContactTopicsBaseOptions
73
- // uses optional { id?, email? } (not a discriminated union).
74
- const data = await withSpinner(
75
- {
76
- loading: 'Updating topic subscriptions...',
77
- success: 'Topic subscriptions updated',
78
- fail: 'Failed to update topic subscriptions',
79
- },
80
- () => resend.contacts.topics.update({ ...contactIdentifier(id), topics }),
81
- 'update_topics_error',
82
- globalOpts,
83
- );
84
-
85
- if (!globalOpts.json && isInteractive()) {
86
- console.log(`Topic subscriptions updated for contact: ${id}`);
87
- } else {
88
- outputResult(data, { json: globalOpts.json });
89
- }
90
- });
@@ -1,77 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import type { UpdateContactOptions } from 'resend';
3
- import { runWrite } from '../../lib/actions';
4
- import type { GlobalOpts } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { contactIdentifier, parsePropertiesJson } from './utils';
7
-
8
- export const updateContactCommand = new Command('update')
9
- .description("Update a contact's subscription status or custom properties")
10
- .argument(
11
- '<id>',
12
- 'Contact UUID or email address — both are accepted by the API',
13
- )
14
- .option(
15
- '--unsubscribed',
16
- 'Globally unsubscribe the contact from all broadcasts',
17
- )
18
- .option(
19
- '--no-unsubscribed',
20
- 'Re-subscribe the contact (clears the global unsubscribe flag)',
21
- )
22
- .option(
23
- '--properties <json>',
24
- 'JSON object of properties to merge (e.g. \'{"company":"Acme"}\'); set a key to null to clear it',
25
- )
26
- .addHelpText(
27
- 'after',
28
- buildHelpText({
29
- context: `The <id> argument accepts either a UUID or an email address.
30
-
31
- Subscription toggle:
32
- --unsubscribed Sets unsubscribed: true — contact will not receive any broadcasts.
33
- --no-unsubscribed Sets unsubscribed: false — re-enables broadcast delivery.
34
- Omitting both flags leaves the subscription status unchanged.
35
-
36
- Properties: --properties merges the given JSON object with existing properties.
37
- Set a key to null to clear it: '{"company":null}'.`,
38
- output: ` {"object":"contact","id":"<id>"}`,
39
- errorCodes: ['auth_error', 'invalid_properties', 'update_error'],
40
- examples: [
41
- 'resend contacts update 479e3145-dd38-4932-8c0c-e58b548c9e76 --unsubscribed',
42
- 'resend contacts update user@example.com --no-unsubscribed',
43
- `resend contacts update 479e3145-dd38-4932-8c0c-e58b548c9e76 --properties '{"plan":"pro"}'`,
44
- 'resend contacts update user@example.com --unsubscribed --json',
45
- ],
46
- }),
47
- )
48
- .action(async (id, opts, cmd) => {
49
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
50
-
51
- const properties = parsePropertiesJson(opts.properties, globalOpts);
52
-
53
- // contactIdentifier resolves UUID vs email. The spread of a discriminated
54
- // union requires an explicit cast because TypeScript cannot narrow it
55
- // through a spread at the call site.
56
- const payload = {
57
- ...contactIdentifier(id),
58
- ...(opts.unsubscribed !== undefined && {
59
- unsubscribed: opts.unsubscribed,
60
- }),
61
- ...(properties && { properties }),
62
- } as UpdateContactOptions;
63
-
64
- await runWrite(
65
- {
66
- spinner: {
67
- loading: 'Updating contact...',
68
- success: 'Contact updated',
69
- fail: 'Failed to update contact',
70
- },
71
- sdkCall: (resend) => resend.contacts.update(payload),
72
- errorCode: 'update_error',
73
- successMsg: `Contact updated: ${id}`,
74
- },
75
- globalOpts,
76
- );
77
- });
@@ -1,119 +0,0 @@
1
- import type { ContactSegmentsBaseOptions, ContactTopic } from 'resend';
2
- import type { GlobalOpts } from '../../lib/client';
3
- import { outputError } from '../../lib/output';
4
- import { renderTable } from '../../lib/table';
5
-
6
- // ─── Table renderers ─────────────────────────────────────────────────────────
7
-
8
- export function renderContactsTable(
9
- contacts: Array<{
10
- id: string;
11
- email: string;
12
- first_name: string | null;
13
- last_name: string | null;
14
- unsubscribed: boolean;
15
- }>,
16
- ): string {
17
- const rows = contacts.map((c) => [
18
- c.email,
19
- c.first_name ?? '',
20
- c.last_name ?? '',
21
- c.unsubscribed ? 'yes' : 'no',
22
- c.id,
23
- ]);
24
- return renderTable(
25
- ['Email', 'First Name', 'Last Name', 'Unsubscribed', 'ID'],
26
- rows,
27
- '(no contacts)',
28
- );
29
- }
30
-
31
- export function renderContactTopicsTable(topics: ContactTopic[]): string {
32
- const rows = topics.map((t) => [
33
- t.name,
34
- t.subscription,
35
- t.id,
36
- t.description ?? '',
37
- ]);
38
- return renderTable(
39
- ['Name', 'Subscription', 'ID', 'Description'],
40
- rows,
41
- '(no topic subscriptions)',
42
- );
43
- }
44
-
45
- // ─── Contact identifier helpers ───────────────────────────────────────────────
46
- //
47
- // The Resend SDK uses two different discriminated-union shapes depending on
48
- // the API surface:
49
- //
50
- // • contactIdentifier — produces { id } | { email } for endpoints that
51
- // accept SelectingField (update, get, remove) or { id?, email? }
52
- // (topics list/update).
53
- //
54
- // • segmentContactIdentifier — produces { contactId } | { email } for the
55
- // contacts.segments.* endpoints, which use ContactSegmentsBaseOptions.
56
- //
57
- // Centralising the `str.includes('@')` check here prevents it from drifting
58
- // across six separate command files.
59
-
60
- export function contactIdentifier(
61
- id: string,
62
- ): { id: string } | { email: string } {
63
- return id.includes('@') ? { email: id } : { id };
64
- }
65
-
66
- export function segmentContactIdentifier(
67
- id: string,
68
- ): ContactSegmentsBaseOptions {
69
- return id.includes('@') ? { email: id } : { contactId: id };
70
- }
71
-
72
- // ─── JSON flag helpers ────────────────────────────────────────────────────────
73
-
74
- export function parseTopicsJson(
75
- raw: string,
76
- globalOpts: GlobalOpts,
77
- ): Array<{ id: string; subscription: 'opt_in' | 'opt_out' }> {
78
- let parsed: unknown;
79
- try {
80
- parsed = JSON.parse(raw);
81
- } catch {
82
- outputError(
83
- {
84
- message:
85
- 'Invalid --topics JSON. Expected an array of {id, subscription} objects.',
86
- code: 'invalid_topics',
87
- },
88
- { json: globalOpts.json },
89
- );
90
- }
91
- if (!Array.isArray(parsed)) {
92
- outputError(
93
- {
94
- message:
95
- 'Invalid --topics JSON. Expected an array of {id, subscription} objects.',
96
- code: 'invalid_topics',
97
- },
98
- { json: globalOpts.json },
99
- );
100
- }
101
- return parsed as Array<{ id: string; subscription: 'opt_in' | 'opt_out' }>;
102
- }
103
-
104
- export function parsePropertiesJson(
105
- raw: string | undefined,
106
- globalOpts: GlobalOpts,
107
- ): Record<string, string | number | null> | undefined {
108
- if (!raw) {
109
- return undefined;
110
- }
111
- try {
112
- return JSON.parse(raw) as Record<string, string | number | null>;
113
- } catch {
114
- outputError(
115
- { message: 'Invalid --properties JSON.', code: 'invalid_properties' },
116
- { json: globalOpts.json },
117
- );
118
- }
119
- }