Skip to content

feat: add emails get command#47

Merged
felipefreitag merged 2 commits intomainfrom
cursor/emails-get-command-eb02
Mar 12, 2026
Merged

feat: add emails get command#47
felipefreitag merged 2 commits intomainfrom
cursor/emails-get-command-eb02

Conversation

@vcapretz
Copy link
Contributor

@vcapretz vcapretz commented Mar 12, 2026

Add resend emails get <id> command to support retrieving email details.

The existing resend emails receiving get <id> command only retrieves details for received emails. This PR introduces a new resend emails get <id> command that leverages the resend.emails.get(id) SDK method to retrieve details for any email, aligning with user expectations for a general email retrieval command.

Slack Thread

Open in Web Open in Cursor 

Summary by cubic

Adds resend emails get <id> to fetch a sent email by ID, providing a general email lookup aligned with the SDK. This replaces the need to use the receiving-only path for basic lookups.

  • New Features

    • resend emails get <id> using resend.emails.get(id) with interactive output (From, To, Subject, Status, Date, Scheduled) and --json for the full object.
    • Updated help with examples and error codes (auth_error, fetch_error); added tests for SDK call, JSON output, auth error, and fetch error.
  • Bug Fixes

    • Fixed a test in the emails get suite.

Written for commit f720c4e. Summary will update on new commits.

@cursor
Copy link

cursor bot commented Mar 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vcapretz vcapretz changed the title Emails get command feat: add emails get command Mar 12, 2026
@vcapretz vcapretz self-assigned this Mar 12, 2026
Adds a new 'resend emails get <id>' subcommand that retrieves a sent
email by ID using the existing resend.emails.get() SDK method.

Interactive output shows from, to, subject, status (last_event),
date, and scheduled_at fields. JSON output returns the full email
object.

Also adds tests covering SDK call, JSON output, auth error, and
fetch error paths.

Co-authored-by: Vitor Capretz <capretzvitor@gmail.com>
@felipefreitag felipefreitag force-pushed the cursor/emails-get-command-eb02 branch from f3a022e to 9fedf82 Compare March 12, 2026 13:48
@felipefreitag felipefreitag marked this pull request as ready for review March 12, 2026 13:48
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/commands/emails/get.test.ts">

<violation number="1" location="tests/commands/emails/get.test.ts:9">
P2: This test uses Bun’s test runtime (`bun:test`) and Bun-only mocking APIs (`mock.module`), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., `import { describe, test, expect, vi } from 'vitest'` and use `vi.fn/vi.mock/vi.spyOn`).</violation>

<violation number="2" location="tests/commands/emails/get.test.ts:59">
P2: `setupOutputSpies()` doesn’t return a `restore()` method, so `spies?.restore()` will throw when spies are set. Restore the specific spies instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


afterEach(() => {
restoreEnv();
spies?.restore();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: setupOutputSpies() doesn’t return a restore() method, so spies?.restore() will throw when spies are set. Restore the specific spies instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 59:

<comment>`setupOutputSpies()` doesn’t return a `restore()` method, so `spies?.restore()` will throw when spies are set. Restore the specific spies instead.</comment>

<file context>
@@ -0,0 +1,132 @@
+
+  afterEach(() => {
+    restoreEnv();
+    spies?.restore();
+    errorSpy?.mockRestore();
+    stderrSpy?.mockRestore();
</file context>
Fix with Cubic

mock,
spyOn,
test,
} from 'bun:test';
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This test uses Bun’s test runtime (bun:test) and Bun-only mocking APIs (mock.module), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., import { describe, test, expect, vi } from 'vitest' and use vi.fn/vi.mock/vi.spyOn).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 9:

<comment>This test uses Bun’s test runtime (`bun:test`) and Bun-only mocking APIs (`mock.module`), but the existing suite and helpers are built around Vitest. Under the Vitest runner this file will fail to import/use Bun APIs. Align this test with Vitest (e.g., `import { describe, test, expect, vi } from 'vitest'` and use `vi.fn/vi.mock/vi.spyOn`).</comment>

<file context>
@@ -0,0 +1,132 @@
+  mock,
+  spyOn,
+  test,
+} from 'bun:test';
+import {
+  captureTestEnv,
</file context>
Fix with Cubic

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/commands/emails/get.test.ts">

<violation number="1" location="tests/commands/emails/get.test.ts:76">
P2: This assertion no longer verifies call count, so the test can pass even if `emails.get` is invoked multiple times.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

);
await getEmailCommand.parseAsync(['email_abc123'], { from: 'user' });

expect(mockGet).toHaveBeenCalledWith('email_abc123');
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This assertion no longer verifies call count, so the test can pass even if emails.get is invoked multiple times.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/commands/emails/get.test.ts, line 76:

<comment>This assertion no longer verifies call count, so the test can pass even if `emails.get` is invoked multiple times.</comment>

<file context>
@@ -74,8 +73,7 @@ describe('emails get command', () => {
 
-    expect(mockGet).toHaveBeenCalledTimes(1);
-    expect(mockGet.mock.calls[0][0]).toBe('email_abc123');
+    expect(mockGet).toHaveBeenCalledWith('email_abc123');
   });
 
</file context>
Suggested change
expect(mockGet).toHaveBeenCalledWith('email_abc123');
expect(mockGet).toHaveBeenCalledTimes(1);
expect(mockGet).toHaveBeenCalledWith('email_abc123');
Fix with Cubic

@felipefreitag felipefreitag merged commit 20e5b75 into main Mar 12, 2026
7 checks passed
@felipefreitag felipefreitag deleted the cursor/emails-get-command-eb02 branch March 12, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants