@processfocus/plugin-resend 0.1.0-next.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/LICENSE.md +28 -0
- package/README.md +329 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/mock-resend-plugin.d.ts +100 -0
- package/dist/lib/mock-resend-plugin.js +355 -0
- package/dist/lib/mock-resend-plugin.js.map +1 -0
- package/dist/lib/resend-client.d.ts +73 -0
- package/dist/lib/resend-client.js +169 -0
- package/dist/lib/resend-client.js.map +1 -0
- package/dist/lib/resend-server-plugin.d.ts +12 -0
- package/dist/lib/resend-server-plugin.js +255 -0
- package/dist/lib/resend-server-plugin.js.map +1 -0
- package/dist/lib/resend-step.d.ts +134 -0
- package/dist/lib/resend-step.js +209 -0
- package/dist/lib/resend-step.js.map +1 -0
- package/dist/lib/resend-webhook-event.d.ts +88 -0
- package/dist/lib/resend-webhook-event.js +260 -0
- package/dist/lib/resend-webhook-event.js.map +1 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +4 -0
- package/dist/runtime.js.map +1 -0
- package/dist/test-support.d.ts +1 -0
- package/dist/test-support.js +2 -0
- package/dist/test-support.js.map +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +2 -0
- package/dist/testing.js.map +1 -0
- package/package.json +55 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# O'Saasy License Agreement
|
|
2
|
+
|
|
3
|
+
Copyright © 2026, Xplain Technology Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
1. The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
2. No licensee or downstream recipient may use the Software (including
|
|
16
|
+
any modified or derivative versions) to directly compete with the
|
|
17
|
+
original Licensor by offering it to third parties as a hosted,
|
|
18
|
+
managed, or Software-as-a-Service (SaaS) product or cloud service
|
|
19
|
+
where the primary value of the service is the functionality of the
|
|
20
|
+
Software itself.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
23
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
24
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
25
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
26
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
28
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# @processfocus/plugin-resend
|
|
2
|
+
|
|
3
|
+
Resend email plugin for Process Focus business processes. Provides a `ResendStep` system step that sends emails via the Resend API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This package is part of the workspace. Add it to your process dependencies:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@processfocus/plugin-resend": "0.1.0-next.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configuration
|
|
18
|
+
|
|
19
|
+
Set the `RESEND_API_KEY` environment variable with your Resend API key.
|
|
20
|
+
|
|
21
|
+
### Deployed Environments
|
|
22
|
+
|
|
23
|
+
For cloud-hosted deployments, use `pfcli` to set the secret:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun cli/pfcli/src/main.ts config set RESEND_API_KEY="re_xxxxxxxx" --project <project-id> --stage "<stage-name>" --secret
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Email Routing (Development/Staging)
|
|
30
|
+
|
|
31
|
+
To prevent sending emails to real recipients during development or staging:
|
|
32
|
+
|
|
33
|
+
- `RESEND_ENABLED` - Set to `"true"` to send emails to real recipients. Defaults to `"false"`.
|
|
34
|
+
- `RESEND_REROUTE_EMAIL` - When `RESEND_ENABLED` is not `"true"`, all emails are sent to this address instead. CC and BCC are ignored in this mode.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Reroute all emails to a test inbox
|
|
38
|
+
bun cli/pfcli/src/main.ts config set RESEND_ENABLED="false" --project <project-id> --stage "Development"
|
|
39
|
+
bun cli/pfcli/src/main.ts config set RESEND_REROUTE_EMAIL="test@example.com" --project <project-id> --stage "Development" --secret
|
|
40
|
+
|
|
41
|
+
# Enable real email delivery for production
|
|
42
|
+
bun cli/pfcli/src/main.ts config set RESEND_ENABLED="true" --project <project-id> --stage "Production"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### System Notification Sender
|
|
46
|
+
|
|
47
|
+
`ResendStep` uses its own `from` prop, but platform notification emails need a
|
|
48
|
+
separate sender identity. These include task assignment notifications, public
|
|
49
|
+
form links, and fatal execution failure notifications.
|
|
50
|
+
|
|
51
|
+
Each organisation owns this sender configuration through its job-worker
|
|
52
|
+
`NotificationDeliveryConfig`. If an org uses Resend for notification delivery,
|
|
53
|
+
its custom job layer should provide:
|
|
54
|
+
|
|
55
|
+
- `EmailSender` backed by `ResendClient`.
|
|
56
|
+
- `NotificationDeliveryConfig` that reads `FRONTEND_BASE_URL`,
|
|
57
|
+
`NOTIFICATION_SENDER_EMAIL`, and optionally `NOTIFICATION_SENDER_NAME`.
|
|
58
|
+
|
|
59
|
+
Configure those values with `pfcli config set`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bun cli/pfcli/src/main.ts config set FRONTEND_BASE_URL="https://example.processfocus.com" --project <project-id> --stage "Production"
|
|
63
|
+
bun cli/pfcli/src/main.ts config set NOTIFICATION_SENDER_EMAIL="noreply@example.com" --project <project-id> --stage "Production"
|
|
64
|
+
bun cli/pfcli/src/main.ts config set NOTIFICATION_SENDER_NAME="Example School" --project <project-id> --stage "Production"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Redeploy the environment after changing stage config so the runtime receives the
|
|
68
|
+
new values.
|
|
69
|
+
|
|
70
|
+
`FRONTEND_BASE_URL` is required so notification emails can link back to tasks,
|
|
71
|
+
public forms, and executions. If it is missing, the job worker fails to start
|
|
72
|
+
with a configuration error. If `NOTIFICATION_SENDER_NAME` is omitted or empty,
|
|
73
|
+
the sender falls back to the raw email address.
|
|
74
|
+
|
|
75
|
+
If the sender email is missing, notification preferences may still enqueue a
|
|
76
|
+
notification job, but the job worker will skip delivery before calling Resend.
|
|
77
|
+
`NOTIFICATION_SENDER_EMAIL` must use a Resend-verified domain. `RESEND_API_KEY`
|
|
78
|
+
and `RESEND_ENABLED` must also be configured as described above, because
|
|
79
|
+
notification delivery still sends through Resend.
|
|
80
|
+
|
|
81
|
+
Example org wiring:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { Config, Effect, Layer, Option } from "effect"
|
|
85
|
+
import {
|
|
86
|
+
type EmailMessage,
|
|
87
|
+
EmailSender,
|
|
88
|
+
NotificationDeliveryConfig,
|
|
89
|
+
NotificationDeliverySendError,
|
|
90
|
+
} from "@processfocus/runtime"
|
|
91
|
+
import { ResendClient } from "@processfocus/plugin-resend"
|
|
92
|
+
import { ResendServerPlugin } from "@processfocus/plugin-resend/runtime"
|
|
93
|
+
|
|
94
|
+
// This executable org export opts both local and cloud runtime hosts into the
|
|
95
|
+
// Resend client, deferred-step behavior, and /webhooks/resend descriptor.
|
|
96
|
+
export const ServerPlugins = [ResendServerPlugin]
|
|
97
|
+
|
|
98
|
+
const NotificationEmailSenderLive = Layer.effect(
|
|
99
|
+
EmailSender,
|
|
100
|
+
Effect.gen(function* () {
|
|
101
|
+
const resendClient = yield* ResendClient
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
send: (message: EmailMessage) =>
|
|
105
|
+
resendClient
|
|
106
|
+
.sendEmail({
|
|
107
|
+
to: message.to,
|
|
108
|
+
from: message.from,
|
|
109
|
+
subject: message.subject,
|
|
110
|
+
html: message.html,
|
|
111
|
+
})
|
|
112
|
+
.pipe(
|
|
113
|
+
Effect.asVoid,
|
|
114
|
+
Effect.mapError(
|
|
115
|
+
(cause) =>
|
|
116
|
+
new NotificationDeliverySendError({
|
|
117
|
+
recipientEmail: message.to,
|
|
118
|
+
message:
|
|
119
|
+
cause instanceof Error ? cause.message : String(cause),
|
|
120
|
+
cause,
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
const NotificationDeliveryConfigLive = Layer.effect(
|
|
129
|
+
NotificationDeliveryConfig,
|
|
130
|
+
Effect.gen(function* () {
|
|
131
|
+
const frontendBaseUrl = yield* Config.string("FRONTEND_BASE_URL")
|
|
132
|
+
const senderEmail = yield* Config.option(
|
|
133
|
+
Config.string("NOTIFICATION_SENDER_EMAIL"),
|
|
134
|
+
)
|
|
135
|
+
const senderName = yield* Config.option(
|
|
136
|
+
Config.string("NOTIFICATION_SENDER_NAME"),
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
getFrontendBaseUrl: () => frontendBaseUrl,
|
|
141
|
+
getSenderIdentity: () =>
|
|
142
|
+
senderEmail.pipe(
|
|
143
|
+
Option.match({
|
|
144
|
+
onNone: () => undefined,
|
|
145
|
+
onSome: (email) => ({
|
|
146
|
+
email,
|
|
147
|
+
...(Option.isSome(senderName) && senderName.value.length > 0
|
|
148
|
+
? { name: senderName.value }
|
|
149
|
+
: {}),
|
|
150
|
+
}),
|
|
151
|
+
}),
|
|
152
|
+
),
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
// The registered server plugin supplies ResendClient to this org layer.
|
|
158
|
+
export const CustomJobLayer = Layer.mergeAll(
|
|
159
|
+
NotificationDeliveryConfigLive,
|
|
160
|
+
NotificationEmailSenderLive,
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Webhook Delivery Tracking
|
|
165
|
+
|
|
166
|
+
When the organisation exports `ResendServerPlugin`, local and cloud runtimes
|
|
167
|
+
use deferred completion. The process step is sent first, then stays pending
|
|
168
|
+
until Resend calls back with a terminal webhook event. Organisations without
|
|
169
|
+
that registration do not expose the Resend webhook or install Resend job
|
|
170
|
+
services.
|
|
171
|
+
|
|
172
|
+
Configure a Resend webhook for your deployed environment at:
|
|
173
|
+
|
|
174
|
+
- `https://<your-domain>/webhooks/resend`
|
|
175
|
+
- If you do not use a custom domain: `https://<env>.<project-id>.app.processfocus.com/webhooks/resend`
|
|
176
|
+
|
|
177
|
+
Subscribe the webhook to these Resend events:
|
|
178
|
+
|
|
179
|
+
- `email.bounced`
|
|
180
|
+
- `email.delivered`
|
|
181
|
+
- `email.failed`
|
|
182
|
+
- `email.suppressed`
|
|
183
|
+
|
|
184
|
+
Store the signing secret that Resend gives you as `RESEND_WEBHOOK_SECRET`:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
pfcli config set RESEND_WEBHOOK_SECRET="whsec_xxxxxxxx" --project <project-id> --stage "<stage-name>" --secret
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Notes:
|
|
191
|
+
|
|
192
|
+
- `email.delivered` completes the deferred step.
|
|
193
|
+
- `email.failed`, `email.bounced`, and `email.suppressed` fail the deferred step.
|
|
194
|
+
- If no webhook is configured, or `RESEND_WEBHOOK_SECRET` is missing, resend steps can remain running indefinitely.
|
|
195
|
+
- This still applies when `RESEND_ENABLED="false"` or `RESEND_REROUTE_EMAIL` is set. Rerouted emails are still tracked through Resend webhooks.
|
|
196
|
+
|
|
197
|
+
A typical resend payload:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"created_at": "2026-04-13T00:05:43.089Z",
|
|
202
|
+
"data": {
|
|
203
|
+
"created_at": "2026-04-13T00:05:42.051Z",
|
|
204
|
+
"email_id": "5d405080-89b2-4465-8c6d-27d00a88ef91",
|
|
205
|
+
"from": "ACME <noreply@example.com>",
|
|
206
|
+
"subject": "Enrolment enquiry received",
|
|
207
|
+
"tags": {
|
|
208
|
+
"pf_environment": "test",
|
|
209
|
+
"pf_todo_id": "todo-01KP22H0SM1NEW1031BZ9D3KN6"
|
|
210
|
+
},
|
|
211
|
+
"to": [
|
|
212
|
+
"test@example.com"
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
"type": "email.delivered"
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Usage
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { ResendStep } from "@processfocus/plugin-resend"
|
|
223
|
+
|
|
224
|
+
const sendConfirmation = new ResendStep(flow, "Send confirmation", {
|
|
225
|
+
from: "Process Focus <noreply@processfocus.com>",
|
|
226
|
+
input: (state) => Effect.succeed({
|
|
227
|
+
to: [state.email],
|
|
228
|
+
subject: "Your request has been approved",
|
|
229
|
+
html: `<p>Hello ${state.name}, your request was approved.</p>`,
|
|
230
|
+
}),
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## ResendStep API
|
|
235
|
+
|
|
236
|
+
### Constructor Props
|
|
237
|
+
|
|
238
|
+
- `from: string` - Default sender address (e.g., `"Process Focus <noreply@processfocus.com>"`)
|
|
239
|
+
- `input` - Function mapping state to `ResendEmailInput`
|
|
240
|
+
- `name?`, `purpose?`, `phase?`, `sla?` - Standard step props
|
|
241
|
+
|
|
242
|
+
### ResendEmailInput
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
interface ResendEmailInput {
|
|
246
|
+
readonly to: string | readonly string[]
|
|
247
|
+
readonly subject: string
|
|
248
|
+
readonly html?: string
|
|
249
|
+
readonly text?: string
|
|
250
|
+
readonly from?: string // overrides step's default
|
|
251
|
+
readonly replyTo?: string | readonly string[]
|
|
252
|
+
readonly cc?: string | readonly string[]
|
|
253
|
+
readonly bcc?: string | readonly string[]
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Output
|
|
258
|
+
|
|
259
|
+
The step returns `{ emailId: string }` which is the Resend email ID.
|
|
260
|
+
|
|
261
|
+
## DNS Configuration
|
|
262
|
+
|
|
263
|
+
Configure the records supplied by Resend for your own sending domain:
|
|
264
|
+
|
|
265
|
+
- **DKIM**: `resend._domainkey` TXT record
|
|
266
|
+
- **MX**: `send` subdomain pointing to Amazon SES
|
|
267
|
+
- **SPF**: `send` subdomain TXT record
|
|
268
|
+
- **DMARC**: `_dmarc` TXT record
|
|
269
|
+
|
|
270
|
+
## Testing
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
bun scripts/nx-quiet.ts run @processfocus/plugin-resend:test
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Mock Resend Test Support
|
|
277
|
+
|
|
278
|
+
Tests can import `makeMockResendPlugin()` from
|
|
279
|
+
`@processfocus/plugin-resend/test-support`. It returns `{ layer, controller }`.
|
|
280
|
+
|
|
281
|
+
The layer provides:
|
|
282
|
+
|
|
283
|
+
- `ResendClient` for `ResendStep` sends.
|
|
284
|
+
- `ResendDeferredDelivery` for deferred `ResendStep.executeStep()` tests.
|
|
285
|
+
- `EmailSender` and `NotificationDeliveryConfig` for notification-delivery tests.
|
|
286
|
+
|
|
287
|
+
The controller lists captured messages, finds messages by provider email id,
|
|
288
|
+
Todo id, or Public Completion Invitation Attempt id, and creates signed
|
|
289
|
+
Resend-style delivery, bounce, suppression, and recipient-failure callback
|
|
290
|
+
requests.
|
|
291
|
+
|
|
292
|
+
`controller.clear()` removes captured messages and resets mock email and delivery
|
|
293
|
+
id counters, so old ids can be reused after clearing.
|
|
294
|
+
|
|
295
|
+
Notification-delivery Tags used with `./testing` (`EmailSender`,
|
|
296
|
+
`NotificationDeliveryConfig`) come from `@processfocus/runtime`. The testing
|
|
297
|
+
entrypoint itself exports `makeMockResendPlugin` and is not re-exported from
|
|
298
|
+
the package root.
|
|
299
|
+
|
|
300
|
+
By default, captured message and webhook timestamps use the current clock. Pass
|
|
301
|
+
`now` to `makeMockResendPlugin()` or per-event timestamp overrides when tests
|
|
302
|
+
need deterministic fake-time assertions.
|
|
303
|
+
|
|
304
|
+
Mock sending is enabled by default so unit tests capture normal sends without
|
|
305
|
+
environment setup. Set `enabled: false` to exercise reroute behavior.
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
import { Effect } from "effect"
|
|
309
|
+
import { makeMockResendPlugin } from "@processfocus/plugin-resend/test-support"
|
|
310
|
+
import { ResendClient } from "@processfocus/plugin-resend"
|
|
311
|
+
|
|
312
|
+
const resend = makeMockResendPlugin({ environment: "dev" })
|
|
313
|
+
|
|
314
|
+
const result = await Effect.runPromise(
|
|
315
|
+
Effect.gen(function* () {
|
|
316
|
+
const client = yield* ResendClient
|
|
317
|
+
return yield* client.sendEmail({
|
|
318
|
+
to: "external@example.com",
|
|
319
|
+
from: "Process Focus <notifications@example.com>",
|
|
320
|
+
subject: "Complete form",
|
|
321
|
+
html: "<p>Please complete the form.</p>",
|
|
322
|
+
tags: [{ name: "pf_todo_id", value: "todo-123" }],
|
|
323
|
+
})
|
|
324
|
+
}).pipe(Effect.provide(resend.layer)),
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
const delivered = resend.controller.emitDelivery(result.emailId)
|
|
328
|
+
// Pass `delivered.request` to the Resend webhook handler in integration tests.
|
|
329
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type ResendApiAttachment, ResendClient, ResendClientConfig, ResendDeferredDelivery, type ResendEmailRequest, type ResendEmailResponse, type ResendEmailTemplate, ResendError, } from "./lib/resend-client.js";
|
|
2
|
+
export * from "./lib/resend-step.js";
|
|
3
|
+
export * from "./lib/resend-webhook-event.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EAItB,WAAW,GACZ,MAAM,qBAAqB,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { EmailSender, NotificationDeliveryConfig } from "@processfocus/runtime";
|
|
3
|
+
import { ResendClient, ResendDeferredDelivery, type ResendEmailRequest } from "./resend-client.js";
|
|
4
|
+
export declare const DEFAULT_MOCK_RESEND_WEBHOOK_SECRET: string;
|
|
5
|
+
export interface MockResendSenderIdentity {
|
|
6
|
+
readonly email: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MockResendPluginOptions {
|
|
10
|
+
readonly enabled?: boolean;
|
|
11
|
+
readonly rerouteEmail?: string;
|
|
12
|
+
readonly environment?: string;
|
|
13
|
+
readonly frontendBaseUrl?: string;
|
|
14
|
+
readonly sender?: MockResendSenderIdentity | null;
|
|
15
|
+
readonly webhookSecret?: string;
|
|
16
|
+
readonly webhookUrl?: string;
|
|
17
|
+
readonly emailIdPrefix?: string;
|
|
18
|
+
readonly deliveryIdPrefix?: string;
|
|
19
|
+
readonly now?: () => Date;
|
|
20
|
+
}
|
|
21
|
+
export interface MockResendSentMessage {
|
|
22
|
+
readonly emailId: string;
|
|
23
|
+
readonly originalRequest: ResendEmailRequest;
|
|
24
|
+
readonly request: ResendEmailRequest;
|
|
25
|
+
readonly originalTo: string | readonly string[];
|
|
26
|
+
readonly sentTo: string | readonly string[];
|
|
27
|
+
readonly rerouted: boolean;
|
|
28
|
+
readonly createdAt: string;
|
|
29
|
+
}
|
|
30
|
+
export type MockResendWebhookEventType = "email.delivered" | "email.bounced" | "email.suppressed" | "email.failed";
|
|
31
|
+
export interface MockResendWebhookPayload {
|
|
32
|
+
readonly type: MockResendWebhookEventType;
|
|
33
|
+
readonly created_at: string;
|
|
34
|
+
readonly data: {
|
|
35
|
+
readonly created_at: string;
|
|
36
|
+
readonly email_id: string;
|
|
37
|
+
readonly from?: string;
|
|
38
|
+
readonly subject?: string;
|
|
39
|
+
readonly to: readonly string[];
|
|
40
|
+
readonly tags: Readonly<Record<string, string>>;
|
|
41
|
+
readonly bounce?: {
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly subType: string;
|
|
44
|
+
readonly message: string;
|
|
45
|
+
};
|
|
46
|
+
readonly failed?: {
|
|
47
|
+
readonly reason: string;
|
|
48
|
+
readonly recipient: string;
|
|
49
|
+
};
|
|
50
|
+
readonly suppressed?: {
|
|
51
|
+
readonly reason: string;
|
|
52
|
+
readonly recipient: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface MockResendSignedCallback {
|
|
57
|
+
readonly request: Request;
|
|
58
|
+
readonly headers: Headers;
|
|
59
|
+
readonly body: string;
|
|
60
|
+
readonly payload: MockResendWebhookPayload;
|
|
61
|
+
readonly webhookSecret: string;
|
|
62
|
+
}
|
|
63
|
+
export type MockResendMessageRef = string | MockResendSentMessage;
|
|
64
|
+
export interface MockResendEventOptions {
|
|
65
|
+
readonly deliveryId?: string;
|
|
66
|
+
readonly timestampSeconds?: number;
|
|
67
|
+
readonly eventCreatedAt?: string;
|
|
68
|
+
readonly emailCreatedAt?: string;
|
|
69
|
+
readonly webhookUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface MockResendBounceEventOptions extends MockResendEventOptions {
|
|
72
|
+
readonly bounceType?: string;
|
|
73
|
+
readonly bounceSubType?: string;
|
|
74
|
+
readonly message?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface MockResendSuppressionEventOptions extends MockResendEventOptions {
|
|
77
|
+
readonly recipient?: string;
|
|
78
|
+
readonly reason?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface MockResendRecipientFailureEventOptions extends MockResendEventOptions {
|
|
81
|
+
readonly recipient?: string;
|
|
82
|
+
readonly reason?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface MockResendController {
|
|
85
|
+
readonly webhookSecret: string;
|
|
86
|
+
readonly listSentMessages: () => readonly MockResendSentMessage[];
|
|
87
|
+
readonly clear: () => void;
|
|
88
|
+
readonly findMessageByEmailId: (emailId: string) => MockResendSentMessage | undefined;
|
|
89
|
+
readonly findMessageByTodoId: (todoId: string) => MockResendSentMessage | undefined;
|
|
90
|
+
readonly findMessageByPublicCompletionInvitationAttemptId: (attemptId: string) => MockResendSentMessage | undefined;
|
|
91
|
+
readonly emitDelivery: (message: MockResendMessageRef, options?: MockResendEventOptions) => MockResendSignedCallback;
|
|
92
|
+
readonly emitBounce: (message: MockResendMessageRef, options?: MockResendBounceEventOptions) => MockResendSignedCallback;
|
|
93
|
+
readonly emitSuppression: (message: MockResendMessageRef, options?: MockResendSuppressionEventOptions) => MockResendSignedCallback;
|
|
94
|
+
readonly emitRecipientFailure: (message: MockResendMessageRef, options?: MockResendRecipientFailureEventOptions) => MockResendSignedCallback;
|
|
95
|
+
}
|
|
96
|
+
export interface MockResendPlugin {
|
|
97
|
+
readonly layer: Layer.Layer<ResendClient | EmailSender | NotificationDeliveryConfig | ResendDeferredDelivery, never, never>;
|
|
98
|
+
readonly controller: MockResendController;
|
|
99
|
+
}
|
|
100
|
+
export declare const makeMockResendPlugin: (options?: MockResendPluginOptions) => MockResendPlugin;
|