Stone.js API
    Preparing search index...

    What an application calls to reach someone.

    The one sentence that shapes everything here: decide now, deliver later. A request resolves who the person is, renders the message in their language, and hands the delivery to a queue. Reaching a mail provider takes as long as it takes, and a request that waits for one is a request that times out on a function-as-a-service platform, from the endpoint the user is watching.

    It also never throws at its caller. A notification is almost always a side effect of something that already succeeded: an account was created, a guardian was invited. Failing that operation because a mail provider was down would undo work that was correct. Every failure comes back as an outcome and goes to the log.

    Index
    • Parameters

      • dependencies: { blueprint: IBlueprint; container?: IContainer }

        Auto-wired services.

      Returns Notifier

    • Perform one delivery, to one person, on every channel it names.

      Called here when nothing is queued, and by the queue job when something is. Same code either way, which is what makes a retry mean exactly what the first attempt meant.

      Parameters

      Returns Promise<DeliveryOutcome[]>

      What each channel answered.

    • Deliver what a notice says about a domain event.

      The entry the event subscription calls, and the reason this module is not a service somebody has to remember to call: a module emits what happened, and the notice that named that event decides who learns about it. The emitting module knows nothing about any of this.

      Parameters

      • name: string

        The notice's name.

      • event: unknown

        The domain event, as the bus delivered it.

      Returns Promise<NotificationReceipt>

      What happened, or that it was queued.

    • Tell someone something.

      Parameters

      • to: RecipientInput | RecipientInput[]

        Who to tell: a recipient, an id, or several of either.

      • template: string

        The template key. Never a rendered body: what is not copied does not have to be erased, and a key survives a translation being fixed.

      • params: Record<string, unknown> = {}

        What the template needs.

      • options: NotifyOptions = {}

        Which channels, which language, whether to wait.

      Returns Promise<NotificationReceipt>

      What happened, or that it was queued.

    • What a notice would send, without sending it.

      For a screen that shows a member of staff what a guardian is about to receive, and for a test that checks a notice without a channel. It renders exactly what delivery would render, per channel, which is what makes it worth having rather than approximating.

      Parameters

      • to: RecipientInput | RecipientInput[]

        Who it would be for.

      • template: string

        The notice or template name.

      • params: Record<string, unknown> = {}

        What it needs.

      • options: NotifyOptions = {}

        Which channels, which language.

      Returns Promise<
          { channel: string; message: RenderedNotification; recipient: Recipient }[],
      >

      One rendered message per recipient and channel.