@classytic/notifications 1.2.0 → 2.1.0
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/CHANGELOG.md +154 -37
- package/README.md +437 -201
- package/dist/channels/index.d.mts +2 -2
- package/dist/channels/index.mjs +2 -2
- package/dist/index.d.mts +39 -18
- package/dist/index.mjs +129 -28
- package/dist/providers/index.d.mts +136 -0
- package/dist/providers/index.mjs +280 -0
- package/dist/push.channel-OkjPEVTN.mjs +519 -0
- package/dist/push.channel-YtZrCCH1.d.mts +73 -0
- package/dist/status-webhook-Bb4UoinT.d.mts +268 -0
- package/dist/status-webhook-XY42DCj_.mjs +582 -0
- package/dist/types-BMs4UhKD.d.mts +572 -0
- package/dist/utils/index.d.mts +3 -3
- package/dist/utils/index.mjs +3 -3
- package/package.json +30 -13
- package/dist/concurrency-CV_XyiBQ.d.mts +0 -139
- package/dist/console.channel-BoWi_5nH.d.mts +0 -39
- package/dist/console.channel-CfA4b_Er.mjs +0 -246
- package/dist/merge-hooks-B4_uHR9x.mjs +0 -233
- package/dist/types-BnjZ7x2U.d.mts +0 -297
- /package/dist/{errors-DAIVZx_Q.mjs → errors-FYJYmfvj.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,154 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@classytic/notifications` will be documented in this file.
|
|
4
|
-
|
|
5
|
-
## [
|
|
6
|
-
|
|
7
|
-
### Added
|
|
8
|
-
|
|
9
|
-
- **
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
- `
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@classytic/notifications` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.1.0] - 2026-05-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Email provider abstraction** at the new `@classytic/notifications/providers`
|
|
10
|
+
subpath export — for multi-tenant hosts that need to store an SMTP
|
|
11
|
+
credential per organization and route sends through it:
|
|
12
|
+
- `EMAIL_PRESETS` / `EMAIL_PROVIDER_OPTIONS` — Resend, Gmail (App
|
|
13
|
+
Password), SendGrid, Mailgun, AWS SES (SMTP), and Custom SMTP. Every
|
|
14
|
+
preset is SMTP-based; the table captures host / port / secure /
|
|
15
|
+
userSource / passSource and leaves the secret bits to the
|
|
16
|
+
credential blob.
|
|
17
|
+
- `buildEmailTransport(data)` — turns an `EmailCredentialData` blob
|
|
18
|
+
into a `nodemailer.Transporter`. Dynamic `import('nodemailer')` so
|
|
19
|
+
the peer stays optional.
|
|
20
|
+
- `buildFromHeader(data)` — formats `"Brand" <hello@…>` (or bare
|
|
21
|
+
email).
|
|
22
|
+
- `getEmailCredentialSchema()` — union-of-fields form schema; the UI
|
|
23
|
+
hides irrelevant fields based on the selected provider.
|
|
24
|
+
- `testEmailCredential(data)` — opens an SMTP connection and runs
|
|
25
|
+
`verify()`. Returns `{ status: 'OK' | 'Error', message }` instead
|
|
26
|
+
of throwing.
|
|
27
|
+
- SES preset opts into `allowHostOverride` so callers can target a
|
|
28
|
+
non-default region by supplying
|
|
29
|
+
`host: 'email-smtp.<region>.amazonaws.com'`. Fixed-host presets
|
|
30
|
+
(Resend / Gmail / SendGrid / Mailgun) deliberately ignore host
|
|
31
|
+
overrides to prevent "changed host, kept the API key" footguns.
|
|
32
|
+
- **`Channel.canSend(payload)` pre-flight hook (optional).** Channels
|
|
33
|
+
can return a `SendResult` (typically `{ status: 'skipped' }`) before
|
|
34
|
+
the service consumes a rate-limit token. Built-in `EmailChannel`,
|
|
35
|
+
`SmsChannel`, and `PushChannel` implement it to skip when the
|
|
36
|
+
recipient field for that channel is missing — preventing a mixed-
|
|
37
|
+
channel batch from burning, say, email quota on a payload that was
|
|
38
|
+
never going to deliver email. Channels that omit `canSend` keep
|
|
39
|
+
working exactly as before.
|
|
40
|
+
- **`queueFailureMode` config knob** on `NotificationService`. Controls
|
|
41
|
+
how the queue processor signals failure to the queue adapter:
|
|
42
|
+
- `'throw-on-total-failure'` (new default) — when
|
|
43
|
+
`sent === 0 && failed > 0`, the processor throws so the queue
|
|
44
|
+
marks the job failed and its retry policy kicks in. Partial
|
|
45
|
+
successes resolve normally so a retry can't double-send the
|
|
46
|
+
channels that already delivered.
|
|
47
|
+
- `'always-complete'` — legacy behavior preserved for hosts whose
|
|
48
|
+
delivery log is the source of truth for failures.
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- **Queue jobs no longer silently complete on total dispatch failure.**
|
|
53
|
+
Previously, the queue processor swallowed `DispatchResult` and
|
|
54
|
+
resolved every job, so `MemoryQueue` (or a BullMQ adapter) would
|
|
55
|
+
mark a job completed even when every channel raised. The processor
|
|
56
|
+
now propagates total failure under the default `queueFailureMode`.
|
|
57
|
+
Opt back into the old behavior with
|
|
58
|
+
`queueFailureMode: 'always-complete'`.
|
|
59
|
+
- **Rate-limit tokens are no longer consumed for deterministic skips.**
|
|
60
|
+
`sendToChannel` calls `channel.canSend?.(payload)` before
|
|
61
|
+
`rateLimitStore.consume()`. This fixes a quota-exhaustion footgun
|
|
62
|
+
where a payload addressing an email recipient with no `phone` would
|
|
63
|
+
still decrement the SMS channel's quota.
|
|
64
|
+
- `package.json` adds a `typesVersions` map so node10-style resolvers
|
|
65
|
+
find subpath declarations (`./channels`, `./providers`, `./utils`).
|
|
66
|
+
|
|
67
|
+
### Test infrastructure
|
|
68
|
+
|
|
69
|
+
- Live network tests now live behind a dedicated
|
|
70
|
+
`vitest.live.config.ts` and the `npm run test:live` script. The
|
|
71
|
+
default `npm test` glob no longer includes `*.live.test.ts`, so a
|
|
72
|
+
fresh checkout — even with the workspace `.env.dev` mounted —
|
|
73
|
+
cannot accidentally trigger real SMTP sends.
|
|
74
|
+
- `prepublishOnly` and `release` now run `npm test` (unit suite) in
|
|
75
|
+
addition to the build + typecheck.
|
|
76
|
+
- New live "send" suite (`EMAIL_LIVE_SEND_TO=<inbox>`) actually invokes
|
|
77
|
+
`nodemailer.sendMail` for each provider with creds in the
|
|
78
|
+
environment, so deliverability can be smoke-tested before publish.
|
|
79
|
+
The send gate is intentionally NOT placed in shared env files —
|
|
80
|
+
export it per-shell.
|
|
81
|
+
- `tests/setup-env.ts` auto-loads workspace `../.env.dev` plus
|
|
82
|
+
package-local `.env` / `.env.test` / `.env.test.local`; shell vars
|
|
83
|
+
always win.
|
|
84
|
+
|
|
85
|
+
### Dependencies
|
|
86
|
+
|
|
87
|
+
- `nodemailer >=6` remains the only optional peer dependency.
|
|
88
|
+
|
|
89
|
+
## [2.0.0] - 2026-03-24
|
|
90
|
+
|
|
91
|
+
### Added
|
|
92
|
+
|
|
93
|
+
- `SmsChannel` and `PushChannel` with bring-your-own-provider integrations
|
|
94
|
+
- Rate limiting, delivery logging, and queue-backed delivery
|
|
95
|
+
- Built-in template resolver via `createSimpleResolver()`
|
|
96
|
+
- Channel fallback with `withFallback()`
|
|
97
|
+
- Delayed delivery via `payload.delay`
|
|
98
|
+
- Status webhook helper via `createStatusHandler()`
|
|
99
|
+
- Provider adapter examples and observability notes
|
|
100
|
+
- `DispatchResult.queued` plus `send:rate_limited` and `send:queued` events
|
|
101
|
+
|
|
102
|
+
### Changed
|
|
103
|
+
|
|
104
|
+
- Skipped notifications now go through delivery logging and lifecycle events
|
|
105
|
+
- `EmailChannel` now protects critical mail fields from being overridden by defaults
|
|
106
|
+
- `pMap()` now validates invalid concurrency values
|
|
107
|
+
- `MemoryQueue.drain()` now cancels delayed jobs correctly
|
|
108
|
+
- `WebhookChannel` now uses a static `node:crypto` import
|
|
109
|
+
- Queue processing is owned by the service when a queue adapter is attached
|
|
110
|
+
- `withFallback()` now works correctly with queued delivery
|
|
111
|
+
- Bumped `tsdown` to v0.21.4
|
|
112
|
+
|
|
113
|
+
### Removed
|
|
114
|
+
|
|
115
|
+
- `batchBcc` from `EmailChannelConfig`
|
|
116
|
+
- `priority` from `QueueEnqueueOptions`
|
|
117
|
+
|
|
118
|
+
### Dependencies
|
|
119
|
+
|
|
120
|
+
- `nodemailer >=6` remains the only optional peer dependency
|
|
121
|
+
|
|
122
|
+
## [1.1.0] - 2026-02-24
|
|
123
|
+
|
|
124
|
+
### Added
|
|
125
|
+
|
|
126
|
+
- **EmailChannel** — Send email notifications via Nodemailer (SMTP, Gmail, SES, any transport)
|
|
127
|
+
- Lazy nodemailer import (zero overhead if unused)
|
|
128
|
+
- Pre-created transporter support for SES and custom transports
|
|
129
|
+
- `verify()` method for SMTP connection health checks
|
|
130
|
+
- `close()` method for graceful shutdown
|
|
131
|
+
- Attachments, CC/BCC, reply-to, custom `from` per-send
|
|
132
|
+
- **EmailChannel types** — `EmailChannelConfig`, `SmtpTransportOptions`, `EmailAttachment`, `NodemailerTransporter`
|
|
133
|
+
- **`QuietHoursConfig` type export** — Now available for consumers using `isQuietHours()` directly
|
|
134
|
+
|
|
135
|
+
## [1.0.0] - 2026-02-20
|
|
136
|
+
|
|
137
|
+
### Added
|
|
138
|
+
|
|
139
|
+
- **NotificationService** — Central orchestrator with send, batch send, hook factories, and lifecycle events
|
|
140
|
+
- **WebhookChannel** — HTTP POST/PUT with HMAC-SHA256 signing, custom headers, timeout (zero deps, native fetch)
|
|
141
|
+
- **ConsoleChannel** — Logs to console for development and testing
|
|
142
|
+
- **BaseChannel** — Abstract base class with event filtering and wildcard support (`user.*`)
|
|
143
|
+
- **Templates** — Pluggable template resolver (React Email, MJML, Handlebars, etc.)
|
|
144
|
+
- **Retry + Backoff** — Exponential, linear, or fixed backoff with jitter; per-channel overrides
|
|
145
|
+
- **User Preferences** — Per-user, per-event, per-channel opt-in/out with quiet hours
|
|
146
|
+
- **Quiet Hours** — Timezone-aware quiet period enforcement via `Intl.DateTimeFormat` (zero deps)
|
|
147
|
+
- **Idempotency** — Built-in deduplication with pluggable stores (memory default, Redis/DB via interface)
|
|
148
|
+
- **Batch Sending** — Worker-pool concurrency (`pMap`) with progress callback
|
|
149
|
+
- **Lifecycle Events** — `before:send` (fail-fast), `after:send`, `send:success`, `send:failed`, `send:retry`
|
|
150
|
+
- **Hook Factories** — `createHooks()` + `mergeHooks()` for EventEmitter/MongoKit/custom integration
|
|
151
|
+
- **Error Classes** — `NotificationError`, `ChannelError`, `ProviderNotInstalledError`
|
|
152
|
+
- **Utilities** — `withRetry`, `calculateDelay`, `resolveRetryConfig`, `Emitter`, `pMap`, `isQuietHours`, `MemoryIdempotencyStore`
|
|
153
|
+
- Full TypeScript types with ESM-only output
|
|
154
|
+
- Zero required dependencies (nodemailer is optional peer)
|