@hogsend/plugin-resend 0.4.0 → 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 +6 -0
- package/package.json +3 -2
- package/src/types.ts +19 -138
package/README.md
CHANGED
|
@@ -4,6 +4,12 @@ Resend email delivery for [Hogsend](https://github.com/dougwithseismic/hogsend):
|
|
|
4
4
|
single + batch sends, tracked sends, webhook parsing/verification, and an email
|
|
5
5
|
service with bounce tracking.
|
|
6
6
|
|
|
7
|
+
`createResendProvider` is the **reference implementation** of the `EmailProvider`
|
|
8
|
+
contract — the contract itself lives in `@hogsend/core` (canonical author import
|
|
9
|
+
`@hogsend/engine`); this package re-exports `EmailProvider` and its supporting
|
|
10
|
+
types for back-compat. To support another provider, implement that interface. See
|
|
11
|
+
[docs/adr/0001-provider-boundary.md](https://github.com/dougwithseismic/hogsend/blob/main/docs/adr/0001-provider-boundary.md).
|
|
12
|
+
|
|
7
13
|
This package ships raw TypeScript source; consumers bundle it via their own build
|
|
8
14
|
(tsup `noExternal`). See the
|
|
9
15
|
[release model](https://github.com/dougwithseismic/hogsend/blob/main/docs/RELEASING.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hogsend/plugin-resend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"resend": "^6.12.3",
|
|
26
26
|
"svix": "^1.94.0",
|
|
27
|
-
"@hogsend/
|
|
27
|
+
"@hogsend/core": "^0.5.0",
|
|
28
|
+
"@hogsend/email": "^0.5.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/node": "^22.0.0",
|
package/src/types.ts
CHANGED
|
@@ -1,138 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface BatchEmailItem {
|
|
22
|
-
from: string;
|
|
23
|
-
to: string | string[];
|
|
24
|
-
subject: string;
|
|
25
|
-
react: ReactElement;
|
|
26
|
-
replyTo?: string | string[];
|
|
27
|
-
cc?: string | string[];
|
|
28
|
-
bcc?: string | string[];
|
|
29
|
-
tags?: Array<{ name: string; value: string }>;
|
|
30
|
-
headers?: Record<string, string>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface SendResult {
|
|
34
|
-
id: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// Webhook events
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
|
|
41
|
-
interface WebhookEventBase {
|
|
42
|
-
created_at: string;
|
|
43
|
-
data: {
|
|
44
|
-
email_id: string;
|
|
45
|
-
from: string;
|
|
46
|
-
to: string[];
|
|
47
|
-
subject: string;
|
|
48
|
-
created_at: string;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface EmailSentEvent extends WebhookEventBase {
|
|
53
|
-
type: "email.sent";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface EmailDeliveredEvent extends WebhookEventBase {
|
|
57
|
-
type: "email.delivered";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface EmailBouncedEvent extends WebhookEventBase {
|
|
61
|
-
type: "email.bounced";
|
|
62
|
-
data: WebhookEventBase["data"] & {
|
|
63
|
-
bounce: {
|
|
64
|
-
message: string;
|
|
65
|
-
type: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface EmailComplainedEvent extends WebhookEventBase {
|
|
71
|
-
type: "email.complained";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface EmailDeliveryDelayedEvent extends WebhookEventBase {
|
|
75
|
-
type: "email.delivery_delayed";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface EmailOpenedEvent extends WebhookEventBase {
|
|
79
|
-
type: "email.opened";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface EmailClickedEvent extends WebhookEventBase {
|
|
83
|
-
type: "email.clicked";
|
|
84
|
-
data: WebhookEventBase["data"] & {
|
|
85
|
-
click: {
|
|
86
|
-
link: string;
|
|
87
|
-
timestamp: string;
|
|
88
|
-
ipAddress: string;
|
|
89
|
-
userAgent: string;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type WebhookEvent =
|
|
95
|
-
| EmailSentEvent
|
|
96
|
-
| EmailDeliveredEvent
|
|
97
|
-
| EmailBouncedEvent
|
|
98
|
-
| EmailComplainedEvent
|
|
99
|
-
| EmailDeliveryDelayedEvent
|
|
100
|
-
| EmailOpenedEvent
|
|
101
|
-
| EmailClickedEvent;
|
|
102
|
-
|
|
103
|
-
export type WebhookEventType = WebhookEvent["type"];
|
|
104
|
-
|
|
105
|
-
export type WebhookHandlerMap = {
|
|
106
|
-
[K in WebhookEventType]?: (
|
|
107
|
-
event: Extract<WebhookEvent, { type: K }>,
|
|
108
|
-
) => void | Promise<void>;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// ---------------------------------------------------------------------------
|
|
112
|
-
// EmailProvider contract (the entire provider surface)
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The dumb delivery + webhook parse/verify contract every email provider
|
|
117
|
-
* implements (Resend, Postmark, SES, …). All tracking, DB, preference, and
|
|
118
|
-
* render logic lives in the engine's `createTrackedMailer`, never here.
|
|
119
|
-
*/
|
|
120
|
-
export interface EmailProvider {
|
|
121
|
-
/** Deliver a single message. Returns the provider message id. */
|
|
122
|
-
send(options: SendEmailOptions): Promise<SendResult>;
|
|
123
|
-
|
|
124
|
-
/** Deliver a batch of messages. */
|
|
125
|
-
sendBatch(emails: BatchEmailItem[]): Promise<{ results: SendResult[] }>;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Verify a provider webhook signature and return the parsed event. Throws
|
|
129
|
-
* if the signature is missing/invalid.
|
|
130
|
-
*/
|
|
131
|
-
verifyWebhook(opts: {
|
|
132
|
-
payload: string;
|
|
133
|
-
headers: Record<string, string>;
|
|
134
|
-
}): WebhookEvent;
|
|
135
|
-
|
|
136
|
-
/** Parse an unsigned webhook payload (used in trusted contexts/tests). */
|
|
137
|
-
parseWebhook(payload: string): WebhookEvent;
|
|
138
|
-
}
|
|
1
|
+
// The email-provider contract now lives in the neutral @hogsend/core package.
|
|
2
|
+
// These re-exports keep every existing `import ... from "@hogsend/plugin-resend"`
|
|
3
|
+
// working unchanged.
|
|
4
|
+
export type {
|
|
5
|
+
BatchEmailItem,
|
|
6
|
+
EmailBouncedEvent,
|
|
7
|
+
EmailClickedEvent,
|
|
8
|
+
EmailComplainedEvent,
|
|
9
|
+
EmailDeliveredEvent,
|
|
10
|
+
EmailDeliveryDelayedEvent,
|
|
11
|
+
EmailOpenedEvent,
|
|
12
|
+
EmailProvider,
|
|
13
|
+
EmailSentEvent,
|
|
14
|
+
SendEmailOptions,
|
|
15
|
+
SendResult,
|
|
16
|
+
WebhookEvent,
|
|
17
|
+
WebhookEventType,
|
|
18
|
+
WebhookHandlerMap,
|
|
19
|
+
} from "@hogsend/core";
|