@decocms/apps-resend 7.37.1 → 7.37.3
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.
- package/package.json +3 -3
- package/src/__tests__/send.test.ts +16 -12
- package/src/actions/send.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/apps-resend",
|
|
3
|
-
"version": "7.37.
|
|
3
|
+
"version": "7.37.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco app: Resend transactional email integration",
|
|
6
6
|
"repository": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"lint:unused": "knip"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@decocms/blocks": "7.37.
|
|
32
|
-
"@decocms/apps-commerce": "7.37.
|
|
31
|
+
"@decocms/blocks": "7.37.3",
|
|
32
|
+
"@decocms/apps-commerce": "7.37.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^19.0.0",
|
|
@@ -35,19 +35,23 @@ describe("sendEmail", () => {
|
|
|
35
35
|
expect(result.data).toEqual({ id: "email_abc123" });
|
|
36
36
|
expect(result.error).toBeNull();
|
|
37
37
|
|
|
38
|
-
expect(fetchSpy).toHaveBeenCalledWith(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
expect(fetchSpy).toHaveBeenCalledWith(
|
|
39
|
+
"https://api.resend.com/emails",
|
|
40
|
+
expect.objectContaining({
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: "Bearer re_test_123",
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
},
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
from: "Test <test@example.com>",
|
|
48
|
+
to: "user@example.com",
|
|
49
|
+
subject: "Hello",
|
|
50
|
+
html: "<p>World</p>",
|
|
51
|
+
}),
|
|
52
|
+
signal: expect.any(AbortSignal),
|
|
49
53
|
}),
|
|
50
|
-
|
|
54
|
+
);
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
it("falls back to defaults when fields are omitted", async () => {
|
package/src/actions/send.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { withFetchTimeout } from "@decocms/blocks/sdk/fetchTimeout";
|
|
1
2
|
import { getResendConfig } from "../client";
|
|
2
3
|
import type { CreateEmailOptions, CreateEmailResponse } from "../types";
|
|
3
4
|
|
|
5
|
+
const timeoutFetch = withFetchTimeout();
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Send an email via Resend API.
|
|
6
9
|
*
|
|
@@ -32,7 +35,7 @@ export async function sendEmail(
|
|
|
32
35
|
...(payload.headers && { headers: payload.headers }),
|
|
33
36
|
};
|
|
34
37
|
|
|
35
|
-
const response = await
|
|
38
|
+
const response = await timeoutFetch("https://api.resend.com/emails", {
|
|
36
39
|
method: "POST",
|
|
37
40
|
headers: {
|
|
38
41
|
Authorization: `Bearer ${config.apiKey}`,
|