resend-cli 1.2.0 → 1.2.2

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 (193) hide show
  1. package/.github/workflows/release.yml +35 -8
  2. package/README.md +12 -1
  3. package/biome.json +1 -1
  4. package/bun.lock +0 -3
  5. package/package.json +3 -4
  6. package/src/cli.ts +23 -5
  7. package/src/commands/auth/login.ts +10 -8
  8. package/src/commands/doctor.ts +30 -112
  9. package/src/lib/client.ts +3 -0
  10. package/src/lib/config.ts +2 -3
  11. package/src/lib/spinner.ts +17 -10
  12. package/src/lib/update-check.ts +172 -0
  13. package/tests/commands/auth/login.test.ts +3 -1
  14. package/tests/lib/config.test.ts +4 -6
  15. package/tests/lib/update-check.test.ts +169 -0
  16. package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
  17. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
  18. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
  19. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
  20. package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
  21. package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
  22. package/.claude/worktrees/emails-list/LICENSE +0 -21
  23. package/.claude/worktrees/emails-list/README.md +0 -424
  24. package/.claude/worktrees/emails-list/biome.json +0 -36
  25. package/.claude/worktrees/emails-list/bun.lock +0 -76
  26. package/.claude/worktrees/emails-list/bunfig.toml +0 -2
  27. package/.claude/worktrees/emails-list/install.ps1 +0 -140
  28. package/.claude/worktrees/emails-list/install.sh +0 -301
  29. package/.claude/worktrees/emails-list/package.json +0 -43
  30. package/.claude/worktrees/emails-list/renovate.json +0 -6
  31. package/.claude/worktrees/emails-list/src/cli.ts +0 -74
  32. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
  33. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
  34. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
  35. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
  36. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
  37. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
  38. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
  39. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
  40. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
  41. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
  42. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
  43. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
  44. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
  45. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
  46. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
  47. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
  48. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
  49. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
  50. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
  51. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
  52. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
  53. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
  54. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
  55. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
  56. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
  57. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
  58. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
  59. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
  60. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
  61. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
  62. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
  63. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
  64. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
  65. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
  66. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
  67. package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
  68. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
  69. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
  70. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
  71. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
  72. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
  73. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
  74. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
  75. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
  76. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
  77. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
  78. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
  79. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
  80. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
  81. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
  82. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
  83. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
  84. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
  85. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
  86. package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
  87. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
  88. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
  89. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
  90. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
  91. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
  92. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
  93. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
  94. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
  95. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
  96. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
  97. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
  98. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
  99. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
  100. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
  101. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
  102. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
  103. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
  104. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
  105. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
  106. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
  107. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
  108. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
  109. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
  110. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
  111. package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
  112. package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
  113. package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
  114. package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
  115. package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
  116. package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
  117. package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
  118. package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
  119. package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
  120. package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
  121. package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
  122. package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
  123. package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
  124. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
  125. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
  126. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
  127. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
  128. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
  129. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
  130. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
  131. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
  132. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
  133. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
  134. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
  135. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
  136. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
  137. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
  138. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
  139. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
  140. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
  141. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
  142. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
  143. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
  144. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
  145. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
  146. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
  147. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
  148. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
  149. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
  150. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
  151. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
  152. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
  153. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
  154. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
  155. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
  156. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
  157. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
  158. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
  159. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
  160. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
  161. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
  162. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
  163. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
  164. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
  165. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
  166. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
  167. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
  168. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
  169. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
  170. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
  171. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
  172. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
  173. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
  174. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
  175. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
  176. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
  177. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
  178. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
  179. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
  180. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
  181. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
  182. package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
  183. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
  184. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
  185. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
  186. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
  187. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
  188. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
  189. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
  190. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
  191. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
  192. package/.claude/worktrees/emails-list/tsconfig.json +0 -14
  193. package/.github/workflows/test-build-windows.yml +0 -44
@@ -1,60 +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 { renderBroadcastsTable } from './utils';
11
-
12
- export const listBroadcastsCommand = new Command('list')
13
- .alias('ls')
14
- .description(
15
- 'List broadcasts — returns summary objects (use "get <id>" for full details including html/text)',
16
- )
17
- .option('--limit <n>', 'Maximum number of results to return (1-100)', '10')
18
- .option(
19
- '--after <cursor>',
20
- 'Cursor for forward pagination — list items after this ID',
21
- )
22
- .option(
23
- '--before <cursor>',
24
- 'Cursor for backward pagination — list items before this ID',
25
- )
26
- .addHelpText(
27
- 'after',
28
- buildHelpText({
29
- context: `Note: List results include name, status, created_at, and id only.
30
- To retrieve full details (html, from, subject), use: resend broadcasts get <id>`,
31
- output: ` {"object":"list","has_more":false,"data":[{"id":"...","name":"...","status":"draft|queued|sent","created_at":"..."}]}`,
32
- errorCodes: ['auth_error', 'invalid_limit', 'list_error'],
33
- examples: [
34
- 'resend broadcasts list',
35
- 'resend broadcasts list --limit 5',
36
- 'resend broadcasts list --after d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --limit 10',
37
- 'resend broadcasts list --json',
38
- ],
39
- }),
40
- )
41
- .action(async (opts, cmd) => {
42
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
43
- const limit = parseLimitOpt(opts.limit, globalOpts);
44
- const paginationOpts = buildPaginationOpts(limit, opts.after, opts.before);
45
- await runList(
46
- {
47
- spinner: {
48
- loading: 'Fetching broadcasts...',
49
- success: 'Broadcasts fetched',
50
- fail: 'Failed to list broadcasts',
51
- },
52
- sdkCall: (resend) => resend.broadcasts.list(paginationOpts),
53
- onInteractive: (list) => {
54
- console.log(renderBroadcastsTable(list.data));
55
- printPaginationHint(list);
56
- },
57
- },
58
- globalOpts,
59
- );
60
- });
@@ -1,56 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runWrite } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const sendBroadcastCommand = new Command('send')
7
- .description(
8
- 'Send a draft broadcast (API-created drafts only — dashboard broadcasts cannot be sent via API)',
9
- )
10
- .argument('<id>', 'Broadcast ID')
11
- .option(
12
- '--scheduled-at <datetime>',
13
- 'Schedule delivery — ISO 8601 or natural language e.g. "in 1 hour", "tomorrow at 9am ET"',
14
- )
15
- .addHelpText(
16
- 'after',
17
- buildHelpText({
18
- context: `Note: Only broadcasts created via the API can be sent via this command.
19
- Broadcasts created in the Resend dashboard cannot be sent programmatically.
20
-
21
- Scheduling:
22
- --scheduled-at accepts ISO 8601 (e.g. 2026-08-05T11:52:01Z) or
23
- natural language (e.g. "in 1 hour", "tomorrow at 9am ET").`,
24
- output: ` {"id":"<broadcast-id>"}`,
25
- errorCodes: ['auth_error', 'send_error'],
26
- examples: [
27
- 'resend broadcasts send d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6',
28
- 'resend broadcasts send d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --scheduled-at "in 1 hour"',
29
- 'resend broadcasts send d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --scheduled-at "2026-08-05T11:52:01Z" --json',
30
- ],
31
- }),
32
- )
33
- .action(async (id, opts, cmd) => {
34
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
35
-
36
- const successMsg = opts.scheduledAt
37
- ? `\nBroadcast scheduled: ${id} (sends: ${opts.scheduledAt})`
38
- : `\nBroadcast sent: ${id}`;
39
-
40
- await runWrite(
41
- {
42
- spinner: {
43
- loading: 'Sending broadcast...',
44
- success: 'Broadcast sent',
45
- fail: 'Failed to send broadcast',
46
- },
47
- sdkCall: (resend) =>
48
- resend.broadcasts.send(id, {
49
- ...(opts.scheduledAt && { scheduledAt: opts.scheduledAt }),
50
- }),
51
- errorCode: 'send_error',
52
- successMsg,
53
- },
54
- globalOpts,
55
- );
56
- });
@@ -1,95 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runWrite } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { readFile } from '../../lib/files';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { outputError } from '../../lib/output';
7
-
8
- export const updateBroadcastCommand = new Command('update')
9
- .description(
10
- 'Update a draft broadcast — only drafts can be updated; sent broadcasts are immutable',
11
- )
12
- .argument('<id>', 'Broadcast ID')
13
- .option('--from <address>', 'Update sender address')
14
- .option('--subject <subject>', 'Update subject')
15
- .option(
16
- '--html <html>',
17
- 'Update HTML body (supports {{{FIRST_NAME|fallback}}} variable interpolation)',
18
- )
19
- .option(
20
- '--html-file <path>',
21
- 'Path to an HTML file to replace the body (supports {{{FIRST_NAME|fallback}}} variable interpolation)',
22
- )
23
- .option('--text <text>', 'Update plain-text body')
24
- .option('--name <name>', 'Update internal label')
25
- .addHelpText(
26
- 'after',
27
- buildHelpText({
28
- context: `Note: Only draft broadcasts can be updated.
29
- If the broadcast is already sent or sending, the API will return an error.
30
-
31
- Variable interpolation:
32
- HTML bodies support triple-brace syntax for contact properties.
33
- Example: {{{FIRST_NAME|Friend}}} — uses FIRST_NAME or falls back to "Friend".`,
34
- output: ` {"id":"<broadcast-id>"}`,
35
- errorCodes: [
36
- 'auth_error',
37
- 'no_changes',
38
- 'file_read_error',
39
- 'update_error',
40
- ],
41
- examples: [
42
- 'resend broadcasts update d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --subject "Updated Subject"',
43
- 'resend broadcasts update d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --html-file ./new-email.html',
44
- 'resend broadcasts update d1c2b3a4-5e6f-7a8b-9c0d-e1f2a3b4c5d6 --name "Q1 Newsletter" --from "news@domain.com" --json',
45
- ],
46
- }),
47
- )
48
- .action(async (id, opts, cmd) => {
49
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
50
-
51
- if (
52
- !opts.from &&
53
- !opts.subject &&
54
- !opts.html &&
55
- !opts.htmlFile &&
56
- !opts.text &&
57
- !opts.name
58
- ) {
59
- outputError(
60
- {
61
- message:
62
- 'Provide at least one option to update: --from, --subject, --html, --html-file, --text, or --name.',
63
- code: 'no_changes',
64
- },
65
- { json: globalOpts.json },
66
- );
67
- }
68
-
69
- let html = opts.html;
70
-
71
- if (opts.htmlFile) {
72
- html = readFile(opts.htmlFile, globalOpts);
73
- }
74
-
75
- await runWrite(
76
- {
77
- spinner: {
78
- loading: 'Updating broadcast...',
79
- success: 'Broadcast updated',
80
- fail: 'Failed to update broadcast',
81
- },
82
- sdkCall: (resend) =>
83
- resend.broadcasts.update(id, {
84
- ...(opts.from && { from: opts.from }),
85
- ...(opts.subject && { subject: opts.subject }),
86
- ...(html && { html }),
87
- ...(opts.text && { text: opts.text }),
88
- ...(opts.name && { name: opts.name }),
89
- }),
90
- errorCode: 'update_error',
91
- successMsg: `\nBroadcast updated: ${id}`,
92
- },
93
- globalOpts,
94
- );
95
- });
@@ -1,35 +0,0 @@
1
- import { renderTable } from '../../lib/table';
2
-
3
- export function broadcastStatusIndicator(status: string): string {
4
- switch (status) {
5
- case 'draft':
6
- return '○ Draft';
7
- case 'queued':
8
- return '⏳ Queued';
9
- case 'sent':
10
- return '✓ Sent';
11
- default:
12
- return status;
13
- }
14
- }
15
-
16
- export function renderBroadcastsTable(
17
- broadcasts: Array<{
18
- id: string;
19
- name: string | null;
20
- status: string;
21
- created_at: string;
22
- }>,
23
- ): string {
24
- const rows = broadcasts.map((b) => [
25
- b.name ?? '(untitled)',
26
- b.status,
27
- b.created_at,
28
- b.id,
29
- ]);
30
- return renderTable(
31
- ['Name', 'Status', 'Created', 'ID'],
32
- rows,
33
- '(no broadcasts)',
34
- );
35
- }
@@ -1,118 +0,0 @@
1
- import { Command, Option } from '@commander-js/extra-typings';
2
- import type { CreateContactPropertyOptions } from 'resend';
3
- import { runCreate } from '../../lib/actions';
4
- import type { GlobalOpts } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { outputError } from '../../lib/output';
7
- import { requireSelect, requireText } from '../../lib/prompts';
8
-
9
- export const createContactPropertyCommand = new Command('create')
10
- .description('Create a new contact property definition')
11
- .addOption(
12
- new Option(
13
- '--key <key>',
14
- 'Property key name, used in broadcast template interpolation (e.g. company_name, department)',
15
- ),
16
- )
17
- .addOption(
18
- new Option(
19
- '--type <type>',
20
- "Property data type: 'string' for text values, 'number' for numeric values",
21
- ).choices(['string', 'number'] as const),
22
- )
23
- .option(
24
- '--fallback-value <value>',
25
- 'Default value used in broadcast templates when a contact has no value set for this property',
26
- )
27
- .addHelpText(
28
- 'after',
29
- buildHelpText({
30
- context: `Property keys are used as identifiers in broadcast HTML template interpolation:
31
- {{{PROPERTY_NAME|fallback}}} — triple-brace syntax substitutes the contact's value
32
- {{{company_name|Unknown}}} — falls back to "Unknown" if the property is not set
33
-
34
- Reserved keys (cannot be used): FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL
35
-
36
- Non-interactive: --key and --type are required. --fallback-value is optional.
37
- Warning: do not create properties with reserved key names — they will conflict with
38
- built-in contact fields and may cause unexpected behavior in broadcasts.`,
39
- output: ` {"object":"contact_property","id":"<id>"}`,
40
- errorCodes: [
41
- 'auth_error',
42
- 'missing_key',
43
- 'missing_type',
44
- 'invalid_fallback_value',
45
- 'create_error',
46
- ],
47
- examples: [
48
- 'resend contact-properties create --key company_name --type string',
49
- 'resend contact-properties create --key company_name --type string --fallback-value "Unknown"',
50
- 'resend contact-properties create --key employee_count --type number --fallback-value 0',
51
- 'resend contact-properties create --key department --type string --json',
52
- ],
53
- }),
54
- )
55
- .action(async (opts, cmd) => {
56
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
57
-
58
- const key = await requireText(
59
- opts.key,
60
- { message: 'Property key', placeholder: 'company_name' },
61
- { message: 'Missing --key flag.', code: 'missing_key' },
62
- globalOpts,
63
- );
64
-
65
- const type = await requireSelect(
66
- opts.type,
67
- {
68
- message: 'Property data type',
69
- options: [
70
- { value: 'string' as const, label: 'string — text values' },
71
- { value: 'number' as const, label: 'number — numeric values' },
72
- ],
73
- },
74
- { message: 'Missing --type flag.', code: 'missing_type' },
75
- globalOpts,
76
- );
77
-
78
- let fallbackValue: string | number | undefined;
79
- if (opts.fallbackValue !== undefined) {
80
- if (type === 'number') {
81
- const parsed = parseFloat(opts.fallbackValue);
82
- if (Number.isNaN(parsed)) {
83
- outputError(
84
- {
85
- message:
86
- '--fallback-value must be a valid number for number-type properties.',
87
- code: 'invalid_fallback_value',
88
- },
89
- { json: globalOpts.json },
90
- );
91
- }
92
- fallbackValue = parsed;
93
- } else {
94
- fallbackValue = opts.fallbackValue;
95
- }
96
- }
97
-
98
- const payload = {
99
- key,
100
- type,
101
- ...(fallbackValue !== undefined && { fallbackValue }),
102
- } as CreateContactPropertyOptions;
103
-
104
- await runCreate(
105
- {
106
- spinner: {
107
- loading: 'Creating contact property...',
108
- success: 'Contact property created',
109
- fail: 'Failed to create contact property',
110
- },
111
- sdkCall: (resend) => resend.contactProperties.create(payload),
112
- onInteractive: (data) => {
113
- console.log(`\nContact property created: ${data.id}`);
114
- },
115
- },
116
- globalOpts,
117
- );
118
- });
@@ -1,48 +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 deleteContactPropertyCommand = new Command('delete')
7
- .alias('rm')
8
- .description('Delete a contact property definition')
9
- .argument('<id>', 'Contact property UUID')
10
- .option(
11
- '--yes',
12
- 'Skip the confirmation prompt (required in non-interactive mode)',
13
- )
14
- .addHelpText(
15
- 'after',
16
- buildHelpText({
17
- context: `WARNING: Deleting a property definition removes that property value from ALL contacts
18
- permanently. This cannot be undone, and any broadcasts that reference this property key
19
- via {{{PROPERTY_NAME}}} will render an empty string or their inline fallback instead.
20
-
21
- Non-interactive: --yes is required to confirm deletion when stdin/stdout is not a TTY.`,
22
- output: ` {"object":"contact_property","id":"<id>","deleted":true}`,
23
- errorCodes: ['auth_error', 'confirmation_required', 'delete_error'],
24
- examples: [
25
- 'resend contact-properties delete b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --yes',
26
- 'resend contact-properties delete b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --yes --json',
27
- ],
28
- }),
29
- )
30
- .action(async (id, opts, cmd) => {
31
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
32
- await runDelete(
33
- id,
34
- !!opts.yes,
35
- {
36
- confirmMessage: `Delete contact property "${id}"?\nThis will remove this property from ALL contacts permanently.`,
37
- spinner: {
38
- loading: 'Deleting contact property...',
39
- success: 'Contact property deleted',
40
- fail: 'Failed to delete contact property',
41
- },
42
- object: 'contact_property',
43
- successMsg: 'Contact property deleted.',
44
- sdkCall: (resend) => resend.contactProperties.remove(id),
45
- },
46
- globalOpts,
47
- );
48
- });
@@ -1,46 +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 getContactPropertyCommand = new Command('get')
7
- .description('Retrieve a contact property definition by ID')
8
- .argument('<id>', 'Contact property UUID')
9
- .addHelpText(
10
- 'after',
11
- buildHelpText({
12
- output: ` {
13
- "object": "contact_property",
14
- "id": "<uuid>",
15
- "key": "company_name",
16
- "type": "string",
17
- "fallbackValue": null,
18
- "createdAt": "2026-01-01T00:00:00.000Z"
19
- }`,
20
- errorCodes: ['auth_error', 'fetch_error'],
21
- examples: [
22
- 'resend contact-properties get b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d',
23
- 'resend contact-properties get b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --json',
24
- ],
25
- }),
26
- )
27
- .action(async (id, _opts, cmd) => {
28
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
29
- await runGet(
30
- {
31
- spinner: {
32
- loading: 'Fetching contact property...',
33
- success: 'Contact property fetched',
34
- fail: 'Failed to fetch contact property',
35
- },
36
- sdkCall: (resend) => resend.contactProperties.get(id),
37
- onInteractive: (data) => {
38
- console.log(`\n${data.key} (${data.type})`);
39
- console.log(`ID: ${data.id}`);
40
- console.log(`Created: ${data.createdAt}`);
41
- console.log(`Fallback value: ${data.fallbackValue ?? '(none)'}`);
42
- },
43
- },
44
- globalOpts,
45
- );
46
- });
@@ -1,48 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { createContactPropertyCommand } from './create';
4
- import { deleteContactPropertyCommand } from './delete';
5
- import { getContactPropertyCommand } from './get';
6
- import { listContactPropertiesCommand } from './list';
7
- import { updateContactPropertyCommand } from './update';
8
-
9
- export const contactPropertiesCommand = new Command('contact-properties')
10
- .description(
11
- 'Manage contact property definitions — schema for custom data on contacts',
12
- )
13
- .addHelpText(
14
- 'after',
15
- buildHelpText({
16
- context: `Contact properties define the schema for custom data stored on contacts.
17
- Think of them as column definitions — you create a property definition (e.g. company_name)
18
- and then set values for that property on individual contacts via "resend contacts update --properties".
19
-
20
- Property values are interpolated into broadcast HTML using triple-brace syntax:
21
- {{{PROPERTY_NAME|fallback}}} — inline fallback if property value is absent
22
- {{{company_name|Unknown Company}}} — example: renders the company or "Unknown Company"
23
-
24
- Reserved property keys (built-in, cannot be created): FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL
25
-
26
- Supported types:
27
- string — text values (default for most properties)
28
- number — numeric values (useful for counts, scores, thresholds)
29
-
30
- Note: property keys and types are immutable after creation. Only the fallback value can
31
- be updated. Deleting a property removes it from all contacts.`,
32
- examples: [
33
- 'resend contact-properties list',
34
- 'resend contact-properties create --key company_name --type string',
35
- 'resend contact-properties create --key plan --type string --fallback-value "free"',
36
- 'resend contact-properties create --key score --type number --fallback-value 0',
37
- 'resend contact-properties get b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d',
38
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --fallback-value "Unknown"',
39
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --clear-fallback-value',
40
- 'resend contact-properties delete b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --yes',
41
- ],
42
- }),
43
- )
44
- .addCommand(createContactPropertyCommand)
45
- .addCommand(getContactPropertyCommand)
46
- .addCommand(listContactPropertiesCommand, { isDefault: true })
47
- .addCommand(updateContactPropertyCommand)
48
- .addCommand(deleteContactPropertyCommand);
@@ -1,68 +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 { renderContactPropertiesTable } from './utils';
11
-
12
- export const listContactPropertiesCommand = new Command('list')
13
- .alias('ls')
14
- .description('List all contact property definitions')
15
- .option(
16
- '--limit <n>',
17
- 'Maximum number of contact properties to return (1-100)',
18
- '10',
19
- )
20
- .option(
21
- '--after <cursor>',
22
- 'Return contact properties after this cursor (next page)',
23
- )
24
- .option(
25
- '--before <cursor>',
26
- 'Return contact properties before this cursor (previous page)',
27
- )
28
- .addHelpText(
29
- 'after',
30
- buildHelpText({
31
- context: `Pagination: use --after or --before with a contact property ID as the cursor.
32
- Only one of --after or --before may be used at a time.
33
- The response includes has_more: true when additional pages exist.`,
34
- output: ` {
35
- "object": "list",
36
- "has_more": false,
37
- "data": [
38
- { "id": "<uuid>", "key": "company_name", "type": "string", "fallbackValue": null, "createdAt": "..." }
39
- ]
40
- }`,
41
- errorCodes: ['auth_error', 'invalid_limit', 'list_error'],
42
- examples: [
43
- 'resend contact-properties list',
44
- 'resend contact-properties list --limit 25 --json',
45
- 'resend contact-properties list --after b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --json',
46
- ],
47
- }),
48
- )
49
- .action(async (opts, cmd) => {
50
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
51
- const limit = parseLimitOpt(opts.limit, globalOpts);
52
- const paginationOpts = buildPaginationOpts(limit, opts.after, opts.before);
53
- await runList(
54
- {
55
- spinner: {
56
- loading: 'Fetching contact properties...',
57
- success: 'Contact properties fetched',
58
- fail: 'Failed to list contact properties',
59
- },
60
- sdkCall: (resend) => resend.contactProperties.list(paginationOpts),
61
- onInteractive: (list) => {
62
- console.log(renderContactPropertiesTable(list.data));
63
- printPaginationHint(list);
64
- },
65
- },
66
- globalOpts,
67
- );
68
- });
@@ -1,88 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runWrite } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { outputError } from '../../lib/output';
6
-
7
- export const updateContactPropertyCommand = new Command('update')
8
- .description('Update a contact property definition')
9
- .argument('<id>', 'Contact property UUID')
10
- .option(
11
- '--fallback-value <value>',
12
- 'New fallback value used in broadcast templates when a contact has no value set for this property',
13
- )
14
- .option(
15
- '--clear-fallback-value',
16
- 'Remove the fallback value (sets it to null)',
17
- )
18
- .addHelpText(
19
- 'after',
20
- buildHelpText({
21
- context: `Note: the property key and type cannot be changed after creation. Only the fallback value
22
- is updatable. Renaming a property would break existing broadcasts that reference the old key.
23
-
24
- --fallback-value and --clear-fallback-value are mutually exclusive.
25
-
26
- The fallback value is used in broadcast template interpolation when a contact has no value:
27
- {{{company_name|Unknown}}} — inline fallback (takes precedence over the property's fallback)
28
- {{{company_name}}} — uses the property's stored fallback value if set`,
29
- output: ` {"object":"contact_property","id":"<id>"}`,
30
- errorCodes: [
31
- 'auth_error',
32
- 'no_changes',
33
- 'conflicting_flags',
34
- 'update_error',
35
- ],
36
- examples: [
37
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --fallback-value "Acme Corp"',
38
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --fallback-value 42',
39
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --clear-fallback-value',
40
- 'resend contact-properties update b4a3c2d1-6e5f-8a7b-0c9d-2e1f4a3b6c5d --fallback-value "Unknown" --json',
41
- ],
42
- }),
43
- )
44
- .action(async (id, opts, cmd) => {
45
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
46
-
47
- if (opts.fallbackValue === undefined && !opts.clearFallbackValue) {
48
- outputError(
49
- {
50
- message:
51
- 'Provide at least one option to update: --fallback-value or --clear-fallback-value.',
52
- code: 'no_changes',
53
- },
54
- { json: globalOpts.json },
55
- );
56
- }
57
-
58
- if (opts.fallbackValue !== undefined && opts.clearFallbackValue) {
59
- outputError(
60
- {
61
- message:
62
- '--fallback-value and --clear-fallback-value are mutually exclusive.',
63
- code: 'conflicting_flags',
64
- },
65
- { json: globalOpts.json },
66
- );
67
- }
68
-
69
- const fallbackValue = opts.clearFallbackValue ? null : opts.fallbackValue;
70
-
71
- await runWrite(
72
- {
73
- spinner: {
74
- loading: 'Updating contact property...',
75
- success: 'Contact property updated',
76
- fail: 'Failed to update contact property',
77
- },
78
- sdkCall: (resend) =>
79
- resend.contactProperties.update({
80
- id,
81
- ...(fallbackValue !== undefined && { fallbackValue }),
82
- }),
83
- errorCode: 'update_error',
84
- successMsg: `Contact property updated: ${id}`,
85
- },
86
- globalOpts,
87
- );
88
- });