@cfxlabsinc/b2b-services
    Preparing search index...

    Reusable email send core: recipient deduplication → active template resolution → rendering → SendGrid transport. ONE implementation, reused by both the Lambda handler (event-driven sends) and admin sendTest (manual test sends).

    Orchestrates the full send pipeline so callers need only provide:

    • Recipients (email + name)
    • Notification payload
    • Template key

    This is the notification analogue of how wire-email-handler consumes @cfxlabsinc/wire-email-services.

    Index
    • Parameters

      • args: {
            emailTemplateService: EmailTemplateService;
            fromEmail: string;
            renderTemplate: (
                input: {
                    template: StoredEmailTemplate;
                    variables: Readonly<Record<string, string | undefined>>;
                },
            ) => Promise<RenderedEmailTemplate>;
            sendgridClient: Pick<SendgridClient, "sendMail">;
        }
        • emailTemplateService: EmailTemplateService

          Resolves the active (live) email template for a given template key. The lambda and admin sendTest paths both need this.

        • fromEmail: string
        • renderTemplate: (
              input: {
                  template: StoredEmailTemplate;
                  variables: Readonly<Record<string, string | undefined>>;
              },
          ) => Promise<RenderedEmailTemplate>

          Injected by the composition root, as a type-only dependency here. Importing the renderer's value would pull React Email into every graph that imports this barrel; only a root that explicitly imports @cfxlabsinc/notification-services/email-render pays that cost.

        • sendgridClient: Pick<SendgridClient, "sendMail">

      Returns EmailSendCore

    • Send an email notification via the active template.

      Orchestrates:

      1. Recipient deduplication (lowercased email)
      2. Active template resolution
      3. Rendering (if renderer is wired)
      4. SendGrid transport

      Throws on SendGrid errors; caller must handle retries/DLQ.

      Parameters

      • __namedParameters: {
            notification: EmailNotification;
            recipients: { email: string; name?: string }[];
            templateKey:
                | "IDENTITY"
                | "ORGANIZATION"
                | "LEDGER_ACCOUNT"
                | "PAYMENT_INSTRUMENT"
                | "DEPOSIT"
                | "WITHDRAW"
                | "TRANSFER"
                | "CARD_TRANSACTION";
        }
        • notification: EmailNotification

          Notification payload

        • recipients: { email: string; name?: string }[]
        • templateKey:
              | "IDENTITY"
              | "ORGANIZATION"
              | "LEDGER_ACCOUNT"
              | "PAYMENT_INSTRUMENT"
              | "DEPOSIT"
              | "WITHDRAW"
              | "TRANSFER"
              | "CARD_TRANSACTION"

          Template key for active template lookup

      Returns Promise<EmailSendOutcome>