@classytic/notifications 2.3.0 → 2.4.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 CHANGED
@@ -2,6 +2,62 @@
2
2
 
3
3
  All notable changes to `@classytic/notifications` will be documented in this file.
4
4
 
5
+ ## [2.4.0] - 2026-08-17
6
+
7
+ ### Fixed — `providerMessageId` now works the way 2.3.0 claimed
8
+
9
+ 2.3.0 introduced `SendResult.providerMessageId` as the cross-channel correlation
10
+ key but populated it on **email only**, so the property it exists to provide did not
11
+ hold: a consumer reading `providerMessageId` got a value for email and `undefined`
12
+ for push and sms, and still had to know which channel produced the result before it
13
+ could find the id in the untyped `metadata` bag. A half-migrated contract is worse
14
+ than none — it reads as available and silently isn't.
15
+
16
+ - **`PushChannel` sets `providerMessageId`** (from the provider's `messageId`).
17
+ - **`SmsChannel` sets `providerMessageId`** (from the provider's `sid`). This is the
18
+ case that motivates the field: three vendors, three spellings (`messageId`, `id`,
19
+ `sid`), one concept.
20
+ - `WebhookChannel` and `ConsoleChannel` deliberately leave it **unset** — a 2xx from
21
+ an HTTP POST is not a message identifier, and synthesising one would make an
22
+ unjoinable send look joinable. Absent means "no correlation is possible", never
23
+ "delivery unknown".
24
+
25
+ ### Fixed — restores `metadata.messageId` on `EmailChannel`
26
+
27
+ 2.3.0 deleted it in the same MINOR that added `providerMessageId`, so anyone reading
28
+ `metadata.messageId` lost it on a range-satisfying `^2.2.0` upgrade with nothing to
29
+ signal the change. The removal was right in direction and wrong in timing. It is
30
+ back for a deprecation window.
31
+
32
+ **All three id-bearing channels now mirror their provider id under both names** —
33
+ `providerMessageId` (read this) and the legacy `metadata` key (`messageId` for
34
+ email/push, `sid` for sms). **3.0.0 removes the legacy keys from every channel at
35
+ once**, as one deliberate break rather than three accidental ones.
36
+
37
+ Pinned by `tests/channels.test.ts` → `providerMessageId across channels`, including
38
+ a case that asserts a consumer can read the id **without branching on channel** —
39
+ the actual contract, so a channel regressing to metadata-only fails there.
40
+
41
+ ## [2.3.0] - 2026-08-16
42
+
43
+ Recorded retroactively; this release shipped without a changelog entry.
44
+
45
+ ### Added
46
+
47
+ - **`SendResult.providerMessageId`** — the typed cross-channel correlation key, so a
48
+ delivery receipt (SES bounce, SMS DLR, push feedback) can be joined back to the
49
+ send that produced it.
50
+ - **`SendResult.subject`** + `NotificationSubject` (`{ sourceModel, sourceId }`) —
51
+ the business document a notification concerns, so "show me every message we sent
52
+ about invoice X" stops being a scan over an unindexed `metadata` blob.
53
+
54
+ ### Changed — BREAKING, shipped as a minor
55
+
56
+ - `EmailChannel` stopped emitting `metadata.messageId`. Readers of that key broke on
57
+ upgrade with no signal. **Restored in 2.4.0**; upgrade straight to 2.4.0.
58
+ - Only `EmailChannel` populated `providerMessageId`; push and sms did not. **Fixed
59
+ in 2.4.0.**
60
+
5
61
  ## [2.2.0] - 2026-06-03
6
62
 
7
63
  - `SendResult.retryable?: boolean` — when `false`, service short-circuits `withRetry` immediately (permanent failures: bad credentials, invalid address, hard bounce, 4xx)
@@ -1,2 +1,2 @@
1
- import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "../push.channel-CfPaV8z5.mjs";
1
+ import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "../push.channel-1tNMyaXl.mjs";
2
2
  export { BaseChannel, ConsoleChannel, EmailChannel, PushChannel, SmsChannel, WebhookChannel };
@@ -1,3 +1,3 @@
1
- import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "../push.channel-BhktEp30.mjs";
1
+ import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "../push.channel-BkgxUc82.mjs";
2
2
 
3
3
  export { BaseChannel, ConsoleChannel, EmailChannel, PushChannel, SmsChannel, WebhookChannel };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as TemplateResult, B as DeliveryLogQuery, C as RetryConfig, D as SmsProvider, E as SmsChannelConfig, F as QueueJob, G as MemoryRateLimitStore, H as IDEMPOTENCY_DEFAULT_TTL, I as QueueJobStatus, K as RateLimitConfig, L as QueueProcessor, M as MemoryQueue, N as QueueAdapter, O as SmtpTransportOptions, P as QueueEnqueueOptions, R as DeliveryLog, S as ResolvedRetryConfig, T as ServiceEvent, U as IdempotencyStore, V as MemoryDeliveryLog, W as MemoryIdempotencyStore, _ as NotificationServiceConfig, a as ChannelConfig, b as PushProvider, c as EmailChannelConfig, d as HookMap, f as Logger, g as NotificationPreferences, h as NotificationPayload, i as Channel, j as WebhookChannelConfig, k as TemplateResolver, l as EventHandler, m as NotificationHookConfig, n as BatchProgress, o as DispatchResult, p as NodemailerTransporter, q as RateLimitStore, r as BatchResult, s as EmailAttachment, t as BatchOptions, u as HookHandler, v as PreferenceResolver, w as SendResult, x as Recipient, y as PushChannelConfig, z as DeliveryLogEntry } from "./types-B5InMRIc.mjs";
2
- import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "./push.channel-CfPaV8z5.mjs";
3
- import { C as resolveRetryConfig, S as calculateDelay, T as mergeHooks, _ as isQuietHours, a as createStatusHandler, b as ProviderNotInstalledError, c as InterpolateOptions, d as TemplateMap, f as createSimpleResolver, g as QuietHoursConfig, h as pMap, i as StatusUpdate, l as SimpleResolverOptions, m as PMapOptions, n as StatusHandler, o as FallbackOptions, p as interpolateHtml, r as StatusHandlerConfig, s as withFallback, t as DeliveryStatus, u as TemplateDefinition, v as ChannelError, w as withRetry, x as Emitter, y as NotificationError } from "./status-webhook-NDUgykHA.mjs";
1
+ import { A as TemplateResult, B as DeliveryLogQuery, C as RetryConfig, D as SmsProvider, E as SmsChannelConfig, F as QueueJob, G as MemoryRateLimitStore, H as IDEMPOTENCY_DEFAULT_TTL, I as QueueJobStatus, K as RateLimitConfig, L as QueueProcessor, M as MemoryQueue, N as QueueAdapter, O as SmtpTransportOptions, P as QueueEnqueueOptions, R as DeliveryLog, S as ResolvedRetryConfig, T as ServiceEvent, U as IdempotencyStore, V as MemoryDeliveryLog, W as MemoryIdempotencyStore, _ as NotificationServiceConfig, a as ChannelConfig, b as PushProvider, c as EmailChannelConfig, d as HookMap, f as Logger, g as NotificationPreferences, h as NotificationPayload, i as Channel, j as WebhookChannelConfig, k as TemplateResolver, l as EventHandler, m as NotificationHookConfig, n as BatchProgress, o as DispatchResult, p as NodemailerTransporter, q as RateLimitStore, r as BatchResult, s as EmailAttachment, t as BatchOptions, u as HookHandler, v as PreferenceResolver, w as SendResult, x as Recipient, y as PushChannelConfig, z as DeliveryLogEntry } from "./types-DkFudalo.mjs";
2
+ import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "./push.channel-1tNMyaXl.mjs";
3
+ import { C as resolveRetryConfig, S as calculateDelay, T as mergeHooks, _ as isQuietHours, a as createStatusHandler, b as ProviderNotInstalledError, c as InterpolateOptions, d as TemplateMap, f as createSimpleResolver, g as QuietHoursConfig, h as pMap, i as StatusUpdate, l as SimpleResolverOptions, m as PMapOptions, n as StatusHandler, o as FallbackOptions, p as interpolateHtml, r as StatusHandlerConfig, s as withFallback, t as DeliveryStatus, u as TemplateDefinition, v as ChannelError, w as withRetry, x as Emitter, y as NotificationError } from "./status-webhook-CuCdFeVN.mjs";
4
4
  //#region src/NotificationService.d.ts
5
5
  declare class NotificationService {
6
6
  private channels;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as MemoryQueue, c as pMap, d as MemoryIdempotencyStore, f as isQuietHours, g as Emitter, h as withRetry, i as interpolateHtml, l as MemoryRateLimitStore, m as resolveRetryConfig, n as withFallback, o as MemoryDeliveryLog, p as calculateDelay, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_TTL } from "./status-webhook-B4Sv8X_G.mjs";
2
2
  import { n as NotificationError, r as ProviderNotInstalledError, t as ChannelError } from "./errors-BxRjct-E.mjs";
3
- import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "./push.channel-BhktEp30.mjs";
3
+ import { a as EmailChannel, i as WebhookChannel, n as SmsChannel, o as BaseChannel, r as ConsoleChannel, t as PushChannel } from "./push.channel-BkgxUc82.mjs";
4
4
 
5
5
  //#region src/NotificationService.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { C as RetryConfig, E as SmsChannelConfig, K as RateLimitConfig, a as ChannelConfig, c as EmailChannelConfig, h as NotificationPayload, i as Channel, j as WebhookChannelConfig, w as SendResult, y as PushChannelConfig } from "./types-B5InMRIc.mjs";
1
+ import { C as RetryConfig, E as SmsChannelConfig, K as RateLimitConfig, a as ChannelConfig, c as EmailChannelConfig, h as NotificationPayload, i as Channel, j as WebhookChannelConfig, w as SendResult, y as PushChannelConfig } from "./types-DkFudalo.mjs";
2
2
  //#region src/channels/BaseChannel.d.ts
3
3
  declare abstract class BaseChannel<TConfig extends ChannelConfig = ChannelConfig> implements Channel {
4
4
  readonly name: string;
@@ -175,7 +175,18 @@ var EmailChannel = class EmailChannel extends BaseChannel {
175
175
  * and a consumer has to know which channel produced the result before it can
176
176
  * find the id — which is why `SendResult.providerMessageId` exists.
177
177
  */
178
- providerMessageId: result.messageId
178
+ providerMessageId: result.messageId,
179
+ /**
180
+ * RESTORED in 2.4.0. 2.3.0 introduced `providerMessageId` and deleted this
181
+ * in the same MINOR, so a consumer reading `metadata.messageId` lost it on
182
+ * a range-satisfying upgrade with nothing to tell them — the removal was
183
+ * correct in direction and wrong in timing. It is back for the deprecation
184
+ * window, so all three id-bearing channels behave identically, and 3.0.0
185
+ * removes it from every channel at once as one deliberate break.
186
+ *
187
+ * @deprecated read `providerMessageId`; removed in 3.0.0
188
+ */
189
+ metadata: { messageId: result.messageId }
179
190
  };
180
191
  } catch (err) {
181
192
  const message = err instanceof Error ? err.message : String(err);
@@ -413,6 +424,23 @@ var SmsChannel = class extends BaseChannel {
413
424
  return {
414
425
  status: "sent",
415
426
  channel: this.name,
427
+ /**
428
+ * The TYPED correlation key. SMS is the case that makes the argument:
429
+ * the provider calls it `sid`, email calls it `messageId`, push calls
430
+ * it `messageId` — three spellings for one concept, so a delivery
431
+ * receipt (a DLR) could only be joined back to its send by code that
432
+ * already knew which channel had produced the result. That is the
433
+ * exact coupling `SendResult.providerMessageId` removes.
434
+ */
435
+ providerMessageId: result.sid,
436
+ /**
437
+ * Kept for one release alongside the typed field. Dropping it here
438
+ * would be a silent removal in a MINOR — exactly what 2.3.0 did to
439
+ * email's `metadata.messageId`, breaking readers with no signal.
440
+ * Removed in 3.0.0, from every channel at once.
441
+ *
442
+ * @deprecated read `providerMessageId`; removed in 3.0.0
443
+ */
416
444
  metadata: { sid: result.sid }
417
445
  };
418
446
  } catch (err) {
@@ -537,6 +565,22 @@ var PushChannel = class extends BaseChannel {
537
565
  return {
538
566
  status: "sent",
539
567
  channel: this.name,
568
+ /**
569
+ * The TYPED correlation key — same contract email publishes. A push
570
+ * receipt (FCM/APNs feedback, an Expo receipt lookup) arrives naming
571
+ * this id, and until it was here a consumer had to know the result
572
+ * came from THIS channel before it could find it under the untyped
573
+ * key `metadata.messageId`.
574
+ */
575
+ providerMessageId: result.messageId,
576
+ /**
577
+ * Kept for one release alongside the typed field. Dropping it here
578
+ * would be a silent removal in a MINOR — exactly what 2.3.0 did to
579
+ * email's `metadata.messageId`, breaking readers with no signal.
580
+ * Removed in 3.0.0, from every channel at once.
581
+ *
582
+ * @deprecated read `providerMessageId`; removed in 3.0.0
583
+ */
540
584
  metadata: { messageId: result.messageId }
541
585
  };
542
586
  } catch (err) {
@@ -1,4 +1,4 @@
1
- import { C as RetryConfig, S as ResolvedRetryConfig, d as HookMap, h as NotificationPayload, k as TemplateResolver, o as DispatchResult, u as HookHandler } from "./types-B5InMRIc.mjs";
1
+ import { C as RetryConfig, S as ResolvedRetryConfig, d as HookMap, h as NotificationPayload, k as TemplateResolver, o as DispatchResult, u as HookHandler } from "./types-DkFudalo.mjs";
2
2
  //#region src/utils/merge-hooks.d.ts
3
3
  type HookInput = Record<string, HookHandler | HookHandler[]>;
4
4
  declare function mergeHooks(...hookConfigs: (HookInput | null | undefined)[]): HookMap;
@@ -418,8 +418,21 @@ interface SendResult {
418
418
  * Optional because it is genuinely absent for synchronous channels (in-app feed) and
419
419
  * for providers that acknowledge without issuing an id. Absent means "no correlation
420
420
  * is possible", NOT "delivery unknown" — a consumer must not infer failure from it.
421
+ *
422
+ * Populated by every channel whose provider issues one: `email` (`messageId`),
423
+ * `push` (`messageId`), `sms` (`sid`). `webhook` and `console` leave it unset
424
+ * because there is no id to report — a 2xx from an HTTP POST is not a message
425
+ * identifier, and inventing one would make an unjoinable send look joinable.
421
426
  */
422
427
  providerMessageId?: string;
428
+ /**
429
+ * Free-form per-channel extras.
430
+ *
431
+ * Until 3.0.0 the id-bearing channels ALSO mirror their provider id here under
432
+ * the legacy key (`messageId` for email/push, `sid` for sms). That duplication
433
+ * is the deprecation window, not the contract: read {@link providerMessageId},
434
+ * which is the same value under one name on every channel.
435
+ */
423
436
  metadata?: Record<string, unknown>;
424
437
  }
425
438
  /** Result from dispatching to all channels */
@@ -1,3 +1,3 @@
1
- import { B as DeliveryLogQuery, F as QueueJob, G as MemoryRateLimitStore, H as IDEMPOTENCY_DEFAULT_TTL, I as QueueJobStatus, K as RateLimitConfig, L as QueueProcessor, M as MemoryQueue, N as QueueAdapter, P as QueueEnqueueOptions, R as DeliveryLog, U as IdempotencyStore, V as MemoryDeliveryLog, W as MemoryIdempotencyStore, q as RateLimitStore, z as DeliveryLogEntry } from "../types-B5InMRIc.mjs";
2
- import { C as resolveRetryConfig, S as calculateDelay, T as mergeHooks, _ as isQuietHours, a as createStatusHandler, b as ProviderNotInstalledError, c as InterpolateOptions, d as TemplateMap, f as createSimpleResolver, g as QuietHoursConfig, h as pMap, i as StatusUpdate, m as PMapOptions, n as StatusHandler, o as FallbackOptions, p as interpolateHtml, r as StatusHandlerConfig, s as withFallback, t as DeliveryStatus, u as TemplateDefinition, v as ChannelError, w as withRetry, x as Emitter, y as NotificationError } from "../status-webhook-NDUgykHA.mjs";
1
+ import { B as DeliveryLogQuery, F as QueueJob, G as MemoryRateLimitStore, H as IDEMPOTENCY_DEFAULT_TTL, I as QueueJobStatus, K as RateLimitConfig, L as QueueProcessor, M as MemoryQueue, N as QueueAdapter, P as QueueEnqueueOptions, R as DeliveryLog, U as IdempotencyStore, V as MemoryDeliveryLog, W as MemoryIdempotencyStore, q as RateLimitStore, z as DeliveryLogEntry } from "../types-DkFudalo.mjs";
2
+ import { C as resolveRetryConfig, S as calculateDelay, T as mergeHooks, _ as isQuietHours, a as createStatusHandler, b as ProviderNotInstalledError, c as InterpolateOptions, d as TemplateMap, f as createSimpleResolver, g as QuietHoursConfig, h as pMap, i as StatusUpdate, m as PMapOptions, n as StatusHandler, o as FallbackOptions, p as interpolateHtml, r as StatusHandlerConfig, s as withFallback, t as DeliveryStatus, u as TemplateDefinition, v as ChannelError, w as withRetry, x as Emitter, y as NotificationError } from "../status-webhook-CuCdFeVN.mjs";
3
3
  export { ChannelError, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, Emitter, type FallbackOptions, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, type PMapOptions, ProviderNotInstalledError, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, type TemplateDefinition, type TemplateMap, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, withFallback, withRetry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/notifications",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Multi-channel notifications (Email, SMS, Push, Webhook) with rate limiting, delivery tracking, queue adapters, channel fallback, templates, retry — zero required dependencies",
5
5
  "type": "module",
6
6
  "sideEffects": false,