@visulima/notification 1.0.9 → 1.0.11
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 +16 -0
- package/dist/channels/email/index.d.ts +23 -23
- package/dist/channels/email/index.js +1 -1
- package/dist/channels/inapp/index.d.ts +31 -31
- package/dist/digest/index.d.ts +55 -55
- package/dist/digest/index.js +1 -1
- package/dist/events/index.d.ts +16 -16
- package/dist/i18n/index.d.ts +21 -21
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +97 -108
- package/dist/index.js +1 -1
- package/dist/layouts/index.d.ts +28 -28
- package/dist/middleware/index.d.ts +49 -49
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/Notification-BuS_QjJv.js +1 -0
- package/dist/packem_shared/NotificationError-B1ZZqWxL.js +1 -0
- package/dist/packem_shared/{RequiredOptionError-CuL42XRq.js → RequiredOptionError-CH4g-BZM.js} +1 -1
- package/dist/packem_shared/apnsProvider-BV5-wOvD.js +1 -0
- package/dist/packem_shared/{circuitBreakerMiddleware-BlZN7SVT.js → circuitBreakerMiddleware-o3G_6N3s.js} +1 -1
- package/dist/packem_shared/{createDigester-vMNPejGF.js → createDigester-DCwWhmpi.js} +1 -1
- package/dist/packem_shared/{createNotificationWorkflow-B70OgeED.js → createNotificationWorkflow-lseG_9fC.js} +1 -1
- package/dist/packem_shared/createQueueWorker-BIXWHJLY.js +1 -0
- package/dist/packem_shared/{createTranslator-CY91C2eS.js → createTranslator-BL2M8eeD.js} +1 -1
- package/dist/packem_shared/{discordProvider-BhfXcCcI.js → discordProvider-D4LpBljj.js} +1 -1
- package/dist/packem_shared/{emailChannel-CNDlX96Q.js → emailChannel-BoLLbyrn.js} +1 -1
- package/dist/packem_shared/{expoProvider-DsZR4sUk.js → expoProvider-BPJr9c0e.js} +1 -1
- package/dist/packem_shared/{failoverProvider-D1dAmW8U.js → failoverProvider-CJsDGjzf.js} +1 -1
- package/dist/packem_shared/fcmProvider-qIR12R9m.js +1 -0
- package/dist/packem_shared/hmacBase64-CNksyDoB.js +1 -0
- package/dist/packem_shared/{messageBirdProvider-BfiTaNLn.js → messageBirdProvider-FK9_UONf.js} +1 -1
- package/dist/packem_shared/{mockProvider-BLwTZlkw.js → mockProvider-C2hHPSVa.js} +1 -1
- package/dist/packem_shared/{msTeamsProvider-DrmL3RYX.js → msTeamsProvider-DeGPjmCt.js} +1 -1
- package/dist/packem_shared/notification.d-D0ado_cy.d.ts +104 -0
- package/dist/packem_shared/{plivoProvider-Dr8d5yD3.js → plivoProvider-DaCu7J3X.js} +1 -1
- package/dist/packem_shared/{provider.d-BQAGriz6.d.ts → provider.d-Dh32nRm9.d.ts} +10 -10
- package/dist/packem_shared/{roundRobinProvider-BetXJUUm.js → roundRobinProvider-HowYifRe.js} +1 -1
- package/dist/packem_shared/{slackProvider-DPG1IlA0.js → slackProvider-Caxbs4Pa.js} +1 -1
- package/dist/packem_shared/{slackWebhook-Cpmm_0El.js → slackWebhook-IB4mVnBk.js} +1 -1
- package/dist/packem_shared/{sms-CU-OZvNU.js → sms-BbxkOLQm.js} +1 -1
- package/dist/packem_shared/{snsProvider-C2T2UxDK.js → snsProvider-BS4D6w-i.js} +3 -3
- package/dist/packem_shared/{standardWebhook-Bk0UUeDW.js → standardWebhook-C_AQWUi5.js} +1 -1
- package/dist/packem_shared/{telegramProvider-wyx3ksVm.js → telegramProvider-BIc_GgpY.js} +1 -1
- package/dist/packem_shared/{telnyxProvider-jgpEwgPh.js → telnyxProvider-wjmTXBwh.js} +1 -1
- package/dist/packem_shared/{tracer.d-Co1s_NwG.d.ts → tracer.d-BPznIQx9.d.ts} +2 -2
- package/dist/packem_shared/{twilioProvider-DMYWqvgZ.js → twilioProvider-Bf_zsF9z.js} +1 -1
- package/dist/packem_shared/twilioWebhook-Hhf9aWV1.js +1 -0
- package/dist/packem_shared/types.d-BU-37j3S.d.ts +10 -0
- package/dist/packem_shared/{types.d-GUzX1jTk.d.ts → types.d-C7l7qdMG.d.ts} +52 -52
- package/dist/packem_shared/{types.d-CximoA8M.d.ts → types.d-CRs03TYV.d.ts} +13 -13
- package/dist/packem_shared/{types.d-C1GoEAlI.d-Bv3grfyD.d.ts → types.d-CcjfiGpo.d-DuZME7ry.d.ts} +27 -34
- package/dist/packem_shared/{types.d-67TogK4k.d.ts → types.d-r8K0ICyx.d.ts} +7 -7
- package/dist/packem_shared/{vonageProvider-CT4KoWXu.js → vonageProvider-oRg9dpS1.js} +1 -1
- package/dist/packem_shared/{webPushProvider-DwjmWASr.js → webPushProvider-BtZHb_X_.js} +1 -1
- package/dist/packem_shared/{webcrypto-bY7wJCB5.js → webcrypto-CFuQmh5-.js} +1 -1
- package/dist/packem_shared/webhookProvider-CwkDb1cZ.js +1 -0
- package/dist/preferences/index.d.ts +19 -19
- package/dist/providers/chat/discord/index.d.ts +5 -5
- package/dist/providers/chat/discord/index.js +1 -1
- package/dist/providers/chat/msteams/index.d.ts +7 -7
- package/dist/providers/chat/msteams/index.js +1 -1
- package/dist/providers/chat/slack/index.d.ts +6 -6
- package/dist/providers/chat/slack/index.js +1 -1
- package/dist/providers/chat/telegram/index.d.ts +5 -5
- package/dist/providers/chat/telegram/index.js +1 -1
- package/dist/providers/failover/index.d.ts +7 -7
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/mock/index.d.ts +5 -5
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +14 -14
- package/dist/providers/push/apns/index.d.ts +9 -9
- package/dist/providers/push/apns/index.js +1 -1
- package/dist/providers/push/expo/index.d.ts +5 -5
- package/dist/providers/push/expo/index.js +1 -1
- package/dist/providers/push/fcm/index.d.ts +13 -13
- package/dist/providers/push/fcm/index.js +1 -1
- package/dist/providers/push/web-push/index.d.ts +11 -11
- package/dist/providers/push/web-push/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +8 -8
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/sms/messagebird/index.d.ts +5 -5
- package/dist/providers/sms/messagebird/index.js +1 -1
- package/dist/providers/sms/plivo/index.d.ts +5 -5
- package/dist/providers/sms/plivo/index.js +1 -1
- package/dist/providers/sms/sns/index.d.ts +6 -6
- package/dist/providers/sms/sns/index.js +1 -1
- package/dist/providers/sms/telnyx/index.d.ts +5 -5
- package/dist/providers/sms/telnyx/index.js +1 -1
- package/dist/providers/sms/twilio/index.d.ts +5 -5
- package/dist/providers/sms/twilio/index.js +1 -1
- package/dist/providers/sms/vonage/index.d.ts +5 -5
- package/dist/providers/sms/vonage/index.js +1 -1
- package/dist/providers/webhook/index.d.ts +7 -7
- package/dist/providers/webhook/index.js +1 -1
- package/dist/queue/bullmq-queue.d.ts +24 -24
- package/dist/queue/index.d.ts +17 -15
- package/dist/queue/index.js +1 -1
- package/dist/queue/pg-boss-queue.d.ts +27 -26
- package/dist/queue/pg-boss-queue.js +1 -1
- package/dist/queue/sqs-queue.d.ts +27 -27
- package/dist/queue/sqs-queue.js +1 -1
- package/dist/queue/unstorage-queue.d.ts +21 -14
- package/dist/queue/unstorage-queue.js +1 -1
- package/dist/routing/index.d.ts +22 -22
- package/dist/template-engines/handlebars.d.ts +13 -13
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/liquid.d.ts +13 -13
- package/dist/template-engines/liquid.js +1 -1
- package/dist/template-engines/string.d.ts +17 -17
- package/dist/utils/result.d.ts +32 -32
- package/dist/utils/result.js +1 -1
- package/dist/webhooks/index.d.ts +84 -84
- package/dist/webhooks/index.js +1 -1
- package/dist/workflow/index.d.ts +42 -42
- package/dist/workflow/index.js +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/Notification-B22tuJPy.js +0 -1
- package/dist/packem_shared/NotificationError-DVfMJQ1u.js +0 -1
- package/dist/packem_shared/apnsProvider-C9WSv5sc.js +0 -1
- package/dist/packem_shared/createQueueWorker-DjQBxjXc.js +0 -1
- package/dist/packem_shared/fcmProvider-DWRx8XBv.js +0 -1
- package/dist/packem_shared/hmacBase64-BhhoX0uo.js +0 -1
- package/dist/packem_shared/notification.d-DFCVTods.d.ts +0 -104
- package/dist/packem_shared/twilioWebhook-C-Iwuv7y.js +0 -1
- package/dist/packem_shared/types.d-td-F2Oh0.d.ts +0 -10
- package/dist/packem_shared/webhookProvider-CPA1nKXJ.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## @visulima/notification [1.0.11](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.10...%40visulima%2Fnotification%401.0.11) (2026-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/email:** upgraded to 2.1.8
|
|
7
|
+
* **@visulima/error:** upgraded to 6.1.0
|
|
8
|
+
* **@visulima/workflow:** upgraded to 2.0.0
|
|
9
|
+
|
|
10
|
+
## @visulima/notification [1.0.10](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.9...%40visulima%2Fnotification%401.0.10) (2026-07-27)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* **@visulima/email:** upgraded to 2.1.7
|
|
16
|
+
|
|
1
17
|
## @visulima/notification [1.0.9](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.8...%40visulima%2Fnotification%401.0.9) (2026-07-27)
|
|
2
18
|
|
|
3
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
2
|
-
import { E as EmailChannelPayload } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as Provider } from "../../packem_shared/provider.d-Dh32nRm9.js";
|
|
2
|
+
import { E as EmailChannelPayload } from "../../packem_shared/types.d-C7l7qdMG.js";
|
|
3
3
|
/**
|
|
4
|
-
* The result shape returned by `@visulima/email`'s `Mail.send`.
|
|
5
|
-
*/
|
|
4
|
+
* The result shape returned by `@visulima/email`'s `Mail.send`.
|
|
5
|
+
*/
|
|
6
6
|
interface EmailSendResult {
|
|
7
7
|
data?: {
|
|
8
8
|
messageId: string;
|
|
@@ -15,9 +15,9 @@ interface EmailSendResult {
|
|
|
15
15
|
success: boolean;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Structural type for a `@visulima/email` `Mail` instance. Kept structural so the email
|
|
19
|
-
* peer stays optional — pass a configured `createMail(...)` result.
|
|
20
|
-
*/
|
|
18
|
+
* Structural type for a `@visulima/email` `Mail` instance. Kept structural so the email
|
|
19
|
+
* peer stays optional — pass a configured `createMail(...)` result.
|
|
20
|
+
*/
|
|
21
21
|
interface EmailLike {
|
|
22
22
|
send: (message: unknown) => Promise<EmailSendResult>;
|
|
23
23
|
}
|
|
@@ -26,21 +26,21 @@ interface EmailChannelConfig {
|
|
|
26
26
|
id?: string;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Adapts a configured `@visulima/email` `Mail` instance into a notification channel
|
|
30
|
-
* provider, so email can participate in multi-channel sends and routing.
|
|
31
|
-
* @param mail A `Mail` instance from `createMail(...)`.
|
|
32
|
-
* @param config Optional config.
|
|
33
|
-
* @returns An email-channel provider.
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { createMail } from "@visulima/email";
|
|
37
|
-
* import { resendProvider } from "@visulima/email/providers/resend";
|
|
38
|
-
* import { createNotification } from "@visulima/notification";
|
|
39
|
-
* import { emailChannel } from "@visulima/notification/channels/email";
|
|
40
|
-
*
|
|
41
|
-
* const mail = createMail(resendProvider({ apiKey }));
|
|
42
|
-
* const notify = createNotification({ email: emailChannel(mail) });
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
29
|
+
* Adapts a configured `@visulima/email` `Mail` instance into a notification channel
|
|
30
|
+
* provider, so email can participate in multi-channel sends and routing.
|
|
31
|
+
* @param mail A `Mail` instance from `createMail(...)`.
|
|
32
|
+
* @param config Optional config.
|
|
33
|
+
* @returns An email-channel provider.
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { createMail } from "@visulima/email";
|
|
37
|
+
* import { resendProvider } from "@visulima/email/providers/resend";
|
|
38
|
+
* import { createNotification } from "@visulima/notification";
|
|
39
|
+
* import { emailChannel } from "@visulima/notification/channels/email";
|
|
40
|
+
*
|
|
41
|
+
* const mail = createMail(resendProvider({ apiKey }));
|
|
42
|
+
* const notify = createNotification({ email: emailChannel(mail) });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
45
|
declare const emailChannel: (mail: EmailLike, config?: EmailChannelConfig) => Provider<unknown, EmailChannelPayload>;
|
|
46
46
|
export { type EmailChannelConfig, type EmailLike, emailChannel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{emailChannel as l}from"../../packem_shared/emailChannel-
|
|
1
|
+
import{emailChannel as l}from"../../packem_shared/emailChannel-BoLLbyrn.js";export{l as emailChannel};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
2
|
-
import { I as InAppPayload } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as Provider } from "../../packem_shared/provider.d-Dh32nRm9.js";
|
|
2
|
+
import { I as InAppPayload } from "../../packem_shared/types.d-C7l7qdMG.js";
|
|
3
3
|
import { S as Storage } from "../../packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.js";
|
|
4
4
|
/**
|
|
5
|
-
* A persisted in-app notification.
|
|
6
|
-
*/
|
|
5
|
+
* A persisted in-app notification.
|
|
6
|
+
*/
|
|
7
7
|
interface StoredNotification {
|
|
8
8
|
actions?: {
|
|
9
9
|
label: string;
|
|
@@ -24,9 +24,9 @@ interface ListOptions {
|
|
|
24
24
|
unreadOnly?: boolean;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Backing store for the in-app channel. The default {@link MemoryInAppStore} is
|
|
28
|
-
* in-process; back it with a persistent store for production feeds.
|
|
29
|
-
*/
|
|
27
|
+
* Backing store for the in-app channel. The default {@link MemoryInAppStore} is
|
|
28
|
+
* in-process; back it with a persistent store for production feeds.
|
|
29
|
+
*/
|
|
30
30
|
interface InAppStore {
|
|
31
31
|
add: (notification: Omit<StoredNotification, "createdAt" | "id" | "read"> & {
|
|
32
32
|
id?: string;
|
|
@@ -38,8 +38,8 @@ interface InAppStore {
|
|
|
38
38
|
unreadCount: (subscriberId: string) => Promise<number>;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* In-memory {@link InAppStore}.
|
|
42
|
-
*/
|
|
41
|
+
* In-memory {@link InAppStore}.
|
|
42
|
+
*/
|
|
43
43
|
declare class MemoryInAppStore implements InAppStore {
|
|
44
44
|
#private;
|
|
45
45
|
add(notification: Omit<StoredNotification, "createdAt" | "id" | "read"> & {
|
|
@@ -58,25 +58,25 @@ interface InAppProviderConfig {
|
|
|
58
58
|
store?: InAppStore;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* In-app channel provider. Persists notifications to an {@link InAppStore} for a feed/inbox
|
|
62
|
-
* UI to query. Expose the store via `getInstance()` to read/markRead.
|
|
63
|
-
* @param config Provider `id` and the backing {@link InAppStore} (defaults to in-memory).
|
|
64
|
-
* @returns A provider that writes notifications into the configured store.
|
|
65
|
-
*/
|
|
61
|
+
* In-app channel provider. Persists notifications to an {@link InAppStore} for a feed/inbox
|
|
62
|
+
* UI to query. Expose the store via `getInstance()` to read/markRead.
|
|
63
|
+
* @param config Provider `id` and the backing {@link InAppStore} (defaults to in-memory).
|
|
64
|
+
* @returns A provider that writes notifications into the configured store.
|
|
65
|
+
*/
|
|
66
66
|
declare const inAppProvider: (config?: InAppProviderConfig) => Provider<InAppProviderConfig, InAppPayload, InAppStore>;
|
|
67
67
|
/**
|
|
68
|
-
* An {@link InAppStore} backed by an [unstorage](https://unstorage.unjs.io) driver, giving durable,
|
|
69
|
-
* multi-backend persistence (Redis, filesystem, Cloudflare KV, ...). `unstorage` is an optional peer
|
|
70
|
-
* dependency — pass a configured `Storage` instance.
|
|
71
|
-
*
|
|
72
|
-
* Each notification is stored under `prefix:item:id`, and a per-subscriber index list is kept under
|
|
73
|
-
* `prefix:index:subscriberId` so `list`/`unreadCount`/`markAllRead` avoid scanning every key.
|
|
74
|
-
*
|
|
75
|
-
* The per-subscriber index is eventually-consistent: the item and index keys are written
|
|
76
|
-
* non-atomically, so a concurrent reader may briefly observe one without the other.
|
|
77
|
-
*
|
|
78
|
-
* Edge-safe: works on Cloudflare KV (and other edge runtimes) via the matching unstorage driver.
|
|
79
|
-
*/
|
|
68
|
+
* An {@link InAppStore} backed by an [unstorage](https://unstorage.unjs.io) driver, giving durable,
|
|
69
|
+
* multi-backend persistence (Redis, filesystem, Cloudflare KV, ...). `unstorage` is an optional peer
|
|
70
|
+
* dependency — pass a configured `Storage` instance.
|
|
71
|
+
*
|
|
72
|
+
* Each notification is stored under `prefix:item:id`, and a per-subscriber index list is kept under
|
|
73
|
+
* `prefix:index:subscriberId` so `list`/`unreadCount`/`markAllRead` avoid scanning every key.
|
|
74
|
+
*
|
|
75
|
+
* The per-subscriber index is eventually-consistent: the item and index keys are written
|
|
76
|
+
* non-atomically, so a concurrent reader may briefly observe one without the other.
|
|
77
|
+
*
|
|
78
|
+
* Edge-safe: works on Cloudflare KV (and other edge runtimes) via the matching unstorage driver.
|
|
79
|
+
*/
|
|
80
80
|
declare class UnstorageInAppStore implements InAppStore {
|
|
81
81
|
#private;
|
|
82
82
|
constructor(storage: Storage, prefix?: string);
|
|
@@ -90,10 +90,10 @@ declare class UnstorageInAppStore implements InAppStore {
|
|
|
90
90
|
remove(id: string): Promise<void>;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Convenience factory for {@link UnstorageInAppStore}.
|
|
94
|
-
* @param storage A configured unstorage `Storage` instance (optional peer).
|
|
95
|
-
* @param prefix Key prefix under which notifications are stored.
|
|
96
|
-
* @returns A new {@link UnstorageInAppStore}.
|
|
97
|
-
*/
|
|
93
|
+
* Convenience factory for {@link UnstorageInAppStore}.
|
|
94
|
+
* @param storage A configured unstorage `Storage` instance (optional peer).
|
|
95
|
+
* @param prefix Key prefix under which notifications are stored.
|
|
96
|
+
* @returns A new {@link UnstorageInAppStore}.
|
|
97
|
+
*/
|
|
98
98
|
declare const createUnstorageInAppStore: (storage: Storage, prefix?: string) => UnstorageInAppStore;
|
|
99
99
|
export { type InAppProviderConfig, type InAppStore, type ListOptions, MemoryInAppStore, type StoredNotification, UnstorageInAppStore, createUnstorageInAppStore, inAppProvider };
|
package/dist/digest/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MaybePromise, D as Duration } from "../packem_shared/types.d-
|
|
1
|
+
import { M as MaybePromise, D as Duration } from "../packem_shared/types.d-CcjfiGpo.d-DuZME7ry.js";
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
/** A single event buffered inside a digest window. */
|
|
4
4
|
interface DigestEvent<PayloadT> {
|
|
@@ -17,19 +17,19 @@ interface DigestWindow<PayloadT> {
|
|
|
17
17
|
wakeAt: number;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Durability contract for `createDigester`. Implementations own the buffered
|
|
21
|
-
* windows and the "what is due" query; the digester stays storage-agnostic.
|
|
22
|
-
*
|
|
23
|
-
* `read` and `remove` are separate (rather than a single destructive `drain`) so
|
|
24
|
-
* the digester can flush a window's events *before* removing it — a failed flush
|
|
25
|
-
* leaves the window in place to be retried (at-least-once).
|
|
26
|
-
*/
|
|
20
|
+
* Durability contract for `createDigester`. Implementations own the buffered
|
|
21
|
+
* windows and the "what is due" query; the digester stays storage-agnostic.
|
|
22
|
+
*
|
|
23
|
+
* `read` and `remove` are separate (rather than a single destructive `drain`) so
|
|
24
|
+
* the digester can flush a window's events *before* removing it — a failed flush
|
|
25
|
+
* leaves the window in place to be retried (at-least-once).
|
|
26
|
+
*/
|
|
27
27
|
interface DigestStore<PayloadT> {
|
|
28
28
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
* Append an event to the window for `key`, opening it (with `wakeAt`) if absent.
|
|
30
|
+
* The window's `wakeAt` is fixed when it opens — later events do not extend it.
|
|
31
|
+
* @returns `true` if this call opened a new window.
|
|
32
|
+
*/
|
|
33
33
|
append: (key: string, event: DigestEvent<PayloadT>, wakeAt: number) => Promise<boolean>;
|
|
34
34
|
/** Keys whose window `wakeAt` is at or before `now`, up to `limit`. */
|
|
35
35
|
due: (now: number, limit: number) => Promise<string[]>;
|
|
@@ -43,11 +43,11 @@ interface DigesterOptions<PayloadT> {
|
|
|
43
43
|
/** Group events into windows by this key (e.g. `subscriberId` or `subscriberId:postId`). */
|
|
44
44
|
key: (event: PayloadT) => string;
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
* Called once per window when it closes, with every event collected. Delivery is
|
|
47
|
+
* **at-least-once**: the window is removed only after `onFlush` resolves, so a
|
|
48
|
+
* throwing `onFlush` is retried on the next sweep (and may run again if removal
|
|
49
|
+
* later fails). Make it idempotent.
|
|
50
|
+
*/
|
|
51
51
|
onFlush: (events: DigestEvent<PayloadT>[], key: string) => MaybePromise<void>;
|
|
52
52
|
/** The durable store; defaults to an in-memory store. */
|
|
53
53
|
store?: DigestStore<PayloadT>;
|
|
@@ -62,32 +62,32 @@ interface Digester<PayloadT> {
|
|
|
62
62
|
sweep: (now?: number, limit?: number) => Promise<number>;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Create a {@link Digester} that batches events into time/cron windows keyed by
|
|
66
|
-
* `options.key`, flushing each closed window once via `options.onFlush` — turning
|
|
67
|
-
* a burst of N events into a single notification.
|
|
68
|
-
*
|
|
69
|
-
* Windows close on a poll: call {@link Digester.sweep} from a cron job, a
|
|
70
|
-
* Cloudflare alarm, or any timer (alongside a workflow runtime's `sweep`).
|
|
71
|
-
* @param options Key function, window duration, flush handler and optional store.
|
|
72
|
-
* @returns A {@link Digester}.
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const digester = createDigester<{ subscriberId: string; postId: string }>({
|
|
76
|
-
* key: (event) => `${event.subscriberId}:${event.postId}`,
|
|
77
|
-
* window: { amount: 10, unit: "minutes" },
|
|
78
|
-
* onFlush: (events) => runtime.trigger(summaryWorkflow, { count: events.length, events }),
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* await digester.add({ subscriberId: "u1", postId: "p1" }); // opens a 10-minute window
|
|
82
|
-
* // …later, on a timer:
|
|
83
|
-
* await digester.sweep();
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
65
|
+
* Create a {@link Digester} that batches events into time/cron windows keyed by
|
|
66
|
+
* `options.key`, flushing each closed window once via `options.onFlush` — turning
|
|
67
|
+
* a burst of N events into a single notification.
|
|
68
|
+
*
|
|
69
|
+
* Windows close on a poll: call {@link Digester.sweep} from a cron job, a
|
|
70
|
+
* Cloudflare alarm, or any timer (alongside a workflow runtime's `sweep`).
|
|
71
|
+
* @param options Key function, window duration, flush handler and optional store.
|
|
72
|
+
* @returns A {@link Digester}.
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const digester = createDigester<{ subscriberId: string; postId: string }>({
|
|
76
|
+
* key: (event) => `${event.subscriberId}:${event.postId}`,
|
|
77
|
+
* window: { amount: 10, unit: "minutes" },
|
|
78
|
+
* onFlush: (events) => runtime.trigger(summaryWorkflow, { count: events.length, events }),
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* await digester.add({ subscriberId: "u1", postId: "p1" }); // opens a 10-minute window
|
|
82
|
+
* // …later, on a timer:
|
|
83
|
+
* await digester.sweep();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
86
|
declare const createDigester: <PayloadT>(options: DigesterOptions<PayloadT>) => Digester<PayloadT>;
|
|
87
87
|
/**
|
|
88
|
-
* In-process {@link DigestStore}. Ideal for tests and single-instance apps; swap
|
|
89
|
-
* for the unstorage adapter for durability across restarts and instances.
|
|
90
|
-
*/
|
|
88
|
+
* In-process {@link DigestStore}. Ideal for tests and single-instance apps; swap
|
|
89
|
+
* for the unstorage adapter for durability across restarts and instances.
|
|
90
|
+
*/
|
|
91
91
|
declare class MemoryDigestStore<PayloadT> implements DigestStore<PayloadT> {
|
|
92
92
|
#private;
|
|
93
93
|
append(key: string, event: DigestEvent<PayloadT>, wakeAt: number): Promise<boolean>;
|
|
@@ -96,9 +96,9 @@ declare class MemoryDigestStore<PayloadT> implements DigestStore<PayloadT> {
|
|
|
96
96
|
due(now: number, limit: number): Promise<string[]>;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Minimal structural view of an [unstorage](https://unstorage.unjs.io) instance,
|
|
100
|
-
* declared locally so the package needs no hard `unstorage` dependency.
|
|
101
|
-
*/
|
|
99
|
+
* Minimal structural view of an [unstorage](https://unstorage.unjs.io) instance,
|
|
100
|
+
* declared locally so the package needs no hard `unstorage` dependency.
|
|
101
|
+
*/
|
|
102
102
|
interface UnstorageLike {
|
|
103
103
|
getItem: <T = unknown>(key: string) => Promise<T | null>;
|
|
104
104
|
getKeys: (base?: string) => Promise<string[]>;
|
|
@@ -106,17 +106,17 @@ interface UnstorageLike {
|
|
|
106
106
|
setItem: (key: string, value: unknown) => Promise<void>;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* {@link DigestStore} backed by [unstorage](https://unstorage.unjs.io), for durable,
|
|
110
|
-
* edge-friendly digest windows over any unstorage driver.
|
|
111
|
-
*
|
|
112
|
-
* Each window is a single self-contained document keyed by `digest:w:` plus the
|
|
113
|
-
* digest key; there is no shared index, so concurrent `add`s for different keys cannot
|
|
114
|
-
* lose-update each other. `due` scans the window documents under the prefix — fine for the
|
|
115
|
-
* transient, bounded set of open windows. Individual reads/writes are still not
|
|
116
|
-
* transactional, so concurrent writers on the *same* key (or a sweep racing an
|
|
117
|
-
* `add` for that key) can drop an event or double-flush; for that level of
|
|
118
|
-
* contention prefer a store with atomic guarantees, or sweep from one instance.
|
|
119
|
-
*/
|
|
109
|
+
* {@link DigestStore} backed by [unstorage](https://unstorage.unjs.io), for durable,
|
|
110
|
+
* edge-friendly digest windows over any unstorage driver.
|
|
111
|
+
*
|
|
112
|
+
* Each window is a single self-contained document keyed by `digest:w:` plus the
|
|
113
|
+
* digest key; there is no shared index, so concurrent `add`s for different keys cannot
|
|
114
|
+
* lose-update each other. `due` scans the window documents under the prefix — fine for the
|
|
115
|
+
* transient, bounded set of open windows. Individual reads/writes are still not
|
|
116
|
+
* transactional, so concurrent writers on the *same* key (or a sweep racing an
|
|
117
|
+
* `add` for that key) can drop an event or double-flush; for that level of
|
|
118
|
+
* contention prefer a store with atomic guarantees, or sweep from one instance.
|
|
119
|
+
*/
|
|
120
120
|
declare class UnstorageDigestStore<PayloadT> implements DigestStore<PayloadT> {
|
|
121
121
|
#private;
|
|
122
122
|
constructor(storage: UnstorageLike);
|
package/dist/digest/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../packem_shared/createDigester-
|
|
1
|
+
import{default as r}from"../packem_shared/createDigester-DCwWhmpi.js";import{default as a}from"../packem_shared/MemoryDigestStore-Bw-sE5MI.js";import{default as f}from"../packem_shared/UnstorageDigestStore-QAcO3Vb_.js";export{a as MemoryDigestStore,f as UnstorageDigestStore,r as createDigester};
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { N as NotificationEvent, e as NotificationEventType } from "../packem_shared/types.d-
|
|
1
|
+
import { N as NotificationEvent, e as NotificationEventType } from "../packem_shared/types.d-C7l7qdMG.js";
|
|
2
2
|
/**
|
|
3
|
-
* An append-only timeline store for notification events.
|
|
4
|
-
*/
|
|
3
|
+
* An append-only timeline store for notification events.
|
|
4
|
+
*/
|
|
5
5
|
interface EventStore {
|
|
6
6
|
append: (event: NotificationEvent) => void | Promise<void>;
|
|
7
7
|
timeline: (messageId: string) => NotificationEvent[] | Promise<NotificationEvent[]>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* In-memory {@link EventStore} keyed by message id.
|
|
11
|
-
*/
|
|
10
|
+
* In-memory {@link EventStore} keyed by message id.
|
|
11
|
+
*/
|
|
12
12
|
declare class MemoryEventStore implements EventStore {
|
|
13
13
|
#private;
|
|
14
14
|
append(event: NotificationEvent): void;
|
|
@@ -16,22 +16,22 @@ declare class MemoryEventStore implements EventStore {
|
|
|
16
16
|
}
|
|
17
17
|
type NotificationEventListener = (event: NotificationEvent) => void;
|
|
18
18
|
/**
|
|
19
|
-
* A tiny synchronous event bus for notification lifecycle events. Listeners can subscribe
|
|
20
|
-
* to a specific {@link NotificationEventType} or to all events with `"*"`.
|
|
21
|
-
*/
|
|
19
|
+
* A tiny synchronous event bus for notification lifecycle events. Listeners can subscribe
|
|
20
|
+
* to a specific {@link NotificationEventType} or to all events with `"*"`.
|
|
21
|
+
*/
|
|
22
22
|
declare class NotificationEventBus {
|
|
23
23
|
#private;
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
* Subscribes to an event type (or `"*"` for all).
|
|
26
|
+
* @param type A specific {@link NotificationEventType} to listen for, or `"*"` for every event.
|
|
27
|
+
* @param listener The callback invoked with each matching event.
|
|
28
|
+
* @returns An unsubscribe function.
|
|
29
|
+
*/
|
|
30
30
|
on(type: "*" | NotificationEventType, listener: NotificationEventListener): () => void;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
* Emits an event to matching listeners.
|
|
33
|
+
* @param event The event to emit.
|
|
34
|
+
*/
|
|
35
35
|
emit(event: NotificationEvent): void;
|
|
36
36
|
}
|
|
37
37
|
export { type EventStore, MemoryEventStore, NotificationEventBus, NotificationEventListener };
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -17,26 +17,26 @@ interface Translator {
|
|
|
17
17
|
translate: (locale: string, key: string, values?: Record<string, unknown>) => string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Create a {@link Translator} over a set of locale message tables, using
|
|
21
|
-
* [ICU MessageFormat](https://formatjs.io/docs/core-concepts/icu-syntax/) (plurals,
|
|
22
|
-
* select, number/date) via `intl-messageformat`, with region → language → fallback
|
|
23
|
-
* resolution driven by the subscriber's locale. Edge-safe and dependency-light
|
|
24
|
-
* (requires the `intl-messageformat` peer).
|
|
25
|
-
* @param options Message tables, fallback locale, and an optional missing-key handler.
|
|
26
|
-
* @returns A {@link Translator}.
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const t = createTranslator({
|
|
30
|
-
* fallbackLocale: "en",
|
|
31
|
-
* messages: {
|
|
32
|
-
* en: { likes: "{count, plural, one {# like} other {# likes}}" },
|
|
33
|
-
* de_DE: { likes: "{count, plural, one {# Like} other {# Likes}}" },
|
|
34
|
-
* },
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* t.translate("de_DE", "likes", { count: 3 }); // "3 Likes"
|
|
38
|
-
* t.translate("fr", "likes", { count: 1 }); // falls back to en → "1 like"
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
20
|
+
* Create a {@link Translator} over a set of locale message tables, using
|
|
21
|
+
* [ICU MessageFormat](https://formatjs.io/docs/core-concepts/icu-syntax/) (plurals,
|
|
22
|
+
* select, number/date) via `intl-messageformat`, with region → language → fallback
|
|
23
|
+
* resolution driven by the subscriber's locale. Edge-safe and dependency-light
|
|
24
|
+
* (requires the `intl-messageformat` peer).
|
|
25
|
+
* @param options Message tables, fallback locale, and an optional missing-key handler.
|
|
26
|
+
* @returns A {@link Translator}.
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const t = createTranslator({
|
|
30
|
+
* fallbackLocale: "en",
|
|
31
|
+
* messages: {
|
|
32
|
+
* en: { likes: "{count, plural, one {# like} other {# likes}}" },
|
|
33
|
+
* de_DE: { likes: "{count, plural, one {# Like} other {# Likes}}" },
|
|
34
|
+
* },
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* t.translate("de_DE", "likes", { count: 3 }); // "3 Likes"
|
|
38
|
+
* t.translate("fr", "likes", { count: 1 }); // falls back to en → "1 like"
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
41
|
declare const createTranslator: (options: TranslatorOptions) => Translator;
|
|
42
42
|
export { type Translator, type TranslatorOptions, createTranslator };
|
package/dist/i18n/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../packem_shared/createTranslator-
|
|
1
|
+
import{default as e}from"../packem_shared/createTranslator-BL2M8eeD.js";export{e as createTranslator};
|