alepha@docs:~/docs/reference/primitives$
cat $notification.md | pretty1 min read
#$notification
#Import
typescript
1import { $notification } from "alepha/api/notifications";
#Overview
Creates a notification primitive: a delivery template, pushed through a durable outbox.
Provides type-safe, reusable notification templates with multi-language support, variable substitution, and categorization.
The channel set is open. email and sms are the two the framework
ships, and each is one NotificationChannel service among however many the
container registers. A package outside the framework adds its own key by
declaration merging on NotificationChannels, and a template that
names a channel nothing provides refuses to boot rather than silently
sending nothing.
#Options
| Option | Type | Required | Description |
|---|---|---|---|
name |
string |
No | |
description |
string |
No | |
category |
string |
No | |
critical |
boolean |
No | |
sensitive |
boolean |
No | Marks the template's rendered variables as personal data |
translations |
Object |
No | |
schema |
T |
Yes |
#Examples
ts
1class NotificationTemplates { 2 welcomeEmail = $notification({ 3 name: "welcome-email", 4 category: "onboarding", 5 schema: z.object({ username: z.text(), activationLink: z.text() }), 6 email: { 7 subject: "Welcome to our platform!", 8 body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}` 9 }10 });11 12 async sendWelcome(user: User) {13 await this.welcomeEmail.push({14 variables: { username: user.name, activationLink: generateLink() },15 contact: user.email16 });17 }18}