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

    Domain-agnostic notification core. Writer services hand it a NotifiableEvent (the event they already publish) plus the EmailNotification payload their <Domain>NotificationService built; the core resolves who should be emailed and sends. This is the notification analogue of TransactionCacheBuster — one injected collaborator the writer calls right after publish + cache-bust.

    notify is best-effort: it never throws, so a SendGrid / PropelAuth / preferences failure can never fail the mutation that triggered it.

    Recipient resolution reproduces the customer-dashboard webhook handler exactly: customer-configured emailAddresses, plus PropelAuth org users matching the configured userIds / userGroups or the object's dashboard "creator", each gated by the per-user preference overlay.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Resolve recipients for event and send notification. Best-effort: logs and swallows any failure so the caller's mutation is never affected.

      Parameters

      • __namedParameters: {
            buildNotification: () => | {
                customerName: string;
                depositUrl: string;
                id: string;
                name: string;
                status: | "ACTIVE"
                | "DISABLED"
                | "DELETED"
                | "PENDING_VERIFICATION"
                | "REVIEW"
                | "BLOCKED";
                supportUrl: string;
                template: "IDENTITY";
                url: string;
            }
            | {
                customerName: string;
                depositUrl: string;
                id: string;
                name: string;
                status: "ACTIVE"
                | "DISABLED"
                | "PENDING_VERIFICATION";
                supportUrl: string;
                template: "ORGANIZATION";
                url: string;
            }
            | {
                customerName: string;
                id: string;
                name: string;
                supportUrl: string;
                template: "LEDGER_ACCOUNT";
                url: string;
            }
            | {
                customerName: string;
                id: string;
                name: string;
                paymentUrl: string;
                status: "ACTIVE"
                | "PENDING_VERIFICATION"
                | "BLOCKED";
                supportUrl: string;
                template: "PAYMENT_INSTRUMENT";
                type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "WALLET";
                url: string;
            }
            | {
                account: string;
                accountUrl: string;
                amount: string;
                customerName: string;
                date?: string;
                entityName: string;
                id: string;
                imad?: string;
                memo?: string;
                omad?: string;
                reference?: string;
                senderName?: string;
                status: "PENDING"
                | "CANCELLED"
                | "DEPOSITED";
                supportUrl: string;
                template: "DEPOSIT";
                type: "US_WIRE" | "US_BANK_ACH" | "SWIFT_WIRE" | "DIRECT";
                url: string;
            }
            | {
                account: string;
                accountUrl: string;
                amount: string;
                customerName: string;
                entityName: string;
                id: string;
                imad?: string;
                omad?: string;
                paymentInstrumentName: string;
                status: "PENDING"
                | "COMPLETED"
                | "RETURNED";
                supportUrl: string;
                template: "WITHDRAW";
                type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "BLOCKCHAIN";
                url: string;
            }
            | {
                amount: string;
                customerName: string;
                id: string;
                senderMessage?: string;
                sourceAccount: string;
                sourceAccountUrl: string;
                sourceCustomerName: string;
                status: "PENDING"
                | "CANCELLED"
                | "SUCCEEDED";
                supportUrl: string;
                targetAccount: string;
                targetAccountUrl: string;
                targetCustomerName: string;
                template: "TRANSFER";
                type: "INTERNAL" | "NETWORK_SENDER" | "NETWORK_RECEIVER";
                url: string;
            }
            | {
                amount: string;
                card: string;
                id: string;
                merchantName: string;
                reason?: string;
                status: "PENDING"
                | "COMPLETED"
                | "DECLINED"
                | "AUTHORIZED";
                supportUrl: string;
                template: "CARD_TRANSACTION";
                type: "AUTHORIZATION" | "REVERSAL";
                url: string;
            }
            | Promise<
                | {
                    customerName: string;
                    depositUrl: string;
                    id: string;
                    name: string;
                    status: | "ACTIVE"
                    | "DISABLED"
                    | "DELETED"
                    | "PENDING_VERIFICATION"
                    | "REVIEW"
                    | "BLOCKED";
                    supportUrl: string;
                    template: "IDENTITY";
                    url: string;
                }
                | {
                    customerName: string;
                    depositUrl: string;
                    id: string;
                    name: string;
                    status: "ACTIVE"
                    | "DISABLED"
                    | "PENDING_VERIFICATION";
                    supportUrl: string;
                    template: "ORGANIZATION";
                    url: string;
                }
                | {
                    customerName: string;
                    id: string;
                    name: string;
                    supportUrl: string;
                    template: "LEDGER_ACCOUNT";
                    url: string;
                }
                | {
                    customerName: string;
                    id: string;
                    name: string;
                    paymentUrl: string;
                    status: "ACTIVE"
                    | "PENDING_VERIFICATION"
                    | "BLOCKED";
                    supportUrl: string;
                    template: "PAYMENT_INSTRUMENT";
                    type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "WALLET";
                    url: string;
                }
                | {
                    account: string;
                    accountUrl: string;
                    amount: string;
                    customerName: string;
                    date?: string;
                    entityName: string;
                    id: string;
                    imad?: string;
                    memo?: string;
                    omad?: string;
                    reference?: string;
                    senderName?: string;
                    status: "PENDING"
                    | "CANCELLED"
                    | "DEPOSITED";
                    supportUrl: string;
                    template: "DEPOSIT";
                    type: "US_WIRE" | "US_BANK_ACH" | "SWIFT_WIRE" | "DIRECT";
                    url: string;
                }
                | {
                    account: string;
                    accountUrl: string;
                    amount: string;
                    customerName: string;
                    entityName: string;
                    id: string;
                    imad?: string;
                    omad?: string;
                    paymentInstrumentName: string;
                    status: "PENDING"
                    | "COMPLETED"
                    | "RETURNED";
                    supportUrl: string;
                    template: "WITHDRAW";
                    type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "BLOCKCHAIN";
                    url: string;
                }
                | {
                    amount: string;
                    customerName: string;
                    id: string;
                    senderMessage?: string;
                    sourceAccount: string;
                    sourceAccountUrl: string;
                    sourceCustomerName: string;
                    status: "PENDING"
                    | "CANCELLED"
                    | "SUCCEEDED";
                    supportUrl: string;
                    targetAccount: string;
                    targetAccountUrl: string;
                    targetCustomerName: string;
                    template: "TRANSFER";
                    type: "INTERNAL" | "NETWORK_SENDER" | "NETWORK_RECEIVER";
                    url: string;
                }
                | {
                    amount: string;
                    card: string;
                    id: string;
                    merchantName: string;
                    reason?: string;
                    status: "PENDING"
                    | "COMPLETED"
                    | "DECLINED"
                    | "AUTHORIZED";
                    supportUrl: string;
                    template: "CARD_TRANSACTION";
                    type: "AUTHORIZATION" | "REVERSAL";
                    url: string;
                },
            >;
            event: NotifiableEvent;
            objectId: string;
            templateId: string;
        }
        • buildNotification: () => | {
              customerName: string;
              depositUrl: string;
              id: string;
              name: string;
              status: | "ACTIVE"
              | "DISABLED"
              | "DELETED"
              | "PENDING_VERIFICATION"
              | "REVIEW"
              | "BLOCKED";
              supportUrl: string;
              template: "IDENTITY";
              url: string;
          }
          | {
              customerName: string;
              depositUrl: string;
              id: string;
              name: string;
              status: "ACTIVE"
              | "DISABLED"
              | "PENDING_VERIFICATION";
              supportUrl: string;
              template: "ORGANIZATION";
              url: string;
          }
          | {
              customerName: string;
              id: string;
              name: string;
              supportUrl: string;
              template: "LEDGER_ACCOUNT";
              url: string;
          }
          | {
              customerName: string;
              id: string;
              name: string;
              paymentUrl: string;
              status: "ACTIVE"
              | "PENDING_VERIFICATION"
              | "BLOCKED";
              supportUrl: string;
              template: "PAYMENT_INSTRUMENT";
              type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "WALLET";
              url: string;
          }
          | {
              account: string;
              accountUrl: string;
              amount: string;
              customerName: string;
              date?: string;
              entityName: string;
              id: string;
              imad?: string;
              memo?: string;
              omad?: string;
              reference?: string;
              senderName?: string;
              status: "PENDING"
              | "CANCELLED"
              | "DEPOSITED";
              supportUrl: string;
              template: "DEPOSIT";
              type: "US_WIRE" | "US_BANK_ACH" | "SWIFT_WIRE" | "DIRECT";
              url: string;
          }
          | {
              account: string;
              accountUrl: string;
              amount: string;
              customerName: string;
              entityName: string;
              id: string;
              imad?: string;
              omad?: string;
              paymentInstrumentName: string;
              status: "PENDING"
              | "COMPLETED"
              | "RETURNED";
              supportUrl: string;
              template: "WITHDRAW";
              type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "BLOCKCHAIN";
              url: string;
          }
          | {
              amount: string;
              customerName: string;
              id: string;
              senderMessage?: string;
              sourceAccount: string;
              sourceAccountUrl: string;
              sourceCustomerName: string;
              status: "PENDING"
              | "CANCELLED"
              | "SUCCEEDED";
              supportUrl: string;
              targetAccount: string;
              targetAccountUrl: string;
              targetCustomerName: string;
              template: "TRANSFER";
              type: "INTERNAL" | "NETWORK_SENDER" | "NETWORK_RECEIVER";
              url: string;
          }
          | {
              amount: string;
              card: string;
              id: string;
              merchantName: string;
              reason?: string;
              status: "PENDING"
              | "COMPLETED"
              | "DECLINED"
              | "AUTHORIZED";
              supportUrl: string;
              template: "CARD_TRANSACTION";
              type: "AUTHORIZATION" | "REVERSAL";
              url: string;
          }
          | Promise<
              | {
                  customerName: string;
                  depositUrl: string;
                  id: string;
                  name: string;
                  status: | "ACTIVE"
                  | "DISABLED"
                  | "DELETED"
                  | "PENDING_VERIFICATION"
                  | "REVIEW"
                  | "BLOCKED";
                  supportUrl: string;
                  template: "IDENTITY";
                  url: string;
              }
              | {
                  customerName: string;
                  depositUrl: string;
                  id: string;
                  name: string;
                  status: "ACTIVE"
                  | "DISABLED"
                  | "PENDING_VERIFICATION";
                  supportUrl: string;
                  template: "ORGANIZATION";
                  url: string;
              }
              | {
                  customerName: string;
                  id: string;
                  name: string;
                  supportUrl: string;
                  template: "LEDGER_ACCOUNT";
                  url: string;
              }
              | {
                  customerName: string;
                  id: string;
                  name: string;
                  paymentUrl: string;
                  status: "ACTIVE"
                  | "PENDING_VERIFICATION"
                  | "BLOCKED";
                  supportUrl: string;
                  template: "PAYMENT_INSTRUMENT";
                  type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "WALLET";
                  url: string;
              }
              | {
                  account: string;
                  accountUrl: string;
                  amount: string;
                  customerName: string;
                  date?: string;
                  entityName: string;
                  id: string;
                  imad?: string;
                  memo?: string;
                  omad?: string;
                  reference?: string;
                  senderName?: string;
                  status: "PENDING"
                  | "CANCELLED"
                  | "DEPOSITED";
                  supportUrl: string;
                  template: "DEPOSIT";
                  type: "US_WIRE" | "US_BANK_ACH" | "SWIFT_WIRE" | "DIRECT";
                  url: string;
              }
              | {
                  account: string;
                  accountUrl: string;
                  amount: string;
                  customerName: string;
                  entityName: string;
                  id: string;
                  imad?: string;
                  omad?: string;
                  paymentInstrumentName: string;
                  status: "PENDING"
                  | "COMPLETED"
                  | "RETURNED";
                  supportUrl: string;
                  template: "WITHDRAW";
                  type: "US_WIRE" | "SWIFT_WIRE" | "US_ACH" | "BLOCKCHAIN";
                  url: string;
              }
              | {
                  amount: string;
                  customerName: string;
                  id: string;
                  senderMessage?: string;
                  sourceAccount: string;
                  sourceAccountUrl: string;
                  sourceCustomerName: string;
                  status: "PENDING"
                  | "CANCELLED"
                  | "SUCCEEDED";
                  supportUrl: string;
                  targetAccount: string;
                  targetAccountUrl: string;
                  targetCustomerName: string;
                  template: "TRANSFER";
                  type: "INTERNAL" | "NETWORK_SENDER" | "NETWORK_RECEIVER";
                  url: string;
              }
              | {
                  amount: string;
                  card: string;
                  id: string;
                  merchantName: string;
                  reason?: string;
                  status: "PENDING"
                  | "COMPLETED"
                  | "DECLINED"
                  | "AUTHORIZED";
                  supportUrl: string;
                  template: "CARD_TRANSACTION";
                  type: "AUTHORIZATION" | "REVERSAL";
                  url: string;
              },
          >

          Builds the email payload; only invoked when there is ≥1 recipient.

        • event: NotifiableEvent
        • objectId: string

          Id of the object this event concerns — equal to the notification's id. Used for the creator backfill, and resolved before the payload is built so we can skip building it when there are no recipients.

        • templateId: string

          SendGrid template id for this notification, owned by the domain service.

      Returns Promise<void>