@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
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { SERVER_PLUGIN_HOST_INTERFACE_VERSION, WebhookCallbackHost, } from "@processfocus/runtime";
|
|
2
|
+
import { Config, Data, Effect, Either, Layer, Option, Redacted } from "effect";
|
|
3
|
+
import { ResendClientConfigFromEnv, ResendClientLive, ResendDeferredDelivery, } from "./resend-client.js";
|
|
4
|
+
import { decodeResendWebhookPayload, getSvixHeaderValues, isResendWebhookRecord, normalizeResendEmail, parseResendWebhookEvent, verifyResendWebhookSignature, } from "./resend-webhook-event.js";
|
|
5
|
+
export const RESEND_WEBHOOK_PATH = "/webhooks/resend";
|
|
6
|
+
class InvalidRequestBodyError extends Data.TaggedError("InvalidRequestBodyError") {
|
|
7
|
+
}
|
|
8
|
+
const textResponse = (status, body) => new Response(body, {
|
|
9
|
+
status,
|
|
10
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
11
|
+
});
|
|
12
|
+
const okResponse = () => textResponse(200, "ok");
|
|
13
|
+
const retryableResponse = (body) => new Response(body, {
|
|
14
|
+
status: 503,
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
17
|
+
"Retry-After": "5",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const getStoredResendMetadata = (state) => {
|
|
21
|
+
const internal = state["_internal"];
|
|
22
|
+
if (!isResendWebhookRecord(internal))
|
|
23
|
+
return null;
|
|
24
|
+
const resend = internal["resend"];
|
|
25
|
+
if (!isResendWebhookRecord(resend))
|
|
26
|
+
return null;
|
|
27
|
+
const emailId = resend["emailId"];
|
|
28
|
+
const primaryTo = resend["primaryTo"];
|
|
29
|
+
const environment = resend["environment"];
|
|
30
|
+
if (typeof emailId !== "string" ||
|
|
31
|
+
typeof primaryTo !== "string" ||
|
|
32
|
+
typeof environment !== "string") {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return { emailId, primaryTo, environment };
|
|
36
|
+
};
|
|
37
|
+
const getWebhookConfig = Effect.gen(function* () {
|
|
38
|
+
const secret = yield* Config.option(Config.redacted("RESEND_WEBHOOK_SECRET"));
|
|
39
|
+
const environment = yield* Config.string("PF_ENV").pipe(Config.withDefault("local"));
|
|
40
|
+
return {
|
|
41
|
+
webhookSecret: Option.map(secret, Redacted.value).pipe(Option.getOrUndefined),
|
|
42
|
+
environment,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
/** Provider-owned Resend callback behavior behind generic host callbacks. */
|
|
46
|
+
export const handleResendWebhookRequest = (request) => Effect.gen(function* () {
|
|
47
|
+
if (request.method !== "POST") {
|
|
48
|
+
return textResponse(405, "Method Not Allowed");
|
|
49
|
+
}
|
|
50
|
+
const callbacks = yield* WebhookCallbackHost;
|
|
51
|
+
const config = yield* getWebhookConfig;
|
|
52
|
+
if (!config.webhookSecret) {
|
|
53
|
+
yield* Effect.logError("RESEND_WEBHOOK_SECRET is not configured");
|
|
54
|
+
return textResponse(503, "Resend webhook secret is not configured");
|
|
55
|
+
}
|
|
56
|
+
const svixHeaders = getSvixHeaderValues(request.headers);
|
|
57
|
+
if (!svixHeaders) {
|
|
58
|
+
return textResponse(400, "Missing webhook signature headers");
|
|
59
|
+
}
|
|
60
|
+
const rawBodyResult = yield* Effect.either(Effect.tryPromise({
|
|
61
|
+
try: () => request.text(),
|
|
62
|
+
catch: (cause) => new InvalidRequestBodyError({ cause }),
|
|
63
|
+
}));
|
|
64
|
+
if (Either.isLeft(rawBodyResult)) {
|
|
65
|
+
yield* Effect.logError("Failed to read Resend webhook request body", {
|
|
66
|
+
error: String(rawBodyResult.left),
|
|
67
|
+
});
|
|
68
|
+
return textResponse(400, "Invalid request body");
|
|
69
|
+
}
|
|
70
|
+
const rawBody = rawBodyResult.right;
|
|
71
|
+
if (!verifyResendWebhookSignature({
|
|
72
|
+
payload: rawBody,
|
|
73
|
+
headers: request.headers,
|
|
74
|
+
webhookSecret: config.webhookSecret,
|
|
75
|
+
})) {
|
|
76
|
+
return textResponse(401, "Invalid webhook signature");
|
|
77
|
+
}
|
|
78
|
+
const deliveryId = svixHeaders.id;
|
|
79
|
+
const payloadResult = yield* Effect.either(decodeResendWebhookPayload(rawBody));
|
|
80
|
+
if (Either.isLeft(payloadResult)) {
|
|
81
|
+
yield* Effect.logError("Failed to parse Resend webhook payload", {
|
|
82
|
+
error: String(payloadResult.left),
|
|
83
|
+
});
|
|
84
|
+
return textResponse(400, "Invalid JSON payload");
|
|
85
|
+
}
|
|
86
|
+
const event = parseResendWebhookEvent({
|
|
87
|
+
deliveryId,
|
|
88
|
+
payload: payloadResult.right,
|
|
89
|
+
});
|
|
90
|
+
const webhookEnvironment = event.publicCompletion?.environment ?? event.deferredTodo?.environment;
|
|
91
|
+
const logContext = {
|
|
92
|
+
deliveryId,
|
|
93
|
+
eventType: event.eventType,
|
|
94
|
+
...(event.emailId !== undefined && { emailId: event.emailId }),
|
|
95
|
+
...(webhookEnvironment !== undefined && { webhookEnvironment }),
|
|
96
|
+
...(event.recipients.length > 0 && { recipients: event.recipients }),
|
|
97
|
+
};
|
|
98
|
+
if (event.publicCompletion !== undefined) {
|
|
99
|
+
const publicCompletion = event.publicCompletion;
|
|
100
|
+
if (publicCompletion.environment === undefined) {
|
|
101
|
+
yield* Effect.logInfo("Ignoring public-completion Resend webhook without environment tag", {
|
|
102
|
+
...logContext,
|
|
103
|
+
todoId: publicCompletion.todoId,
|
|
104
|
+
invitationAttemptId: publicCompletion.invitationAttemptId,
|
|
105
|
+
expectedEnvironment: config.environment,
|
|
106
|
+
});
|
|
107
|
+
return okResponse();
|
|
108
|
+
}
|
|
109
|
+
if (publicCompletion.environment !== config.environment) {
|
|
110
|
+
yield* Effect.logInfo("Ignoring public-completion Resend webhook for a different environment", {
|
|
111
|
+
...logContext,
|
|
112
|
+
todoId: publicCompletion.todoId,
|
|
113
|
+
invitationAttemptId: publicCompletion.invitationAttemptId,
|
|
114
|
+
expectedEnvironment: config.environment,
|
|
115
|
+
});
|
|
116
|
+
return okResponse();
|
|
117
|
+
}
|
|
118
|
+
if (publicCompletion.invitationAttemptId === undefined) {
|
|
119
|
+
yield* Effect.logInfo("Ignoring public-completion Resend webhook without invitation attempt tag", { ...logContext, todoId: publicCompletion.todoId });
|
|
120
|
+
return okResponse();
|
|
121
|
+
}
|
|
122
|
+
if (!event.delivered && event.failure === null) {
|
|
123
|
+
yield* Effect.logInfo("Ignoring non-terminal public-completion Resend webhook event", {
|
|
124
|
+
...logContext,
|
|
125
|
+
todoId: publicCompletion.todoId,
|
|
126
|
+
invitationAttemptId: publicCompletion.invitationAttemptId,
|
|
127
|
+
});
|
|
128
|
+
return okResponse();
|
|
129
|
+
}
|
|
130
|
+
if (event.delivered) {
|
|
131
|
+
yield* callbacks.applyPublicCompletionCallback({
|
|
132
|
+
status: "delivered",
|
|
133
|
+
deliveryId,
|
|
134
|
+
todoId: publicCompletion.todoId,
|
|
135
|
+
invitationAttemptId: publicCompletion.invitationAttemptId,
|
|
136
|
+
...(event.emailId !== undefined && {
|
|
137
|
+
providerMessageId: event.emailId,
|
|
138
|
+
}),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else if (event.failure !== null) {
|
|
142
|
+
yield* callbacks.applyPublicCompletionCallback({
|
|
143
|
+
status: "failed",
|
|
144
|
+
deliveryId,
|
|
145
|
+
todoId: publicCompletion.todoId,
|
|
146
|
+
invitationAttemptId: publicCompletion.invitationAttemptId,
|
|
147
|
+
...(event.emailId !== undefined && {
|
|
148
|
+
providerMessageId: event.emailId,
|
|
149
|
+
}),
|
|
150
|
+
failureKind: event.failure.failureKind,
|
|
151
|
+
failureReason: event.failure.failureReason,
|
|
152
|
+
...(event.failure.details !== undefined && {
|
|
153
|
+
failureDetails: event.failure.details,
|
|
154
|
+
}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return okResponse();
|
|
158
|
+
}
|
|
159
|
+
if (event.deferredTodo?.environment !== config.environment) {
|
|
160
|
+
yield* Effect.logInfo("Ignoring Resend webhook for a different environment", { ...logContext, expectedEnvironment: config.environment });
|
|
161
|
+
return okResponse();
|
|
162
|
+
}
|
|
163
|
+
const todoId = event.deferredTodo?.todoId;
|
|
164
|
+
if (!todoId) {
|
|
165
|
+
yield* Effect.logInfo("Ignoring Resend webhook without todo correlation tag", logContext);
|
|
166
|
+
return okResponse();
|
|
167
|
+
}
|
|
168
|
+
if (!event.delivered && event.failure === null) {
|
|
169
|
+
yield* Effect.logInfo("Ignoring non-terminal Resend webhook event", {
|
|
170
|
+
...logContext,
|
|
171
|
+
todoId,
|
|
172
|
+
});
|
|
173
|
+
return okResponse();
|
|
174
|
+
}
|
|
175
|
+
const snapshot = yield* callbacks.lookupDeferredTodo(todoId);
|
|
176
|
+
if (!snapshot) {
|
|
177
|
+
yield* Effect.logInfo("Resend webhook todo not found, skipping callback", {
|
|
178
|
+
...logContext,
|
|
179
|
+
todoId,
|
|
180
|
+
});
|
|
181
|
+
return okResponse();
|
|
182
|
+
}
|
|
183
|
+
const metadata = getStoredResendMetadata(snapshot.state);
|
|
184
|
+
if (!metadata) {
|
|
185
|
+
yield* Effect.logWarning("Resend webhook todo has no deferred Resend metadata yet, requesting retry", { ...logContext, todoId });
|
|
186
|
+
return retryableResponse("Deferred Resend metadata not persisted yet; retry webhook");
|
|
187
|
+
}
|
|
188
|
+
if (metadata.environment !== config.environment) {
|
|
189
|
+
yield* Effect.logInfo("Ignoring Resend webhook because stored metadata environment differs", {
|
|
190
|
+
...logContext,
|
|
191
|
+
todoId,
|
|
192
|
+
storedEnvironment: metadata.environment,
|
|
193
|
+
expectedEnvironment: config.environment,
|
|
194
|
+
});
|
|
195
|
+
return okResponse();
|
|
196
|
+
}
|
|
197
|
+
const primaryRecipient = normalizeResendEmail(metadata.primaryTo);
|
|
198
|
+
if (!event.recipients.includes(primaryRecipient)) {
|
|
199
|
+
yield* Effect.logWarning("Ignoring Resend webhook because recipients do not include the stored primary recipient", {
|
|
200
|
+
...logContext,
|
|
201
|
+
todoId,
|
|
202
|
+
primaryRecipient,
|
|
203
|
+
storedEmailId: metadata.emailId,
|
|
204
|
+
});
|
|
205
|
+
return okResponse();
|
|
206
|
+
}
|
|
207
|
+
if (event.delivered) {
|
|
208
|
+
yield* Effect.logInfo("Completing deferred Resend todo from delivery webhook", {
|
|
209
|
+
...logContext,
|
|
210
|
+
todoId,
|
|
211
|
+
primaryRecipient,
|
|
212
|
+
storedEmailId: metadata.emailId,
|
|
213
|
+
});
|
|
214
|
+
const result = yield* callbacks.completeDeferredTodo({
|
|
215
|
+
todoId,
|
|
216
|
+
callbackId: deliveryId,
|
|
217
|
+
output: { emailId: metadata.emailId },
|
|
218
|
+
});
|
|
219
|
+
if (result._tag === "Ignored") {
|
|
220
|
+
yield* Effect.log("Resend webhook delivery already completed, skipping duplicate callback", { deliveryId, todoId, emailId: metadata.emailId });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else if (event.failure !== null) {
|
|
224
|
+
yield* Effect.logWarning("Failing deferred Resend todo from failure webhook", {
|
|
225
|
+
...logContext,
|
|
226
|
+
todoId,
|
|
227
|
+
primaryRecipient,
|
|
228
|
+
storedEmailId: metadata.emailId,
|
|
229
|
+
failureReason: event.failure.failureReason,
|
|
230
|
+
...event.failure.details,
|
|
231
|
+
});
|
|
232
|
+
yield* callbacks.failDeferredTodo({
|
|
233
|
+
todoId,
|
|
234
|
+
callbackId: deliveryId,
|
|
235
|
+
failureReason: event.failure.failureReason,
|
|
236
|
+
errorTag: event.failure.errorTag,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return okResponse();
|
|
240
|
+
}).pipe(Effect.catchAllCause((cause) => Effect.logError("Failed to process Resend webhook", { cause }).pipe(Effect.as(textResponse(500, "Failed to process webhook")))));
|
|
241
|
+
export const ResendDeferredDeliveryFromEnv = Layer.effect(ResendDeferredDelivery, Config.string("PF_ENV").pipe(Config.withDefault("local"), Effect.map((environment) => ({ environment }))));
|
|
242
|
+
export const ResendServerPluginJobLayer = Layer.merge(Layer.provideMerge(ResendClientLive, ResendClientConfigFromEnv), ResendDeferredDeliveryFromEnv);
|
|
243
|
+
export const makeResendServerPlugin = (options) => ({
|
|
244
|
+
identity: "email.resend",
|
|
245
|
+
hostInterfaceVersion: SERVER_PLUGIN_HOST_INTERFACE_VERSION,
|
|
246
|
+
jobLayer: options?.jobLayer ?? ResendServerPluginJobLayer,
|
|
247
|
+
webhooks: [
|
|
248
|
+
{
|
|
249
|
+
path: RESEND_WEBHOOK_PATH,
|
|
250
|
+
handle: handleResendWebhookRequest,
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
export const ResendServerPlugin = makeResendServerPlugin();
|
|
255
|
+
//# sourceMappingURL=resend-server-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend-server-plugin.js","sourceRoot":"","sources":["../../src/lib/resend-server-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EAGpC,mBAAmB,GACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC9E,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAA;AAE/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AAiBrD,MAAM,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CACpD,yBAAyB,CAGzB;CAAG;AAEL,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE,CACpD,IAAI,QAAQ,CAAC,IAAI,EAAE;IACjB,MAAM;IACN,OAAO,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE;CACzD,CAAC,CAAA;AAEJ,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AAEhD,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE,CACzC,IAAI,QAAQ,CAAC,IAAI,EAAE;IACjB,MAAM,EAAE,GAAG;IACX,OAAO,EAAE;QACP,cAAc,EAAE,2BAA2B;QAC3C,aAAa,EAAE,GAAG;KACnB;CACF,CAAC,CAAA;AAEJ,MAAM,uBAAuB,GAAG,C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AAE,OAAO,EAAE,QAAQ,IAAI,0BAA0B;IACzD,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,0BAA0B;SACnC;KACF;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,EAAE,CAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { type AuthorTaggedError, type FlowContext, type FlowPath, type FormStepMeta, type IStepScope, type InferSchemaType, type Phase, type Process, type SlaConfig, type StepJobContext, type StepMeta, type StepResult, SystemStep } from "processfocus";
|
|
3
|
+
import { type ResendEmailTemplate, ResendError } from "./resend-client.js";
|
|
4
|
+
/**
|
|
5
|
+
* An attachment backed by the document store.
|
|
6
|
+
* The file content is fetched server-side and base64-encoded for the
|
|
7
|
+
* Resend API.
|
|
8
|
+
*/
|
|
9
|
+
export interface ResendEmailAttachment {
|
|
10
|
+
readonly filename: string;
|
|
11
|
+
readonly storePrefix: string;
|
|
12
|
+
readonly fileId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Input type for ResendEmailStep - the data needed to send an email.
|
|
16
|
+
*
|
|
17
|
+
* When sending with a Resend template:
|
|
18
|
+
* - `from` and `subject` are optional if the template already defines them
|
|
19
|
+
* - if `from` or `subject` are provided here, they override the template values
|
|
20
|
+
*/
|
|
21
|
+
export interface ResendEmailInput {
|
|
22
|
+
readonly to: string | readonly string[];
|
|
23
|
+
readonly subject?: string;
|
|
24
|
+
readonly html?: string;
|
|
25
|
+
readonly text?: string;
|
|
26
|
+
readonly template?: ResendEmailTemplate;
|
|
27
|
+
readonly from?: string;
|
|
28
|
+
readonly replyTo?: string | readonly string[];
|
|
29
|
+
readonly cc?: string | readonly string[];
|
|
30
|
+
readonly bcc?: string | readonly string[];
|
|
31
|
+
readonly attachments?: readonly ResendEmailAttachment[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Output schema for ResendStep - returns the email ID from Resend API.
|
|
35
|
+
*/
|
|
36
|
+
export declare const resendOutput: {
|
|
37
|
+
emailId: typeof Schema.String;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for forEach (multi-instance) steps in ResendStep.
|
|
41
|
+
*/
|
|
42
|
+
export interface ResendForEachConfig<TState, TSteps extends Record<string, StepMeta | FormStepMeta>> {
|
|
43
|
+
readonly items: (state: TState, ctx: FlowContext<TSteps>) => Effect.Effect<ReadonlyArray<ResendEmailInput>, AuthorTaggedError, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Props for ResendStep - sends emails via Resend API.
|
|
47
|
+
*
|
|
48
|
+
* @typeParam TState - Accumulated state from previous steps
|
|
49
|
+
* @typeParam TSteps - Record of completed step metadata for ctx.step access
|
|
50
|
+
* @typeParam TIsForEach - Whether this step uses forEach semantics
|
|
51
|
+
*/
|
|
52
|
+
export type ResendStepProps<TState = Record<string, never>, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>, TIsForEach extends boolean = boolean> = {
|
|
53
|
+
readonly name?: string;
|
|
54
|
+
readonly purpose?: string;
|
|
55
|
+
readonly phase?: Phase;
|
|
56
|
+
readonly sla?: SlaConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Default sender address, e.g. "Process Focus <noreply@processfocus.com>".
|
|
59
|
+
* Optional when sending with a Resend template that already defines a sender.
|
|
60
|
+
* If both are provided, the step/input value overrides the template default.
|
|
61
|
+
*/
|
|
62
|
+
readonly from?: string;
|
|
63
|
+
} & (TIsForEach extends true ? {
|
|
64
|
+
forEach: ResendForEachConfig<TState, TSteps>;
|
|
65
|
+
input?: never;
|
|
66
|
+
} : {
|
|
67
|
+
input: (state: TState, ctx: FlowContext<TSteps>) => Effect.Effect<ResendEmailInput>;
|
|
68
|
+
forEach?: never;
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* ResendStep sends emails via the Resend API.
|
|
72
|
+
*
|
|
73
|
+
* Uses the shared Resend client from the plugin runtime layer.
|
|
74
|
+
* Returns the email ID from Resend in the output.
|
|
75
|
+
*
|
|
76
|
+
* @typeParam TState - Accumulated state from previous steps
|
|
77
|
+
* @typeParam TSteps - Record of completed step metadata for ctx.step access
|
|
78
|
+
* @typeParam TId - Step identifier literal type
|
|
79
|
+
* @typeParam TIsForEach - Whether this step uses forEach semantics
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const sendConfirmation = new ResendStep(flow, "Send confirmation", {
|
|
84
|
+
* from: "Process Focus <noreply@processfocus.com>",
|
|
85
|
+
* input: (state) => Effect.succeed({
|
|
86
|
+
* to: [state.email],
|
|
87
|
+
* subject: "Your request has been approved",
|
|
88
|
+
* html: `<p>Hello ${state.name}, your request was approved.</p>`,
|
|
89
|
+
* }),
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare class ResendStep<TState = Record<string, never>, TSteps extends Record<string, StepMeta | FormStepMeta> = Record<string, never>, TId extends string = string, TIsForEach extends boolean = boolean> extends SystemStep<TState, TSteps, ResendEmailInput, typeof resendOutput, TId, TIsForEach> {
|
|
94
|
+
/**
|
|
95
|
+
* Default sender address for emails.
|
|
96
|
+
*/
|
|
97
|
+
readonly from: string | undefined;
|
|
98
|
+
constructor(scope: Process | IStepScope<TState, TSteps> | FlowPath<TState, Schema.Struct.Fields | undefined, TSteps>, id: TId, props: ResendStepProps<TState, TSteps, any>);
|
|
99
|
+
/**
|
|
100
|
+
* Validate input and resolve attachments. Shared by both execute() and
|
|
101
|
+
* executeStep() to ensure consistent validation across modes.
|
|
102
|
+
*/
|
|
103
|
+
private validateAndResolve;
|
|
104
|
+
/**
|
|
105
|
+
* Build a ResendEmailRequest from input and resolved values.
|
|
106
|
+
*/
|
|
107
|
+
private buildSendRequest;
|
|
108
|
+
/**
|
|
109
|
+
* Execute the email send via Resend API.
|
|
110
|
+
*
|
|
111
|
+
* Delegates delivery to the shared plugin Resend client.
|
|
112
|
+
* Returns the email ID from the Resend response.
|
|
113
|
+
*
|
|
114
|
+
* Error handling:
|
|
115
|
+
* - API errors are wrapped in ResendError
|
|
116
|
+
* - Non-2xx responses are failed
|
|
117
|
+
*/
|
|
118
|
+
execute(input: ResendEmailInput): Effect.Effect<InferSchemaType<typeof resendOutput>, ResendError, unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* Execute the step and wrap output as a StepResult.
|
|
121
|
+
*
|
|
122
|
+
* When the ResendDeferredDelivery capability is available (AWS runtime),
|
|
123
|
+
* sends the email, tags it for webhook correlation, persists internal
|
|
124
|
+
* tracking metadata into process state, and returns a deferred result.
|
|
125
|
+
*
|
|
126
|
+
* When the capability is absent (local runtime), falls back to the
|
|
127
|
+
* default immediate-completion behavior.
|
|
128
|
+
*/
|
|
129
|
+
executeStep(input: ResendEmailInput, jobContext: StepJobContext): Effect.Effect<StepResult, AuthorTaggedError, unknown>;
|
|
130
|
+
/**
|
|
131
|
+
* Deferred execution path: sends the email, tags it, returns state update.
|
|
132
|
+
*/
|
|
133
|
+
private executeDeferred;
|
|
134
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Effect, Encoding, Option, Schema } from "effect";
|
|
2
|
+
import { DocumentStoreService } from "@processfocus/runtime";
|
|
3
|
+
import { StepProcessStateReader, SystemStep, } from "processfocus";
|
|
4
|
+
import { ResendClient, ResendDeferredDelivery, ResendError, } from "./resend-client.js";
|
|
5
|
+
/**
|
|
6
|
+
* Output schema for ResendStep - returns the email ID from Resend API.
|
|
7
|
+
*/
|
|
8
|
+
export const resendOutput = {
|
|
9
|
+
emailId: Schema.String,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* ResendStep sends emails via the Resend API.
|
|
13
|
+
*
|
|
14
|
+
* Uses the shared Resend client from the plugin runtime layer.
|
|
15
|
+
* Returns the email ID from Resend in the output.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam TState - Accumulated state from previous steps
|
|
18
|
+
* @typeParam TSteps - Record of completed step metadata for ctx.step access
|
|
19
|
+
* @typeParam TId - Step identifier literal type
|
|
20
|
+
* @typeParam TIsForEach - Whether this step uses forEach semantics
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const sendConfirmation = new ResendStep(flow, "Send confirmation", {
|
|
25
|
+
* from: "Process Focus <noreply@processfocus.com>",
|
|
26
|
+
* input: (state) => Effect.succeed({
|
|
27
|
+
* to: [state.email],
|
|
28
|
+
* subject: "Your request has been approved",
|
|
29
|
+
* html: `<p>Hello ${state.name}, your request was approved.</p>`,
|
|
30
|
+
* }),
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export class ResendStep extends SystemStep {
|
|
35
|
+
/**
|
|
36
|
+
* Default sender address for emails.
|
|
37
|
+
*/
|
|
38
|
+
from;
|
|
39
|
+
constructor(scope, id,
|
|
40
|
+
// biome-ignore lint/suspicious/noExplicitAny: Discriminated union requires relaxed typing in constructor
|
|
41
|
+
props) {
|
|
42
|
+
super(scope, id, {
|
|
43
|
+
...props,
|
|
44
|
+
output: resendOutput,
|
|
45
|
+
});
|
|
46
|
+
this.from = props.from;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate input and resolve attachments. Shared by both execute() and
|
|
50
|
+
* executeStep() to ensure consistent validation across modes.
|
|
51
|
+
*/
|
|
52
|
+
validateAndResolve(input) {
|
|
53
|
+
return Effect.gen(this, function* () {
|
|
54
|
+
if (input.template &&
|
|
55
|
+
(input.html !== undefined || input.text !== undefined)) {
|
|
56
|
+
return yield* new ResendError({
|
|
57
|
+
message: "Email template cannot be combined with 'html' or 'text' content",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (!input.template && !input.html && !input.text) {
|
|
61
|
+
return yield* new ResendError({
|
|
62
|
+
message: "Email must include either 'html', 'text', or 'template' content",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const sender = input.from ?? this.from;
|
|
66
|
+
if (!input.template && sender === undefined) {
|
|
67
|
+
return yield* new ResendError({
|
|
68
|
+
message: "Email with 'html' or 'text' content must include a 'from' address",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (!input.template && input.subject === undefined) {
|
|
72
|
+
return yield* new ResendError({
|
|
73
|
+
message: "Email with 'html' or 'text' content must include a 'subject'",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
let resolvedAttachments;
|
|
77
|
+
if (input.attachments && input.attachments.length > 0) {
|
|
78
|
+
const docStore = yield* DocumentStoreService;
|
|
79
|
+
resolvedAttachments = [];
|
|
80
|
+
for (const att of input.attachments) {
|
|
81
|
+
const { content } = yield* docStore
|
|
82
|
+
.getFileContent(att.fileId, att.storePrefix)
|
|
83
|
+
.pipe(Effect.mapError((error) => new ResendError({
|
|
84
|
+
message: `Failed to fetch attachment "${att.filename}": ${String(error)}`,
|
|
85
|
+
cause: error,
|
|
86
|
+
})));
|
|
87
|
+
// Base64-encode for Resend API (platform-agnostic, no Node.js Buffer)
|
|
88
|
+
const base64 = Encoding.encodeBase64(content);
|
|
89
|
+
resolvedAttachments.push({
|
|
90
|
+
filename: att.filename,
|
|
91
|
+
content: base64,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { sender, resolvedAttachments };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build a ResendEmailRequest from input and resolved values.
|
|
100
|
+
*/
|
|
101
|
+
buildSendRequest(input, sender, resolvedAttachments, tags) {
|
|
102
|
+
return {
|
|
103
|
+
to: input.to,
|
|
104
|
+
...(sender !== undefined && { from: sender }),
|
|
105
|
+
...(input.subject !== undefined && { subject: input.subject }),
|
|
106
|
+
...(input.html !== undefined && { html: input.html }),
|
|
107
|
+
...(input.text !== undefined && { text: input.text }),
|
|
108
|
+
...(input.template !== undefined && { template: input.template }),
|
|
109
|
+
...(input.replyTo !== undefined && { replyTo: input.replyTo }),
|
|
110
|
+
...(input.cc !== undefined && { cc: input.cc }),
|
|
111
|
+
...(input.bcc !== undefined && { bcc: input.bcc }),
|
|
112
|
+
...(resolvedAttachments !== undefined && {
|
|
113
|
+
attachments: resolvedAttachments,
|
|
114
|
+
}),
|
|
115
|
+
...(tags !== undefined && { tags }),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Execute the email send via Resend API.
|
|
120
|
+
*
|
|
121
|
+
* Delegates delivery to the shared plugin Resend client.
|
|
122
|
+
* Returns the email ID from the Resend response.
|
|
123
|
+
*
|
|
124
|
+
* Error handling:
|
|
125
|
+
* - API errors are wrapped in ResendError
|
|
126
|
+
* - Non-2xx responses are failed
|
|
127
|
+
*/
|
|
128
|
+
execute(input) {
|
|
129
|
+
return Effect.gen(this, function* () {
|
|
130
|
+
const resendClient = yield* ResendClient;
|
|
131
|
+
const { sender, resolvedAttachments } = yield* this.validateAndResolve(input);
|
|
132
|
+
const result = yield* resendClient.sendEmail(this.buildSendRequest(input, sender, resolvedAttachments));
|
|
133
|
+
return { emailId: result.emailId };
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Execute the step and wrap output as a StepResult.
|
|
138
|
+
*
|
|
139
|
+
* When the ResendDeferredDelivery capability is available (AWS runtime),
|
|
140
|
+
* sends the email, tags it for webhook correlation, persists internal
|
|
141
|
+
* tracking metadata into process state, and returns a deferred result.
|
|
142
|
+
*
|
|
143
|
+
* When the capability is absent (local runtime), falls back to the
|
|
144
|
+
* default immediate-completion behavior.
|
|
145
|
+
*/
|
|
146
|
+
executeStep(input, jobContext) {
|
|
147
|
+
// Capture super reference outside Effect.gen (super is not accessible
|
|
148
|
+
// inside generator functions).
|
|
149
|
+
const superExecuteStep = super.executeStep.bind(this);
|
|
150
|
+
return Effect.gen(this, function* () {
|
|
151
|
+
const deferredOption = yield* Effect.serviceOption(ResendDeferredDelivery);
|
|
152
|
+
return yield* Option.match(deferredOption, {
|
|
153
|
+
onNone: () => superExecuteStep(input, jobContext),
|
|
154
|
+
onSome: (deferred) => this.executeDeferred(input, jobContext, deferred.environment),
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deferred execution path: sends the email, tags it, returns state update.
|
|
160
|
+
*/
|
|
161
|
+
executeDeferred(input, jobContext, environment) {
|
|
162
|
+
return Effect.gen(this, function* () {
|
|
163
|
+
// Idempotency guard: if process state already has resend metadata,
|
|
164
|
+
// the email was sent on a previous attempt that failed to mark the
|
|
165
|
+
// job completed. Return deferred without re-sending.
|
|
166
|
+
const readerOption = yield* Effect.serviceOption(StepProcessStateReader);
|
|
167
|
+
const idempotent = yield* Option.match(readerOption, {
|
|
168
|
+
onNone: () => Effect.succeed(false),
|
|
169
|
+
onSome: (reader) => Effect.gen(function* () {
|
|
170
|
+
const state = yield* reader.getProcessStateByTodoId(jobContext.todoId);
|
|
171
|
+
const internal = state["_internal"];
|
|
172
|
+
return internal?.["resend"] !== undefined;
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
if (idempotent) {
|
|
176
|
+
return { _tag: "Deferred" };
|
|
177
|
+
}
|
|
178
|
+
// Deferred mode requires exactly one primary `to` recipient
|
|
179
|
+
if (typeof input.to !== "string") {
|
|
180
|
+
return yield* new ResendError({
|
|
181
|
+
message: "Deferred Resend mode requires exactly one primary 'to' recipient (string), not an array",
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const resendClient = yield* ResendClient;
|
|
185
|
+
const { sender, resolvedAttachments } = yield* this.validateAndResolve(input);
|
|
186
|
+
const result = yield* resendClient.sendEmail(this.buildSendRequest(input, sender, resolvedAttachments, [
|
|
187
|
+
{ name: "pf_todo_id", value: jobContext.todoId },
|
|
188
|
+
{ name: "pf_environment", value: environment },
|
|
189
|
+
]));
|
|
190
|
+
const primaryTo = typeof result.sentTo === "string" ? result.sentTo : input.to;
|
|
191
|
+
return {
|
|
192
|
+
_tag: "Deferred",
|
|
193
|
+
stateUpdate: {
|
|
194
|
+
_internal: {
|
|
195
|
+
resend: {
|
|
196
|
+
emailId: result.emailId,
|
|
197
|
+
// Store the actual delivered-to recipient so rerouted sends still
|
|
198
|
+
// complete from the Resend webhook callback.
|
|
199
|
+
primaryTo,
|
|
200
|
+
environment,
|
|
201
|
+
todoId: jobContext.todoId,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}).pipe(Effect.withSpan("ResendStep.executeDeferred"));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=resend-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resend-step.js","sourceRoot":"","sources":["../../src/lib/resend-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAYL,sBAAsB,EAEtB,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,YAAY,EACZ,sBAAsB,EAGtB,WAAW,GACZ,MAAM,iBAAiB,CAAA;AAiCxB;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAA;AAyDD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,UAQX,SAAQ,UAOT;IACC;;OAEG;IACM,IAAI,CAAoB;IAEjC,YACE,KAG8D,EAC9D,EAAO;IACP,yGAAyG;IACzG,KAA2C;QAE3C,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE;YACf,GAAG,KAAK;YACR,MAAM,EAAE,YAAY;SACrB,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GA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