Skip to content

Commit 6bc1946

Browse files
committed
resend
1 parent 06ccd3d commit 6bc1946

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

AGENTS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,18 @@ If any of the above commands fail or show errors:
8383
- **No dependencies field**: Do not use the `dependencies` field in plugin `index.ts` files. All API calls should use native `fetch`.
8484
- **Why**: Using `fetch` instead of SDKs reduces supply chain attack surface. SDKs have transitive dependencies that could be compromised.
8585

86+
## Step Output Format
87+
All plugin steps must return a standardized output format:
88+
89+
```typescript
90+
// Success
91+
return { success: true, data: { id: "...", name: "..." } };
92+
93+
// Error
94+
return { success: false, error: { message: "Error description" } };
95+
```
96+
97+
- **outputFields** in plugin `index.ts` should reference fields without `data.` prefix (e.g., `{ field: "id" }` not `{ field: "data.id" }`)
98+
- Template variables automatically unwrap: `{{GetUser.firstName}}` resolves to `data.firstName`
99+
- Logs display only the inner `data` or `error` object, not the full wrapper
100+

plugins/resend/steps/send-email.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ type ResendErrorResponse = {
1717
};
1818

1919
type SendEmailResult =
20-
| { success: true; id: string }
21-
| { success: false; error: string };
20+
| { success: true; data: { id: string } }
21+
| { success: false; error: { message: string } };
2222

2323
export type SendEmailCoreInput = {
2424
emailFrom?: string;
@@ -51,8 +51,10 @@ async function stepHandler(
5151
if (!apiKey) {
5252
return {
5353
success: false,
54-
error:
55-
"RESEND_API_KEY is not configured. Please add it in Project Integrations.",
54+
error: {
55+
message:
56+
"RESEND_API_KEY is not configured. Please add it in Project Integrations.",
57+
},
5658
};
5759
}
5860

@@ -61,8 +63,10 @@ async function stepHandler(
6163
if (!senderEmail) {
6264
return {
6365
success: false,
64-
error:
65-
"No sender is configured. Please add it in the action or in Project Integrations.",
66+
error: {
67+
message:
68+
"No sender is configured. Please add it in the action or in Project Integrations.",
69+
},
6670
};
6771
}
6872

@@ -95,17 +99,20 @@ async function stepHandler(
9599
const errorData = (await response.json()) as ResendErrorResponse;
96100
return {
97101
success: false,
98-
error: errorData.message || `HTTP ${response.status}: Failed to send email`,
102+
error: {
103+
message:
104+
errorData.message || `HTTP ${response.status}: Failed to send email`,
105+
},
99106
};
100107
}
101108

102109
const data = (await response.json()) as ResendEmailResponse;
103-
return { success: true, id: data.id };
110+
return { success: true, data: { id: data.id } };
104111
} catch (error) {
105-
const message = error instanceof Error ? error.message : String(error);
112+
const errorMessage = error instanceof Error ? error.message : String(error);
106113
return {
107114
success: false,
108-
error: `Failed to send email: ${message}`,
115+
error: { message: `Failed to send email: ${errorMessage}` },
109116
};
110117
}
111118
}

0 commit comments

Comments
 (0)