import { defineWorkflow } from "openworkflow";
import * as v from "valibot";
const emailSchema = v.object({
to: v.pipe(v.string(), v.email()),
subject: v.pipe(v.string(), v.minLength(1)),
body: v.string(),
});
export const sendEmail = defineWorkflow(
{
name: "send-email",
schema: emailSchema,
},
async ({ input, step }) => {
// `input` is fully typed as { to: string; subject: string; body: string }
await step.run({ name: "send-email" }, async () => {
await emailProvider.send({
to: input.to,
subject: input.subject,
body: input.body,
});
});
return { success: true, recipient: input.to };
},
);