managarten/packages/notify-client/README.md
Till JS bfeeef7819 chore(matrix): final scrub of stale matrix references
A grep audit after the previous matrix removal commits found a handful
of stragglers in non-runtime files that the earlier sweeps missed:

- services/mana-llm/CLAUDE.md: removed matrix-ollama-bot from the
  consumer-apps diagram and from the related-services table
- services/mana-video-gen/CLAUDE.md: removed "Matrix Bots" integration
  bullet
- packages/notify-client/README.md: removed sendMatrix() doc entry
  (the method itself was already gone in the prior cleanup)
- docker/grafana/dashboards/logs-explorer.json: dropped the "Matrix
  Stack" log row that queried tier="matrix" (would show no data forever)
- docker/grafana/dashboards/master-overview.json: dropped the "Matrix
  Bots" stat panel that counted up{job=~"matrix-.*-bot"}
- apps/mana/apps/landing/src/data/ecosystem-health.json: regenerated via
  scripts/ecosystem-audit.mjs to drop matrix from the app list, icon
  counts, file analytics, top offenders and authGuard missing list
- .gitignore: removed services/matrix-stt-bot/data/ pattern (the
  service itself was deleted long ago)

Production-side stragglers also addressed (not in this commit):
- DROP USER synapse on prod Postgres (the parallel cleanup commit
  2514831a3 dropped DATABASE matrix + DATABASE synapse but left the
  role behind)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 16:47:54 +02:00

148 lines
3.3 KiB
Markdown

# @mana/notify-client
Client SDK for the mana-notify notification service.
## Installation
```bash
pnpm add @mana/notify-client
```
## Usage
### Basic Usage
```typescript
import { NotifyClient } from '@mana/notify-client';
const notify = new NotifyClient({
serviceUrl: 'http://localhost:3040',
serviceKey: process.env.MANA_NOTIFY_SERVICE_KEY,
appId: 'your-app-id',
});
// Send email
await notify.sendEmail({
to: 'user@example.com',
template: 'auth-password-reset',
data: { resetUrl: 'https://...', userName: 'Max' },
});
// Send push notification
await notify.sendPush({
userId: 'user-uuid',
title: 'New Message',
body: 'You have a new message',
data: { messageId: 'xxx' },
});
// Send to specific token
await notify.sendPush({
token: 'ExponentPushToken[xxx]',
title: 'Hello',
body: 'World',
});
// Schedule notification
await notify.scheduleEmail({
to: 'user@example.com',
template: 'calendar-reminder',
data: { eventTitle: 'Meeting' },
scheduledFor: new Date('2024-12-20T13:45:00Z'),
});
```
### NestJS Integration
```typescript
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { NotifyModule } from '@mana/notify-client/nestjs';
@Module({
imports: [
ConfigModule.forRoot(),
NotifyModule.forRootAsync({
imports: [ConfigModule],
useFactory: (config: ConfigService) => ({
serviceUrl: config.get('MANA_NOTIFY_URL', 'http://localhost:3040'),
serviceKey: config.get('MANA_NOTIFY_SERVICE_KEY'),
appId: config.get('APP_ID'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}
```
Then inject the client:
```typescript
import { Injectable, Inject } from '@nestjs/common';
import { NOTIFY_CLIENT, NotifyClient } from '@mana/notify-client/nestjs';
@Injectable()
export class NotificationService {
constructor(@Inject(NOTIFY_CLIENT) private readonly notify: NotifyClient) {}
async sendWelcomeEmail(email: string, name: string) {
await this.notify.sendEmail({
to: email,
template: 'auth-welcome',
data: { userName: name },
});
}
}
```
## API Reference
### NotifyClient
#### Constructor
```typescript
new NotifyClient({
serviceUrl: string; // mana-notify service URL
serviceKey: string; // Service authentication key
appId: string; // Your application ID
timeout?: number; // Request timeout in ms (default: 30000)
});
```
#### Methods
##### Email
- `sendEmail(options)` - Send an email immediately
- `scheduleEmail(options)` - Schedule an email for later
##### Push Notifications
- `sendPush(options)` - Send a push notification
- `schedulePush(options)` - Schedule a push notification
##### Other Channels
- `sendWebhook(options)` - Send a webhook
##### Batch & Management
- `sendBatch(notifications)` - Send multiple notifications
- `getNotification(id)` - Get notification status
- `cancelNotification(id)` - Cancel a pending notification
##### Templates
- `listTemplates(appId?)` - List available templates
- `getTemplate(slug, locale?)` - Get a template
- `previewTemplate(slug, data, locale?)` - Preview a rendered template
## Environment Variables
| Variable | Description |
|----------|-------------|
| `MANA_NOTIFY_URL` | mana-notify service URL |
| `MANA_NOTIFY_SERVICE_KEY` | Service authentication key |
| `APP_ID` | Your application ID |