@sanoma-ai/connector-resend 0.4.7 → 0.5.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sanoma-ai/connector-resend
2
2
 
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).
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), and the [sending domain](#sending-domain) they send from, as a resource a data file declares.
4
4
 
5
5
  ## Usage
6
6
 
@@ -22,23 +22,68 @@ defineWorkflow({
22
22
  // ...
23
23
  uses: [resend.broadcast.create, resend.broadcast.send],
24
24
  run: async (ctx, input) => {
25
- const email = await ctx.resend.broadcast.create({ audience: "newsletter", subject: input.title, html: input.body });
25
+ const email = await ctx.resend.broadcast.create({
26
+ audience: "newsletter",
27
+ from: "Acme <news@acme.example>",
28
+ subject: input.title,
29
+ html: input.body,
30
+ });
26
31
  return ctx.resend.broadcast.send({ id: email.id });
27
32
  },
28
33
  });
29
34
  ```
30
35
 
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 }`:
36
+ `emails.send` takes `to` (an address, or a list of 1 to 50), `from` (optional, see below), `subject`, and `html`, `text` or both (Resend makes the text from the HTML when there is none), and returns the email's `{ id }`:
32
37
 
33
38
  ```ts
34
39
  defineWorkflow({
35
40
  // ...
36
41
  uses: [resend.emails.send],
37
42
  run: async (ctx, input) =>
38
- ctx.resend.emails.send({ to: input.email, subject: "Following up", text: `Hi ${input.name},…` }),
43
+ ctx.resend.emails.send({
44
+ to: input.email,
45
+ from: "Acme <hello@acme.example>",
46
+ subject: "Following up",
47
+ text: `Hi ${input.name},…`,
48
+ }),
39
49
  });
40
50
  ```
41
51
 
52
+ ## Sending domain
53
+
54
+ `resend.domain`, from `@sanoma-ai/connector-resend/resources`, is a domain Resend sends from, which a data file declares. Its `dns_records` are the records the domain's zone must hold, in the shape `dnsRecord` (from `@sanoma-ai/workflows`) gives them, so a zone's record set can take them whole, as `cloudflare.records` (in `@sanoma-ai/connector-cloudflare`) does through `from: "dns_records"`:
55
+
56
+ ```ts
57
+ // resources/mail.ts
58
+ import { cloudflare } from "@sanoma-ai/connector-cloudflare/resources";
59
+ import { resend } from "@sanoma-ai/connector-resend/resources";
60
+
61
+ export const mail = resend.domain({ name: "sanoma.work" });
62
+ export const mailDns = cloudflare.records({ zone: "sanoma.work", name: "resend", records: mail });
63
+ ```
64
+
65
+ | Field | Who sets it | What it is |
66
+ | -------------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | `name` | declared (identity) | The domain, in lower case: `example.com`, or a subdomain such as `mail.example.com` (Resend recommends one). Apply finds a domain of that name in the account and binds it. |
68
+ | `region` | declared, optional | Where Resend sends from: `us-east-1` (Resend's default), `eu-west-1`, `sa-east-1` or `ap-northeast-1`. |
69
+ | `custom_return_path` | declared, optional | The Return-Path subdomain, `send` by default (`send.example.com`). A read takes it from the name of the domain's SPF record; one none shows is not drift. |
70
+ | `id` | Resend | The domain's id, which the binding keeps. |
71
+ | `status` | Resend | `not_started`, `pending`, `verified`, `failed`, `temporary_failure`, `partially_verified` or `partially_failed`. |
72
+ | `records` | Resend | The DNS records Resend asks for, as Resend gives them (`record`, `name`, `type`, `value`, `ttl`, `status`, `priority`). |
73
+ | `dns_records` | Resend | The same records as a zone holds them: `{ type, name, content, priority?, ttl }`, each `name` in full and in lower case with no trailing dot, a TXT record's text without quotes, `ttl` 1 for Resend's `Auto`. |
74
+
75
+ `name`, `region` and `custom_return_path` cannot change: a declaration that changes one plans a replace, which deletes the domain (Resend holds one domain of a name) and makes it again, with a new DKIM key, so new records; apply asks first.
76
+
77
+ Apply creates the domain, asks Resend to verify it at once, and reads it. Resend keeps checking for up to 72 hours, so the records the same apply writes a few seconds later verify it.
78
+
79
+ A domain is declared `verified`: any other status (`partially_verified` too) is drift (`status: verified → pending`), and apply plans an `update`, which asks Resend to verify it again.
80
+
81
+ A create tried again after its reply was lost finds the name registered already, and takes the domain of that name in the account, unless its region or Return-Path is not the one declared (refused, `conflict`). When another account holds it, the create is refused (`registered`): [claim it](https://resend.com/docs/dashboard/domains/claim) in Resend's dashboard.
82
+
83
+ An update approved while the domain was pending, which finds Resend has verified it since, is done. A replace that deleted the domain and then failed (`replace_incomplete` when its create failed, naming the deleted domain) finishes when tried again: the domain is gone, so it makes it, taking the one the failed try made.
84
+
85
+ Domains need a full-access API key: Resend answers a sending-only key's domain calls 401 `restricted_api_key`, which the driver refuses, saying so. Resend's free plan has 3 domains. Later: TLS (`tls`), open and click tracking and their subdomain, and receiving, which the type does not declare yet (Resend's defaults hold; a domain with any of them on has their records among `records` and `dns_records` too).
86
+
42
87
  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.
43
88
 
44
89
  ## Driver
@@ -53,7 +98,7 @@ export default defineConfig({ workflows, connectors: [resend], policy });
53
98
 
54
99
  `./driver` (`resendDriver`; `resendDriver({ timeoutMs })`, 15 s by default) and `./fake` (`fakeResend`) are internal entries, for tests.
55
100
 
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.
101
+ `audience` is Resend's `segment_id` (Resend renamed audiences to segments). `from`, for a broadcast or an email, is the input's, a sender on a domain verified in Resend, else the deprecated `RESEND_FROM` in the environment; Resend requires one, and the driver refuses a call with neither, before calling Resend. `broadcast.send` returns `status: "queued"` when it sends: Resend replies with the id only and sends in the background.
57
102
 
58
103
  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.
59
104
 
@@ -61,12 +106,12 @@ The client is generated by [Hey API](https://heyapi.dev) from Resend's [OpenAPI
61
106
 
62
107
  It reads this on every call, never when the config loads:
63
108
 
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. |
109
+ | Variable | What it is |
110
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
111
+ | `RESEND_API_KEY` | A Resend API key: a full-access one for [sending domains](#sending-domain), else sending access. |
112
+ | `RESEND_FROM` | Deprecated ([sanoma#531](https://github.com/Sanoma-AI/sanoma/issues/531)): the sender of a broadcast or email whose input has no `from`. |
68
113
 
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.
114
+ 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. A send that takes `RESEND_FROM` logs a warning, once a process: pass `from` instead. The driver declares both in its `env` ([Credentials](https://www.npmjs.com/package/@sanoma-ai/workflows#credentials)): the worker starts without the key, warning, and the app's connector page shows their status and lets you set them.
70
115
 
71
116
  ### Idempotency
72
117
 
@@ -74,7 +119,7 @@ Resend documents `Idempotency-Key` for emails only, not broadcasts. `emails.send
74
119
 
75
120
  ### Errors and retries
76
121
 
77
- A 408, a 429 (except `daily_quota_exceeded` and `monthly_quota_exceeded`), a 409 `concurrent_idempotent_requests` (a request with the same key still in flight), a 5xx, a timeout (15 s; `timeoutMs` changes it) or no reply is retryable; any other 4xx is not. `status` and `vendorCode` (Resend's error `name`) are kept. Resend allows 10 requests per second per team.
122
+ A 408, a 429 (except `daily_quota_exceeded` and `monthly_quota_exceeded`), a 409 `concurrent_idempotent_requests` (a request with the same key still in flight) or `resource_locked` (another request on the same resource), a 5xx, a timeout (15 s; `timeoutMs` changes it) or no reply is retryable; any other 4xx is not. `status` and `vendorCode` (Resend's error `name`) are kept. Resend allows 10 requests per second per team.
78
123
 
79
124
  ### Plan
80
125
 
@@ -90,22 +135,31 @@ SANOMA_LIVE=1 RESEND_API_KEY=re_... RESEND_TEST_AUDIENCE=<segment id> RESEND_TES
90
135
 
91
136
  A recording loses ids, addresses, the sender's domain and keys. The error cases, and the broadcasts that are no longer drafts, only replay.
92
137
 
138
+ The sending domain's replies (`features/domain.feature`'s fixtures and `domain-restricted-key.json`) are **written from Resend's API reference, not recorded**: no account was at hand when the type was written, so a reply the reference gets wrong is wrong here too, and the first live run re-records them. That run needs a full-access key and a throwaway domain you own, which it creates and deletes (one of the free plan's 3): put the domain in place of `example.com` in `features/domain.feature` for the run, and in `RESEND_TEST_DOMAIN`, which the scrub turns back into `example.com` (with each DKIM key's `p=…` as `p=redacted`), then put the feature back:
139
+
140
+ ```sh
141
+ SANOMA_LIVE=1 SANOMA_RECORD=1 RESEND_API_KEY=re_... RESEND_TEST_AUDIENCE=<segment id> RESEND_TEST_DOMAIN=<domain> pnpm vitest run connectors/resend/test/features.test.ts
142
+ ```
143
+
144
+ It checks what the reference leaves open: whether Resend names a subdomain's records relative to the zone (`send.mail`) or to the domain (`send`), the read's TXT quoting, and the 403 a name registered already gets. The driver's domain tests only replay.
145
+
93
146
  ## Steps and features
94
147
 
95
148
  The connector carries steps for [scenarios](https://github.com/Sanoma-AI/sanoma/blob/main/packages/workflows/README.md#steps-a-connector-ships) (`resendSteps`, attached with `withSetup`), which a company's scenario can use beside the generic steps and other connectors' ones:
96
149
 
97
- | Keyword | Step | What it does |
98
- | ------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
99
- | Given | `a Resend broadcast {string}` | Seeds a draft broadcast with that subject through `resend.broadcast.create`, named `broadcast` (`$broadcast.id`) |
100
- | Given | `Resend fails to send once` | The next `resend.broadcast.send` fails (`failNext`) |
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 |
150
+ | Keyword | Step | What it does |
151
+ | ------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
152
+ | Given | `a Resend broadcast {string}` | Seeds a draft broadcast with that subject through `resend.broadcast.create`, named `broadcast` (`$broadcast.id`) |
153
+ | Given | `a Resend domain {string}` | Seeds a sending domain of that name through `resend.domain.create`, asked to verify, named `domain` (`$domain.id`) |
154
+ | Given | `Resend fails to send once` | The next `resend.broadcast.send` fails (`failNext`) |
155
+ | Then | `the Resend broadcast {string} is sent` | The broadcast with that subject, seeded or created by the run, was sent |
156
+ | Then | `a Resend email to {string} is sent` | The run sent an email to that address, alone or in its list |
103
157
 
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/`.
158
+ `features/broadcast.feature` creates and sends a broadcast, `features/emails.feature` sends an email, and `features/domain.feature` creates, reads, imports, plans and deletes a sending domain, with these steps and the generic ones for an operation's own test, on the fake and on Resend's replies (`create-and-send.json`, `send-an-email.json`, and the domain's, written from the reference): `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/`.
105
159
 
106
160
  ## Testing
107
161
 
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`.
162
+ `@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), `state.domains` (the sending domains, by id, as Resend gives them) and `calls`.
109
163
 
110
164
  ```ts
111
165
  import { withSetup } from "@sanoma-ai/workflows";
@@ -130,8 +184,14 @@ Like Resend, the fake refuses to send a broadcast twice, unless the second call
130
184
  - `fake.rateLimit("resend.broadcast.send")` throws a `DriverError` with status 429.
131
185
  - `const release = fake.hold("resend.broadcast.send")` makes the call wait until `release()`.
132
186
 
187
+ A domain it makes has a DKIM key made from its id, an MX record `feedback-smtp.<region>.amazonses.com` (priority 10) and an SPF TXT record, named relative to the zone as Resend names them (the fake takes the zone to be the last two labels). Asked to verify, it stays `pending`, as at Resend until the zone holds the records: `fake.verifyDomain(id)` makes it and its records `verified`, `fake.failDomain(id)` `failed`. Like Resend, it holds one domain of a name. It neither takes `RESEND_FROM` for a send with no `from` nor refuses one, as the driver does.
188
+
133
189
  `fake.reset()` empties it between tests. Pass `{ calls }` with one array to several fakes to see their calls in one order.
134
190
 
135
191
  [`@sanoma-ai/testing`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md) (in the sanoma repository, not published) has `startTestWorker` and `testDatabaseUrl` to run a test's worker with the fake on a database of its own.
136
192
 
193
+ ## Changes
194
+
195
+ - 0.5.0: the resource type `resend.domain`. `RESEND_FROM` is deprecated: it still stands in for a missing `from`, warning once, and retires once `login.from` exists (sanoma#531), so pass `from`. It needs `@sanoma-ai/workflows` 0.10.5 or later, for `from` references.
196
+
137
197
  License: FSL-1.1-ALv2.
@@ -1,9 +1,119 @@
1
1
  import { z } from "zod";
2
+ /** The regions Resend sends from (https://resend.com/docs/api-reference/domains/create-domain). */
3
+ declare const REGIONS: readonly ["us-east-1", "eu-west-1", "sa-east-1", "ap-northeast-1"];
4
+ export type Region = (typeof REGIONS)[number];
5
+ /** The region a domain sends from when its declaration names none: Resend's default. */
6
+ export declare const DEFAULT_REGION = "us-east-1";
7
+ /** The Return-Path subdomain when a declaration names none: Resend's default (`send.example.com`). */
8
+ export declare const DEFAULT_RETURN_PATH = "send";
9
+ /** A domain's status at Resend: `verified` once its DNS records are found, the rest until then or when they are lost. */
10
+ declare const STATUSES: readonly ["not_started", "pending", "verified", "failed", "temporary_failure", "partially_verified", "partially_failed"];
11
+ export type DomainStatus = (typeof STATUSES)[number];
12
+ /** A DNS record as Resend gives it: its own fields, its name as Resend writes it. */
13
+ export declare const resendRecord: z.ZodObject<{
14
+ record: z.ZodString;
15
+ name: z.ZodString;
16
+ type: z.ZodString;
17
+ value: z.ZodString;
18
+ ttl: z.ZodOptional<z.ZodString>;
19
+ status: z.ZodOptional<z.ZodString>;
20
+ priority: z.ZodOptional<z.ZodNumber>;
21
+ }, z.core.$strip>;
2
22
  /**
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).
23
+ * `resend.domain({ name, region?, custom_return_path? })`: a domain Resend sends from. Apply
24
+ * creates it and asks Resend to verify it, which Resend keeps checking for 72 hours; its
25
+ * `dns_records` are what the zone must hold, which `cloudflare.records` takes (`from:
26
+ * "dns_records"`). A domain is declared verified, so one Resend has not verified is drift, and
27
+ * apply asks Resend to verify it again.
28
+ */
29
+ export declare const domain: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
30
+ name: z.ZodString;
31
+ region: z.ZodOptional<z.ZodEnum<{
32
+ "ap-northeast-1": "ap-northeast-1";
33
+ "eu-west-1": "eu-west-1";
34
+ "sa-east-1": "sa-east-1";
35
+ "us-east-1": "us-east-1";
36
+ }>>;
37
+ custom_return_path: z.ZodOptional<z.ZodString>;
38
+ id: z.ZodOptional<z.ZodString>;
39
+ status: z.ZodOptional<z.ZodEnum<{
40
+ failed: "failed";
41
+ not_started: "not_started";
42
+ partially_failed: "partially_failed";
43
+ partially_verified: "partially_verified";
44
+ pending: "pending";
45
+ temporary_failure: "temporary_failure";
46
+ verified: "verified";
47
+ }>>;
48
+ records: z.ZodOptional<z.ZodArray<z.ZodObject<{
49
+ record: z.ZodString;
50
+ name: z.ZodString;
51
+ type: z.ZodString;
52
+ value: z.ZodString;
53
+ ttl: z.ZodOptional<z.ZodString>;
54
+ status: z.ZodOptional<z.ZodString>;
55
+ priority: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strip>>>;
57
+ dns_records: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
+ type: z.ZodEnum<{
59
+ CAA: "CAA";
60
+ CNAME: "CNAME";
61
+ MX: "MX";
62
+ TXT: "TXT";
63
+ }>;
64
+ name: z.ZodString;
65
+ content: z.ZodString;
66
+ priority: z.ZodOptional<z.ZodNumber>;
67
+ ttl: z.ZodOptional<z.ZodNumber>;
68
+ }, z.core.$strip>>>;
69
+ }, z.core.$strip>, "resend.domain", {}, true>;
70
+ /**
71
+ * Resend's Broadcasts API (https://resend.com/docs/api-reference/broadcasts), its one-email send
72
+ * (https://resend.com/docs/api-reference/emails/send-email) and its sending domains, the resource
73
+ * type `resend.domain` (https://resend.com/docs/api-reference/domains).
5
74
  */
6
75
  export declare const resendOps: import("@sanoma-ai/workflows").Connector<"resend", {
76
+ readonly domain: import("@sanoma-ai/workflows").Resource<z.ZodObject<{
77
+ name: z.ZodString;
78
+ region: z.ZodOptional<z.ZodEnum<{
79
+ "ap-northeast-1": "ap-northeast-1";
80
+ "eu-west-1": "eu-west-1";
81
+ "sa-east-1": "sa-east-1";
82
+ "us-east-1": "us-east-1";
83
+ }>>;
84
+ custom_return_path: z.ZodOptional<z.ZodString>;
85
+ id: z.ZodOptional<z.ZodString>;
86
+ status: z.ZodOptional<z.ZodEnum<{
87
+ failed: "failed";
88
+ not_started: "not_started";
89
+ partially_failed: "partially_failed";
90
+ partially_verified: "partially_verified";
91
+ pending: "pending";
92
+ temporary_failure: "temporary_failure";
93
+ verified: "verified";
94
+ }>>;
95
+ records: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
+ record: z.ZodString;
97
+ name: z.ZodString;
98
+ type: z.ZodString;
99
+ value: z.ZodString;
100
+ ttl: z.ZodOptional<z.ZodString>;
101
+ status: z.ZodOptional<z.ZodString>;
102
+ priority: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$strip>>>;
104
+ dns_records: z.ZodOptional<z.ZodArray<z.ZodObject<{
105
+ type: z.ZodEnum<{
106
+ CAA: "CAA";
107
+ CNAME: "CNAME";
108
+ MX: "MX";
109
+ TXT: "TXT";
110
+ }>;
111
+ name: z.ZodString;
112
+ content: z.ZodString;
113
+ priority: z.ZodOptional<z.ZodNumber>;
114
+ ttl: z.ZodOptional<z.ZodNumber>;
115
+ }, z.core.$strip>>>;
116
+ }, z.core.$strip>, "resend.domain", {}, true>;
7
117
  readonly broadcast: {
8
118
  readonly create: {
9
119
  readonly effect: "write";
@@ -53,3 +163,4 @@ export declare const resendOps: import("@sanoma-ai/workflows").Connector<"resend
53
163
  };
54
164
  };
55
165
  }>;
166
+ export {};
package/dist/connector.js CHANGED
@@ -1,17 +1,102 @@
1
- import { defineConnector, vendorInfo } from "@sanoma-ai/workflows";
1
+ import { compareDeclared, defineConnector, defineResource, dnsRecord, vendorInfo } from "@sanoma-ai/workflows";
2
+ import { DOMAIN_NAME } from "@sanoma-ai/workflows/shared";
2
3
  import { z } from "zod";
4
+ /** The regions Resend sends from (https://resend.com/docs/api-reference/domains/create-domain). */
5
+ const REGIONS = ["us-east-1", "eu-west-1", "sa-east-1", "ap-northeast-1"];
6
+ /** The region a domain sends from when its declaration names none: Resend's default. */
7
+ export const DEFAULT_REGION = "us-east-1";
8
+ /** The Return-Path subdomain when a declaration names none: Resend's default (`send.example.com`). */
9
+ export const DEFAULT_RETURN_PATH = "send";
10
+ /** A domain's status at Resend: `verified` once its DNS records are found, the rest until then or when they are lost. */
11
+ const STATUSES = [
12
+ "not_started",
13
+ "pending",
14
+ "verified",
15
+ "failed",
16
+ "temporary_failure",
17
+ "partially_verified",
18
+ "partially_failed",
19
+ ];
20
+ /** A DNS record as Resend gives it: its own fields, its name as Resend writes it. */
21
+ export const resendRecord = z.object({
22
+ record: z.string().describe("What it is for: `SPF` and `DKIM` for sending, `Receiving`, `Tracking`, `TrackingCAA`"),
23
+ name: z.string(),
24
+ type: z.string(),
25
+ value: z.string(),
26
+ ttl: z.string().optional(),
27
+ status: z.string().optional(),
28
+ priority: z.number().int().optional(),
29
+ });
30
+ /** A sending domain as the operations read it: what a data file declares, and what Resend sets. */
31
+ const domainSchema = z.object({
32
+ name: z
33
+ .string()
34
+ .regex(DOMAIN_NAME, "a domain name in lower case, such as `example.com` or `mail.example.com`")
35
+ .describe("The domain to send from, such as `example.com`, or a subdomain such as `mail.example.com`"),
36
+ region: z
37
+ .enum(REGIONS)
38
+ .optional()
39
+ .describe("Where Resend sends from: `us-east-1` (the default), `eu-west-1`, `sa-east-1` or `ap-northeast-1`"),
40
+ custom_return_path: z
41
+ .string()
42
+ .regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, "one DNS label in lower case, such as `send`")
43
+ .optional()
44
+ .describe("The Return-Path subdomain, `send` by default (`send.example.com`)"),
45
+ id: z.string().optional().describe("The domain's id at Resend"),
46
+ status: z.enum(STATUSES).optional().describe("Whether Resend found its DNS records: `verified` once it has"),
47
+ records: z.array(resendRecord).optional().describe("The DNS records Resend asks for, as Resend gives them"),
48
+ dns_records: z
49
+ .array(dnsRecord)
50
+ .optional()
51
+ .describe("The same records as a zone holds them: full lower-case names, TXT text unquoted, ttl 1 for automatic"),
52
+ });
53
+ /** A domain's fields: what Resend sets, and what it cannot change in place. */
54
+ const fields = {
55
+ immutable: ["name", "region", "custom_return_path"],
56
+ vendorOwned: ["id", "status", "records", "dns_records"],
57
+ writeOnly: [],
58
+ };
3
59
  /**
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).
60
+ * `resend.domain({ name, region?, custom_return_path? })`: a domain Resend sends from. Apply
61
+ * creates it and asks Resend to verify it, which Resend keeps checking for 72 hours; its
62
+ * `dns_records` are what the zone must hold, which `cloudflare.records` takes (`from:
63
+ * "dns_records"`). A domain is declared verified, so one Resend has not verified is drift, and
64
+ * apply asks Resend to verify it again.
65
+ */
66
+ export const domain = defineResource({
67
+ vendor: "resend",
68
+ type: "domain",
69
+ title: "Domain",
70
+ identity: "name",
71
+ schema: domainSchema,
72
+ fields,
73
+ find: ({ name }) => name,
74
+ bindingId: (state) => String(state.id),
75
+ // The status is compared too, declared `verified` (a declaration never holds one). A Return-Path
76
+ // the records do not show (no SPF record read) is not drift: the read cannot tell it.
77
+ normalize: (state, desired) => ({
78
+ ...compareDeclared(fields, state, desired),
79
+ ...(state.custom_return_path === undefined && { custom_return_path: desired.custom_return_path }),
80
+ status: state.status ?? "verified",
81
+ }),
82
+ writable: true,
83
+ // Its DKIM key is Resend's: one made again needs new DNS records, so apply asks first.
84
+ stateless: false,
85
+ });
86
+ /**
87
+ * Resend's Broadcasts API (https://resend.com/docs/api-reference/broadcasts), its one-email send
88
+ * (https://resend.com/docs/api-reference/emails/send-email) and its sending domains, the resource
89
+ * type `resend.domain` (https://resend.com/docs/api-reference/domains).
6
90
  */
7
91
  export const resendOps = defineConnector("resend", {
92
+ domain,
8
93
  broadcast: {
9
94
  create: {
10
95
  effect: "write",
11
96
  description: "Create a broadcast to an audience. Nothing is sent.",
12
97
  input: z.object({
13
98
  audience: z.string().min(1),
14
- from: z.string().optional(),
99
+ from: z.string().optional().describe("The sender, such as `Acme <news@acme.example>`, on a verified domain"),
15
100
  subject: z.string().min(1),
16
101
  html: z.string(),
17
102
  }),
@@ -32,7 +117,10 @@ export const resendOps = defineConnector("resend", {
32
117
  input: z
33
118
  .object({
34
119
  to: z.union([z.string().min(1), z.array(z.string().min(1)).min(1).max(50)]),
35
- from: z.string().optional(),
120
+ from: z
121
+ .string()
122
+ .optional()
123
+ .describe("The sender, such as `Acme <news@acme.example>`, on a verified domain"),
36
124
  subject: z.string().min(1),
37
125
  html: z.string().optional(),
38
126
  text: z.string().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CACtC,QAAQ,EACR;IACE,SAAS,EAAE;QACT,MAAM,EAAE;YACN,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,qDAAqD;YAClE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;gBACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC3B,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;aACjB,CAAC;YACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACrC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,sEAAsE;YACnF,OAAO,EAAE,EAAE,MAAM,EAAE,wBAAwB,EAAE;YAC7C,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACnC,MAAM,EAAE,CAAC,CAAC,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AAC"}
@@ -0,0 +1,191 @@
1
+ import { type DnsRecord, type PlanAction } from "@sanoma-ai/workflows";
2
+ import type { z } from "zod";
3
+ import { type DomainStatus, type Region, resendRecord } from "./connector.ts";
4
+ /** A DNS record as Resend gives one. */
5
+ export type ApiRecord = z.infer<typeof resendRecord>;
6
+ /** A domain as `GET /domains/{id}` gives it, cut to the fields read here. */
7
+ export interface ApiDomain {
8
+ id: string;
9
+ name: string;
10
+ status: DomainStatus;
11
+ region: Region;
12
+ records: ApiRecord[];
13
+ }
14
+ /** Resend's domain API, cut. Each call fails with a `DriverError`. */
15
+ export interface DomainApi {
16
+ /** Undefined when Resend holds a domain of that name already, in this account or another (403). */
17
+ create(body: {
18
+ name: string;
19
+ region?: Region;
20
+ custom_return_path?: string;
21
+ }): Promise<{
22
+ id: string;
23
+ } | undefined>;
24
+ /** One page of `GET /domains`, after the domain `after` names; `next` the cursor of the next page, if there is one. */
25
+ list(after?: string): Promise<{
26
+ data: {
27
+ id: string;
28
+ name: string;
29
+ }[];
30
+ next?: string;
31
+ }>;
32
+ /** Undefined when Resend has no such domain (404). */
33
+ get(id: string): Promise<ApiDomain | undefined>;
34
+ verify(id: string): Promise<void>;
35
+ /** Nothing when Resend has no such domain (404). */
36
+ remove(id: string): Promise<void>;
37
+ }
38
+ /**
39
+ * A record's full name, from the name Resend gives: Resend writes most relative to the zone
40
+ * (`send`, or `send.mail` for `mail.example.com` in the zone `example.com`; `mail` for the
41
+ * subdomain itself) and some in full (`links.example.com`). A relative name whose last labels
42
+ * begin the domain's is relative to a parent zone, so those labels are not repeated.
43
+ */
44
+ export declare function fullName(name: string, domainName: string): string;
45
+ /** A record as a zone holds it (`dnsRecord`): its full name, a TXT record's text unquoted, `Auto` as ttl 1. */
46
+ export declare function dnsOf(record: ApiRecord, domainName: string): DnsRecord | undefined;
47
+ /** The type's operations (`domain.*`) over `api`. */
48
+ export declare function domainOperations(api: DomainApi): {
49
+ import: ({ id }: {
50
+ id: string;
51
+ }) => Promise<{
52
+ id: string;
53
+ gone: boolean;
54
+ state: {
55
+ name: string;
56
+ region: "ap-northeast-1" | "eu-west-1" | "sa-east-1" | "us-east-1";
57
+ custom_return_path?: string | undefined;
58
+ id: string;
59
+ status: "failed" | "not_started" | "partially_failed" | "partially_verified" | "pending" | "temporary_failure" | "verified";
60
+ records: {
61
+ record: string;
62
+ name: string;
63
+ type: string;
64
+ value: string;
65
+ ttl?: string | undefined;
66
+ status?: string | undefined;
67
+ priority?: number | undefined;
68
+ }[];
69
+ dns_records: {
70
+ type: "CAA" | "CNAME" | "MX" | "TXT";
71
+ name: string;
72
+ content: string;
73
+ priority?: number | undefined;
74
+ ttl?: number | undefined;
75
+ }[];
76
+ };
77
+ } | {
78
+ state?: undefined;
79
+ id: string;
80
+ gone: boolean;
81
+ }>;
82
+ read: ({ id }: {
83
+ id: string;
84
+ }) => Promise<{
85
+ id: string;
86
+ gone: boolean;
87
+ state: {
88
+ name: string;
89
+ region: "ap-northeast-1" | "eu-west-1" | "sa-east-1" | "us-east-1";
90
+ custom_return_path?: string | undefined;
91
+ id: string;
92
+ status: "failed" | "not_started" | "partially_failed" | "partially_verified" | "pending" | "temporary_failure" | "verified";
93
+ records: {
94
+ record: string;
95
+ name: string;
96
+ type: string;
97
+ value: string;
98
+ ttl?: string | undefined;
99
+ status?: string | undefined;
100
+ priority?: number | undefined;
101
+ }[];
102
+ dns_records: {
103
+ type: "CAA" | "CNAME" | "MX" | "TXT";
104
+ name: string;
105
+ content: string;
106
+ priority?: number | undefined;
107
+ ttl?: number | undefined;
108
+ }[];
109
+ };
110
+ } | {
111
+ state?: undefined;
112
+ id: string;
113
+ gone: boolean;
114
+ }>;
115
+ plan: (input: {
116
+ id?: string;
117
+ desired?: Record<string, unknown>;
118
+ }) => Promise<{
119
+ action: PlanAction;
120
+ planned?: Record<string, unknown>;
121
+ unknown: string[];
122
+ replace: string[];
123
+ }>;
124
+ create: ({ desired }: {
125
+ desired: Record<string, unknown>;
126
+ }) => Promise<{
127
+ id: string;
128
+ state: {
129
+ name: string;
130
+ region: "ap-northeast-1" | "eu-west-1" | "sa-east-1" | "us-east-1";
131
+ custom_return_path?: string | undefined;
132
+ id: string;
133
+ status: "failed" | "not_started" | "partially_failed" | "partially_verified" | "pending" | "temporary_failure" | "verified";
134
+ records: {
135
+ record: string;
136
+ name: string;
137
+ type: string;
138
+ value: string;
139
+ ttl?: string | undefined;
140
+ status?: string | undefined;
141
+ priority?: number | undefined;
142
+ }[];
143
+ dns_records: {
144
+ type: "CAA" | "CNAME" | "MX" | "TXT";
145
+ name: string;
146
+ content: string;
147
+ priority?: number | undefined;
148
+ ttl?: number | undefined;
149
+ }[];
150
+ };
151
+ }>;
152
+ update: ({ id, desired, expect, }: {
153
+ id: string;
154
+ desired: Record<string, unknown>;
155
+ expect?: {
156
+ action: PlanAction;
157
+ replace: string[];
158
+ };
159
+ }) => Promise<{
160
+ id: string;
161
+ state: {
162
+ name: string;
163
+ region: "ap-northeast-1" | "eu-west-1" | "sa-east-1" | "us-east-1";
164
+ custom_return_path?: string | undefined;
165
+ id: string;
166
+ status: "failed" | "not_started" | "partially_failed" | "partially_verified" | "pending" | "temporary_failure" | "verified";
167
+ records: {
168
+ record: string;
169
+ name: string;
170
+ type: string;
171
+ value: string;
172
+ ttl?: string | undefined;
173
+ status?: string | undefined;
174
+ priority?: number | undefined;
175
+ }[];
176
+ dns_records: {
177
+ type: "CAA" | "CNAME" | "MX" | "TXT";
178
+ name: string;
179
+ content: string;
180
+ priority?: number | undefined;
181
+ ttl?: number | undefined;
182
+ }[];
183
+ };
184
+ }>;
185
+ delete: ({ id }: {
186
+ id: string;
187
+ }) => Promise<{
188
+ id: string;
189
+ gone: true;
190
+ }>;
191
+ };