@sanoma-ai/connector-resend 0.4.0 → 0.4.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.
- package/README.md +28 -15
- package/dist/connector.d.ts +20 -1
- package/dist/connector.js +22 -11
- package/dist/connector.js.map +1 -1
- package/dist/driver.d.ts +2 -2
- package/dist/driver.js +31 -17
- package/dist/driver.js.map +1 -1
- package/dist/fake.d.ts +62 -3
- package/dist/fake.js +10 -3
- package/dist/fake.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/sdk.gen.d.ts +5 -1
- package/dist/generated/sdk.gen.js +12 -0
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/types.gen.d.ts +120 -0
- package/dist/index.d.ts +20 -3
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/steps.d.ts +3 -2
- package/dist/steps.js +14 -2
- package/dist/steps.js.map +1 -1
- package/features/emails.feature +20 -0
- package/logo-dark.svg +1 -0
- package/logo.svg +1 -0
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sanoma-ai/connector-resend
|
|
2
2
|
|
|
3
|
-
[Resend Broadcasts API](https://resend.com/docs/api-reference/broadcasts) operations for [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows).
|
|
3
|
+
[Resend Broadcasts API](https://resend.com/docs/api-reference/broadcasts) and [one-email send](https://resend.com/docs/api-reference/emails/send-email) operations for [`@sanoma-ai/workflows`](https://www.npmjs.com/package/@sanoma-ai/workflows).
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
npm install @sanoma-ai/connector-resend
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
| Operation | Effect | What it does
|
|
12
|
-
| ------------------------- | ------- |
|
|
13
|
-
| `resend.broadcast.create` | `write` | Create a broadcast to an audience. Nothing is sent.
|
|
14
|
-
| `resend.broadcast.send` | `send` | Send a broadcast to every contact in its audience. Cannot be undone.
|
|
11
|
+
| Operation | Effect | What it does |
|
|
12
|
+
| ------------------------- | ------- | ------------------------------------------------------------------------- |
|
|
13
|
+
| `resend.broadcast.create` | `write` | Create a broadcast to an audience. Nothing is sent. |
|
|
14
|
+
| `resend.broadcast.send` | `send` | Send a broadcast to every contact in its audience. Cannot be undone. |
|
|
15
|
+
| `resend.emails.send` | `send` | Send one email to an address, or to a list of up to 50. Cannot be undone. |
|
|
15
16
|
|
|
16
17
|
```ts
|
|
17
18
|
import { resend } from "@sanoma-ai/connector-resend";
|
|
@@ -27,6 +28,17 @@ defineWorkflow({
|
|
|
27
28
|
});
|
|
28
29
|
```
|
|
29
30
|
|
|
31
|
+
`emails.send` takes `to` (an address, or a list of 1 to 50), `subject`, `html`, `text` or both (Resend makes the text from the HTML when there is none), and an optional `from`, and returns the email's `{ id }`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
defineWorkflow({
|
|
35
|
+
// ...
|
|
36
|
+
uses: [resend.emails.send],
|
|
37
|
+
run: async (ctx, input) =>
|
|
38
|
+
ctx.resend.emails.send({ to: input.email, subject: "Following up", text: `Hi ${input.name},…` }),
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
30
42
|
The logo the app shows beside these operations is Resend's lettermark from its [brand kit](https://resend.com/brand), black or white. It is there only to identify the service an operation calls.
|
|
31
43
|
|
|
32
44
|
## Driver
|
|
@@ -41,7 +53,7 @@ export default defineConfig({ workflows, connectors: [resend], policy });
|
|
|
41
53
|
|
|
42
54
|
`./driver` (`resendDriver`; `resendDriver({ timeoutMs })`, 15 s by default) and `./fake` (`fakeResend`) are internal entries, for tests.
|
|
43
55
|
|
|
44
|
-
`audience` is Resend's `segment_id` (Resend renamed audiences to segments). `from
|
|
56
|
+
`audience` is Resend's `segment_id` (Resend renamed audiences to segments). `from`, for a broadcast or an email, comes from the input, else `RESEND_FROM` in the environment; Resend requires one. `broadcast.send` returns `status: "queued"` when it sends: Resend replies with the id only and sends in the background.
|
|
45
57
|
|
|
46
58
|
The client is generated by [Hey API](https://heyapi.dev) from Resend's [OpenAPI spec](https://github.com/resend/resend-openapi), pinned to a commit and cut to the operations it calls in `openapi-ts.config.ts`: `pnpm run generate` rewrites `src/generated/`, which is never edited by hand.
|
|
47
59
|
|
|
@@ -49,16 +61,16 @@ The client is generated by [Hey API](https://heyapi.dev) from Resend's [OpenAPI
|
|
|
49
61
|
|
|
50
62
|
It reads this on every call, never when the config loads:
|
|
51
63
|
|
|
52
|
-
| Variable | What it is
|
|
53
|
-
| ---------------- |
|
|
54
|
-
| `RESEND_API_KEY` | A Resend API key.
|
|
55
|
-
| `RESEND_FROM` | Optional: the sender of a broadcast whose input has no `from`, such as `Acme <news@acme.example>`, on a domain verified in Resend. |
|
|
64
|
+
| Variable | What it is |
|
|
65
|
+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `RESEND_API_KEY` | A Resend API key. |
|
|
67
|
+
| `RESEND_FROM` | Optional: the sender of a broadcast or email whose input has no `from`, such as `Acme <news@acme.example>`, on a domain verified in Resend. |
|
|
56
68
|
|
|
57
|
-
When the key is unset, a call fails, not retryable, naming it; so does a `create` with no sender from either place. The driver declares both in its `env` ([Credentials](https://www.npmjs.com/package/@sanoma-ai/workflows#credentials)): the worker starts without them, warning, and the app's connector page shows their status and lets you set them.
|
|
69
|
+
When the key is unset, a call fails, not retryable, naming it; so does a `broadcast.create` or `emails.send` with no sender from either place. The driver declares both in its `env` ([Credentials](https://www.npmjs.com/package/@sanoma-ai/workflows#credentials)): the worker starts without them, warning, and the app's connector page shows their status and lets you set them.
|
|
58
70
|
|
|
59
71
|
### Idempotency
|
|
60
72
|
|
|
61
|
-
Resend documents `Idempotency-Key` for emails only, not broadcasts. The driver sends the call's key on
|
|
73
|
+
Resend documents `Idempotency-Key` for emails only, not broadcasts. `emails.send` sends the call's key, so a retried call (its reply lost, or its worker restarted) gets the first email's id back and sends nothing, for 24 hours, how long Resend keeps a key; the same key with another input fails for good (409 `invalid_idempotent_request`). The driver sends the call's key on the broadcast requests too, and names the broadcast after it so it traces to its run. A replayed `create` can leave a second draft, which sends nothing. `send` reads the broadcast first and sends only a `draft` or `scheduled` one, so a replayed `send` whose reply was lost sends nothing: it returns `queued` or `sent`, as Resend says the broadcast is, and fails for good on a `canceled` one. The read and the send are two requests, not one: two tries of one call running at once (a recovering worker re-running a call another worker still runs) could both read a draft and both send it, and Resend documents nothing that would stop the second.
|
|
62
74
|
|
|
63
75
|
### Errors and retries
|
|
64
76
|
|
|
@@ -70,7 +82,7 @@ Broadcasts are on the free Marketing plan (1,000 contacts, 3 segments, 3 domains
|
|
|
70
82
|
|
|
71
83
|
### Testing the driver
|
|
72
84
|
|
|
73
|
-
`test/driver.test.ts` replays Resend's recorded replies (`test/fixtures`) with [`@sanoma-ai/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#replaying-a-vendors-api), which says what `SANOMA_LIVE` and `SANOMA_RECORD` do: `pnpm vitest run connectors/resend` needs no account. Live, they create broadcasts and send one to a test segment
|
|
85
|
+
`test/driver.test.ts` replays Resend's recorded replies (`test/fixtures`) with [`@sanoma-ai/testing/replay`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#replaying-a-vendors-api), which says what `SANOMA_LIVE` and `SANOMA_RECORD` do: `pnpm vitest run connectors/resend` needs no account. Live, they create broadcasts and send one to a test segment, and send emails to Resend's test inbox, `delivered@resend.dev`:
|
|
74
86
|
|
|
75
87
|
```sh
|
|
76
88
|
SANOMA_LIVE=1 RESEND_API_KEY=re_... RESEND_TEST_AUDIENCE=<segment id> RESEND_TEST_FROM="Test <test@your-domain>" pnpm vitest run connectors/resend
|
|
@@ -87,12 +99,13 @@ The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/
|
|
|
87
99
|
| Given | `a Resend broadcast {string}` | Seeds a draft broadcast with that subject through `resend.broadcast.create`, named `broadcast` (`$broadcast.id`) |
|
|
88
100
|
| Given | `Resend fails to send once` | The next `resend.broadcast.send` fails (`failNext`) |
|
|
89
101
|
| Then | `the Resend broadcast {string} is sent` | The broadcast with that subject, seeded or created by the run, was sent |
|
|
102
|
+
| Then | `a Resend email to {string} is sent` | The run sent an email to that address, alone or in its list |
|
|
90
103
|
|
|
91
|
-
`features/broadcast.feature` creates and sends a broadcast, with these steps and the generic ones for an operation's own test, on the fake and on Resend's recorded replies (`create-and-send.json`): `test/features.test.ts` runs them with [`describeFeatures`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#a-connectors-own-features). A scenario tagged `@fake-only` has no recording. The package ships `features/`.
|
|
104
|
+
`features/broadcast.feature` creates and sends a broadcast, and `features/emails.feature` sends an email, with these steps and the generic ones for an operation's own test, on the fake and on Resend's recorded replies (`create-and-send.json`, `send-an-email.json`): `test/features.test.ts` runs them with [`describeFeatures`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#a-connectors-own-features). A scenario tagged `@fake-only` has no recording. The package ships `features/`.
|
|
92
105
|
|
|
93
106
|
## Testing
|
|
94
107
|
|
|
95
|
-
`@sanoma-ai/connector-resend/fake` is an in-memory Resend that emails nobody, the fake the connector carries: each sandbox run makes one of its own. A test that reads or seeds one attaches it to the connector itself, then checks `state.broadcasts` and `calls`.
|
|
108
|
+
`@sanoma-ai/connector-resend/fake` is an in-memory Resend that emails nobody, the fake the connector carries: each sandbox run makes one of its own. A test that reads or seeds one attaches it to the connector itself, then checks `state.broadcasts`, `state.emails` (the emails sent, by id) and `calls`.
|
|
96
109
|
|
|
97
110
|
```ts
|
|
98
111
|
import { withSetup } from "@sanoma-ai/workflows";
|
package/dist/connector.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Resend's Broadcasts API (https://resend.com/docs/api-reference/broadcasts) and its one-email send
|
|
4
|
+
* (https://resend.com/docs/api-reference/emails/send-email).
|
|
5
|
+
*/
|
|
3
6
|
export declare const resendOps: import("@sanoma-ai/workflows").Connector<"resend", {
|
|
4
7
|
readonly broadcast: {
|
|
5
8
|
readonly create: {
|
|
@@ -33,4 +36,20 @@ export declare const resendOps: import("@sanoma-ai/workflows").Connector<"resend
|
|
|
33
36
|
}, z.core.$strip>;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
39
|
+
readonly emails: {
|
|
40
|
+
readonly send: {
|
|
41
|
+
readonly effect: "send";
|
|
42
|
+
readonly description: "Send one email to an address, or to a list of up to 50. Cannot be undone.";
|
|
43
|
+
readonly input: z.ZodObject<{
|
|
44
|
+
to: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
45
|
+
from: z.ZodOptional<z.ZodString>;
|
|
46
|
+
subject: z.ZodString;
|
|
47
|
+
html: z.ZodOptional<z.ZodString>;
|
|
48
|
+
text: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
readonly output: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
36
55
|
}>;
|
package/dist/connector.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { defineConnector } from "@sanoma-ai/workflows";
|
|
1
|
+
import { defineConnector, vendorInfo } from "@sanoma-ai/workflows";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
/**
|
|
4
|
-
* Resend's
|
|
5
|
-
*
|
|
4
|
+
* Resend's Broadcasts API (https://resend.com/docs/api-reference/broadcasts) and its one-email send
|
|
5
|
+
* (https://resend.com/docs/api-reference/emails/send-email).
|
|
6
6
|
*/
|
|
7
|
-
const lettermark = (fill) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="450 450 900 900"><path fill="${fill}" d="M1000.46 450C1174.77 450 1278.43 553.669 1278.43 691.282C1278.43 828.896 1174.77 932.563 1000.46 932.563H912.382L1350 1350H1040.82L707.794 1033.48C683.944 1011.47 672.936 985.781 672.935 963.765C672.935 932.572 694.959 905.049 737.161 893.122L908.712 847.244C973.85 829.812 1018.81 779.353 1018.81 713.298C1018.8 632.567 952.745 585.78 871.095 585.78H450V450H1000.46Z"/></svg>`;
|
|
8
|
-
/** Resend Broadcasts API: https://resend.com/docs/api-reference/broadcasts */
|
|
9
7
|
export const resendOps = defineConnector("resend", {
|
|
10
8
|
broadcast: {
|
|
11
9
|
create: {
|
|
@@ -27,10 +25,23 @@ export const resendOps = defineConnector("resend", {
|
|
|
27
25
|
output: z.object({ id: z.string(), status: z.enum(["queued", "sent"]) }),
|
|
28
26
|
},
|
|
29
27
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
emails: {
|
|
29
|
+
send: {
|
|
30
|
+
effect: "send",
|
|
31
|
+
description: "Send one email to an address, or to a list of up to 50. Cannot be undone.",
|
|
32
|
+
input: z
|
|
33
|
+
.object({
|
|
34
|
+
to: z.union([z.string().min(1), z.array(z.string().min(1)).min(1).max(50)]),
|
|
35
|
+
from: z.string().optional(),
|
|
36
|
+
subject: z.string().min(1),
|
|
37
|
+
html: z.string().optional(),
|
|
38
|
+
text: z.string().optional(),
|
|
39
|
+
})
|
|
40
|
+
.refine((email) => Boolean(email.html || email.text), {
|
|
41
|
+
message: "an email needs `html`, `text` or both, not empty",
|
|
42
|
+
}),
|
|
43
|
+
output: z.object({ id: z.string() }),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}, vendorInfo(import.meta.url));
|
|
36
47
|
//# sourceMappingURL=connector.js.map
|
package/dist/connector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mapp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EAAE;YACJ,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,2EAA2E;YACxF,KAAK,EAAE,CAAC;iBACL,MAAM,CAAC;gBACN,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;aAC5B,CAAC;iBACD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE;gBACpD,OAAO,EAAE,kDAAkD;aAC5D,CAAC;YACJ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACrC;KACF;CACF,EACD,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAC5B,CAAC"}
|
package/dist/driver.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export interface ResendDriverOptions {
|
|
|
3
3
|
timeoutMs?: number;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Calls Resend's Broadcasts API with the key in `RESEND_API_KEY`, read on
|
|
7
|
-
* `RESEND_FROM`, the sender of a broadcast whose input names none. The contract's `audience` is
|
|
6
|
+
* Calls Resend's Broadcasts API and its one-email send with the key in `RESEND_API_KEY`, read on
|
|
7
|
+
* every call, as is `RESEND_FROM`, the sender of a broadcast or email whose input names none. The contract's `audience` is
|
|
8
8
|
* Resend's `segment_id`: Resend renamed audiences to segments.
|
|
9
9
|
*/
|
|
10
10
|
export declare function resendDriver(options?: ResendDriverOptions): import("@sanoma-ai/workflows").Driver;
|
package/dist/driver.js
CHANGED
|
@@ -4,7 +4,7 @@ import { resendOps } from "./connector.js";
|
|
|
4
4
|
// Generated by `pnpm run generate` (openapi-ts.config.ts); never edited by hand.
|
|
5
5
|
import { client as generated } from "./generated/client.gen.js";
|
|
6
6
|
import { createClient } from "./generated/client/index.js";
|
|
7
|
-
import { broadcastsCreate, broadcastsGet, broadcastsSend } from "./generated/index.js";
|
|
7
|
+
import { broadcastsCreate, broadcastsGet, broadcastsSend, emailsSend } from "./generated/index.js";
|
|
8
8
|
/** The environment variables the driver reads, on every call. */
|
|
9
9
|
const env = z.object({
|
|
10
10
|
RESEND_API_KEY: z.string().describe("an API key"),
|
|
@@ -12,7 +12,7 @@ const env = z.object({
|
|
|
12
12
|
.string()
|
|
13
13
|
.min(1)
|
|
14
14
|
.optional()
|
|
15
|
-
.describe("the sender of a broadcast whose input has no `from`, such as `Acme <news@acme.example>`, on a domain verified in Resend"),
|
|
15
|
+
.describe("the sender of a broadcast or email whose input has no `from`, such as `Acme <news@acme.example>`, on a domain verified in Resend"),
|
|
16
16
|
});
|
|
17
17
|
/** Resend's error body. The spec declares none; the docs give `{ statusCode, name, message }`. */
|
|
18
18
|
const errorBody = z
|
|
@@ -54,16 +54,23 @@ function failure(op, timeoutMs) {
|
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
/** The broadcast in a reply Resend accepted: the spec leaves its id optional, and a proxy may answer instead. */
|
|
58
|
-
function
|
|
57
|
+
/** The broadcast or email in a reply Resend accepted: the spec leaves its id optional, and a proxy may answer instead. */
|
|
58
|
+
function replied(op, reply) {
|
|
59
59
|
if (reply.data?.id)
|
|
60
60
|
return reply.data;
|
|
61
61
|
const { status } = reply.response;
|
|
62
|
-
throw new DriverError(`resend: ${op} replied ${status} without
|
|
62
|
+
throw new DriverError(`resend: ${op} replied ${status} without an id`, { retryable: false, status });
|
|
63
|
+
}
|
|
64
|
+
/** The sender: the input's `from` (unless empty), else `RESEND_FROM`, read at the call; Resend requires one. */
|
|
65
|
+
function senderOf(op, from) {
|
|
66
|
+
const sender = from || process.env.RESEND_FROM;
|
|
67
|
+
if (sender)
|
|
68
|
+
return sender;
|
|
69
|
+
throw new DriverError(`resend: ${op} needs \`from\` in its input, or RESEND_FROM set`, { retryable: false });
|
|
63
70
|
}
|
|
64
71
|
/**
|
|
65
|
-
* Calls Resend's Broadcasts API with the key in `RESEND_API_KEY`, read on
|
|
66
|
-
* `RESEND_FROM`, the sender of a broadcast whose input names none. The contract's `audience` is
|
|
72
|
+
* Calls Resend's Broadcasts API and its one-email send with the key in `RESEND_API_KEY`, read on
|
|
73
|
+
* every call, as is `RESEND_FROM`, the sender of a broadcast or email whose input names none. The contract's `audience` is
|
|
67
74
|
* Resend's `segment_id`: Resend renamed audiences to segments.
|
|
68
75
|
*/
|
|
69
76
|
export function resendDriver(options = {}) {
|
|
@@ -76,7 +83,8 @@ export function resendDriver(options = {}) {
|
|
|
76
83
|
const api = createClient({
|
|
77
84
|
...generated.getConfig(),
|
|
78
85
|
auth: key,
|
|
79
|
-
// Resend documents Idempotency-Key for emails only; it is sent in case
|
|
86
|
+
// Resend documents Idempotency-Key for emails only (kept 24 hours); it is sent in case
|
|
87
|
+
// broadcasts honour it too.
|
|
80
88
|
headers: { "Idempotency-Key": call.idempotencyKey },
|
|
81
89
|
fetch: (input, init) => fetch(input, { ...init, signal: AbortSignal.timeout(timeoutMs) }),
|
|
82
90
|
});
|
|
@@ -86,12 +94,7 @@ export function resendDriver(options = {}) {
|
|
|
86
94
|
return defineDriver(resendOps, {
|
|
87
95
|
broadcast: {
|
|
88
96
|
create: async (input, call) => {
|
|
89
|
-
const from = input.from
|
|
90
|
-
if (!from) {
|
|
91
|
-
throw new DriverError("resend: broadcast.create needs `from` in its input, or RESEND_FROM set", {
|
|
92
|
-
retryable: false,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
97
|
+
const from = senderOf("broadcast.create", input.from);
|
|
95
98
|
const reply = await broadcastsCreate({
|
|
96
99
|
client: client("broadcast.create", call),
|
|
97
100
|
// `name` shows in Resend's dashboard only: it ties the broadcast to the call that made it.
|
|
@@ -103,13 +106,13 @@ export function resendDriver(options = {}) {
|
|
|
103
106
|
name: call.idempotencyKey,
|
|
104
107
|
},
|
|
105
108
|
});
|
|
106
|
-
return { id:
|
|
109
|
+
return { id: replied("broadcast.create", reply).id };
|
|
107
110
|
},
|
|
108
111
|
send: async ({ id }, call) => {
|
|
109
112
|
const api = client("broadcast.send", call);
|
|
110
113
|
// A replay of a send whose reply was lost must not send again: send only a broadcast that
|
|
111
114
|
// is still a draft or scheduled, and otherwise say where it is.
|
|
112
|
-
const { status } =
|
|
115
|
+
const { status } = replied("broadcast.send", await broadcastsGet({ client: api, path: { id } }));
|
|
113
116
|
if (status === "sent")
|
|
114
117
|
return { id, status: "sent" };
|
|
115
118
|
if (status === "queued")
|
|
@@ -121,7 +124,18 @@ export function resendDriver(options = {}) {
|
|
|
121
124
|
}
|
|
122
125
|
const reply = await broadcastsSend({ client: api, path: { id }, body: {} });
|
|
123
126
|
// Resend replies with the id only: it accepts the broadcast and sends it in the background.
|
|
124
|
-
return { id:
|
|
127
|
+
return { id: replied("broadcast.send", reply).id, status: "queued" };
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
emails: {
|
|
131
|
+
// The call's idempotency key makes a retry within 24 hours return the first email's id
|
|
132
|
+
// and send nothing; Resend refuses the key with another input (409, final).
|
|
133
|
+
send: async ({ to, from, subject, html, text }, call) => {
|
|
134
|
+
const reply = await emailsSend({
|
|
135
|
+
client: client("emails.send", call),
|
|
136
|
+
body: { to, from: senderOf("emails.send", from), subject, html, text },
|
|
137
|
+
});
|
|
138
|
+
return { id: replied("emails.send", reply).id };
|
|
125
139
|
},
|
|
126
140
|
},
|
|
127
141
|
}, { env });
|
package/dist/driver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAoB,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,iFAAiF;AACjF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAoB,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,iFAAiF;AACjF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOnG,iEAAiE;AACjE,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;IACjD,WAAW,EAAE,CAAC;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KAAK;qBACjB,CACF,CAAC;gBACJ,CAAC;gBACD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC5E,4FAA4F;gBAC5F,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,QAAiB,EAAE,CAAC;YAChF,CAAC;SACF;QACD,MAAM,EAAE;YACN,uFAAuF;YACvF,4EAA4E;YAC5E,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE;gBACtD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC;oBAC7B,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC;oBACnC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE;iBACvE,CAAC,CAAC;gBACH,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YAClD,CAAC;SACF;KACF,EACD,EAAE,GAAG,EAAE,CACR,CAAC;AACJ,CAAC"}
|
package/dist/fake.d.ts
CHANGED
|
@@ -7,12 +7,71 @@ export interface FakeResendBroadcast {
|
|
|
7
7
|
html: string;
|
|
8
8
|
status: "draft" | "sent";
|
|
9
9
|
}
|
|
10
|
+
export interface FakeResendEmail {
|
|
11
|
+
id: string;
|
|
12
|
+
to: string | string[];
|
|
13
|
+
from?: string;
|
|
14
|
+
subject: string;
|
|
15
|
+
html?: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
}
|
|
10
18
|
export interface FakeResendState extends Record<string, unknown> {
|
|
11
19
|
seq: number;
|
|
12
20
|
broadcasts: Record<string, FakeResendBroadcast>;
|
|
21
|
+
/** The emails `emails.send` sent, by id. */
|
|
22
|
+
emails: Record<string, FakeResendEmail>;
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
|
-
* An in-memory Resend for tests: broadcasts live in `state.broadcasts`,
|
|
16
|
-
* emailed.
|
|
25
|
+
* An in-memory Resend for tests: broadcasts live in `state.broadcasts`, the emails sent in
|
|
26
|
+
* `state.emails`, and nothing is emailed.
|
|
17
27
|
*/
|
|
18
|
-
export declare function fakeResend(options?: FakeOptions): import("@sanoma-ai/workflows/fake").Fake<FakeResendState, "
|
|
28
|
+
export declare function fakeResend(options?: FakeOptions): import("@sanoma-ai/workflows/fake").Fake<FakeResendState, import("@sanoma-ai/workflows").OpIdOf<"resend", {
|
|
29
|
+
readonly broadcast: {
|
|
30
|
+
readonly create: {
|
|
31
|
+
readonly effect: "write";
|
|
32
|
+
readonly description: "Create a broadcast to an audience. Nothing is sent.";
|
|
33
|
+
readonly input: import("zod").ZodObject<{
|
|
34
|
+
audience: import("zod").ZodString;
|
|
35
|
+
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
36
|
+
subject: import("zod").ZodString;
|
|
37
|
+
html: import("zod").ZodString;
|
|
38
|
+
}, import("zod/v4/core").$strip>;
|
|
39
|
+
readonly output: import("zod").ZodObject<{
|
|
40
|
+
id: import("zod").ZodString;
|
|
41
|
+
}, import("zod/v4/core").$strip>;
|
|
42
|
+
};
|
|
43
|
+
readonly send: {
|
|
44
|
+
readonly effect: "send";
|
|
45
|
+
readonly description: "Send a broadcast to every contact in its audience. Cannot be undone.";
|
|
46
|
+
readonly phrases: {
|
|
47
|
+
readonly expect: "broadcast {id} is sent";
|
|
48
|
+
};
|
|
49
|
+
readonly input: import("zod").ZodObject<{
|
|
50
|
+
id: import("zod").ZodString;
|
|
51
|
+
}, import("zod/v4/core").$strip>;
|
|
52
|
+
readonly output: import("zod").ZodObject<{
|
|
53
|
+
id: import("zod").ZodString;
|
|
54
|
+
status: import("zod").ZodEnum<{
|
|
55
|
+
queued: "queued";
|
|
56
|
+
sent: "sent";
|
|
57
|
+
}>;
|
|
58
|
+
}, import("zod/v4/core").$strip>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
readonly emails: {
|
|
62
|
+
readonly send: {
|
|
63
|
+
readonly effect: "send";
|
|
64
|
+
readonly description: "Send one email to an address, or to a list of up to 50. Cannot be undone.";
|
|
65
|
+
readonly input: import("zod").ZodObject<{
|
|
66
|
+
to: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
|
|
67
|
+
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
68
|
+
subject: import("zod").ZodString;
|
|
69
|
+
html: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
71
|
+
}, import("zod/v4/core").$strip>;
|
|
72
|
+
readonly output: import("zod").ZodObject<{
|
|
73
|
+
id: import("zod").ZodString;
|
|
74
|
+
}, import("zod/v4/core").$strip>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}>>;
|
package/dist/fake.js
CHANGED
|
@@ -2,12 +2,12 @@ import { DriverError } from "@sanoma-ai/workflows";
|
|
|
2
2
|
import { defineFake } from "@sanoma-ai/workflows/fake";
|
|
3
3
|
import { resendOps } from "./connector.js";
|
|
4
4
|
/**
|
|
5
|
-
* An in-memory Resend for tests: broadcasts live in `state.broadcasts`,
|
|
6
|
-
* emailed.
|
|
5
|
+
* An in-memory Resend for tests: broadcasts live in `state.broadcasts`, the emails sent in
|
|
6
|
+
* `state.emails`, and nothing is emailed.
|
|
7
7
|
*/
|
|
8
8
|
export function fakeResend(options = {}) {
|
|
9
9
|
return defineFake(resendOps, {
|
|
10
|
-
initial: () => ({ seq: 0, broadcasts: {} }),
|
|
10
|
+
initial: () => ({ seq: 0, broadcasts: {}, emails: {} }),
|
|
11
11
|
ops: (state) => ({
|
|
12
12
|
broadcast: {
|
|
13
13
|
create: async (input) => {
|
|
@@ -26,6 +26,13 @@ export function fakeResend(options = {}) {
|
|
|
26
26
|
return { id, status: "queued" };
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
+
emails: {
|
|
30
|
+
send: async (input) => {
|
|
31
|
+
const id = `em_${String(++state.seq).padStart(4, "0")}`;
|
|
32
|
+
state.emails[id] = { id, ...input };
|
|
33
|
+
return { id };
|
|
34
|
+
},
|
|
35
|
+
},
|
|
29
36
|
}),
|
|
30
37
|
}, options);
|
|
31
38
|
}
|
package/dist/fake.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake.js","sourceRoot":"","sources":["../src/fake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"fake.js","sourceRoot":"","sources":["../src/fake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA2B3C;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAO,GAAgB,EAAE;IAClD,OAAO,UAAU,CACf,SAAS,EACT;QACE,OAAO,EAAE,GAAoB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACxE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACf,SAAS,EAAE;gBACT,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;oBACtB,MAAM,EAAE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,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { broadcastsCreate, broadcastsGet, broadcastsSend, type Options } from "./sdk.gen.ts";
|
|
2
|
-
export type { BroadcastsCreateData, BroadcastsCreateResponse, BroadcastsCreateResponses, BroadcastsGetData, BroadcastsGetResponse, BroadcastsGetResponses, BroadcastsSendData, BroadcastsSendResponse, BroadcastsSendResponses, ClientOptions, CreateBroadcastOptions, CreateBroadcastResponseSuccess, GetBroadcastResponseSuccess, SendBroadcastOptions, SendBroadcastResponseSuccess, } from "./types.gen.ts";
|
|
1
|
+
export { broadcastsCreate, broadcastsGet, broadcastsSend, emailsSend, type Options } from "./sdk.gen.ts";
|
|
2
|
+
export type { Attachment, BroadcastsCreateData, BroadcastsCreateResponse, BroadcastsCreateResponses, BroadcastsGetData, BroadcastsGetResponse, BroadcastsGetResponses, BroadcastsSendData, BroadcastsSendResponse, BroadcastsSendResponses, ClientOptions, CreateBroadcastOptions, CreateBroadcastResponseSuccess, EmailsSendData, EmailsSendResponse, EmailsSendResponses, EmailTemplateInput, GetBroadcastResponseSuccess, SendBroadcastOptions, SendBroadcastResponseSuccess, SendEmailRequest, SendEmailResponse, Tag, } from "./types.gen.ts";
|
package/dist/generated/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from "./client/index.ts";
|
|
2
|
-
import type { BroadcastsCreateData, BroadcastsCreateResponses, BroadcastsGetData, BroadcastsGetResponses, BroadcastsSendData, BroadcastsSendResponses } from "./types.gen.ts";
|
|
2
|
+
import type { BroadcastsCreateData, BroadcastsCreateResponses, BroadcastsGetData, BroadcastsGetResponses, BroadcastsSendData, BroadcastsSendResponses, EmailsSendData, EmailsSendResponses } from "./types.gen.ts";
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -13,6 +13,10 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
13
13
|
*/
|
|
14
14
|
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Send an email
|
|
18
|
+
*/
|
|
19
|
+
export declare const emailsSend: <ThrowOnError extends boolean = true>(options?: Options<EmailsSendData, ThrowOnError>) => RequestResult<EmailsSendResponses, unknown, ThrowOnError>;
|
|
16
20
|
/**
|
|
17
21
|
* Create a broadcast
|
|
18
22
|
*/
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
import { client } from "./client.gen.js";
|
|
3
|
+
/**
|
|
4
|
+
* Send an email
|
|
5
|
+
*/
|
|
6
|
+
export const emailsSend = (options) => (options?.client ?? client).post({
|
|
7
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
8
|
+
url: "/emails",
|
|
9
|
+
...options,
|
|
10
|
+
headers: {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
...options?.headers,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
3
15
|
/**
|
|
4
16
|
* Create a broadcast
|
|
5
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.gen.js","sourceRoot":"","sources":["../../src/generated/sdk.gen.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.gen.js","sourceRoot":"","sources":["../../src/generated/sdk.gen.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA+BzC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAA+C,EACY,EAAE,CAC7D,CAAC,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC,IAAI,CAA6C;IAC3E,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,GAAG,EAAE,SAAS;IACd,GAAG,OAAO;IACV,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;QAClC,GAAG,OAAO,EAAE,OAAO;KACpB;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAqD,EACY,EAAE,CACnE,CAAC,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC,IAAI,CAAmD;IACjF,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,GAAG,EAAE,aAAa;IAClB,GAAG,OAAO;IACV,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;QAClC,GAAG,OAAO,EAAE,OAAO;KACpB;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAiD,EACa,EAAE,CAChE,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,GAAG,CAAgD;IAC5E,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,GAAG,EAAE,kBAAkB;IACvB,GAAG,OAAO;CACX,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAkD,EACa,EAAE,CACjE,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,IAAI,CAAiD;IAC9E,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,GAAG,EAAE,uBAAuB;IAC5B,GAAG,OAAO;IACV,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;QAClC,GAAG,OAAO,CAAC,OAAO;KACnB;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +1,107 @@
|
|
|
1
1
|
export type ClientOptions = {
|
|
2
2
|
baseUrl: "https://api.resend.com" | (string & {});
|
|
3
3
|
};
|
|
4
|
+
export type SendEmailRequest = {
|
|
5
|
+
/**
|
|
6
|
+
* Sender email address. To include a friendly name, use the format "Your Name <sender@domain.com>".
|
|
7
|
+
*/
|
|
8
|
+
from: string;
|
|
9
|
+
/**
|
|
10
|
+
* Recipient email address. For multiple addresses, send as an array of strings. Max 50.
|
|
11
|
+
*/
|
|
12
|
+
to: string | Array<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Email subject.
|
|
15
|
+
*/
|
|
16
|
+
subject: string;
|
|
17
|
+
/**
|
|
18
|
+
* Bcc recipient email address. For multiple addresses, send as an array of strings.
|
|
19
|
+
*/
|
|
20
|
+
bcc?: string | Array<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Cc recipient email address. For multiple addresses, send as an array of strings.
|
|
23
|
+
*/
|
|
24
|
+
cc?: string | Array<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
27
|
+
*/
|
|
28
|
+
reply_to?: string | Array<string>;
|
|
29
|
+
/**
|
|
30
|
+
* The HTML version of the message.
|
|
31
|
+
*/
|
|
32
|
+
html?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The plain text version of the message.
|
|
35
|
+
*/
|
|
36
|
+
text?: string;
|
|
37
|
+
template?: EmailTemplateInput & unknown;
|
|
38
|
+
/**
|
|
39
|
+
* Custom headers to add to the email.
|
|
40
|
+
*/
|
|
41
|
+
headers?: {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Schedule email to be sent later. The date should be in ISO 8601 format.
|
|
46
|
+
*/
|
|
47
|
+
scheduled_at?: string;
|
|
48
|
+
attachments?: Array<Attachment>;
|
|
49
|
+
tags?: Array<Tag>;
|
|
50
|
+
/**
|
|
51
|
+
* The topic ID to scope the email to. If the recipient is a contact and opted-in to the topic, the email is sent. If opted-out, the email is not sent. If the recipient is not a contact, the email is sent if the topic's default subscription is opt_in.
|
|
52
|
+
*/
|
|
53
|
+
topic_id?: string;
|
|
54
|
+
};
|
|
55
|
+
export type Attachment = {
|
|
56
|
+
/**
|
|
57
|
+
* Content of an attached file.
|
|
58
|
+
*/
|
|
59
|
+
content?: Blob | File;
|
|
60
|
+
/**
|
|
61
|
+
* Name of attached file.
|
|
62
|
+
*/
|
|
63
|
+
filename?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Path where the attachment file is hosted
|
|
66
|
+
*/
|
|
67
|
+
path?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Optional content type for the attachment, if not set it will be derived from the filename property
|
|
70
|
+
*/
|
|
71
|
+
content_type?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Content ID for embedding inline images using cid references (e.g., cid:image001).
|
|
74
|
+
*/
|
|
75
|
+
content_id?: string;
|
|
76
|
+
};
|
|
77
|
+
export type Tag = {
|
|
78
|
+
/**
|
|
79
|
+
* The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
80
|
+
*/
|
|
81
|
+
name?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The value of the email tag.It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.
|
|
84
|
+
*/
|
|
85
|
+
value?: string;
|
|
86
|
+
};
|
|
87
|
+
export type EmailTemplateInput = {
|
|
88
|
+
/**
|
|
89
|
+
* The id of the published email template.
|
|
90
|
+
*/
|
|
91
|
+
id: string;
|
|
92
|
+
/**
|
|
93
|
+
* Template variables object with key/value pairs.
|
|
94
|
+
*/
|
|
95
|
+
variables?: {
|
|
96
|
+
[key: string]: string | number;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export type SendEmailResponse = {
|
|
100
|
+
/**
|
|
101
|
+
* The ID of the sent email.
|
|
102
|
+
*/
|
|
103
|
+
id?: string;
|
|
104
|
+
};
|
|
4
105
|
export type CreateBroadcastOptions = {
|
|
5
106
|
/**
|
|
6
107
|
* Name of the broadcast.
|
|
@@ -141,6 +242,25 @@ export type SendBroadcastResponseSuccess = {
|
|
|
141
242
|
*/
|
|
142
243
|
id?: string;
|
|
143
244
|
};
|
|
245
|
+
export type EmailsSendData = {
|
|
246
|
+
body?: SendEmailRequest;
|
|
247
|
+
headers?: {
|
|
248
|
+
/**
|
|
249
|
+
* A unique identifier for the request to ensure emails are only sent once. [Learn more](https://resend.com/docs/dashboard/emails/idempotency-keys)
|
|
250
|
+
*/
|
|
251
|
+
"Idempotency-Key"?: string;
|
|
252
|
+
};
|
|
253
|
+
path?: never;
|
|
254
|
+
query?: never;
|
|
255
|
+
url: "/emails";
|
|
256
|
+
};
|
|
257
|
+
export type EmailsSendResponses = {
|
|
258
|
+
/**
|
|
259
|
+
* OK
|
|
260
|
+
*/
|
|
261
|
+
200: SendEmailResponse;
|
|
262
|
+
};
|
|
263
|
+
export type EmailsSendResponse = EmailsSendResponses[keyof EmailsSendResponses];
|
|
144
264
|
export type BroadcastsCreateData = {
|
|
145
265
|
body?: CreateBroadcastOptions;
|
|
146
266
|
path?: never;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resend broadcasts
|
|
3
|
-
* (`resendDriver`), which reads its credentials when called, its fake
|
|
4
|
-
* which each sandbox run makes its own, and its steps for Gherkin tests
|
|
2
|
+
* Resend broadcasts, `broadcast.create` and `broadcast.send`, and one email, `emails.send`. It
|
|
3
|
+
* carries its live driver (`resendDriver`), which reads its credentials when called, its fake
|
|
4
|
+
* (`fakeResend`), of which each sandbox run makes its own, and its steps for Gherkin tests
|
|
5
|
+
* (`resendSteps`).
|
|
5
6
|
*/
|
|
6
7
|
export declare const resend: import("@sanoma-ai/workflows").Connector<"resend", {
|
|
7
8
|
readonly broadcast: {
|
|
@@ -36,4 +37,20 @@ export declare const resend: import("@sanoma-ai/workflows").Connector<"resend",
|
|
|
36
37
|
}, import("zod/v4/core").$strip>;
|
|
37
38
|
};
|
|
38
39
|
};
|
|
40
|
+
readonly emails: {
|
|
41
|
+
readonly send: {
|
|
42
|
+
readonly effect: "send";
|
|
43
|
+
readonly description: "Send one email to an address, or to a list of up to 50. Cannot be undone.";
|
|
44
|
+
readonly input: import("zod").ZodObject<{
|
|
45
|
+
to: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
|
|
46
|
+
from: import("zod").ZodOptional<import("zod").ZodString>;
|
|
47
|
+
subject: import("zod").ZodString;
|
|
48
|
+
html: import("zod").ZodOptional<import("zod").ZodString>;
|
|
49
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
|
+
}, import("zod/v4/core").$strip>;
|
|
51
|
+
readonly output: import("zod").ZodObject<{
|
|
52
|
+
id: import("zod").ZodString;
|
|
53
|
+
}, import("zod/v4/core").$strip>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
39
56
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ import { resendDriver } from "./driver.js";
|
|
|
4
4
|
import { fakeResend } from "./fake.js";
|
|
5
5
|
import { resendSteps } from "./steps.js";
|
|
6
6
|
/**
|
|
7
|
-
* Resend broadcasts
|
|
8
|
-
* (`resendDriver`), which reads its credentials when called, its fake
|
|
9
|
-
* which each sandbox run makes its own, and its steps for Gherkin tests
|
|
7
|
+
* Resend broadcasts, `broadcast.create` and `broadcast.send`, and one email, `emails.send`. It
|
|
8
|
+
* carries its live driver (`resendDriver`), which reads its credentials when called, its fake
|
|
9
|
+
* (`fakeResend`), of which each sandbox run makes its own, and its steps for Gherkin tests
|
|
10
|
+
* (`resendSteps`).
|
|
10
11
|
*/
|
|
11
12
|
export const resend = withSetup(resendOps, { driver: resendDriver, fake: fakeResend, steps: resendSteps });
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC"}
|
package/dist/steps.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resend's steps for Gherkin tests: a draft broadcast before the run (named `broadcast`, so an
|
|
3
|
-
* operation's own test can use `$broadcast.id`), Resend failing the next send,
|
|
4
|
-
*
|
|
3
|
+
* operation's own test can use `$broadcast.id`), Resend failing the next send, a broadcast the
|
|
4
|
+
* run sent, found by its subject among those seeded and created, and an email the run sent to an
|
|
5
|
+
* address, alone or in its list.
|
|
5
6
|
*/
|
|
6
7
|
export declare const resendSteps: import("@sanoma-ai/workflows").Steps;
|
package/dist/steps.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { defineSteps } from "@sanoma-ai/workflows";
|
|
2
2
|
import { resendOps } from "./connector.js";
|
|
3
3
|
const { create, send } = resendOps.broadcast;
|
|
4
|
+
const email = resendOps.emails.send;
|
|
4
5
|
/**
|
|
5
6
|
* Resend's steps for Gherkin tests: a draft broadcast before the run (named `broadcast`, so an
|
|
6
|
-
* operation's own test can use `$broadcast.id`), Resend failing the next send,
|
|
7
|
-
*
|
|
7
|
+
* operation's own test can use `$broadcast.id`), Resend failing the next send, a broadcast the
|
|
8
|
+
* run sent, found by its subject among those seeded and created, and an email the run sent to an
|
|
9
|
+
* address, alone or in its list.
|
|
8
10
|
*/
|
|
9
11
|
export const resendSteps = defineSteps("resend", ({ given, then }) => {
|
|
10
12
|
given("a Resend broadcast {string}", (subject) => ({
|
|
@@ -28,5 +30,15 @@ export const resendSteps = defineSteps("resend", ({ given, then }) => {
|
|
|
28
30
|
return `the Resend broadcast "${subject}" (${ids.join(", ")}) was not sent`;
|
|
29
31
|
},
|
|
30
32
|
}));
|
|
33
|
+
then("a Resend email to {string} is sent", (to) => ({
|
|
34
|
+
op: email,
|
|
35
|
+
called: true,
|
|
36
|
+
check: (run) => {
|
|
37
|
+
const sent = run.calls(email).map((c) => c.input.to);
|
|
38
|
+
if (sent.some((addresses) => [addresses].flat().includes(to)))
|
|
39
|
+
return undefined;
|
|
40
|
+
return `no Resend email to ${to} was sent${sent.length ? `; the run sent to ${JSON.stringify(sent)}` : ""}`;
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
31
43
|
});
|
|
32
44
|
//# sourceMappingURL=steps.js.map
|
package/dist/steps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC;AAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;IACnE,KAAK,CAAC,6BAA6B,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC;QACzD,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,EAAE;QACrD,EAAE,EAAE,WAAW;KAChB,CAAC,CAAC,CAAC;IACJ,KAAK,CAAC,2BAA2B,EAAE,GAAG,EAAE,CAAC,CAAC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EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAC;YAChF,OAAO,sBAAsB,EAAE,YAAY,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC9G,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Feature: Resend emails
|
|
2
|
+
One email, to an address or a list of them. Each scenario runs on the fake and on Resend's
|
|
3
|
+
recorded replies (test/fixtures/, named after the scenario), unless tagged @fake-only.
|
|
4
|
+
|
|
5
|
+
Scenario: Send an email
|
|
6
|
+
When resend.emails.send is called with
|
|
7
|
+
| to | delivered@resend.dev |
|
|
8
|
+
| from | Sanoma test <onboarding@resend.dev> |
|
|
9
|
+
| subject | Following up |
|
|
10
|
+
| html | <p>Hello</p> |
|
|
11
|
+
| text | Hello |
|
|
12
|
+
Then a Resend email to "delivered@resend.dev" is sent
|
|
13
|
+
|
|
14
|
+
@fake-only
|
|
15
|
+
Scenario: Send an email to a list
|
|
16
|
+
When resend.emails.send is called with
|
|
17
|
+
"""
|
|
18
|
+
{ "to": ["ada@example.com", "grace@example.com"], "subject": "Following up", "text": "Hello" }
|
|
19
|
+
"""
|
|
20
|
+
Then a Resend email to "grace@example.com" is sent
|
package/logo-dark.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="450 450 900 900"><path fill="#FDFDFD" d="M1000.46 450C1174.77 450 1278.43 553.669 1278.43 691.282C1278.43 828.896 1174.77 932.563 1000.46 932.563H912.382L1350 1350H1040.82L707.794 1033.48C683.944 1011.47 672.936 985.781 672.935 963.765C672.935 932.572 694.959 905.049 737.161 893.122L908.712 847.244C973.85 829.812 1018.81 779.353 1018.81 713.298C1018.8 632.567 952.745 585.78 871.095 585.78H450V450H1000.46Z"/></svg>
|
package/logo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="450 450 900 900"><path fill="black" d="M1000.46 450C1174.77 450 1278.43 553.669 1278.43 691.282C1278.43 828.896 1174.77 932.563 1000.46 932.563H912.382L1350 1350H1040.82L707.794 1033.48C683.944 1011.47 672.936 985.781 672.935 963.765C672.935 932.572 694.959 905.049 737.161 893.122L908.712 847.244C973.85 829.812 1018.81 779.353 1018.81 713.298C1018.8 632.567 952.745 585.78 871.095 585.78H450V450H1000.46Z"/></svg>
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanoma-ai/connector-resend",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Resend Broadcasts
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Resend Broadcasts and email operations for Sanoma workflows",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"connector",
|
|
7
7
|
"email",
|
|
8
8
|
"newsletter",
|
|
9
9
|
"resend",
|
|
10
|
-
"sanoma"
|
|
10
|
+
"sanoma",
|
|
11
|
+
"sanoma-connector"
|
|
11
12
|
],
|
|
12
13
|
"homepage": "https://github.com/Sanoma-AI/sanoma/tree/main/connectors/resend#readme",
|
|
13
14
|
"bugs": "https://github.com/Sanoma-AI/sanoma/issues",
|
|
@@ -20,6 +21,8 @@
|
|
|
20
21
|
"files": [
|
|
21
22
|
"dist",
|
|
22
23
|
"features",
|
|
24
|
+
"logo.svg",
|
|
25
|
+
"logo-dark.svg",
|
|
23
26
|
"README.md",
|
|
24
27
|
"LICENSE"
|
|
25
28
|
],
|
|
@@ -45,17 +48,22 @@
|
|
|
45
48
|
"access": "public"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
|
-
"@sanoma-ai/workflows": "0.4.
|
|
51
|
+
"@sanoma-ai/workflows": "0.4.2",
|
|
49
52
|
"msw": "^3.0.2",
|
|
50
53
|
"zod": "^4.6.5"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
53
|
-
"@sanoma-ai/workflows": "^0.4.
|
|
56
|
+
"@sanoma-ai/workflows": "^0.4.2",
|
|
54
57
|
"zod": "^4"
|
|
55
58
|
},
|
|
56
59
|
"engines": {
|
|
57
60
|
"node": ">=24"
|
|
58
61
|
},
|
|
62
|
+
"sanoma": {
|
|
63
|
+
"title": "Resend",
|
|
64
|
+
"logo": "logo.svg",
|
|
65
|
+
"logoDark": "logo-dark.svg"
|
|
66
|
+
},
|
|
59
67
|
"scripts": {
|
|
60
68
|
"build": "tsc -p tsconfig.build.json",
|
|
61
69
|
"clean": "rm -rf dist",
|