@sanoma-ai/connector-resend 0.4.8 → 0.6.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 +79 -19
- package/dist/connector.d.ts +120 -4
- package/dist/connector.js +104 -5
- package/dist/connector.js.map +1 -1
- package/dist/domains.d.ts +191 -0
- package/dist/domains.js +210 -0
- package/dist/domains.js.map +1 -0
- package/dist/driver.d.ts +3 -3
- package/dist/driver.js +74 -21
- package/dist/driver.js.map +1 -1
- package/dist/fake.d.ts +56 -7
- package/dist/fake.js +86 -7
- 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 +23 -1
- package/dist/generated/sdk.gen.js +46 -0
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/types.gen.d.ts +321 -0
- package/dist/index.d.ts +46 -4
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/resources.d.ts +47 -0
- package/dist/resources.js +7 -0
- package/dist/resources.js.map +1 -0
- package/dist/steps.d.ts +4 -3
- package/dist/steps.js +6 -3
- package/dist/steps.js.map +1 -1
- package/features/domain.feature +82 -0
- package/features/emails.feature +1 -1
- package/package.json +9 -4
|
@@ -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
|
+
};
|
package/dist/domains.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { diffDeclared, dnsRecord, DriverError, errorMessage, } from "@sanoma-ai/workflows";
|
|
2
|
+
import { DEFAULT_REGION, DEFAULT_RETURN_PATH, domain, resendRecord, } from "./connector.js";
|
|
3
|
+
/** The driver's own refusal, before or instead of a call: never retried. */
|
|
4
|
+
const refused = (message, vendorCode, cause) => new DriverError(`resend: ${message}`, { retryable: false, vendorCode, cause });
|
|
5
|
+
/** Resend's ids are UUIDs: an import id that is not one is a domain's name. */
|
|
6
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
|
+
/**
|
|
8
|
+
* A record's full name, from the name Resend gives: Resend writes most relative to the zone
|
|
9
|
+
* (`send`, or `send.mail` for `mail.example.com` in the zone `example.com`; `mail` for the
|
|
10
|
+
* subdomain itself) and some in full (`links.example.com`). A relative name whose last labels
|
|
11
|
+
* begin the domain's is relative to a parent zone, so those labels are not repeated.
|
|
12
|
+
*/
|
|
13
|
+
export function fullName(name, domainName) {
|
|
14
|
+
const given = name.toLowerCase().replace(/\.$/, "");
|
|
15
|
+
if (given === "" || given === "@")
|
|
16
|
+
return domainName;
|
|
17
|
+
if (given === domainName || given.endsWith(`.${domainName}`))
|
|
18
|
+
return given;
|
|
19
|
+
const labels = given.split(".");
|
|
20
|
+
const parts = domainName.split(".");
|
|
21
|
+
// The zone keeps two labels at least.
|
|
22
|
+
for (let k = Math.min(labels.length, parts.length - 2); k > 0; k--) {
|
|
23
|
+
if (labels.slice(-k).join(".") === parts.slice(0, k).join(".")) {
|
|
24
|
+
return [...labels.slice(0, -k), ...parts].join(".");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return `${given}.${domainName}`;
|
|
28
|
+
}
|
|
29
|
+
/** A record as a zone holds it (`dnsRecord`): its full name, a TXT record's text unquoted, `Auto` as ttl 1. */
|
|
30
|
+
export function dnsOf(record, domainName) {
|
|
31
|
+
const { data: type } = dnsRecord.shape.type.safeParse(record.type.toUpperCase());
|
|
32
|
+
if (!type)
|
|
33
|
+
return undefined;
|
|
34
|
+
const seconds = Number(record.ttl);
|
|
35
|
+
return {
|
|
36
|
+
type,
|
|
37
|
+
name: fullName(record.name, domainName),
|
|
38
|
+
// A long TXT value may come as several quoted strings (`"p=AAA" "BBB"`): the zone holds them joined.
|
|
39
|
+
content: type === "TXT" && /^".*"$/s.test(record.value) ? record.value.slice(1, -1).split(/"\s+"/).join("") : record.value,
|
|
40
|
+
...(record.priority !== undefined && { priority: record.priority }),
|
|
41
|
+
ttl: Number.isInteger(seconds) && seconds > 0 ? seconds : 1,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A domain's state, from Resend's domain: its Return-Path from the name of its SPF MX record (or
|
|
46
|
+
* of its first SPF record: Resend gives newer domains CNAME records for SPF instead).
|
|
47
|
+
*/
|
|
48
|
+
function stateOf(d) {
|
|
49
|
+
const name = d.name.toLowerCase();
|
|
50
|
+
const dns = d.records.map((r) => ({ record: r.record, dns: dnsOf(r, name) }));
|
|
51
|
+
const spf = dns.filter((r) => r.record === "SPF").map((r) => r.dns);
|
|
52
|
+
const bounces = spf.find((r) => r?.type === "MX") ?? spf[0];
|
|
53
|
+
const returnPath = bounces?.name.endsWith(`.${name}`) ? bounces.name.slice(0, -name.length - 1) : undefined;
|
|
54
|
+
return {
|
|
55
|
+
name,
|
|
56
|
+
region: d.region,
|
|
57
|
+
// Left out when the records do not show it: `normalize` then compares it as declared.
|
|
58
|
+
...(returnPath && { custom_return_path: returnPath }),
|
|
59
|
+
id: d.id,
|
|
60
|
+
status: d.status,
|
|
61
|
+
records: d.records,
|
|
62
|
+
dns_records: dns.flatMap((r) => (r.dns ? [r.dns] : [])),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The type's operations (`domain.*`) over `api`. */
|
|
66
|
+
export function domainOperations(api) {
|
|
67
|
+
/** The id of the domain named `name`, through every page of `GET /domains`. */
|
|
68
|
+
const idOf = async (name) => {
|
|
69
|
+
const wanted = name.toLowerCase();
|
|
70
|
+
let after;
|
|
71
|
+
for (;;) {
|
|
72
|
+
const page = await api.list(after);
|
|
73
|
+
const found = page.data.find((d) => d.name.toLowerCase() === wanted);
|
|
74
|
+
if (found)
|
|
75
|
+
return found.id;
|
|
76
|
+
// A page with no cursor, or the same one again, is the last.
|
|
77
|
+
if (!page.next || page.next === after)
|
|
78
|
+
return undefined;
|
|
79
|
+
after = page.next;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const read = async ({ id }) => {
|
|
83
|
+
const found = await api.get(id);
|
|
84
|
+
return found ? { id, gone: false, state: stateOf(found) } : { id, gone: true };
|
|
85
|
+
};
|
|
86
|
+
/** Asks Resend to check the domain's records now, then reads it. */
|
|
87
|
+
const verify = async (id) => {
|
|
88
|
+
await api.verify(id);
|
|
89
|
+
const found = await api.get(id);
|
|
90
|
+
if (!found)
|
|
91
|
+
throw refused(`domain ${id} was deleted while it was verified`, "gone");
|
|
92
|
+
return { id, state: stateOf(found) };
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Creates the domain, or takes the one of that name this account holds already (a create that
|
|
96
|
+
* lost its reply made it) when it is the one declared: its id.
|
|
97
|
+
*/
|
|
98
|
+
const make = async ({ name, region, custom_return_path }) => {
|
|
99
|
+
const made = await api.create({
|
|
100
|
+
name,
|
|
101
|
+
...(region && { region }),
|
|
102
|
+
...(custom_return_path && { custom_return_path }),
|
|
103
|
+
});
|
|
104
|
+
if (made)
|
|
105
|
+
return made.id;
|
|
106
|
+
const id = await idOf(name);
|
|
107
|
+
// Not in this account's list: another account holds it.
|
|
108
|
+
if (!id) {
|
|
109
|
+
throw refused(`domain.create: another Resend account holds ${name}; claim it in Resend's dashboard, or declare another`, "registered");
|
|
110
|
+
}
|
|
111
|
+
const held = await api.get(id);
|
|
112
|
+
const state = held && stateOf(held);
|
|
113
|
+
const wanted = { region: region ?? DEFAULT_REGION, custom_return_path: custom_return_path ?? DEFAULT_RETURN_PATH };
|
|
114
|
+
const differs = Object.keys(wanted).filter((f) => state?.[f] !== undefined && state[f] !== wanted[f]);
|
|
115
|
+
if (differs.length) {
|
|
116
|
+
throw refused(`domain.create: this account holds ${name} (${id}) already, with another ${differs.join(" and ")}; import it, or delete it in Resend`, "conflict");
|
|
117
|
+
}
|
|
118
|
+
return id;
|
|
119
|
+
};
|
|
120
|
+
const plan = async ({ id, desired }) => {
|
|
121
|
+
const state = id === undefined ? undefined : (await read({ id })).state;
|
|
122
|
+
const none = { unknown: [], replace: [] };
|
|
123
|
+
if (!desired)
|
|
124
|
+
return { action: state ? "delete" : "none", state, ...none };
|
|
125
|
+
const want = domain.schema.parse(desired);
|
|
126
|
+
const { immutable, vendorOwned } = domain.fields;
|
|
127
|
+
const made = {
|
|
128
|
+
...want,
|
|
129
|
+
region: want.region ?? DEFAULT_REGION,
|
|
130
|
+
custom_return_path: want.custom_return_path ?? DEFAULT_RETURN_PATH,
|
|
131
|
+
...Object.fromEntries(vendorOwned.map((f) => [f, null])),
|
|
132
|
+
};
|
|
133
|
+
const unknown = [...vendorOwned];
|
|
134
|
+
if (!state)
|
|
135
|
+
return { action: "create", planned: made, want, unknown, replace: [] };
|
|
136
|
+
// What drift reports: a declared field that differs, or a status other than `verified`.
|
|
137
|
+
const differs = diffDeclared(domain, state, want).map((d) => d.path);
|
|
138
|
+
const replace = immutable.filter((f) => differs.includes(f));
|
|
139
|
+
if (replace.length)
|
|
140
|
+
return { action: "replace", planned: made, state, want, unknown, replace };
|
|
141
|
+
// Verifying again changes the statuses only: the records stay the same.
|
|
142
|
+
if (differs.length) {
|
|
143
|
+
return {
|
|
144
|
+
action: "update",
|
|
145
|
+
planned: { ...state, status: null, records: null },
|
|
146
|
+
state,
|
|
147
|
+
unknown: ["status", "records"],
|
|
148
|
+
replace: [],
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return { action: "none", planned: state, state, ...none };
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
import: async ({ id }) => {
|
|
155
|
+
if (UUID.test(id))
|
|
156
|
+
return read({ id });
|
|
157
|
+
const found = await idOf(id);
|
|
158
|
+
return found ? read({ id: found }) : { id, gone: true };
|
|
159
|
+
},
|
|
160
|
+
read,
|
|
161
|
+
plan: async (input) => {
|
|
162
|
+
const { state: _, want: __, ...out } = await plan(input);
|
|
163
|
+
return out;
|
|
164
|
+
},
|
|
165
|
+
create: async ({ desired }) => verify(await make(domain.schema.parse(desired))),
|
|
166
|
+
// Nothing of a domain changes in place: an update asks Resend to verify it again, and a
|
|
167
|
+
// replace deletes it (Resend holds one domain of a name) and makes it anew, with a new key.
|
|
168
|
+
update: async ({ id, desired, expect, }) => {
|
|
169
|
+
const fresh = await plan({ id, desired });
|
|
170
|
+
// Verified since the plan was approved (Resend found the records): what it would do is done.
|
|
171
|
+
if (expect?.action === "update" && fresh.action === "none")
|
|
172
|
+
return { id, state: fresh.state };
|
|
173
|
+
// A replace tried again after it deleted the domain: make it, taking the one that try made.
|
|
174
|
+
if (expect?.action === "replace" && fresh.action === "create")
|
|
175
|
+
return verify(await make(fresh.want));
|
|
176
|
+
if (expect && (expect.action !== fresh.action || expect.replace.join() !== fresh.replace.join())) {
|
|
177
|
+
throw refused(`domain.update: the plan changed (${expect.action}, now ${fresh.action})`, "plan_changed");
|
|
178
|
+
}
|
|
179
|
+
if (!fresh.state)
|
|
180
|
+
throw refused(`domain.update: there is no domain ${id}`, "gone");
|
|
181
|
+
if (fresh.action === "none")
|
|
182
|
+
return { id, state: fresh.state };
|
|
183
|
+
if (fresh.action === "replace") {
|
|
184
|
+
await api.remove(id);
|
|
185
|
+
let made;
|
|
186
|
+
try {
|
|
187
|
+
made = await make(fresh.want);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
// Retried, the call finds the domain gone and makes it (above). Later: apply owns a
|
|
191
|
+
// replace, deleting and unbinding, then creating as a step of its own.
|
|
192
|
+
const { name, region } = fresh.state;
|
|
193
|
+
const why = errorMessage(error).replace(/^resend: /, "");
|
|
194
|
+
throw new DriverError(`resend: domain.update: deleted domain ${id} (${name}, ${region}) to make it anew, and the create failed: ${why}`, {
|
|
195
|
+
retryable: error instanceof DriverError && error.retryable,
|
|
196
|
+
vendorCode: "replace_incomplete",
|
|
197
|
+
cause: error,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return verify(made);
|
|
201
|
+
}
|
|
202
|
+
return verify(id);
|
|
203
|
+
},
|
|
204
|
+
delete: async ({ id }) => {
|
|
205
|
+
await api.remove(id);
|
|
206
|
+
return { id, gone: true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,oBAAoB;wBAChC,KAAK,EAAE,KAAK;qBACb,CACF,CAAC;gBACJ,CAAC;gBACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAkB,EAAE,EAAE;YACvC,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAa,EAAE,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,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
|
|
7
|
-
*
|
|
8
|
-
* Resend
|
|
6
|
+
* Calls Resend's Broadcasts API, its one-email send and its domain API with the key in
|
|
7
|
+
* `RESEND_API_KEY`, read on every call. The contract's `audience` is Resend's `segment_id`:
|
|
8
|
+
* 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
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { defineDriver, DriverError, retryableStatus } from "@sanoma-ai/workflows";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { resendOps } from "./connector.js";
|
|
3
|
+
import { resendOps, senderOf } 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, emailsSend } from "./generated/index.js";
|
|
7
|
+
import { broadcastsCreate, broadcastsGet, broadcastsSend, domainsCreate, domainsGet, domainsList, domainsRemove, domainsVerify, emailsSend, } from "./generated/index.js";
|
|
8
|
+
import { domainOperations } from "./domains.js";
|
|
8
9
|
/** The environment variables the driver reads, on every call. */
|
|
9
10
|
const env = z.object({
|
|
10
|
-
RESEND_API_KEY: z.string().describe("an API key"),
|
|
11
|
-
RESEND_FROM: z
|
|
12
|
-
.string()
|
|
13
|
-
.min(1)
|
|
14
|
-
.optional()
|
|
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"),
|
|
11
|
+
RESEND_API_KEY: z.string().describe("an API key: a full-access one to manage domains, else sending access will do"),
|
|
16
12
|
});
|
|
17
13
|
/** Resend's error body. The spec declares none; the docs give `{ statusCode, name, message }`. */
|
|
18
14
|
const errorBody = z
|
|
@@ -43,10 +39,15 @@ function failure(op, timeoutMs) {
|
|
|
43
39
|
return new DriverError(`resend: ${op} replied ${status} with ${cutOff ? "a body cut off" : "a body that is not JSON"}`, { retryable: cutOff, status, cause: error });
|
|
44
40
|
}
|
|
45
41
|
const { name, message } = cutOff ? {} : errorBody.parse(error);
|
|
42
|
+
// A sending-only key answers anything but a send so.
|
|
43
|
+
if (status === 401 && name === "restricted_api_key") {
|
|
44
|
+
return new DriverError(`resend: ${op} needs a full-access API key in RESEND_API_KEY: ${message ?? "this key may only send emails"}`, { retryable: false, status, vendorCode: name });
|
|
45
|
+
}
|
|
46
46
|
// A daily or monthly quota does not lift in the seconds a retry waits; a 409
|
|
47
|
-
// `concurrent_idempotent_requests` is another request with this key still in flight
|
|
47
|
+
// `concurrent_idempotent_requests` is another request with this key still in flight, and
|
|
48
|
+
// `resource_locked` another request on the same resource.
|
|
48
49
|
const retryable = (retryableStatus(status) && !name?.endsWith("_quota_exceeded")) ||
|
|
49
|
-
(status === 409 && name === "concurrent_idempotent_requests");
|
|
50
|
+
(status === 409 && (name === "concurrent_idempotent_requests" || name === "resource_locked"));
|
|
50
51
|
return new DriverError(`resend: ${op} failed (${status}): ${message ?? statusText}`, {
|
|
51
52
|
retryable,
|
|
52
53
|
status,
|
|
@@ -61,21 +62,26 @@ function replied(op, reply) {
|
|
|
61
62
|
const { status } = reply.response;
|
|
62
63
|
throw new DriverError(`resend: ${op} replied ${status} without an id`, { retryable: false, status });
|
|
63
64
|
}
|
|
64
|
-
/**
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
/** A request whose 404 means no such domain: `undefined` then. */
|
|
66
|
+
async function absent(request) {
|
|
67
|
+
try {
|
|
68
|
+
return await request;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof DriverError && error.status === 404)
|
|
72
|
+
return undefined;
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
|
-
* Calls Resend's Broadcasts API
|
|
73
|
-
*
|
|
74
|
-
* Resend
|
|
77
|
+
* Calls Resend's Broadcasts API, its one-email send and its domain API with the key in
|
|
78
|
+
* `RESEND_API_KEY`, read on every call. The contract's `audience` is Resend's `segment_id`:
|
|
79
|
+
* Resend renamed audiences to segments.
|
|
75
80
|
*/
|
|
76
81
|
export function resendDriver(options = {}) {
|
|
77
82
|
const timeoutMs = options.timeoutMs ?? 15_000;
|
|
78
|
-
|
|
83
|
+
/** A client for one call of `op`; `idempotent: false` sends no Idempotency-Key. */
|
|
84
|
+
function client(op, call, { idempotent = true } = {}) {
|
|
79
85
|
const key = process.env.RESEND_API_KEY;
|
|
80
86
|
if (!key)
|
|
81
87
|
throw new DriverError("resend: RESEND_API_KEY is not set", { retryable: false });
|
|
@@ -85,13 +91,60 @@ export function resendDriver(options = {}) {
|
|
|
85
91
|
auth: key,
|
|
86
92
|
// Resend documents Idempotency-Key for emails only (kept 24 hours); it is sent in case
|
|
87
93
|
// broadcasts honour it too.
|
|
88
|
-
headers: { "Idempotency-Key": call.idempotencyKey },
|
|
94
|
+
...(idempotent && { headers: { "Idempotency-Key": call.idempotencyKey } }),
|
|
89
95
|
fetch: (input, init) => fetch(input, { ...init, signal: AbortSignal.timeout(timeoutMs) }),
|
|
90
96
|
});
|
|
91
97
|
api.interceptors.error.use(failure(op, timeoutMs));
|
|
92
98
|
return api;
|
|
93
99
|
}
|
|
100
|
+
/** Resend's domain API for one call of `op`. */
|
|
101
|
+
function domainApi(op, call) {
|
|
102
|
+
// No Idempotency-Key: one call makes several requests (a create and its verify; a replace's
|
|
103
|
+
// delete and create), which must not share one, and Resend documents none for domains.
|
|
104
|
+
const api = client(op, call, { idempotent: false });
|
|
105
|
+
return {
|
|
106
|
+
create: async (body) => {
|
|
107
|
+
try {
|
|
108
|
+
return { id: replied(op, await domainsCreate({ client: api, body })).id };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
// Resend says so only in its message: "The `example.com` domain has been registered already."
|
|
112
|
+
if (error instanceof DriverError && error.status === 403 && /registered already/i.test(error.message)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
list: async (after) => {
|
|
119
|
+
const { data } = await domainsList({ client: api, query: { limit: 100, ...(after && { after }) } });
|
|
120
|
+
const items = data?.data ?? [];
|
|
121
|
+
return {
|
|
122
|
+
data: items.flatMap(({ id, name }) => (id && name ? [{ id, name }] : [])),
|
|
123
|
+
next: data?.has_more === true ? items.at(-1)?.id : undefined,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
get: async (id) => {
|
|
127
|
+
const reply = await absent(domainsGet({ client: api, path: { domain_id: id } }));
|
|
128
|
+
return reply && replied(op, reply);
|
|
129
|
+
},
|
|
130
|
+
verify: async (id) => {
|
|
131
|
+
await domainsVerify({ client: api, path: { domain_id: id } });
|
|
132
|
+
},
|
|
133
|
+
remove: async (id) => {
|
|
134
|
+
await absent(domainsRemove({ client: api, path: { domain_id: id } }));
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const domains = (op, call) => domainOperations(domainApi(`domain.${op}`, call));
|
|
94
139
|
return defineDriver(resendOps, {
|
|
140
|
+
domain: {
|
|
141
|
+
import: (input, call) => domains("import", call).import(input),
|
|
142
|
+
read: (input, call) => domains("read", call).read(input),
|
|
143
|
+
plan: (input, call) => domains("plan", call).plan(input),
|
|
144
|
+
create: (input, call) => domains("create", call).create(input),
|
|
145
|
+
update: (input, call) => domains("update", call).update(input),
|
|
146
|
+
delete: (input, call) => domains("delete", call).delete(input),
|
|
147
|
+
},
|
|
95
148
|
broadcast: {
|
|
96
149
|
create: async (input, call) => {
|
|
97
150
|
const from = senderOf("broadcast.create", input.from);
|
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;
|
|
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,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,iFAAiF;AACjF,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,sBAAsB,CAA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