@owlmeans/mailer 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @owlmeans/mailer
|
|
2
|
+
|
|
3
|
+
Provider-agnostic email dispatch interface for the OwlMeans framework — `MailerService` abstraction and console/dev transport.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
- `MailerService` — `InitializedService` with a single `send(message)` method; implementations are swapped per environment
|
|
8
|
+
- `MailMessage` — `{ to, subject, text?, html? }` shape accepted by all transports
|
|
9
|
+
- `MAILER_SERVICE` constant — context alias for registering and resolving the mailer service
|
|
10
|
+
- Default transport logs to console (suitable for development and unit tests)
|
|
11
|
+
- Production transports provided by `@owlmeans/server-mailer-mailgun` and similar packages
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add @owlmeans/mailer
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { MAILER_SERVICE } from '@owlmeans/mailer'
|
|
23
|
+
import type { MailerService, MailMessage } from '@owlmeans/mailer'
|
|
24
|
+
|
|
25
|
+
// Resolve from context and send
|
|
26
|
+
const mailer = context.service<MailerService>(MAILER_SERVICE)
|
|
27
|
+
await mailer.send({ to: 'user@example.com', subject: 'Welcome', text: 'Hello!' })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For production email via Mailgun, register `@owlmeans/server-mailer-mailgun` in your server context.
|
|
31
|
+
|
|
32
|
+
<!-- owlmeans:agent-guidance:start -->
|
|
33
|
+
## Agent guidance
|
|
34
|
+
|
|
35
|
+
This package ships embedded Claude Code skills and GitHub Copilot instructions under
|
|
36
|
+
`agent-meta/`. After installing your `@owlmeans/*` packages, run the OwlMeans
|
|
37
|
+
agent-skills installer to place them into your project's native locations
|
|
38
|
+
(`.claude/skills/` and `.github/instructions/`):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npx @owlmeans/agent-skills
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The embedded files are version-matched to this package release. Do not edit them
|
|
45
|
+
directly — they are regenerated on each publish. To contribute guidance edits,
|
|
46
|
+
open a PR against the source monorepo.
|
|
47
|
+
<!-- owlmeans:agent-guidance:end -->
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "How to use @owlmeans/mailer — MailerService interface + console/dev transport. Use when sending emails or setting up a mailer in tests."
|
|
3
|
+
applyTo: "**/context.ts, **/services/mail*"
|
|
4
|
+
---
|
|
5
|
+
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
+
|
|
7
|
+
# Using `@owlmeans/mailer`
|
|
8
|
+
|
|
9
|
+
Provider-agnostic email dispatch service. Defines the `MailerService` interface implemented by concrete transports (`@owlmeans/server-mailer-mailgun` for production, `makeConsoleMailerService` for dev/tests).
|
|
10
|
+
|
|
11
|
+
## Public API surface
|
|
12
|
+
|
|
13
|
+
| Symbol | Kind | Purpose |
|
|
14
|
+
|--------|------|---------|
|
|
15
|
+
| `MailerService` | interface | `{ send(message): Promise<void> }` |
|
|
16
|
+
| `MailMessage` | interface | `{ to, subject, text?, html? }` |
|
|
17
|
+
| `MAILER_SERVICE` | const | Default service alias `'mailer-service'` |
|
|
18
|
+
| `makeConsoleMailerService(alias?)` | fn | Dev transport: logs to console and stores messages in `.captured[]` |
|
|
19
|
+
| `makeDefaultConsoleMailerService()` | fn | Alias of `makeConsoleMailerService(MAILER_SERVICE)` |
|
|
20
|
+
| `CONSOLE_MAILER` | const | Default alias for the console transport `'console-mailer'` |
|
|
21
|
+
|
|
22
|
+
## Console transport (dev & tests)
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { makeConsoleMailerService, MAILER_SERVICE } from '@owlmeans/mailer'
|
|
26
|
+
|
|
27
|
+
const mailer = makeConsoleMailerService(MAILER_SERVICE)
|
|
28
|
+
context.registerService(mailer)
|
|
29
|
+
|
|
30
|
+
// In tests: inspect captured messages
|
|
31
|
+
await mailer.send({ to: 'user@example.com', subject: 'Code', text: '123456' })
|
|
32
|
+
console.log(mailer.captured[0].text) // '123456'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The console transport:
|
|
36
|
+
- Logs to `console.log` (not `console.error`) — safe to use in tests without noise.
|
|
37
|
+
- Accumulates all sent messages in `mailer.captured: MailMessage[]`.
|
|
38
|
+
- Never throws unless context is not initialized.
|
|
39
|
+
|
|
40
|
+
## Production wiring
|
|
41
|
+
|
|
42
|
+
Use `@owlmeans/server-mailer-mailgun` for production. The `MAILER_SERVICE` alias is the same — swap transports without changing callers:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// Dev:
|
|
46
|
+
context.registerService(makeConsoleMailerService(MAILER_SERVICE))
|
|
47
|
+
// Prod:
|
|
48
|
+
context.registerService(makeMailgunMailerService(MAILER_SERVICE))
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Rules
|
|
52
|
+
|
|
53
|
+
- Register under `MAILER_SERVICE` alias when called from `OtpService` or other platform code.
|
|
54
|
+
- Never import a concrete transport directly in domain services — always inject via the alias.
|
|
55
|
+
- The `MailMessage.html` field is optional; supply either `text` or `html` (or both).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"package": "@owlmeans/mailer",
|
|
4
|
+
"version": "0.1.9",
|
|
5
|
+
"generatedAt": "2026-06-14T13:34:06.145Z",
|
|
6
|
+
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
|
+
"entries": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "instruction",
|
|
10
|
+
"name": "mailer",
|
|
11
|
+
"category": "package-specific",
|
|
12
|
+
"file": "instructions/mailer.instructions.md",
|
|
13
|
+
"canonicalPath": ".github/instructions/mailer.instructions.md"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/mailer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/context": "^0.1.
|
|
26
|
-
"@owlmeans/error": "^0.1.
|
|
25
|
+
"@owlmeans/context": "^0.1.9",
|
|
26
|
+
"@owlmeans/error": "^0.1.9"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@owlmeans/dep-config": "workspace:*",
|