| 1 | import type * as sesv2 from "@distilled.cloud/aws/sesv2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { ConfigurationSet } from "./ConfigurationSet.ts"; |
| 5 | import type { EmailIdentity } from "./EmailIdentity.ts"; |
| 6 | |
| 7 | /** |
| 8 | * The `sendBulkEmail` request with the binding-injected members removed: |
| 9 | * `ConfigurationSetName` comes from the bound configuration set, and |
| 10 | * `FromEmailAddress` defaults to the bound identity (override it for domain |
| 11 | * identities, e.g. `hello@{domain}`). |
| 12 | */ |
| 13 | export interface SendBulkEmailRequest extends Omit< |
| 14 | sesv2.SendBulkEmailRequest, |
| 15 | "ConfigurationSetName" |
| 16 | > {} |
| 17 | |
| 18 | /** |
| 19 | * Runtime binding for `sesv2:SendBulkEmail`. |
| 20 | * |
| 21 | * Bind this operation to an `EmailIdentity` (and optionally a |
| 22 | * `ConfigurationSet`) inside a function runtime to get a callable that sends |
| 23 | * one templated message to up to 50 destinations per call, with per-entry |
| 24 | * replacement data. The binding grants the function the send actions scoped |
| 25 | * to the identity, the account's templates, and the configuration set. |
| 26 | * |
| 27 | * Bulk sends always render a template — reference one via |
| 28 | * `DefaultContent.Template`. |
| 29 | * ### Sending Email |
| 30 | * **Example:** Send a Templated Message to Many Recipients |
| 31 | * ```typescript |
| 32 | * // init |
| 33 | * const sendBulkEmail = yield* SES.SendBulkEmail(identity, configSet); |
| 34 | * |
| 35 | * // runtime |
| 36 | * const result = yield* sendBulkEmail({ |
| 37 | * DefaultContent: { |
| 38 | * Template: { |
| 39 | * TemplateName: "welcome-template", |
| 40 | * TemplateData: JSON.stringify({ name: "friend" }), |
| 41 | * }, |
| 42 | * }, |
| 43 | * BulkEmailEntries: [ |
| 44 | * { |
| 45 | * Destination: { ToAddresses: ["ada@example.com"] }, |
| 46 | * ReplacementEmailContent: { |
| 47 | * ReplacementTemplate: { |
| 48 | * ReplacementTemplateData: JSON.stringify({ name: "Ada" }), |
| 49 | * }, |
| 50 | * }, |
| 51 | * }, |
| 52 | * ], |
| 53 | * }); |
| 54 | * // result.BulkEmailEntryResults |
| 55 | * ``` |
| 56 | * |
| 57 | * @binding |
| 58 | */ |
| 59 | export interface SendBulkEmail extends Binding.Service< |
| 60 | SendBulkEmail, |
| 61 | "AWS.SES.SendBulkEmail", |
| 62 | <I extends EmailIdentity>( |
| 63 | identity: I, |
| 64 | configurationSet?: ConfigurationSet, |
| 65 | ) => Effect.Effect< |
| 66 | ( |
| 67 | request: SendBulkEmailRequest, |
| 68 | ) => Effect.Effect<sesv2.SendBulkEmailResponse, sesv2.SendBulkEmailError> |
| 69 | > |
| 70 | > {} |
| 71 | export const SendBulkEmail = Binding.Service<SendBulkEmail>( |
| 72 | "AWS.SES.SendBulkEmail", |
| 73 | ); |