@classytic/notifications 2.9.0 → 2.10.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 +38 -0
- package/README.md +27 -2
- package/dist/channels/index.d.mts +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.mjs +102 -11
- package/dist/push/index.d.mts +107 -3
- package/dist/push/index.mjs +131 -2
- package/dist/{status-webhook-Pg_jRXwp.d.mts → status-webhook-DCU8KQLR.d.mts} +7 -2
- package/dist/{status-webhook-D1lNssTZ.mjs → status-webhook-DN3bdqKs.mjs} +18 -1
- package/dist/{telegram.channel-8DKyn1og.d.mts → telegram.channel-DcqdfWmV.d.mts} +1 -1
- package/dist/{types-BNjSzlcY.d.mts → types-D3g8xK2h.d.mts} +20 -1
- package/dist/utils/index.d.mts +3 -3
- package/dist/utils/index.mjs +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@classytic/notifications` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.10.0] - 2026-11-23
|
|
6
|
+
|
|
7
|
+
Implements gaps G3 and G4 of arc-notifications' `docs/push-gaps-2026-11.md` (ADR 0001 in
|
|
8
|
+
arc-ecosystem, `docs/adr/0001-notifications-and-push.md`).
|
|
9
|
+
|
|
10
|
+
### Added: provider retry floors and retry planning (G4)
|
|
11
|
+
|
|
12
|
+
- `TransientPushError.retryFloorMs`: the provider's documented minimum wait, filled by the constructor
|
|
13
|
+
from `pushRetryFloorMs(provider, status)`: FCM 10 s (5xx, network, timeout), FCM 429 60 s, APNs 5xx
|
|
14
|
+
15 min, APNs 429 60 s, network / unknown 10 s. Throw sites may pass their own.
|
|
15
|
+
- `PUSH_RETRY_DEFAULTS`, `pushRetryDelay(err, attempt)` (`max(Retry-After, floor) x 2^(n-1)`, growth
|
|
16
|
+
capped at 60 min, 0 to 20 % jitter that only adds), `planPushRetry({ error, attempt, firstFailureAt,
|
|
17
|
+
now, expiresAt?, maxAttempts? = 5, giveUpAfterMs? })` returning `{ retry: true, delayMs, at }` or
|
|
18
|
+
`{ retry: false, reason: 'permanent' | 'attempts' | 'expired' | 'gave-up' }` (FCM: 60 min window).
|
|
19
|
+
Pure functions: nothing sleeps; schedule the next attempt on a job queue.
|
|
20
|
+
- `retryFloorHint(err)` (root and `/utils`), the floor counterpart of `retryAfterHint`.
|
|
21
|
+
|
|
22
|
+
### Added: per-channel idempotency (G3)
|
|
23
|
+
|
|
24
|
+
- `idempotency.scope: 'channel' | 'payload'`. `'channel'` (new default) claims and records
|
|
25
|
+
`${idempotencyKey}:${channel.name}` per channel, only for channels that sent; a redelivery skips the
|
|
26
|
+
done channels (`skipped`, `duplicate (idempotency)`) and retries the rest. A fully duplicated payload
|
|
27
|
+
keeps the 2.9 shape (`results: []`, `skipped: 1`). With a queue (`throw-on-total-failure`), a
|
|
28
|
+
dispatch with a retryable failed channel now throws so the queue re-runs it; only the unfinished
|
|
29
|
+
channels send. `'payload'` is the 2.9 behaviour.
|
|
30
|
+
|
|
31
|
+
### Changed (migration)
|
|
32
|
+
|
|
33
|
+
- **Idempotency keys** now carry a `:<channel>` suffix by default. A key written by 2.9 does not
|
|
34
|
+
dedupe an event redelivered within its 24 h TTL after the upgrade. Deploy outside a redelivery
|
|
35
|
+
window, or set `idempotency: { scope: 'payload' }` and switch later. Code that reads the store by
|
|
36
|
+
key must append `:<channel>`.
|
|
37
|
+
- **`withRetry` honours `retryFloorMs`** like `Retry-After`: a push `TransientPushError` is never
|
|
38
|
+
retried in process sooner than its floor, and not in process at all when the floor exceeds
|
|
39
|
+
`maxDelay` (default 30 s; so APNs 5xx always goes to the queue). An FCM 5xx through `PushChannel`
|
|
40
|
+
with the default retry config now waits 10 s instead of about 0.5 s. Custom errors without the field
|
|
41
|
+
are unaffected.
|
|
42
|
+
|
|
5
43
|
## [2.9.0] - 2026-11-23
|
|
6
44
|
|
|
7
45
|
### Added: `@classytic/notifications/push`, FCM HTTP v1 and APNs HTTP/2 with no SDK
|
package/README.md
CHANGED
|
@@ -357,7 +357,16 @@ await service.send({
|
|
|
357
357
|
| FCM `UNREGISTERED`, `INVALID_ARGUMENT` naming the token; APNs 410, `BadDeviceToken` | `InvalidPushTokenError` + `onInvalidToken(token, reason)` | no |
|
|
358
358
|
| Payload / topic / sender problems, a platform without a provider | `PushRejectedError` (device kept) | no |
|
|
359
359
|
| Credentials missing, malformed, or refused after one refresh | `PushCredentialsError` | no |
|
|
360
|
-
| 429, 5xx, timeout, network | `TransientPushError` with `retryAfterMs` | yes, never sooner than `Retry-After` |
|
|
360
|
+
| 429, 5xx, timeout, network | `TransientPushError` with `retryAfterMs` and `retryFloorMs` | yes, never sooner than `Retry-After` or the provider floor |
|
|
361
|
+
|
|
362
|
+
**Retry timing (2.10).** Every `TransientPushError` carries `retryFloorMs`, the provider's documented
|
|
363
|
+
minimum: FCM 10 s (60 s on 429), APNs 15 min on 5xx and 60 s on 429, 10 s for network errors
|
|
364
|
+
(`PUSH_RETRY_DEFAULTS`). `pushRetryDelay(err, attempt)` is `max(Retry-After, floor) x 2^(attempt-1)`
|
|
365
|
+
with upward-only jitter; `planPushRetry({ error, attempt, firstFailureAt, now, expiresAt })` adds at
|
|
366
|
+
most 5 attempts, FCM's 60 min give-up window and the notification's expiry, and returns
|
|
367
|
+
`{ retry: true, delayMs }` or `{ retry: false, reason }`. Both are pure: schedule the next attempt on
|
|
368
|
+
your job queue (arc-notifications' `push.device` job does). `withRetry` never retries sooner than a
|
|
369
|
+
floor, and stops in process when the floor exceeds `maxDelay`.
|
|
361
370
|
|
|
362
371
|
- **Tokens**: FCM OAuth2 access tokens are cached until 60 s before expiry with one shared refresh
|
|
363
372
|
for concurrent sends; APNs ES256 provider tokens are reused for 50 minutes (Apple allows 20 to 60).
|
|
@@ -368,7 +377,7 @@ await service.send({
|
|
|
368
377
|
for apps whose data may not leave a jurisdiction.
|
|
369
378
|
- **Observability**: `onDelivery(event)` gets one redacted record per send (token suffix and hash,
|
|
370
379
|
status, reason, latency; never the token or the text).
|
|
371
|
-
- `withRetry` (and so the service)
|
|
380
|
+
- `withRetry` (and so the service) honours `retryAfterMs` and `retryFloorMs` on an error or its `cause`.
|
|
372
381
|
|
|
373
382
|
Arc apps: `@classytic/arc-notifications/push` adds device registration, credentials from env or an
|
|
374
383
|
encrypted admin integration, and a device fan-out channel on top of these providers.
|
|
@@ -711,6 +720,19 @@ A custom `IdempotencyStore` gets the same guarantee by implementing the optional
|
|
|
711
720
|
`claim(key, leaseMs)` / `release(key)` pair; stores with only `has` / `set` keep the
|
|
712
721
|
previous check-then-record behaviour (fine in one process, racy across several).
|
|
713
722
|
|
|
723
|
+
**Per-channel keys (2.10 default).** The key is claimed and recorded per channel as
|
|
724
|
+
`${idempotencyKey}:${channel}`, and recorded only for channels that sent. With
|
|
725
|
+
`channels: ['in-app', 'push']`, an in-app write that succeeded beside a push that failed
|
|
726
|
+
leaves `key:push` free: a redelivery (or the queue's retry) sends the push and skips the
|
|
727
|
+
in-app channel (`skipped`, error `duplicate (idempotency)`). With a queue, a dispatch with a
|
|
728
|
+
retryable failed channel now throws so the queue re-runs it; without a key the old "partial
|
|
729
|
+
success completes" rule stays. `idempotency: { scope: 'payload' }` restores the 2.9
|
|
730
|
+
single key (a failed channel beside a successful one is then never retried).
|
|
731
|
+
|
|
732
|
+
Upgrading from 2.9: keys written by 2.9 have no `:<channel>` suffix, so an event redelivered
|
|
733
|
+
within 24 h of the upgrade is not recognised as a duplicate. Deploy outside a redelivery
|
|
734
|
+
window, or keep `scope: 'payload'` until old keys have expired.
|
|
735
|
+
|
|
714
736
|
## Batch Sending
|
|
715
737
|
|
|
716
738
|
Send thousands of notifications with controlled concurrency:
|
|
@@ -738,6 +760,9 @@ const notifications = new NotificationService({
|
|
|
738
760
|
```
|
|
739
761
|
|
|
740
762
|
Jitter (+-25%) is applied automatically to prevent thundering herd. Per-channel overrides are supported.
|
|
763
|
+
An error that carries `retryAfterMs` (HTTP `Retry-After`) or `retryFloorMs` (a provider's minimum, set
|
|
764
|
+
on every push `TransientPushError`) is never retried sooner; when that wait exceeds `maxDelay` the
|
|
765
|
+
in-process loop stops and the failure is left to your queue.
|
|
741
766
|
|
|
742
767
|
## Lifecycle Events
|
|
743
768
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-
|
|
1
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-DcqdfWmV.mjs";
|
|
2
2
|
export { BaseChannel, ConsoleChannel, EmailChannel, PushChannel, SmsChannel, TelegramChannel, WebhookChannel };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as RateLimitConfig, A as SmsProvider, B as QueueJobStatus, C as PushProviderMessage, D as SendResult, E as RetryConfig, F as WebhookChannelConfig, G as MemoryDeliveryLog, H as DeliveryLog, I as MemoryQueue, J as IdempotencyStore, K as IDEMPOTENCY_DEFAULT_LEASE, L as QueueAdapter, M as TelegramChannelConfig, N as TemplateResolver, O as ServiceEvent, P as TemplateResult, Q as MemoryRateLimitStore, R as QueueEnqueueOptions, S as PushProvider, T as ResolvedRetryConfig, U as DeliveryLogEntry, V as QueueProcessor, W as DeliveryLogQuery, X as RedisIdempotencyClient, Y as MemoryIdempotencyStore, Z as RedisIdempotencyStore, _ as NotificationServiceConfig, a as ChannelConfig, b as PushInterruptionLevel, c as EmailChannelConfig, d as HookMap, et as RateLimitStore, f as Logger, g as NotificationPreferences, h as NotificationPayload, i as Channel, j as SmtpTransportOptions, k as SmsChannelConfig, l as EventHandler, m as NotificationHookConfig, n as BatchProgress, o as DispatchResult, p as NodemailerTransporter, q as IDEMPOTENCY_DEFAULT_TTL, r as BatchResult, s as EmailAttachment, t as BatchOptions, u as HookHandler, v as PreferenceResolver, w as Recipient, x as PushPlatform, y as PushChannelConfig, z as QueueJob } from "./types-
|
|
2
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-
|
|
3
|
-
import { C as
|
|
1
|
+
import { $ as RateLimitConfig, A as SmsProvider, B as QueueJobStatus, C as PushProviderMessage, D as SendResult, E as RetryConfig, F as WebhookChannelConfig, G as MemoryDeliveryLog, H as DeliveryLog, I as MemoryQueue, J as IdempotencyStore, K as IDEMPOTENCY_DEFAULT_LEASE, L as QueueAdapter, M as TelegramChannelConfig, N as TemplateResolver, O as ServiceEvent, P as TemplateResult, Q as MemoryRateLimitStore, R as QueueEnqueueOptions, S as PushProvider, T as ResolvedRetryConfig, U as DeliveryLogEntry, V as QueueProcessor, W as DeliveryLogQuery, X as RedisIdempotencyClient, Y as MemoryIdempotencyStore, Z as RedisIdempotencyStore, _ as NotificationServiceConfig, a as ChannelConfig, b as PushInterruptionLevel, c as EmailChannelConfig, d as HookMap, et as RateLimitStore, f as Logger, g as NotificationPreferences, h as NotificationPayload, i as Channel, j as SmtpTransportOptions, k as SmsChannelConfig, l as EventHandler, m as NotificationHookConfig, n as BatchProgress, o as DispatchResult, p as NodemailerTransporter, q as IDEMPOTENCY_DEFAULT_TTL, r as BatchResult, s as EmailAttachment, t as BatchOptions, u as HookHandler, v as PreferenceResolver, w as Recipient, x as PushPlatform, y as PushChannelConfig, z as QueueJob } from "./types-D3g8xK2h.mjs";
|
|
2
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-DcqdfWmV.mjs";
|
|
3
|
+
import { C as withRetry, S as retryFloorHint, _ as isQuietHours, a as createStatusHandler, b as resolveRetryConfig, 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 Emitter, w as mergeHooks, x as retryAfterHint, y as calculateDelay } from "./status-webhook-DCU8KQLR.mjs";
|
|
4
4
|
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "./errors-DCOaQvhV.mjs";
|
|
5
5
|
//#region src/NotificationService.d.ts
|
|
6
6
|
export declare class NotificationService {
|
|
@@ -13,6 +13,7 @@ export declare class NotificationService {
|
|
|
13
13
|
private idempotencyStore?;
|
|
14
14
|
private idempotencyTtl;
|
|
15
15
|
private idempotencyLease;
|
|
16
|
+
private idempotencyScope;
|
|
16
17
|
private deliveryLog?;
|
|
17
18
|
private rateLimitStore?;
|
|
18
19
|
private queueAdapter?;
|
|
@@ -54,6 +55,18 @@ export declare class NotificationService {
|
|
|
54
55
|
* lifecycle events are always emitted.
|
|
55
56
|
*/
|
|
56
57
|
private sendDirect;
|
|
58
|
+
/** Per-channel keys apply: a key, a store, and `scope: 'channel'` (the default). */
|
|
59
|
+
private perChannelIdempotency;
|
|
60
|
+
/**
|
|
61
|
+
* Per-channel idempotency (G3 in arc-notifications' `docs/push-gaps-2026-11.md`; ADR 0001
|
|
62
|
+
* section 2 item 4 applied at the channel level). Each target channel is claimed under
|
|
63
|
+
* `${key}:${channel}` BEFORE the template is rendered, so a full duplicate stays as cheap as in
|
|
64
|
+
* 2.9. Channels already done are skipped (reported as `skipped`, error `duplicate`); the rest
|
|
65
|
+
* deliver. After delivery a channel that SENT records its key for the TTL; every other claim is
|
|
66
|
+
* released, so a redelivery (or the queue's retry) sends that channel, and only that channel,
|
|
67
|
+
* again. A pipeline error releases every claim it holds.
|
|
68
|
+
*/
|
|
69
|
+
private deliverPerChannel;
|
|
57
70
|
/** Drop a claimed idempotency key so a later retry can deliver. Never throws. */
|
|
58
71
|
private releaseIdempotency;
|
|
59
72
|
/** Steps 2-5 of the send pipeline: template, channel filter, preferences, delivery. */
|
|
@@ -139,4 +152,4 @@ export declare class NotificationService {
|
|
|
139
152
|
off(event: ServiceEvent, handler: EventHandler): this;
|
|
140
153
|
}
|
|
141
154
|
//#endregion
|
|
142
|
-
export { BaseChannel, type BatchOptions, type BatchProgress, type BatchResult, type Channel, type ChannelConfig, ChannelError, ConsoleChannel, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, type DispatchResult, type EmailAttachment, EmailChannel, type EmailChannelConfig, Emitter, type EventHandler, type FallbackOptions, type HookHandler, type HookMap, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, type Logger, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, type NodemailerTransporter, NotificationError, type NotificationHookConfig, type NotificationPayload, type NotificationPreferences, type NotificationServiceConfig, type PMapOptions, PermanentDeliveryError, type PreferenceResolver, ProviderNotInstalledError, PushChannel, type PushChannelConfig, type PushInterruptionLevel, type PushPlatform, type PushProvider, type PushProviderMessage, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type Recipient, type RedisIdempotencyClient, RedisIdempotencyStore, type ResolvedRetryConfig, type RetryConfig, type SendResult, type ServiceEvent, type SimpleResolverOptions, SmsChannel, type SmsChannelConfig, type SmsProvider, type SmtpTransportOptions, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, TelegramChannel, type TelegramChannelConfig, type TemplateDefinition, type TemplateMap, type TemplateResolver, type TemplateResult, WebhookChannel, type WebhookChannelConfig, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
|
155
|
+
export { BaseChannel, type BatchOptions, type BatchProgress, type BatchResult, type Channel, type ChannelConfig, ChannelError, ConsoleChannel, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, type DispatchResult, type EmailAttachment, EmailChannel, type EmailChannelConfig, Emitter, type EventHandler, type FallbackOptions, type HookHandler, type HookMap, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, type Logger, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, type NodemailerTransporter, NotificationError, type NotificationHookConfig, type NotificationPayload, type NotificationPreferences, type NotificationServiceConfig, type PMapOptions, PermanentDeliveryError, type PreferenceResolver, ProviderNotInstalledError, PushChannel, type PushChannelConfig, type PushInterruptionLevel, type PushPlatform, type PushProvider, type PushProviderMessage, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type Recipient, type RedisIdempotencyClient, RedisIdempotencyStore, type ResolvedRetryConfig, type RetryConfig, type SendResult, type ServiceEvent, type SimpleResolverOptions, SmsChannel, type SmsChannelConfig, type SmsProvider, type SmtpTransportOptions, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, TelegramChannel, type TelegramChannelConfig, type TemplateDefinition, type TemplateMap, type TemplateResolver, type TemplateResult, WebhookChannel, type WebhookChannelConfig, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, retryFloorHint, withFallback, withRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as retryAfterHint, a as MemoryQueue, c as pMap, d as IDEMPOTENCY_DEFAULT_TTL, f as MemoryIdempotencyStore, g as resolveRetryConfig, h as calculateDelay, i as interpolateHtml, l as MemoryRateLimitStore, m as isQuietHours, n as withFallback, o as MemoryDeliveryLog, p as RedisIdempotencyStore, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_LEASE, v as
|
|
1
|
+
import { _ as retryAfterHint, a as MemoryQueue, b as Emitter, c as pMap, d as IDEMPOTENCY_DEFAULT_TTL, f as MemoryIdempotencyStore, g as resolveRetryConfig, h as calculateDelay, i as interpolateHtml, l as MemoryRateLimitStore, m as isQuietHours, n as withFallback, o as MemoryDeliveryLog, p as RedisIdempotencyStore, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_LEASE, v as retryFloorHint, y as withRetry } from "./status-webhook-DN3bdqKs.mjs";
|
|
2
2
|
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "./errors-CsQZKfec.mjs";
|
|
3
3
|
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-0XRkIXmt.mjs";
|
|
4
4
|
|
|
@@ -67,6 +67,7 @@ var NotificationService = class {
|
|
|
67
67
|
idempotencyStore;
|
|
68
68
|
idempotencyTtl;
|
|
69
69
|
idempotencyLease;
|
|
70
|
+
idempotencyScope;
|
|
70
71
|
deliveryLog;
|
|
71
72
|
rateLimitStore;
|
|
72
73
|
queueAdapter;
|
|
@@ -82,6 +83,7 @@ var NotificationService = class {
|
|
|
82
83
|
this.idempotencyTtl = config.idempotency.ttl ?? 864e5;
|
|
83
84
|
} else this.idempotencyTtl = IDEMPOTENCY_DEFAULT_TTL;
|
|
84
85
|
this.idempotencyLease = config.idempotency?.leaseMs ?? 3e5;
|
|
86
|
+
this.idempotencyScope = config.idempotency?.scope ?? "channel";
|
|
85
87
|
this.deliveryLog = config.deliveryLog;
|
|
86
88
|
if (config.rateLimitStore) this.rateLimitStore = config.rateLimitStore;
|
|
87
89
|
else if (this.channels.some((ch) => this.getChannelRateLimit(ch))) this.rateLimitStore = new MemoryRateLimitStore();
|
|
@@ -90,9 +92,12 @@ var NotificationService = class {
|
|
|
90
92
|
this.queueAdapter = config.queue;
|
|
91
93
|
this.queueAdapter.process(async (payload) => {
|
|
92
94
|
const dispatch = await this.sendDirect(payload);
|
|
93
|
-
|
|
95
|
+
const perChannel = this.perChannelIdempotency(payload);
|
|
96
|
+
const retryableFailed = dispatch.results.filter((r) => r.status === "failed" && r.retryable !== false);
|
|
97
|
+
const totalFailure = dispatch.sent === 0 && dispatch.failed > 0;
|
|
98
|
+
if (this.queueFailureMode === "throw-on-total-failure" && (totalFailure || perChannel && retryableFailed.length > 0)) {
|
|
94
99
|
const summary = dispatch.results.filter((r) => r.status === "failed").map((r) => `${r.channel}: ${r.error ?? "unknown error"}`).join("; ");
|
|
95
|
-
throw new NotificationError(`Queued dispatch for "${dispatch.event}" failed on every channel: ${summary || "no detail"}`, { code: "QUEUE_DISPATCH_FAILED" });
|
|
100
|
+
throw new NotificationError(totalFailure ? `Queued dispatch for "${dispatch.event}" failed on every channel: ${summary || "no detail"}` : `Queued dispatch for "${dispatch.event}" failed on some channels (retrying those only): ${summary}`, { code: "QUEUE_DISPATCH_FAILED" });
|
|
96
101
|
}
|
|
97
102
|
});
|
|
98
103
|
}
|
|
@@ -171,6 +176,7 @@ var NotificationService = class {
|
|
|
171
176
|
async sendDirect(payload) {
|
|
172
177
|
const start = Date.now();
|
|
173
178
|
await this.emitter.emit("before:send", payload);
|
|
179
|
+
if (this.perChannelIdempotency(payload)) return this.deliverPerChannel(payload, start, payload.idempotencyKey, this.idempotencyStore);
|
|
174
180
|
let claimed = false;
|
|
175
181
|
if (payload.idempotencyKey && this.idempotencyStore) {
|
|
176
182
|
const store = this.idempotencyStore;
|
|
@@ -195,6 +201,78 @@ var NotificationService = class {
|
|
|
195
201
|
if (!delivered || delivered.sent === 0) await this.releaseIdempotency(payload.idempotencyKey);
|
|
196
202
|
}
|
|
197
203
|
}
|
|
204
|
+
/** Per-channel keys apply: a key, a store, and `scope: 'channel'` (the default). */
|
|
205
|
+
perChannelIdempotency(payload) {
|
|
206
|
+
return Boolean(payload.idempotencyKey && this.idempotencyStore && this.idempotencyScope === "channel");
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Per-channel idempotency (G3 in arc-notifications' `docs/push-gaps-2026-11.md`; ADR 0001
|
|
210
|
+
* section 2 item 4 applied at the channel level). Each target channel is claimed under
|
|
211
|
+
* `${key}:${channel}` BEFORE the template is rendered, so a full duplicate stays as cheap as in
|
|
212
|
+
* 2.9. Channels already done are skipped (reported as `skipped`, error `duplicate`); the rest
|
|
213
|
+
* deliver. After delivery a channel that SENT records its key for the TTL; every other claim is
|
|
214
|
+
* released, so a redelivery (or the queue's retry) sends that channel, and only that channel,
|
|
215
|
+
* again. A pipeline error releases every claim it holds.
|
|
216
|
+
*/
|
|
217
|
+
async deliverPerChannel(payload, start, key, store) {
|
|
218
|
+
let candidates = this.channels.filter((ch) => ch.shouldHandle(payload.event));
|
|
219
|
+
if (payload.channels?.length) {
|
|
220
|
+
const targetSet = new Set(payload.channels);
|
|
221
|
+
candidates = candidates.filter((ch) => targetSet.has(ch.name));
|
|
222
|
+
}
|
|
223
|
+
const keyOf = (name) => `${key}:${name}`;
|
|
224
|
+
const fresh = [];
|
|
225
|
+
const duplicates = [];
|
|
226
|
+
const held = /* @__PURE__ */ new Set();
|
|
227
|
+
const done = /* @__PURE__ */ new Set();
|
|
228
|
+
const releaseHeld = async () => {
|
|
229
|
+
for (const name of held) if (!done.has(name)) await this.releaseIdempotency(keyOf(name));
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
for (const channel of candidates) {
|
|
233
|
+
const k = keyOf(channel.name);
|
|
234
|
+
if (store.claim ? !await store.claim(k, this.idempotencyLease) : await store.has(k)) {
|
|
235
|
+
duplicates.push(channel);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
fresh.push(channel);
|
|
239
|
+
if (store.claim) held.add(channel.name);
|
|
240
|
+
}
|
|
241
|
+
} catch (err) {
|
|
242
|
+
await releaseHeld();
|
|
243
|
+
throw err;
|
|
244
|
+
}
|
|
245
|
+
if (candidates.length > 0 && fresh.length === 0) {
|
|
246
|
+
this.logger.debug?.(`Duplicate notification skipped (key: ${key})`);
|
|
247
|
+
return this.finalize(payload, {
|
|
248
|
+
event: payload.event,
|
|
249
|
+
results: [],
|
|
250
|
+
sent: 0,
|
|
251
|
+
failed: 0,
|
|
252
|
+
skipped: 1,
|
|
253
|
+
duration: Date.now() - start
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
return await this.deliver(payload, start, {
|
|
258
|
+
channels: fresh,
|
|
259
|
+
duplicates,
|
|
260
|
+
settle: async (results) => {
|
|
261
|
+
for (const r of results) {
|
|
262
|
+
if (r.status !== "sent") continue;
|
|
263
|
+
done.add(r.channel);
|
|
264
|
+
try {
|
|
265
|
+
await store.set(keyOf(r.channel), this.idempotencyTtl);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
this.logger.warn(`Idempotency store error: ${err instanceof Error ? err.message : err}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
} finally {
|
|
273
|
+
await releaseHeld();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
198
276
|
/** Drop a claimed idempotency key so a later retry can deliver. Never throws. */
|
|
199
277
|
async releaseIdempotency(key) {
|
|
200
278
|
try {
|
|
@@ -204,7 +282,7 @@ var NotificationService = class {
|
|
|
204
282
|
}
|
|
205
283
|
}
|
|
206
284
|
/** Steps 2-5 of the send pipeline: template, channel filter, preferences, delivery. */
|
|
207
|
-
async deliver(payload, start) {
|
|
285
|
+
async deliver(payload, start, perChannel) {
|
|
208
286
|
let enrichedPayload = payload;
|
|
209
287
|
if (payload.template && this.templateResolver) try {
|
|
210
288
|
const rendered = await this.templateResolver(payload.template, payload.data);
|
|
@@ -219,10 +297,14 @@ var NotificationService = class {
|
|
|
219
297
|
this.logger.error(`Template resolution failed for "${payload.template}"`, err);
|
|
220
298
|
throw new NotificationError(`Template "${payload.template}" failed: ${err instanceof Error ? err.message : err}`, { code: "TEMPLATE_ERROR" });
|
|
221
299
|
}
|
|
222
|
-
let activeChannels
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
activeChannels =
|
|
300
|
+
let activeChannels;
|
|
301
|
+
if (perChannel) activeChannels = perChannel.channels;
|
|
302
|
+
else {
|
|
303
|
+
activeChannels = this.channels.filter((ch) => ch.shouldHandle(payload.event));
|
|
304
|
+
if (payload.channels?.length) {
|
|
305
|
+
const targetSet = new Set(payload.channels);
|
|
306
|
+
activeChannels = activeChannels.filter((ch) => targetSet.has(ch.name));
|
|
307
|
+
}
|
|
226
308
|
}
|
|
227
309
|
if (enrichedPayload.recipient.id && this.preferenceResolver) try {
|
|
228
310
|
const prefs = await this.preferenceResolver(enrichedPayload.recipient.id, enrichedPayload.event);
|
|
@@ -259,7 +341,16 @@ var NotificationService = class {
|
|
|
259
341
|
skipped: 0,
|
|
260
342
|
duration: Date.now() - start
|
|
261
343
|
});
|
|
262
|
-
const
|
|
344
|
+
const sentResults = await Promise.all(activeChannels.map((channel) => this.sendToChannel(channel, enrichedPayload)));
|
|
345
|
+
let results = sentResults;
|
|
346
|
+
if (perChannel) {
|
|
347
|
+
await perChannel.settle(sentResults);
|
|
348
|
+
results = [...sentResults, ...perChannel.duplicates.map((ch) => ({
|
|
349
|
+
status: "skipped",
|
|
350
|
+
channel: ch.name,
|
|
351
|
+
error: "duplicate (idempotency)"
|
|
352
|
+
}))];
|
|
353
|
+
}
|
|
263
354
|
const dispatch = {
|
|
264
355
|
event: enrichedPayload.event,
|
|
265
356
|
results,
|
|
@@ -268,7 +359,7 @@ var NotificationService = class {
|
|
|
268
359
|
skipped: results.filter((r) => r.status === "skipped").length,
|
|
269
360
|
duration: Date.now() - start
|
|
270
361
|
};
|
|
271
|
-
if (payload.idempotencyKey && this.idempotencyStore && dispatch.sent > 0) try {
|
|
362
|
+
if (!perChannel && payload.idempotencyKey && this.idempotencyStore && dispatch.sent > 0) try {
|
|
272
363
|
await this.idempotencyStore.set(payload.idempotencyKey, this.idempotencyTtl);
|
|
273
364
|
} catch (err) {
|
|
274
365
|
this.logger.warn(`Idempotency store error: ${err instanceof Error ? err.message : err}`);
|
|
@@ -575,4 +666,4 @@ var NotificationService = class {
|
|
|
575
666
|
*/
|
|
576
667
|
|
|
577
668
|
//#endregion
|
|
578
|
-
export { BaseChannel, ChannelError, ConsoleChannel, EmailChannel, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, NotificationService, PermanentDeliveryError, ProviderNotInstalledError, PushChannel, RedisIdempotencyStore, SmsChannel, TelegramChannel, WebhookChannel, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
|
669
|
+
export { BaseChannel, ChannelError, ConsoleChannel, EmailChannel, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, NotificationService, PermanentDeliveryError, ProviderNotInstalledError, PushChannel, RedisIdempotencyStore, SmsChannel, TelegramChannel, WebhookChannel, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, retryFloorHint, withFallback, withRetry };
|
package/dist/push/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PushProviderMessage, S as PushProvider, b as PushInterruptionLevel, x as PushPlatform } from "../types-
|
|
1
|
+
import { C as PushProviderMessage, S as PushProvider, b as PushInterruptionLevel, x as PushPlatform } from "../types-D3g8xK2h.mjs";
|
|
2
2
|
import { n as NotificationError, r as PermanentDeliveryError } from "../errors-DCOaQvhV.mjs";
|
|
3
3
|
import { KeyObject } from "node:crypto";
|
|
4
4
|
import http2 from "node:http2";
|
|
@@ -68,7 +68,9 @@ export declare class PushCredentialsError extends PermanentDeliveryError {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* A transient failure (429, 5xx, timeout, connection reset). Retryable; `retryAfterMs` carries the
|
|
71
|
-
* provider's `Retry-After`, which the service's retry loop honours (`retryAfterHint`)
|
|
71
|
+
* provider's `Retry-After`, which the service's retry loop honours (`retryAfterHint`), and
|
|
72
|
+
* `retryFloorMs` the provider's minimum wait (FCM 10 s, FCM 429 60 s, APNs 5xx 15 min, APNs 429 60 s;
|
|
73
|
+
* `PUSH_RETRY_DEFAULTS`), which nothing may retry sooner than (2.10).
|
|
72
74
|
*/
|
|
73
75
|
export declare class TransientPushError extends NotificationError {
|
|
74
76
|
readonly retryable: true;
|
|
@@ -77,8 +79,15 @@ export declare class TransientPushError extends NotificationError {
|
|
|
77
79
|
readonly status: number;
|
|
78
80
|
readonly reason: string;
|
|
79
81
|
readonly retryAfterMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The provider's minimum wait before a retry (ms). Defaults from {@link pushRetryFloorMs}
|
|
84
|
+
* (provider + status); a throw site may pass its own. `withRetry` and `planPushRetry` never
|
|
85
|
+
* retry sooner.
|
|
86
|
+
*/
|
|
87
|
+
readonly retryFloorMs: number;
|
|
80
88
|
constructor(provider: PushProviderName, status: number, reason: string, options?: {
|
|
81
89
|
retryAfterMs?: number;
|
|
90
|
+
retryFloorMs?: number;
|
|
82
91
|
cause?: Error;
|
|
83
92
|
});
|
|
84
93
|
}
|
|
@@ -297,6 +306,101 @@ export declare function createContentFreeBuilder(options: ContentFreeOptions): (
|
|
|
297
306
|
*/
|
|
298
307
|
export declare function contentFreeOnly(provider: PushProvider, options: ContentFreeOptions): PushProvider;
|
|
299
308
|
//#endregion
|
|
309
|
+
//#region src/push/retry.d.ts
|
|
310
|
+
/**
|
|
311
|
+
* Push retry timing: provider minimums, `Retry-After`, exponential backoff with jitter, a give-up
|
|
312
|
+
* window and the notification's own expiry. Pure functions: nothing here sleeps. The caller (a job
|
|
313
|
+
* queue, arc-notifications' per-device retry job) schedules the next attempt at the returned delay.
|
|
314
|
+
*
|
|
315
|
+
* Sources (ADR 0001 section 5.3, arc-ecosystem `docs/adr/0001-notifications-and-push.md`):
|
|
316
|
+
* - FCM "Scale FCM" [S3]: first retry at least 10 s; on 429 wait `Retry-After`, else 60 s;
|
|
317
|
+
* exponential after that; stop after 60 min of continuous failure; drop requests that are no
|
|
318
|
+
* longer timely. FCM ErrorCode [S2]: "minimum initial delay of 1 minute" for quota (429).
|
|
319
|
+
* - APNs "Handling notification responses" [A3]: 5xx "After 15 minutes, you can retry";
|
|
320
|
+
* 429 `TooManyRequests` "You can retry with a delay" (the 60 s floor is our value).
|
|
321
|
+
* - Network errors and timeouts: 10 s floor (our value, same as FCM's minimum).
|
|
322
|
+
*
|
|
323
|
+
* @module @classytic/notifications/push
|
|
324
|
+
*/
|
|
325
|
+
/** The numbers behind every push retry decision. Exported so hosts and docs quote one table. */
|
|
326
|
+
export declare const PUSH_RETRY_DEFAULTS: {
|
|
327
|
+
/** FCM: first retry not sooner than 10 s (5xx, network, timeout) [S3]. */
|
|
328
|
+
readonly fcmMinDelayMs: 10000;
|
|
329
|
+
/** FCM 429: `Retry-After`, else 60 s; quota errors need a 1 minute initial delay [S2][S3]. */
|
|
330
|
+
readonly fcmQuotaDelayMs: 60000;
|
|
331
|
+
/** FCM: stop after 60 minutes of continuous failure [S3]. */
|
|
332
|
+
readonly fcmGiveUpAfterMs: 3600000;
|
|
333
|
+
/** APNs 500 / 503: retry after 15 minutes [A3]. */
|
|
334
|
+
readonly apnsServerErrorDelayMs: 900000;
|
|
335
|
+
/** APNs 429 (`TooManyRequests`, `TooManyProviderTokenUpdates`): 60 s (our value) [A3]. */
|
|
336
|
+
readonly apnsTooManyRequestsDelayMs: 60000;
|
|
337
|
+
/** Network failure, timeout, credentials store down, unknown provider: 10 s (our value). */
|
|
338
|
+
readonly networkDelayMs: 10000;
|
|
339
|
+
/** Attempts per device, the first send included (ADR 5.3). */
|
|
340
|
+
readonly maxAttempts: 5;
|
|
341
|
+
/** Backoff growth stops here (a floor or Retry-After above it still wins). */
|
|
342
|
+
readonly maxDelayMs: 3600000;
|
|
343
|
+
/** Upward jitter: a delay is stretched by up to this fraction, never shortened. */
|
|
344
|
+
readonly jitter: 0.2;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* The provider's minimum wait before retrying a transient failure with this HTTP status
|
|
348
|
+
* (`0` = network failure / timeout / no request made). `TransientPushError` fills
|
|
349
|
+
* `retryFloorMs` from this table unless the throw site passes its own.
|
|
350
|
+
*/
|
|
351
|
+
export declare function pushRetryFloorMs(provider: string, status: number): number;
|
|
352
|
+
interface PushRetryDelayOptions {
|
|
353
|
+
/** `[0, 1)` source for jitter. Default `Math.random` (tests pass a constant). */
|
|
354
|
+
readonly random?: () => number;
|
|
355
|
+
/** Cap on exponential growth. Default 60 min. A floor or `Retry-After` above it still wins. */
|
|
356
|
+
readonly maxDelayMs?: number;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* How long to wait before retry number `attempt` (1 = the first retry, after one failed send):
|
|
360
|
+
* `max(Retry-After, provider floor) x 2^(attempt - 1)`, capped at `maxDelayMs`, then stretched by
|
|
361
|
+
* up to 20 % jitter. Jitter only ever ADDS: the result is never below the provider minimum or the
|
|
362
|
+
* provider's `Retry-After`.
|
|
363
|
+
*/
|
|
364
|
+
export declare function pushRetryDelay(error: unknown, attempt: number, options?: PushRetryDelayOptions): number;
|
|
365
|
+
interface PushRetryInput extends PushRetryDelayOptions {
|
|
366
|
+
/** The error the last attempt threw. */
|
|
367
|
+
readonly error: unknown;
|
|
368
|
+
/** Attempts made so far for this message and device (1 after the first failed send). */
|
|
369
|
+
readonly attempt: number;
|
|
370
|
+
/** When the first attempt failed (ms epoch): the FCM 60 min window counts from here. */
|
|
371
|
+
readonly firstFailureAt: number;
|
|
372
|
+
/** Now (ms epoch). */
|
|
373
|
+
readonly now: number;
|
|
374
|
+
/** The notification's expiry (ms epoch). A retry that would land at or after it is dropped. */
|
|
375
|
+
readonly expiresAt?: number;
|
|
376
|
+
/** Total attempts allowed, the first send included. Default 5. */
|
|
377
|
+
readonly maxAttempts?: number;
|
|
378
|
+
/**
|
|
379
|
+
* Stop once this long has passed since `firstFailureAt`. Default: 60 min for FCM errors [S3],
|
|
380
|
+
* none for APNs (bounded by `expiresAt` and `maxAttempts`).
|
|
381
|
+
*/
|
|
382
|
+
readonly giveUpAfterMs?: number;
|
|
383
|
+
}
|
|
384
|
+
type PushRetryDecision = {
|
|
385
|
+
readonly retry: true;
|
|
386
|
+
readonly delayMs: number;
|
|
387
|
+
readonly at: number;
|
|
388
|
+
} | {
|
|
389
|
+
readonly retry: false;
|
|
390
|
+
/**
|
|
391
|
+
* `permanent`: not retryable (dead token, rejected payload, credentials);
|
|
392
|
+
* `attempts`: `maxAttempts` used; `expired`: the next attempt would be past `expiresAt`;
|
|
393
|
+
* `gave-up`: past the provider's continuous-failure window (FCM 60 min).
|
|
394
|
+
*/
|
|
395
|
+
readonly reason: 'permanent' | 'attempts' | 'expired' | 'gave-up';
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Decide whether, and when, to retry one push to one device. Never sleeps; the caller schedules a
|
|
399
|
+
* job at `delayMs`. Order: permanent errors stop, then the attempt budget, then the timing check
|
|
400
|
+
* against the give-up window and the notification's expiry.
|
|
401
|
+
*/
|
|
402
|
+
export declare function planPushRetry(input: PushRetryInput): PushRetryDecision;
|
|
403
|
+
//#endregion
|
|
300
404
|
//#region src/push/jwt.d.ts
|
|
301
405
|
type JwtAlgorithm = 'RS256' | 'ES256';
|
|
302
406
|
/**
|
|
@@ -307,4 +411,4 @@ export declare function signJwt(alg: JwtAlgorithm, key: KeyObject, claims: Recor
|
|
|
307
411
|
/** Short, non-reversible fingerprint (hex) of any string: for cache keys and safe log fields. */
|
|
308
412
|
export declare function fingerprint(value: string, length?: number): string;
|
|
309
413
|
//#endregion
|
|
310
|
-
export type { ApnsCredentials, ApnsProviderOptions, ApnsSession, ApsOptions, ContentFreeMessage, ContentFreeOptions, CredentialsSource, FcmCredentials, FcmProviderOptions, InvalidTokenHandler, InvalidTokenReason, JwtAlgorithm, PushDeliveryEvent, PushDeliveryListener, PushInterruptionLevel, PushPlatform, PushProvider, PushProviderMessage, PushProviderName, PushRouter, PushRouterOptions };
|
|
414
|
+
export type { ApnsCredentials, ApnsProviderOptions, ApnsSession, ApsOptions, ContentFreeMessage, ContentFreeOptions, CredentialsSource, FcmCredentials, FcmProviderOptions, InvalidTokenHandler, InvalidTokenReason, JwtAlgorithm, PushDeliveryEvent, PushDeliveryListener, PushInterruptionLevel, PushPlatform, PushProvider, PushProviderMessage, PushProviderName, PushRetryDecision, PushRetryDelayOptions, PushRetryInput, PushRouter, PushRouterOptions };
|
package/dist/push/index.mjs
CHANGED
|
@@ -57,6 +57,126 @@ function collapseKeyTooLong(key) {
|
|
|
57
57
|
return key !== void 0 && Buffer.byteLength(key, "utf8") > 64;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/push/retry.ts
|
|
62
|
+
/**
|
|
63
|
+
* Push retry timing: provider minimums, `Retry-After`, exponential backoff with jitter, a give-up
|
|
64
|
+
* window and the notification's own expiry. Pure functions: nothing here sleeps. The caller (a job
|
|
65
|
+
* queue, arc-notifications' per-device retry job) schedules the next attempt at the returned delay.
|
|
66
|
+
*
|
|
67
|
+
* Sources (ADR 0001 section 5.3, arc-ecosystem `docs/adr/0001-notifications-and-push.md`):
|
|
68
|
+
* - FCM "Scale FCM" [S3]: first retry at least 10 s; on 429 wait `Retry-After`, else 60 s;
|
|
69
|
+
* exponential after that; stop after 60 min of continuous failure; drop requests that are no
|
|
70
|
+
* longer timely. FCM ErrorCode [S2]: "minimum initial delay of 1 minute" for quota (429).
|
|
71
|
+
* - APNs "Handling notification responses" [A3]: 5xx "After 15 minutes, you can retry";
|
|
72
|
+
* 429 `TooManyRequests` "You can retry with a delay" (the 60 s floor is our value).
|
|
73
|
+
* - Network errors and timeouts: 10 s floor (our value, same as FCM's minimum).
|
|
74
|
+
*
|
|
75
|
+
* @module @classytic/notifications/push
|
|
76
|
+
*/
|
|
77
|
+
/** The numbers behind every push retry decision. Exported so hosts and docs quote one table. */
|
|
78
|
+
const PUSH_RETRY_DEFAULTS = {
|
|
79
|
+
/** FCM: first retry not sooner than 10 s (5xx, network, timeout) [S3]. */
|
|
80
|
+
fcmMinDelayMs: 1e4,
|
|
81
|
+
/** FCM 429: `Retry-After`, else 60 s; quota errors need a 1 minute initial delay [S2][S3]. */
|
|
82
|
+
fcmQuotaDelayMs: 6e4,
|
|
83
|
+
/** FCM: stop after 60 minutes of continuous failure [S3]. */
|
|
84
|
+
fcmGiveUpAfterMs: 36e5,
|
|
85
|
+
/** APNs 500 / 503: retry after 15 minutes [A3]. */
|
|
86
|
+
apnsServerErrorDelayMs: 9e5,
|
|
87
|
+
/** APNs 429 (`TooManyRequests`, `TooManyProviderTokenUpdates`): 60 s (our value) [A3]. */
|
|
88
|
+
apnsTooManyRequestsDelayMs: 6e4,
|
|
89
|
+
/** Network failure, timeout, credentials store down, unknown provider: 10 s (our value). */
|
|
90
|
+
networkDelayMs: 1e4,
|
|
91
|
+
/** Attempts per device, the first send included (ADR 5.3). */
|
|
92
|
+
maxAttempts: 5,
|
|
93
|
+
/** Backoff growth stops here (a floor or Retry-After above it still wins). */
|
|
94
|
+
maxDelayMs: 36e5,
|
|
95
|
+
/** Upward jitter: a delay is stretched by up to this fraction, never shortened. */
|
|
96
|
+
jitter: .2
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The provider's minimum wait before retrying a transient failure with this HTTP status
|
|
100
|
+
* (`0` = network failure / timeout / no request made). `TransientPushError` fills
|
|
101
|
+
* `retryFloorMs` from this table unless the throw site passes its own.
|
|
102
|
+
*/
|
|
103
|
+
function pushRetryFloorMs(provider, status) {
|
|
104
|
+
const d = PUSH_RETRY_DEFAULTS;
|
|
105
|
+
if (provider === "fcm") return status === 429 ? d.fcmQuotaDelayMs : d.fcmMinDelayMs;
|
|
106
|
+
if (provider === "apns") {
|
|
107
|
+
if (status === 429) return d.apnsTooManyRequestsDelayMs;
|
|
108
|
+
if (status >= 500) return d.apnsServerErrorDelayMs;
|
|
109
|
+
return d.networkDelayMs;
|
|
110
|
+
}
|
|
111
|
+
return d.networkDelayMs;
|
|
112
|
+
}
|
|
113
|
+
/** Walk an error and its causes (4 deep) for a numeric field. Structural: any copy of the package. */
|
|
114
|
+
function numericField(error, field) {
|
|
115
|
+
let cursor = error;
|
|
116
|
+
for (let depth = 0; cursor !== null && typeof cursor === "object" && depth < 5; depth++) {
|
|
117
|
+
const value = cursor[field];
|
|
118
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
|
119
|
+
cursor = cursor.cause;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function providerOf(error) {
|
|
123
|
+
let cursor = error;
|
|
124
|
+
for (let depth = 0; cursor !== null && typeof cursor === "object" && depth < 5; depth++) {
|
|
125
|
+
const value = cursor.provider;
|
|
126
|
+
if (typeof value === "string" && value !== "router") return value;
|
|
127
|
+
cursor = cursor.cause;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* How long to wait before retry number `attempt` (1 = the first retry, after one failed send):
|
|
132
|
+
* `max(Retry-After, provider floor) x 2^(attempt - 1)`, capped at `maxDelayMs`, then stretched by
|
|
133
|
+
* up to 20 % jitter. Jitter only ever ADDS: the result is never below the provider minimum or the
|
|
134
|
+
* provider's `Retry-After`.
|
|
135
|
+
*/
|
|
136
|
+
function pushRetryDelay(error, attempt, options = {}) {
|
|
137
|
+
const random = options.random ?? Math.random;
|
|
138
|
+
const floor = numericField(error, "retryFloorMs") ?? PUSH_RETRY_DEFAULTS.networkDelayMs;
|
|
139
|
+
const retryAfter = numericField(error, "retryAfterMs") ?? 0;
|
|
140
|
+
const base = Math.max(floor, retryAfter);
|
|
141
|
+
const n = Math.max(1, Math.floor(attempt));
|
|
142
|
+
const cap = Math.max(options.maxDelayMs ?? PUSH_RETRY_DEFAULTS.maxDelayMs, base);
|
|
143
|
+
const raw = Math.min(base * 2 ** (n - 1), cap);
|
|
144
|
+
const r = Math.min(Math.max(random(), 0), 1);
|
|
145
|
+
return Math.round(raw + raw * PUSH_RETRY_DEFAULTS.jitter * r);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Decide whether, and when, to retry one push to one device. Never sleeps; the caller schedules a
|
|
149
|
+
* job at `delayMs`. Order: permanent errors stop, then the attempt budget, then the timing check
|
|
150
|
+
* against the give-up window and the notification's expiry.
|
|
151
|
+
*/
|
|
152
|
+
function planPushRetry(input) {
|
|
153
|
+
const { error, attempt, firstFailureAt, now } = input;
|
|
154
|
+
if (error?.retryable === false) return {
|
|
155
|
+
retry: false,
|
|
156
|
+
reason: "permanent"
|
|
157
|
+
};
|
|
158
|
+
if (attempt >= (input.maxAttempts ?? PUSH_RETRY_DEFAULTS.maxAttempts)) return {
|
|
159
|
+
retry: false,
|
|
160
|
+
reason: "attempts"
|
|
161
|
+
};
|
|
162
|
+
const delayMs = pushRetryDelay(error, attempt, input);
|
|
163
|
+
const at = now + delayMs;
|
|
164
|
+
if (input.expiresAt !== void 0 && at >= input.expiresAt) return {
|
|
165
|
+
retry: false,
|
|
166
|
+
reason: "expired"
|
|
167
|
+
};
|
|
168
|
+
const window = input.giveUpAfterMs ?? (providerOf(error) === "fcm" ? PUSH_RETRY_DEFAULTS.fcmGiveUpAfterMs : void 0);
|
|
169
|
+
if (window !== void 0 && at - firstFailureAt > window) return {
|
|
170
|
+
retry: false,
|
|
171
|
+
reason: "gave-up"
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
retry: true,
|
|
175
|
+
delayMs,
|
|
176
|
+
at
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
60
180
|
//#endregion
|
|
61
181
|
//#region src/push/errors.ts
|
|
62
182
|
/**
|
|
@@ -122,7 +242,9 @@ var PushCredentialsError = class extends PermanentDeliveryError {
|
|
|
122
242
|
};
|
|
123
243
|
/**
|
|
124
244
|
* A transient failure (429, 5xx, timeout, connection reset). Retryable; `retryAfterMs` carries the
|
|
125
|
-
* provider's `Retry-After`, which the service's retry loop honours (`retryAfterHint`)
|
|
245
|
+
* provider's `Retry-After`, which the service's retry loop honours (`retryAfterHint`), and
|
|
246
|
+
* `retryFloorMs` the provider's minimum wait (FCM 10 s, FCM 429 60 s, APNs 5xx 15 min, APNs 429 60 s;
|
|
247
|
+
* `PUSH_RETRY_DEFAULTS`), which nothing may retry sooner than (2.10).
|
|
126
248
|
*/
|
|
127
249
|
var TransientPushError = class extends NotificationError {
|
|
128
250
|
retryable = true;
|
|
@@ -131,6 +253,12 @@ var TransientPushError = class extends NotificationError {
|
|
|
131
253
|
status;
|
|
132
254
|
reason;
|
|
133
255
|
retryAfterMs;
|
|
256
|
+
/**
|
|
257
|
+
* The provider's minimum wait before a retry (ms). Defaults from {@link pushRetryFloorMs}
|
|
258
|
+
* (provider + status); a throw site may pass its own. `withRetry` and `planPushRetry` never
|
|
259
|
+
* retry sooner.
|
|
260
|
+
*/
|
|
261
|
+
retryFloorMs;
|
|
134
262
|
constructor(provider, status, reason, options) {
|
|
135
263
|
super(`${provider} push failed (retryable): ${status || "network"} ${reason}` + (options?.retryAfterMs !== void 0 ? ` (retry after ${options.retryAfterMs} ms)` : ""), {
|
|
136
264
|
code: "PUSH_TRANSIENT",
|
|
@@ -141,6 +269,7 @@ var TransientPushError = class extends NotificationError {
|
|
|
141
269
|
this.status = status;
|
|
142
270
|
this.reason = reason;
|
|
143
271
|
if (options?.retryAfterMs !== void 0) this.retryAfterMs = options.retryAfterMs;
|
|
272
|
+
this.retryFloorMs = options?.retryFloorMs ?? pushRetryFloorMs(provider, status);
|
|
144
273
|
}
|
|
145
274
|
};
|
|
146
275
|
/** Structural check: is this an invalid-token error (from any copy of this package)? */
|
|
@@ -1001,4 +1130,4 @@ function contentFreeOnly(provider, options) {
|
|
|
1001
1130
|
}
|
|
1002
1131
|
|
|
1003
1132
|
//#endregion
|
|
1004
|
-
export { APNS_HOSTS, APNS_TOKEN_TTL_MS, FCM_ENDPOINT, FCM_SCOPE, GOOGLE_TOKEN_URI, InvalidPushTokenError, OPAQUE_ID, PushCredentialsError, PushRejectedError, TransientPushError, apnsProvider, buildApnsPayload, buildAps, buildFcmMessage, contentFreeOnly, createContentFreeBuilder, credentialsFingerprint, effectiveLevel, fcmProvider, fingerprint, isInvalidPushTokenError, normalizePem, parseFcmServiceAccount, parseRetryAfter, pushRouter, signJwt, tokenHash, tokenSuffix, validateApnsCredentials, validateFcmCredentials };
|
|
1133
|
+
export { APNS_HOSTS, APNS_TOKEN_TTL_MS, FCM_ENDPOINT, FCM_SCOPE, GOOGLE_TOKEN_URI, InvalidPushTokenError, OPAQUE_ID, PUSH_RETRY_DEFAULTS, PushCredentialsError, PushRejectedError, TransientPushError, apnsProvider, buildApnsPayload, buildAps, buildFcmMessage, contentFreeOnly, createContentFreeBuilder, credentialsFingerprint, effectiveLevel, fcmProvider, fingerprint, isInvalidPushTokenError, normalizePem, parseFcmServiceAccount, parseRetryAfter, planPushRetry, pushRetryDelay, pushRetryFloorMs, pushRouter, signJwt, tokenHash, tokenSuffix, validateApnsCredentials, validateFcmCredentials };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as RetryConfig, N as TemplateResolver, T as ResolvedRetryConfig, d as HookMap, h as NotificationPayload, o as DispatchResult, u as HookHandler } from "./types-
|
|
1
|
+
import { E as RetryConfig, N as TemplateResolver, T as ResolvedRetryConfig, d as HookMap, h as NotificationPayload, o as DispatchResult, u as HookHandler } from "./types-D3g8xK2h.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;
|
|
@@ -14,6 +14,11 @@ declare function calculateDelay(attempt: number, config: ResolvedRetryConfig): n
|
|
|
14
14
|
* usually rides on `cause`.
|
|
15
15
|
*/
|
|
16
16
|
declare function retryAfterHint(error: unknown): number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The `retryFloorMs` an error (or one of its causes) carries: the provider's MINIMUM wait before a
|
|
19
|
+
* retry (push: FCM 10 s, FCM 429 60 s, APNs 5xx 15 min; `TransientPushError` sets it). 2.10.
|
|
20
|
+
*/
|
|
21
|
+
declare function retryFloorHint(error: unknown): number | undefined;
|
|
17
22
|
/**
|
|
18
23
|
* Execute a function with retry and backoff
|
|
19
24
|
*
|
|
@@ -320,4 +325,4 @@ interface StatusHandler {
|
|
|
320
325
|
*/
|
|
321
326
|
declare function createStatusHandler(config?: StatusHandlerConfig): StatusHandler;
|
|
322
327
|
//#endregion
|
|
323
|
-
export {
|
|
328
|
+
export { withRetry as C, retryFloorHint as S, isQuietHours as _, createStatusHandler as a, resolveRetryConfig as b, InterpolateOptions as c, TemplateMap as d, createSimpleResolver as f, QuietHoursConfig as g, pMap as h, StatusUpdate as i, SimpleResolverOptions as l, PMapOptions as m, StatusHandler as n, FallbackOptions as o, interpolateHtml as p, StatusHandlerConfig as r, withFallback as s, DeliveryStatus as t, TemplateDefinition as u, Emitter as v, mergeHooks as w, retryAfterHint as x, calculateDelay as y };
|
|
@@ -70,6 +70,18 @@ function retryAfterHint(error) {
|
|
|
70
70
|
cursor = cursor.cause;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The `retryFloorMs` an error (or one of its causes) carries: the provider's MINIMUM wait before a
|
|
75
|
+
* retry (push: FCM 10 s, FCM 429 60 s, APNs 5xx 15 min; `TransientPushError` sets it). 2.10.
|
|
76
|
+
*/
|
|
77
|
+
function retryFloorHint(error) {
|
|
78
|
+
let cursor = error;
|
|
79
|
+
for (let depth = 0; cursor !== null && typeof cursor === "object" && depth < 5; depth++) {
|
|
80
|
+
const floor = cursor.retryFloorMs;
|
|
81
|
+
if (typeof floor === "number" && Number.isFinite(floor) && floor >= 0) return floor;
|
|
82
|
+
cursor = cursor.cause;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
73
85
|
/** Sleep for a given duration */
|
|
74
86
|
function sleep(ms) {
|
|
75
87
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -96,6 +108,11 @@ async function withRetry(fn, config, onRetry, shouldRetry) {
|
|
|
96
108
|
if (hinted > config.maxDelay) break;
|
|
97
109
|
delay = Math.max(delay, hinted);
|
|
98
110
|
}
|
|
111
|
+
const floor = retryFloorHint(lastError);
|
|
112
|
+
if (floor !== void 0) {
|
|
113
|
+
if (floor > config.maxDelay) break;
|
|
114
|
+
delay = Math.max(delay, floor);
|
|
115
|
+
}
|
|
99
116
|
onRetry?.(attempt, lastError);
|
|
100
117
|
await sleep(delay);
|
|
101
118
|
}
|
|
@@ -797,4 +814,4 @@ function createStatusHandler(config = {}) {
|
|
|
797
814
|
}
|
|
798
815
|
|
|
799
816
|
//#endregion
|
|
800
|
-
export { retryAfterHint as _, MemoryQueue as a, pMap as c, IDEMPOTENCY_DEFAULT_TTL as d, MemoryIdempotencyStore as f, resolveRetryConfig as g, calculateDelay as h, interpolateHtml as i, MemoryRateLimitStore as l, isQuietHours as m, withFallback as n, MemoryDeliveryLog as o, RedisIdempotencyStore as p, createSimpleResolver as r, mergeHooks as s, createStatusHandler as t, IDEMPOTENCY_DEFAULT_LEASE as u,
|
|
817
|
+
export { retryAfterHint as _, MemoryQueue as a, Emitter as b, pMap as c, IDEMPOTENCY_DEFAULT_TTL as d, MemoryIdempotencyStore as f, resolveRetryConfig as g, calculateDelay as h, interpolateHtml as i, MemoryRateLimitStore as l, isQuietHours as m, withFallback as n, MemoryDeliveryLog as o, RedisIdempotencyStore as p, createSimpleResolver as r, mergeHooks as s, createStatusHandler as t, IDEMPOTENCY_DEFAULT_LEASE as u, retryFloorHint as v, withRetry as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RateLimitConfig, D as SendResult, E as RetryConfig, F as WebhookChannelConfig, M as TelegramChannelConfig, a as ChannelConfig, c as EmailChannelConfig, h as NotificationPayload, i as Channel, k as SmsChannelConfig, y as PushChannelConfig } from "./types-
|
|
1
|
+
import { $ as RateLimitConfig, D as SendResult, E as RetryConfig, F as WebhookChannelConfig, M as TelegramChannelConfig, a as ChannelConfig, c as EmailChannelConfig, h as NotificationPayload, i as Channel, k as SmsChannelConfig, y as PushChannelConfig } from "./types-D3g8xK2h.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;
|
|
@@ -797,6 +797,22 @@ interface NotificationServiceConfig {
|
|
|
797
797
|
ttl?: number;
|
|
798
798
|
/** In-flight lease for stores with an atomic `claim()` (default: 300000 = 5 min) */
|
|
799
799
|
leaseMs?: number;
|
|
800
|
+
/**
|
|
801
|
+
* What one key deduplicates (2.10).
|
|
802
|
+
*
|
|
803
|
+
* - `'channel'` (default since 2.10): the service claims `${idempotencyKey}:${channel.name}`
|
|
804
|
+
* per channel and records it only for channels that SENT. A redelivery skips the channels
|
|
805
|
+
* already done and retries the rest, so a failed push beside a delivered in-app row is not
|
|
806
|
+
* lost. With a queue, a dispatch with a retryable failed channel throws so the queue
|
|
807
|
+
* retries it (only the unfinished channels send again).
|
|
808
|
+
* - `'payload'`: 2.9 behaviour: one key for the whole payload, recorded as soon as ANY
|
|
809
|
+
* channel sent (a failed channel beside a successful one is never retried).
|
|
810
|
+
*
|
|
811
|
+
* Migration from 2.9: keys in the store now carry a `:<channel>` suffix, so a key written by
|
|
812
|
+
* 2.9 does not dedupe a redelivery after the upgrade (inside its 24 h TTL). Set `'payload'` to
|
|
813
|
+
* keep 2.9 keys and semantics.
|
|
814
|
+
*/
|
|
815
|
+
scope?: 'channel' | 'payload';
|
|
800
816
|
};
|
|
801
817
|
/** Delivery log for audit trail — records every send attempt */
|
|
802
818
|
deliveryLog?: DeliveryLog;
|
|
@@ -811,7 +827,10 @@ interface NotificationServiceConfig {
|
|
|
811
827
|
* when a dispatch had `sent === 0 && failed > 0`, so the queue
|
|
812
828
|
* marks the job failed (and retries up to `maxAttempts`). Partial
|
|
813
829
|
* successes (some channels sent) resolve normally to avoid
|
|
814
|
-
* double-sending the channels that already succeeded
|
|
830
|
+
* double-sending the channels that already succeeded, EXCEPT under
|
|
831
|
+
* per-channel idempotency (`idempotency.scope: 'channel'`, the 2.10
|
|
832
|
+
* default, with a key on the payload): there a retryable failed
|
|
833
|
+
* channel also throws, because the re-run skips the sent channels.
|
|
815
834
|
* - `'always-complete'` — legacy behavior. The processor never
|
|
816
835
|
* throws; queued jobs always resolve as completed, regardless of
|
|
817
836
|
* channel outcome. Keep this if your delivery log is the source
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as RateLimitConfig, B as QueueJobStatus, G as MemoryDeliveryLog, H as DeliveryLog, I as MemoryQueue, J as IdempotencyStore, K as IDEMPOTENCY_DEFAULT_LEASE, L as QueueAdapter, Q as MemoryRateLimitStore, R as QueueEnqueueOptions, U as DeliveryLogEntry, V as QueueProcessor, W as DeliveryLogQuery, X as RedisIdempotencyClient, Y as MemoryIdempotencyStore, Z as RedisIdempotencyStore, et as RateLimitStore, q as IDEMPOTENCY_DEFAULT_TTL, z as QueueJob } from "../types-
|
|
2
|
-
import { C as
|
|
1
|
+
import { $ as RateLimitConfig, B as QueueJobStatus, G as MemoryDeliveryLog, H as DeliveryLog, I as MemoryQueue, J as IdempotencyStore, K as IDEMPOTENCY_DEFAULT_LEASE, L as QueueAdapter, Q as MemoryRateLimitStore, R as QueueEnqueueOptions, U as DeliveryLogEntry, V as QueueProcessor, W as DeliveryLogQuery, X as RedisIdempotencyClient, Y as MemoryIdempotencyStore, Z as RedisIdempotencyStore, et as RateLimitStore, q as IDEMPOTENCY_DEFAULT_TTL, z as QueueJob } from "../types-D3g8xK2h.mjs";
|
|
2
|
+
import { C as withRetry, S as retryFloorHint, _ as isQuietHours, a as createStatusHandler, b as resolveRetryConfig, 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 Emitter, w as mergeHooks, x as retryAfterHint, y as calculateDelay } from "../status-webhook-DCU8KQLR.mjs";
|
|
3
3
|
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "../errors-DCOaQvhV.mjs";
|
|
4
|
-
export { ChannelError, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, Emitter, type FallbackOptions, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, type PMapOptions, PermanentDeliveryError, ProviderNotInstalledError, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type RedisIdempotencyClient, RedisIdempotencyStore, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, type TemplateDefinition, type TemplateMap, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
|
4
|
+
export { ChannelError, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, Emitter, type FallbackOptions, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, type PMapOptions, PermanentDeliveryError, ProviderNotInstalledError, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type RedisIdempotencyClient, RedisIdempotencyStore, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, type TemplateDefinition, type TemplateMap, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, retryFloorHint, withFallback, withRetry };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as retryAfterHint, a as MemoryQueue, c as pMap, d as IDEMPOTENCY_DEFAULT_TTL, f as MemoryIdempotencyStore, g as resolveRetryConfig, h as calculateDelay, i as interpolateHtml, l as MemoryRateLimitStore, m as isQuietHours, n as withFallback, o as MemoryDeliveryLog, p as RedisIdempotencyStore, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_LEASE, v as
|
|
1
|
+
import { _ as retryAfterHint, a as MemoryQueue, b as Emitter, c as pMap, d as IDEMPOTENCY_DEFAULT_TTL, f as MemoryIdempotencyStore, g as resolveRetryConfig, h as calculateDelay, i as interpolateHtml, l as MemoryRateLimitStore, m as isQuietHours, n as withFallback, o as MemoryDeliveryLog, p as RedisIdempotencyStore, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_LEASE, v as retryFloorHint, y as withRetry } from "../status-webhook-DN3bdqKs.mjs";
|
|
2
2
|
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "../errors-CsQZKfec.mjs";
|
|
3
3
|
|
|
4
|
-
export { ChannelError, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, PermanentDeliveryError, ProviderNotInstalledError, RedisIdempotencyStore, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
|
4
|
+
export { ChannelError, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, PermanentDeliveryError, ProviderNotInstalledError, RedisIdempotencyStore, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, retryFloorHint, withFallback, withRetry };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/notifications",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Multi-channel notifications (Email, SMS, Push, Webhook, Telegram) with rate limiting, delivery tracking, queue adapters, channel fallback, templates, retry — zero required dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|