@classytic/notifications 2.8.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 +89 -0
- package/README.md +96 -0
- package/dist/channels/index.d.mts +1 -1
- package/dist/channels/index.mjs +1 -1
- package/dist/errors-DCOaQvhV.d.mts +37 -0
- package/dist/index.d.mts +18 -4
- package/dist/index.mjs +103 -12
- package/dist/push/index.d.mts +414 -0
- package/dist/push/index.mjs +1133 -0
- package/dist/{status-webhook-BlhPvRnD.d.mts → status-webhook-DCU8KQLR.d.mts} +13 -38
- package/dist/{status-webhook-D7Hrr71A.mjs → status-webhook-DN3bdqKs.mjs} +37 -2
- package/dist/{telegram.channel-DnVdyq8_.mjs → telegram.channel-0XRkIXmt.mjs} +37 -3
- package/dist/{telegram.channel-CzQH7Wa8.d.mts → telegram.channel-DcqdfWmV.d.mts} +1 -1
- package/dist/{types-DyUMfkyr.d.mts → types-D3g8xK2h.d.mts} +78 -19
- package/dist/utils/index.d.mts +4 -3
- package/dist/utils/index.mjs +2 -2
- package/package.json +7 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
@@ -8,6 +8,17 @@ declare function mergeHooks(...hookConfigs: (HookInput | null | undefined)[]): H
|
|
|
8
8
|
declare function resolveRetryConfig(config?: RetryConfig): ResolvedRetryConfig;
|
|
9
9
|
/** Calculate delay for a given attempt */
|
|
10
10
|
declare function calculateDelay(attempt: number, config: ResolvedRetryConfig): number;
|
|
11
|
+
/**
|
|
12
|
+
* The `retryAfterMs` an error (or one of its causes, up to 4 deep) carries — set by providers
|
|
13
|
+
* from an HTTP `Retry-After` header. Channels wrap provider errors in `ChannelError`, so the hint
|
|
14
|
+
* usually rides on `cause`.
|
|
15
|
+
*/
|
|
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;
|
|
11
22
|
/**
|
|
12
23
|
* Execute a function with retry and backoff
|
|
13
24
|
*
|
|
@@ -42,42 +53,6 @@ declare class Emitter {
|
|
|
42
53
|
removeAll(event?: string): this;
|
|
43
54
|
}
|
|
44
55
|
//#endregion
|
|
45
|
-
//#region src/utils/errors.d.ts
|
|
46
|
-
/**
|
|
47
|
-
* Notification Errors
|
|
48
|
-
* @module @classytic/notifications
|
|
49
|
-
*/
|
|
50
|
-
declare class NotificationError extends Error {
|
|
51
|
-
readonly code: string;
|
|
52
|
-
readonly channel?: string;
|
|
53
|
-
readonly cause?: Error;
|
|
54
|
-
constructor(message: string, options?: {
|
|
55
|
-
code?: string;
|
|
56
|
-
channel?: string;
|
|
57
|
-
cause?: Error;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
declare class ChannelError extends NotificationError {
|
|
61
|
-
constructor(channel: string, message: string, cause?: Error);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Thrown by a provider for a failure no retry can fix (unregistered device token, invalid
|
|
65
|
-
* recipient). Channels that honour it (PushChannel) return `failed` with `retryable: false`, so
|
|
66
|
-
* the service does not retry. Detected structurally (`retryable === false`), so a provider may
|
|
67
|
-
* also throw any error carrying that flag.
|
|
68
|
-
*/
|
|
69
|
-
declare class PermanentDeliveryError extends NotificationError {
|
|
70
|
-
readonly retryable: false;
|
|
71
|
-
constructor(message: string, options?: {
|
|
72
|
-
code?: string;
|
|
73
|
-
channel?: string;
|
|
74
|
-
cause?: Error;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
declare class ProviderNotInstalledError extends NotificationError {
|
|
78
|
-
constructor(provider: string, installCmd: string);
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
56
|
//#region src/utils/quiet-hours.d.ts
|
|
82
57
|
/**
|
|
83
58
|
* Quiet hours utility
|
|
@@ -350,4 +325,4 @@ interface StatusHandler {
|
|
|
350
325
|
*/
|
|
351
326
|
declare function createStatusHandler(config?: StatusHandlerConfig): StatusHandler;
|
|
352
327
|
//#endregion
|
|
353
|
-
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 };
|
|
@@ -57,6 +57,31 @@ function calculateDelay(attempt, config) {
|
|
|
57
57
|
delay = Math.min(delay + jitter, config.maxDelay);
|
|
58
58
|
return Math.max(0, Math.round(delay));
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The `retryAfterMs` an error (or one of its causes, up to 4 deep) carries — set by providers
|
|
62
|
+
* from an HTTP `Retry-After` header. Channels wrap provider errors in `ChannelError`, so the hint
|
|
63
|
+
* usually rides on `cause`.
|
|
64
|
+
*/
|
|
65
|
+
function retryAfterHint(error) {
|
|
66
|
+
let cursor = error;
|
|
67
|
+
for (let depth = 0; cursor !== null && typeof cursor === "object" && depth < 5; depth++) {
|
|
68
|
+
const hint = cursor.retryAfterMs;
|
|
69
|
+
if (typeof hint === "number" && Number.isFinite(hint) && hint >= 0) return hint;
|
|
70
|
+
cursor = cursor.cause;
|
|
71
|
+
}
|
|
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
|
+
}
|
|
60
85
|
/** Sleep for a given duration */
|
|
61
86
|
function sleep(ms) {
|
|
62
87
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -77,7 +102,17 @@ async function withRetry(fn, config, onRetry, shouldRetry) {
|
|
|
77
102
|
} catch (err) {
|
|
78
103
|
lastError = err instanceof Error ? err : new Error(String(err));
|
|
79
104
|
if (attempt === config.maxAttempts || shouldRetry?.(lastError) === false) break;
|
|
80
|
-
|
|
105
|
+
let delay = calculateDelay(attempt, config);
|
|
106
|
+
const hinted = retryAfterHint(lastError);
|
|
107
|
+
if (hinted !== void 0) {
|
|
108
|
+
if (hinted > config.maxDelay) break;
|
|
109
|
+
delay = Math.max(delay, hinted);
|
|
110
|
+
}
|
|
111
|
+
const floor = retryFloorHint(lastError);
|
|
112
|
+
if (floor !== void 0) {
|
|
113
|
+
if (floor > config.maxDelay) break;
|
|
114
|
+
delay = Math.max(delay, floor);
|
|
115
|
+
}
|
|
81
116
|
onRetry?.(attempt, lastError);
|
|
82
117
|
await sleep(delay);
|
|
83
118
|
}
|
|
@@ -779,4 +814,4 @@ function createStatusHandler(config = {}) {
|
|
|
779
814
|
}
|
|
780
815
|
|
|
781
816
|
//#endregion
|
|
782
|
-
export {
|
|
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 };
|
|
@@ -511,6 +511,24 @@ var SmsChannel = class extends BaseChannel {
|
|
|
511
511
|
* });
|
|
512
512
|
* ```
|
|
513
513
|
*/
|
|
514
|
+
const PLATFORMS = /* @__PURE__ */ new Set([
|
|
515
|
+
"android",
|
|
516
|
+
"ios",
|
|
517
|
+
"web"
|
|
518
|
+
]);
|
|
519
|
+
const LEVELS = /* @__PURE__ */ new Set([
|
|
520
|
+
"passive",
|
|
521
|
+
"active",
|
|
522
|
+
"time-sensitive",
|
|
523
|
+
"critical"
|
|
524
|
+
]);
|
|
525
|
+
/**
|
|
526
|
+
* A data-only (background) push is opted into explicitly — `data.contentAvailable: true` or
|
|
527
|
+
* `data.dataOnly: true` — so a send that merely forgot its title is still skipped as before.
|
|
528
|
+
*/
|
|
529
|
+
function isDataOnly(data) {
|
|
530
|
+
return data.contentAvailable === true || data.dataOnly === true;
|
|
531
|
+
}
|
|
514
532
|
var PushChannel = class extends BaseChannel {
|
|
515
533
|
provider;
|
|
516
534
|
constructor(config) {
|
|
@@ -533,7 +551,7 @@ var PushChannel = class extends BaseChannel {
|
|
|
533
551
|
};
|
|
534
552
|
const title = payload.data.title ?? payload.data.subject ?? "";
|
|
535
553
|
const body = payload.data.body ?? payload.data.text ?? payload.data.message ?? "";
|
|
536
|
-
if (!title && !body) return {
|
|
554
|
+
if (!title && !body && !isDataOnly(payload.data)) return {
|
|
537
555
|
status: "skipped",
|
|
538
556
|
channel: this.name,
|
|
539
557
|
error: "No title or body (data.title, data.body)"
|
|
@@ -549,7 +567,8 @@ var PushChannel = class extends BaseChannel {
|
|
|
549
567
|
};
|
|
550
568
|
const title = data.title ?? data.subject ?? "";
|
|
551
569
|
const body = data.body ?? data.text ?? data.message ?? "";
|
|
552
|
-
|
|
570
|
+
const dataOnly = isDataOnly(data);
|
|
571
|
+
if (!title && !body && !dataOnly) return {
|
|
553
572
|
status: "skipped",
|
|
554
573
|
channel: this.name,
|
|
555
574
|
error: "No title or body (data.title, data.body)"
|
|
@@ -557,6 +576,13 @@ var PushChannel = class extends BaseChannel {
|
|
|
557
576
|
const collapseKey = typeof data.collapseKey === "string" && data.collapseKey ? data.collapseKey : void 0;
|
|
558
577
|
const threadId = typeof data.threadId === "string" && data.threadId ? data.threadId : void 0;
|
|
559
578
|
const badge = typeof data.badge === "number" && Number.isInteger(data.badge) && data.badge >= 0 ? data.badge : void 0;
|
|
579
|
+
const platform = PLATFORMS.has(data.platform) ? data.platform : void 0;
|
|
580
|
+
const priority = data.priority === "high" || data.priority === "normal" ? data.priority : void 0;
|
|
581
|
+
const ttlSeconds = typeof data.ttlSeconds === "number" && Number.isInteger(data.ttlSeconds) && data.ttlSeconds >= 0 ? data.ttlSeconds : void 0;
|
|
582
|
+
const interruptionLevel = LEVELS.has(data.interruptionLevel) ? data.interruptionLevel : void 0;
|
|
583
|
+
const sound = typeof data.sound === "string" || data.sound === null ? data.sound : void 0;
|
|
584
|
+
const channelId = typeof data.channelId === "string" && data.channelId ? data.channelId : void 0;
|
|
585
|
+
const category = typeof data.category === "string" && data.category ? data.category : void 0;
|
|
560
586
|
try {
|
|
561
587
|
const result = await this.provider.send({
|
|
562
588
|
token: recipient.deviceToken,
|
|
@@ -566,7 +592,15 @@ var PushChannel = class extends BaseChannel {
|
|
|
566
592
|
imageUrl: data.imageUrl,
|
|
567
593
|
...collapseKey !== void 0 ? { collapseKey } : {},
|
|
568
594
|
...threadId !== void 0 ? { threadId } : {},
|
|
569
|
-
...badge !== void 0 ? { badge } : {}
|
|
595
|
+
...badge !== void 0 ? { badge } : {},
|
|
596
|
+
...platform !== void 0 ? { platform } : {},
|
|
597
|
+
...priority !== void 0 ? { priority } : {},
|
|
598
|
+
...ttlSeconds !== void 0 ? { ttlSeconds } : {},
|
|
599
|
+
...interruptionLevel !== void 0 ? { interruptionLevel } : {},
|
|
600
|
+
...dataOnly ? { contentAvailable: true } : {},
|
|
601
|
+
...sound !== void 0 ? { sound } : {},
|
|
602
|
+
...channelId !== void 0 ? { channelId } : {},
|
|
603
|
+
...category !== void 0 ? { category } : {}
|
|
570
604
|
});
|
|
571
605
|
return {
|
|
572
606
|
status: "sent",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
@@ -651,31 +651,71 @@ interface SmsChannelConfig extends ChannelConfig {
|
|
|
651
651
|
/** SMS provider implementation (Twilio, SNS, Vonage, etc.) */
|
|
652
652
|
provider: SmsProvider;
|
|
653
653
|
}
|
|
654
|
+
/** The device platform a push token belongs to. */
|
|
655
|
+
type PushPlatform = 'android' | 'ios' | 'web';
|
|
656
|
+
/**
|
|
657
|
+
* How strongly an iOS notification may interrupt (APNs `aps.interruption-level`). `critical`
|
|
658
|
+
* needs Apple's critical-alerts entitlement; providers downgrade it unless allowed.
|
|
659
|
+
*/
|
|
660
|
+
type PushInterruptionLevel = 'passive' | 'active' | 'time-sensitive' | 'critical';
|
|
661
|
+
/**
|
|
662
|
+
* The message a {@link PushProvider} receives. `title` and `body` are always strings; an empty
|
|
663
|
+
* string means "absent" (a data-only push sets both to `''` and `contentAvailable: true`).
|
|
664
|
+
*
|
|
665
|
+
* Every field after `badge` is an optional delivery hint (2.9): a provider that ignores them still
|
|
666
|
+
* delivers, so existing custom providers keep working unchanged.
|
|
667
|
+
*/
|
|
668
|
+
interface PushProviderMessage {
|
|
669
|
+
token: string;
|
|
670
|
+
title: string;
|
|
671
|
+
body: string;
|
|
672
|
+
data?: Record<string, string>;
|
|
673
|
+
imageUrl?: string;
|
|
674
|
+
/**
|
|
675
|
+
* Replace-in-place key: a newer push with the same key replaces the older one on the device
|
|
676
|
+
* instead of stacking (FCM `android.collapseKey` + `notification.tag`, APNs `apns-collapse-id`,
|
|
677
|
+
* at most 64 bytes). From `data.collapseKey`. Absent = every push shows on its own.
|
|
678
|
+
*/
|
|
679
|
+
collapseKey?: string;
|
|
680
|
+
/** Groups notifications in the tray (APNs `aps.thread-id`, Android group). From `data.threadId`. */
|
|
681
|
+
threadId?: string;
|
|
682
|
+
/** App icon badge count (APNs `aps.badge`, Android `notificationCount`). From `data.badge`. */
|
|
683
|
+
badge?: number;
|
|
684
|
+
/** The token's platform; `pushRouter` dispatches on it. From `data.platform`. */
|
|
685
|
+
platform?: PushPlatform;
|
|
686
|
+
/** Delivery priority. `high` wakes the device (default for visible pushes). From `data.priority`. */
|
|
687
|
+
priority?: 'high' | 'normal';
|
|
688
|
+
/** Drop the push if undelivered after this many seconds (`0` = now or never). From `data.ttlSeconds`. */
|
|
689
|
+
ttlSeconds?: number;
|
|
690
|
+
/** iOS interruption level. From `data.interruptionLevel`. */
|
|
691
|
+
interruptionLevel?: PushInterruptionLevel;
|
|
692
|
+
/**
|
|
693
|
+
* Data-only / background push: no visible alert, the app wakes and fetches what it needs
|
|
694
|
+
* (APNs `content-available: 1` + push type `background`; FCM data message). From
|
|
695
|
+
* `data.contentAvailable` or `data.dataOnly`.
|
|
696
|
+
*/
|
|
697
|
+
contentAvailable?: boolean;
|
|
698
|
+
/** Sound name (`'default'` when omitted on a visible push); `null` = silent. From `data.sound`. */
|
|
699
|
+
sound?: string | null;
|
|
700
|
+
/** Android notification channel id. From `data.channelId`. */
|
|
701
|
+
channelId?: string;
|
|
702
|
+
/** APNs `aps.category` / Android `click_action`. From `data.category`. */
|
|
703
|
+
category?: string;
|
|
704
|
+
}
|
|
654
705
|
/**
|
|
655
706
|
* Push notification provider interface (FCM or custom). Throw to fail the send (retried per
|
|
656
707
|
* the retry config); throw a `PermanentDeliveryError` (or any error with `retryable: false`)
|
|
657
708
|
* for a failure no retry can fix, such as an unregistered device token.
|
|
709
|
+
*
|
|
710
|
+
* Built-in providers (FCM HTTP v1, APNs HTTP/2, a platform router) live in
|
|
711
|
+
* `@classytic/notifications/push`.
|
|
658
712
|
*/
|
|
659
713
|
interface PushProvider {
|
|
660
|
-
send(message: {
|
|
661
|
-
token: string;
|
|
662
|
-
title: string;
|
|
663
|
-
body: string;
|
|
664
|
-
data?: Record<string, string>;
|
|
665
|
-
imageUrl?: string;
|
|
666
|
-
/**
|
|
667
|
-
* Replace-in-place key: a newer push with the same key replaces the older one on the device
|
|
668
|
-
* instead of stacking (FCM `android.collapseKey` + `notification.tag`, APNs `apns-collapse-id`,
|
|
669
|
-
* at most 64 bytes). From `data.collapseKey`. Absent = every push shows on its own.
|
|
670
|
-
*/
|
|
671
|
-
collapseKey?: string;
|
|
672
|
-
/** Groups notifications in the tray (APNs `aps.thread-id`, Android group). From `data.threadId`. */
|
|
673
|
-
threadId?: string;
|
|
674
|
-
/** App icon badge count (APNs `aps.badge`, Android `notificationCount`). From `data.badge`. */
|
|
675
|
-
badge?: number;
|
|
676
|
-
}): Promise<{
|
|
714
|
+
send(message: PushProviderMessage): Promise<{
|
|
677
715
|
messageId: string;
|
|
678
716
|
}>;
|
|
717
|
+
/** Release long-lived resources (HTTP/2 sessions). Optional; call on shutdown. */
|
|
718
|
+
close?(): Promise<void> | void;
|
|
679
719
|
}
|
|
680
720
|
/** PushChannel configuration — bring your own push SDK */
|
|
681
721
|
interface PushChannelConfig extends ChannelConfig {
|
|
@@ -757,6 +797,22 @@ interface NotificationServiceConfig {
|
|
|
757
797
|
ttl?: number;
|
|
758
798
|
/** In-flight lease for stores with an atomic `claim()` (default: 300000 = 5 min) */
|
|
759
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';
|
|
760
816
|
};
|
|
761
817
|
/** Delivery log for audit trail — records every send attempt */
|
|
762
818
|
deliveryLog?: DeliveryLog;
|
|
@@ -771,7 +827,10 @@ interface NotificationServiceConfig {
|
|
|
771
827
|
* when a dispatch had `sent === 0 && failed > 0`, so the queue
|
|
772
828
|
* marks the job failed (and retries up to `maxAttempts`). Partial
|
|
773
829
|
* successes (some channels sent) resolve normally to avoid
|
|
774
|
-
* 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.
|
|
775
834
|
* - `'always-complete'` — legacy behavior. The processor never
|
|
776
835
|
* throws; queued jobs always resolve as completed, regardless of
|
|
777
836
|
* channel outcome. Keep this if your delivery log is the source
|
|
@@ -834,4 +893,4 @@ interface BatchResult {
|
|
|
834
893
|
results: DispatchResult[];
|
|
835
894
|
}
|
|
836
895
|
//#endregion
|
|
837
|
-
export {
|
|
896
|
+
export { RateLimitConfig as $, SmsProvider as A, QueueJobStatus as B, PushProviderMessage as C, SendResult as D, RetryConfig as E, WebhookChannelConfig as F, MemoryDeliveryLog as G, DeliveryLog as H, MemoryQueue as I, IdempotencyStore as J, IDEMPOTENCY_DEFAULT_LEASE as K, QueueAdapter as L, TelegramChannelConfig as M, TemplateResolver as N, ServiceEvent as O, TemplateResult as P, MemoryRateLimitStore as Q, QueueEnqueueOptions as R, PushProvider as S, ResolvedRetryConfig as T, DeliveryLogEntry as U, QueueProcessor as V, DeliveryLogQuery as W, RedisIdempotencyClient as X, MemoryIdempotencyStore as Y, RedisIdempotencyStore as Z, NotificationServiceConfig as _, ChannelConfig as a, PushInterruptionLevel as b, EmailChannelConfig as c, HookMap as d, RateLimitStore as et, Logger as f, NotificationPreferences as g, NotificationPayload as h, Channel as i, SmtpTransportOptions as j, SmsChannelConfig as k, EventHandler as l, NotificationHookConfig as m, BatchProgress as n, DispatchResult as o, NodemailerTransporter as p, IDEMPOTENCY_DEFAULT_TTL as q, BatchResult as r, EmailAttachment as s, BatchOptions as t, HookHandler as u, PreferenceResolver as v, Recipient as w, PushPlatform as x, PushChannelConfig as y, QueueJob as z };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as
|
|
3
|
-
|
|
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
|
+
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, retryFloorHint, withFallback, withRetry };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ 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, 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,
|
|
@@ -23,13 +23,18 @@
|
|
|
23
23
|
"./utils": {
|
|
24
24
|
"types": "./dist/utils/index.d.mts",
|
|
25
25
|
"default": "./dist/utils/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./push": {
|
|
28
|
+
"types": "./dist/push/index.d.mts",
|
|
29
|
+
"default": "./dist/push/index.mjs"
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
"typesVersions": {
|
|
29
33
|
"*": {
|
|
30
34
|
"channels": ["./dist/channels/index.d.mts"],
|
|
31
35
|
"providers": ["./dist/providers/index.d.mts"],
|
|
32
|
-
"utils": ["./dist/utils/index.d.mts"]
|
|
36
|
+
"utils": ["./dist/utils/index.d.mts"],
|
|
37
|
+
"push": ["./dist/push/index.d.mts"]
|
|
33
38
|
}
|
|
34
39
|
},
|
|
35
40
|
"files": [
|