@owlmeans/mailer 0.1.18-rc.7 → 0.1.18-rc.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 CHANGED
@@ -13,7 +13,7 @@ Provider-agnostic email dispatch interface for the OwlMeans framework — `Maile
13
13
  ## Installation
14
14
 
15
15
  ```bash
16
- bun add @owlmeans/mailer
16
+ bun add @owlmeans/mailer@^0.1.18-rc.7
17
17
  ```
18
18
 
19
19
  ## Usage
@@ -37,7 +37,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
37
37
  your project's skill store (`.agents/skills/`):
38
38
 
39
39
  ```sh
40
- npx @owlmeans/agent-skills
40
+ npx @owlmeans/agent-skills@^0.1.18-rc.13
41
41
  ```
42
42
 
43
43
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/mailer",
4
- "version": "0.1.18-rc.7",
5
- "generatedAt": "2026-09-01T16:28:56.994Z",
4
+ "version": "0.1.18-rc.9",
5
+ "generatedAt": "2026-09-10T18:54:42.502Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,14 +8,19 @@ metadata:
8
8
 
9
9
  # Using `@owlmeans/mailer`
10
10
 
11
- Provider-agnostic email dispatch service. Defines the `MailerService` interface implemented by concrete transports (`@owlmeans/server-mailer-mailgun` for production, `makeConsoleMailerService` for dev/tests).
11
+ **Install:** `"@owlmeans/mailer": "^0.1.18-rc.9"` in `dependencies`
12
+
13
+ Provider-agnostic email dispatch service. It defines the `MailerService` interface and ships one
14
+ transport of its own — the console/dev one. Real delivery is a separate package:
15
+ `@owlmeans/mailer-smtp` (SMTP, works against any relay) or `@owlmeans/server-mailer-mailgun`
16
+ (Mailgun's HTTP API).
12
17
 
13
18
  ## Public API surface
14
19
 
15
20
  | Symbol | Kind | Purpose |
16
21
  |--------|------|---------|
17
- | `MailerService` | interface | `{ send(message): Promise<void> }` |
18
- | `MailMessage` | interface | `{ to, subject, text?, html? }` |
22
+ | `MailerService` | interface | Extends `InitializedService` (`@owlmeans/context`) with `send(message): Promise<void>` |
23
+ | `MailMessage` | interface | `{ to, subject, text?, html?, from?, replyTo?, headers? }` |
19
24
  | `MAILER_SERVICE` | const | Default service alias `'mailer-service'` |
20
25
  | `makeConsoleMailerService(alias?)` | fn | Dev transport: logs to console and stores messages in `.captured[]` |
21
26
  | `makeDefaultConsoleMailerService()` | fn | Alias of `makeConsoleMailerService(MAILER_SERVICE)` |
@@ -37,16 +42,40 @@ console.log(mailer.captured[0].text) // '123456'
37
42
  The console transport:
38
43
  - Logs to `console.log` (not `console.error`) — safe to use in tests without noise.
39
44
  - Accumulates all sent messages in `mailer.captured: MailMessage[]`.
40
- - Never throws unless context is not initialized.
45
+ - Never throws: it has no transport to fail, which is what makes it the right double in a test.
46
+
47
+ ## Writing a transport
48
+
49
+ The package's whole purpose is a contract other packages implement. A transport is a service built
50
+ with `createService` from `@owlmeans/context` under the alias the caller asks for, whose one
51
+ required member is `send`:
52
+
53
+ ```ts
54
+ import { createService } from '@owlmeans/context'
55
+ import type { MailerService, MailMessage } from '@owlmeans/mailer'
56
+
57
+ export const makeMyMailerService = (alias = 'my-mailer'): MailerService =>
58
+ createService<MailerService>(alias, {
59
+ send: async (message: MailMessage): Promise<void> => { /* reach the provider */ },
60
+ })
61
+ ```
62
+
63
+ `MailerService` extends `InitializedService`, so the context runs the service's lifecycle like any
64
+ other; a transport that has to be torn down declares its own members on top (see the SMTP one's
65
+ `verify()` / `close()`).
41
66
 
42
67
  ## Production wiring
43
68
 
44
- Use `@owlmeans/server-mailer-mailgun` for production. The `MAILER_SERVICE` alias is the same — swap transports without changing callers:
69
+ Every transport registers under the same `MAILER_SERVICE` alias, so swapping one for another
70
+ changes no caller. Select on config rather than on a build flag, so one image serves every
71
+ environment:
45
72
 
46
73
  ```ts
47
- // Dev:
74
+ // Dev / tests:
48
75
  context.registerService(makeConsoleMailerService(MAILER_SERVICE))
49
- // Prod:
76
+ // Production, SMTP relay:
77
+ context.registerService(makeSmtpMailerService(MAILER_SERVICE))
78
+ // Production, Mailgun HTTP API:
50
79
  context.registerService(makeMailgunMailerService(MAILER_SERVICE))
51
80
  ```
52
81
 
@@ -55,3 +84,12 @@ context.registerService(makeMailgunMailerService(MAILER_SERVICE))
55
84
  - Register under `MAILER_SERVICE` alias when called from `OtpService` or other platform code.
56
85
  - Never import a concrete transport directly in domain services — always inject via the alias.
57
86
  - The `MailMessage.html` field is optional; supply either `text` or `html` (or both).
87
+ - `from`, `replyTo` and `headers` are per-message overrides of whatever the transport was
88
+ configured with. A transport that cannot carry headers ignores the field rather than failing —
89
+ the contract is the smallest thing every transport can honour, so nothing here is guaranteed to
90
+ reach the wire.
91
+
92
+ ## Related
93
+
94
+ - [[mailer-smtp]] — the SMTP transport and its `cfg.smtp` block
95
+ - [[server-mailer-mailgun]] — the Mailgun HTTP transport and its `cfg.mailgun` block
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG5D,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAE9C,oFAAoF;AACpF,eAAO,MAAM,wBAAwB,GAAI,cAAsB,KAAG,aAAa,GAAG;IAChF,sEAAsE;IACtE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAexB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,QAAO,UAAU,CAAC,OAAO,wBAAwB,CACnD,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG5D,eAAO,MAAM,cAAc,mBAAmB,CAAA;AAE9C,oFAAoF;AACpF,eAAO,MAAM,wBAAwB,sBAA6B,aAAa,GAAG;IAChF,sEAAsE;IACtE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAexB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,+BAA+B,QAAO,UAAU,CAAC,OAAO,wBAAwB,CACnD,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/mailer",
3
- "version": "0.1.18-rc.7",
3
+ "version": "0.1.18-rc.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.18-rc.7",
26
- "@owlmeans/error": "^0.1.18-rc.7"
25
+ "@owlmeans/context": "^0.1.18-rc.9",
26
+ "@owlmeans/error": "^0.1.18-rc.9"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@owlmeans/dep-config": "workspace:*",