@visulima/notification 0.0.1 → 1.0.0-alpha.2
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 +35 -0
- package/LICENSE.md +874 -0
- package/README.md +313 -6
- package/dist/channels/email/index.d.ts +46 -0
- package/dist/channels/email/index.js +1 -0
- package/dist/channels/inapp/index.d.ts +99 -0
- package/dist/channels/inapp/index.js +1 -0
- package/dist/digest/index.d.ts +128 -0
- package/dist/digest/index.js +1 -0
- package/dist/events/index.d.ts +37 -0
- package/dist/events/index.js +1 -0
- package/dist/i18n/index.d.ts +42 -0
- package/dist/i18n/index.js +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +1 -0
- package/dist/layouts/index.d.ts +45 -0
- package/dist/layouts/index.js +1 -0
- package/dist/middleware/index.d.ts +382 -0
- package/dist/middleware/index.js +1 -0
- package/dist/packem_shared/MemoryDigestStore-Bw-sE5MI.js +1 -0
- package/dist/packem_shared/MemoryEventStore-BGD_xRxu.js +1 -0
- package/dist/packem_shared/MemoryInAppStore-48qlrDCx.js +1 -0
- package/dist/packem_shared/MemoryQueue-CXgWoZoY.js +1 -0
- package/dist/packem_shared/Notification-B22tuJPy.js +1 -0
- package/dist/packem_shared/NotificationError-DVfMJQ1u.js +1 -0
- package/dist/packem_shared/NotificationMessageBuilder-Br_aZusY.js +1 -0
- package/dist/packem_shared/RequiredOptionError-CuL42XRq.js +1 -0
- package/dist/packem_shared/UnstorageDigestStore-QAcO3Vb_.js +1 -0
- package/dist/packem_shared/UnstorageInAppStore-Bq2LoDMO.js +1 -0
- package/dist/packem_shared/apnsProvider-C9WSv5sc.js +1 -0
- package/dist/packem_shared/circuitBreakerMiddleware-BlZN7SVT.js +1 -0
- package/dist/packem_shared/composeMiddleware-D6dR8DUS.js +1 -0
- package/dist/packem_shared/createDigester-vMNPejGF.js +1 -0
- package/dist/packem_shared/createNotificationWorkflow-B70OgeED.js +1 -0
- package/dist/packem_shared/createQueueWorker-DjQBxjXc.js +1 -0
- package/dist/packem_shared/createTranslator-CY91C2eS.js +1 -0
- package/dist/packem_shared/credentials-CG0zkn-W.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-CQmPJd_h.js +1 -0
- package/dist/packem_shared/defineLayout-73TNxYPq.js +1 -0
- package/dist/packem_shared/defineProvider-C9q-7iwt.js +1 -0
- package/dist/packem_shared/discordProvider-ewPfe-J7.js +1 -0
- package/dist/packem_shared/emailChannel-CNDlX96Q.js +1 -0
- package/dist/packem_shared/expoProvider-CXq101FD.js +1 -0
- package/dist/packem_shared/failoverProvider-D1dAmW8U.js +1 -0
- package/dist/packem_shared/fcmProvider-WdJGZ55l.js +1 -0
- package/dist/packem_shared/getHeader-C_gkdnMQ.js +1 -0
- package/dist/packem_shared/hmacBase64-BhhoX0uo.js +1 -0
- package/dist/packem_shared/http-BMYcUNBU.js +1 -0
- package/dist/packem_shared/id-C_FRCsUM.js +1 -0
- package/dist/packem_shared/inAppProvider-ElbahgSj.js +1 -0
- package/dist/packem_shared/loggingMiddleware-Cs6EDLcL.js +1 -0
- package/dist/packem_shared/messageBirdProvider-CHUFB0hd.js +1 -0
- package/dist/packem_shared/mockProvider-BLwTZlkw.js +1 -0
- package/dist/packem_shared/msTeamsProvider-DBhrmuSd.js +1 -0
- package/dist/packem_shared/notification.d-DFCVTods.d.ts +104 -0
- package/dist/packem_shared/otelProvider-b6LVo0BS.js +1 -0
- package/dist/packem_shared/plivoProvider-CIOl6DWw.js +1 -0
- package/dist/packem_shared/provider.d-BQAGriz6.d.ts +33 -0
- package/dist/packem_shared/rateLimitMiddleware-DWmEYq-m.js +1 -0
- package/dist/packem_shared/retryMiddleware-uUJDcUoP.js +1 -0
- package/dist/packem_shared/roundRobinProvider-BetXJUUm.js +1 -0
- package/dist/packem_shared/slackProvider-N1wNtAZ3.js +1 -0
- package/dist/packem_shared/slackWebhook-GEx_GdcV.js +1 -0
- package/dist/packem_shared/sms-CU-OZvNU.js +1 -0
- package/dist/packem_shared/snsProvider-KCciJ-nj.js +4 -0
- package/dist/packem_shared/snsWebhook-ChZnBBT3.js +1 -0
- package/dist/packem_shared/standardWebhook-B-LxP8U7.js +1 -0
- package/dist/packem_shared/suppressionMiddleware-CY-Qo1A_.js +1 -0
- package/dist/packem_shared/telegramProvider-jqR5BhJL.js +1 -0
- package/dist/packem_shared/telemetryMiddleware-B1N4k171.js +1 -0
- package/dist/packem_shared/telnyxProvider-C8TMPir1.js +1 -0
- package/dist/packem_shared/tracer.d-Co1s_NwG.d.ts +494 -0
- package/dist/packem_shared/twilioProvider-BxI0e6LX.js +1 -0
- package/dist/packem_shared/twilioWebhook-F0mTmGXD.js +1 -0
- package/dist/packem_shared/types.d-67TogK4k.d.ts +33 -0
- package/dist/packem_shared/types.d-C1GoEAlI.d-Bv3grfyD.d.ts +83 -0
- package/dist/packem_shared/types.d-CximoA8M.d.ts +29 -0
- package/dist/packem_shared/types.d-GUzX1jTk.d.ts +235 -0
- package/dist/packem_shared/types.d-td-F2Oh0.d.ts +10 -0
- package/dist/packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.d.ts +120 -0
- package/dist/packem_shared/vonageProvider-BF76ca89.js +1 -0
- package/dist/packem_shared/webPushProvider-B962RwsA.js +1 -0
- package/dist/packem_shared/webcrypto-bY7wJCB5.js +1 -0
- package/dist/packem_shared/webhookProvider-BALSb2pc.js +1 -0
- package/dist/preferences/index.d.ts +49 -0
- package/dist/preferences/index.js +1 -0
- package/dist/providers/chat/discord/index.d.ts +14 -0
- package/dist/providers/chat/discord/index.js +1 -0
- package/dist/providers/chat/msteams/index.d.ts +14 -0
- package/dist/providers/chat/msteams/index.js +1 -0
- package/dist/providers/chat/slack/index.d.ts +19 -0
- package/dist/providers/chat/slack/index.js +1 -0
- package/dist/providers/chat/telegram/index.d.ts +18 -0
- package/dist/providers/chat/telegram/index.js +1 -0
- package/dist/providers/failover/index.d.ts +16 -0
- package/dist/providers/failover/index.js +1 -0
- package/dist/providers/mock/index.d.ts +29 -0
- package/dist/providers/mock/index.js +1 -0
- package/dist/providers/opentelemetry/index.d.ts +21 -0
- package/dist/providers/opentelemetry/index.js +1 -0
- package/dist/providers/push/apns/index.d.ts +24 -0
- package/dist/providers/push/apns/index.js +1 -0
- package/dist/providers/push/expo/index.d.ts +14 -0
- package/dist/providers/push/expo/index.js +1 -0
- package/dist/providers/push/fcm/index.d.ts +26 -0
- package/dist/providers/push/fcm/index.js +1 -0
- package/dist/providers/push/web-push/index.d.ts +36 -0
- package/dist/providers/push/web-push/index.js +1 -0
- package/dist/providers/roundrobin/index.d.ts +17 -0
- package/dist/providers/roundrobin/index.js +1 -0
- package/dist/providers/sms/messagebird/index.d.ts +16 -0
- package/dist/providers/sms/messagebird/index.js +1 -0
- package/dist/providers/sms/plivo/index.d.ts +18 -0
- package/dist/providers/sms/plivo/index.js +1 -0
- package/dist/providers/sms/sns/index.d.ts +21 -0
- package/dist/providers/sms/sns/index.js +1 -0
- package/dist/providers/sms/telnyx/index.d.ts +18 -0
- package/dist/providers/sms/telnyx/index.js +1 -0
- package/dist/providers/sms/twilio/index.d.ts +20 -0
- package/dist/providers/sms/twilio/index.js +1 -0
- package/dist/providers/sms/vonage/index.d.ts +18 -0
- package/dist/providers/sms/vonage/index.js +1 -0
- package/dist/providers/webhook/index.d.ts +18 -0
- package/dist/providers/webhook/index.js +1 -0
- package/dist/queue/bullmq-queue.d.ts +58 -0
- package/dist/queue/bullmq-queue.js +1 -0
- package/dist/queue/index.d.ts +50 -0
- package/dist/queue/index.js +1 -0
- package/dist/queue/pg-boss-queue.d.ts +66 -0
- package/dist/queue/pg-boss-queue.js +1 -0
- package/dist/queue/sqs-queue.d.ts +91 -0
- package/dist/queue/sqs-queue.js +1 -0
- package/dist/queue/unstorage-queue.d.ts +30 -0
- package/dist/queue/unstorage-queue.js +1 -0
- package/dist/routing/index.d.ts +35 -0
- package/dist/routing/index.js +1 -0
- package/dist/template-engines/handlebars.d.ts +16 -0
- package/dist/template-engines/handlebars.js +1 -0
- package/dist/template-engines/liquid.d.ts +16 -0
- package/dist/template-engines/liquid.js +1 -0
- package/dist/template-engines/string.d.ts +20 -0
- package/dist/template-engines/string.js +1 -0
- package/dist/utils/result.d.ts +54 -0
- package/dist/utils/result.js +1 -0
- package/dist/webhooks/index.d.ts +110 -0
- package/dist/webhooks/index.js +1 -0
- package/dist/workflow/index.d.ts +83 -0
- package/dist/workflow/index.js +1 -0
- package/package.json +283 -43
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as r}from"../../../packem_shared/expoProvider-CXq101FD.js";export{r as expoProvider};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { M as MaybePromise, d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface FcmConfig extends BaseConfig {
|
|
4
|
+
/**
|
|
5
|
+
* A static OAuth2 access token. Prefer {@link FcmConfig.getAccessToken} for tokens
|
|
6
|
+
* that expire. One of `accessToken` / `getAccessToken` is required.
|
|
7
|
+
*/
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
/** Override the API base URL. */
|
|
10
|
+
endpoint?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a fresh OAuth2 access token. Lets you plug in `google-auth-library` /
|
|
13
|
+
* `firebase-admin` without bundling Google's SDK or `node:crypto` — keeping the
|
|
14
|
+
* provider edge-safe.
|
|
15
|
+
*/
|
|
16
|
+
getAccessToken?: () => MaybePromise<string>;
|
|
17
|
+
/** Firebase project id. Required. */
|
|
18
|
+
projectId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Firebase Cloud Messaging provider (HTTP v1). Edge-safe — you supply the OAuth2 token
|
|
22
|
+
* (static or via `getAccessToken`), so no `node:crypto`/Google SDK is bundled.
|
|
23
|
+
* @see https://firebase.google.com/docs/cloud-messaging/send-message
|
|
24
|
+
*/
|
|
25
|
+
declare const fcmProvider: ProviderFactory<FcmConfig, PushPayload>;
|
|
26
|
+
export { type FcmConfig, fcmProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as f}from"../../../packem_shared/fcmProvider-WdJGZ55l.js";export{f as fcmProvider};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
/**
|
|
4
|
+
* A W3C Push API subscription. The `to` field of a push payload carries one of these
|
|
5
|
+
* (as an object, or its JSON string form) when targeting the web-push provider.
|
|
6
|
+
*/
|
|
7
|
+
interface PushSubscriptionLike {
|
|
8
|
+
/** The push service endpoint URL the encrypted payload is delivered to. */
|
|
9
|
+
endpoint: string;
|
|
10
|
+
/** The subscription's client public key (`p256dh`) and auth secret (`auth`), base64url. */
|
|
11
|
+
keys: {
|
|
12
|
+
auth: string;
|
|
13
|
+
p256dh: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface WebPushConfig extends BaseConfig {
|
|
17
|
+
/** Time-to-live in seconds the push service should retain the message (default 2419200). */
|
|
18
|
+
ttl?: number;
|
|
19
|
+
/** Default delivery urgency hint (`very-low` | `low` | `normal` | `high`). */
|
|
20
|
+
urgency?: "high" | "low" | "normal" | "very-low";
|
|
21
|
+
/** Application server private VAPID key (base64url, raw P-256 scalar `d`). */
|
|
22
|
+
vapidPrivateKey: string;
|
|
23
|
+
/** Application server public VAPID key (base64url, uncompressed P-256 point). */
|
|
24
|
+
vapidPublicKey: string;
|
|
25
|
+
/** VAPID `sub` claim — a `mailto:` or `https:` contact for the app server. */
|
|
26
|
+
vapidSubject: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Web Push provider (VAPID + RFC 8291 `aes128gcm`). Fully edge-safe — JWT signing and
|
|
30
|
+
* payload encryption run on Web Crypto (ECDSA/ECDH P-256, HKDF, AES-GCM); no `node:*`.
|
|
31
|
+
* The `to` target carries a Push API subscription (object or its JSON string form).
|
|
32
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8291
|
|
33
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8292
|
|
34
|
+
*/
|
|
35
|
+
declare const webPushProvider: ProviderFactory<WebPushConfig, PushPayload>;
|
|
36
|
+
export { type PushSubscriptionLike, type WebPushConfig, webPushProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"../../../packem_shared/webPushProvider-B962RwsA.js";export{o as webPushProvider};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface RoundRobinConfig {
|
|
4
|
+
/** When true, falls through to the next provider on failure (default true). */
|
|
5
|
+
failover?: boolean;
|
|
6
|
+
/** Provider id reported on results (default `"roundrobin"`). */
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wraps several same-channel providers and distributes sends across them in rotation.
|
|
11
|
+
* Optionally falls over to the next provider on failure.
|
|
12
|
+
* @param providers The providers to balance across.
|
|
13
|
+
* @param config Optional config.
|
|
14
|
+
* @returns A composite provider.
|
|
15
|
+
*/
|
|
16
|
+
declare const roundRobinProvider: <PayloadT extends BaseNotificationPayload>(providers: Provider<unknown, PayloadT>[], config?: RoundRobinConfig) => Provider<unknown, PayloadT>;
|
|
17
|
+
export { type RoundRobinConfig, roundRobinProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{roundRobinProvider as d}from"../../packem_shared/roundRobinProvider-BetXJUUm.js";export{d as roundRobinProvider};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface MessageBirdConfig extends BaseConfig {
|
|
4
|
+
/** MessageBird (Bird) access key. */
|
|
5
|
+
accessKey: string;
|
|
6
|
+
/** Override the API base URL. */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** Default originator (sender id or number). */
|
|
9
|
+
from?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* MessageBird (Bird) SMS provider. Sends to many recipients in one call.
|
|
13
|
+
* @see https://docs.bird.com/api/sms-messaging
|
|
14
|
+
*/
|
|
15
|
+
declare const messageBirdProvider: ProviderFactory<MessageBirdConfig, SmsPayload>;
|
|
16
|
+
export { type MessageBirdConfig, messageBirdProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"../../../packem_shared/messageBirdProvider-CHUFB0hd.js";export{a as messageBirdProvider};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface PlivoConfig extends BaseConfig {
|
|
4
|
+
/** Plivo Auth ID. */
|
|
5
|
+
authId: string;
|
|
6
|
+
/** Plivo Auth Token. */
|
|
7
|
+
authToken: string;
|
|
8
|
+
/** Override the API base URL. */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Default source number or sender id. */
|
|
11
|
+
from?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Plivo SMS provider. Sends to many recipients in one call (`dst` joined by `<`).
|
|
15
|
+
* @see https://www.plivo.com/docs/sms/api/message
|
|
16
|
+
*/
|
|
17
|
+
declare const plivoProvider: ProviderFactory<PlivoConfig, SmsPayload>;
|
|
18
|
+
export { type PlivoConfig, plivoProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"../../../packem_shared/plivoProvider-CIOl6DWw.js";export{e as plivoProvider};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface SnsConfig extends BaseConfig {
|
|
4
|
+
/** AWS access key id. */
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
/** Override the SNS endpoint (defaults to `https://sns.{region}.amazonaws.com/`). */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** AWS region (defaults to `us-east-1`). */
|
|
9
|
+
region?: string;
|
|
10
|
+
/** AWS secret access key. */
|
|
11
|
+
secretAccessKey: string;
|
|
12
|
+
/** Optional STS session token for temporary credentials. */
|
|
13
|
+
sessionToken?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* AWS SNS SMS provider. Edge-safe — signs the `Publish` action with Signature V4
|
|
17
|
+
* computed entirely via Web Crypto (HMAC-SHA256 + SHA-256), no `node:crypto`.
|
|
18
|
+
* @see https://docs.aws.amazon.com/sns/latest/api/API_Publish.html
|
|
19
|
+
*/
|
|
20
|
+
declare const snsProvider: ProviderFactory<SnsConfig, SmsPayload>;
|
|
21
|
+
export { type SnsConfig, snsProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"../../../packem_shared/snsProvider-KCciJ-nj.js";export{o as snsProvider};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface TelnyxConfig extends BaseConfig {
|
|
4
|
+
/** Telnyx API key (v2). */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** Override the API base URL. */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** Default sender phone number. */
|
|
9
|
+
from?: string;
|
|
10
|
+
/** Messaging profile id (alternative to `from`). */
|
|
11
|
+
messagingProfileId?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Telnyx SMS/MMS provider (v2 API). Edge-safe — `fetch` + Bearer auth.
|
|
15
|
+
* @see https://developers.telnyx.com/api/messaging/send-message
|
|
16
|
+
*/
|
|
17
|
+
declare const telnyxProvider: ProviderFactory<TelnyxConfig, SmsPayload>;
|
|
18
|
+
export { type TelnyxConfig, telnyxProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"../../../packem_shared/telnyxProvider-C8TMPir1.js";export{o as telnyxProvider};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface TwilioConfig extends BaseConfig {
|
|
4
|
+
/** Twilio Account SID. */
|
|
5
|
+
accountSid: string;
|
|
6
|
+
/** Twilio Auth Token. */
|
|
7
|
+
authToken: string;
|
|
8
|
+
/** Override the API base URL. */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Default sender phone number or Messaging Service SID. */
|
|
11
|
+
from?: string;
|
|
12
|
+
/** Use `MessagingServiceSid` instead of `From` when `from` looks like a service SID. */
|
|
13
|
+
messagingServiceSid?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Twilio SMS/MMS provider. Edge-safe — uses `fetch` + Basic auth, no Node built-ins.
|
|
17
|
+
* @see https://www.twilio.com/docs/sms/api/message-resource
|
|
18
|
+
*/
|
|
19
|
+
declare const twilioProvider: ProviderFactory<TwilioConfig, SmsPayload>;
|
|
20
|
+
export { type TwilioConfig, twilioProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"../../../packem_shared/twilioProvider-BxI0e6LX.js";export{e as twilioProvider};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface VonageConfig extends BaseConfig {
|
|
4
|
+
/** Vonage (Nexmo) API key. */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** Vonage (Nexmo) API secret. */
|
|
7
|
+
apiSecret: string;
|
|
8
|
+
/** Override the API base URL. */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Default sender id or phone number. */
|
|
11
|
+
from?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Vonage (Nexmo) SMS provider. Edge-safe — `fetch` + form auth.
|
|
15
|
+
* @see https://developer.vonage.com/en/api/sms
|
|
16
|
+
*/
|
|
17
|
+
declare const vonageProvider: ProviderFactory<VonageConfig, SmsPayload>;
|
|
18
|
+
export { type VonageConfig, vonageProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as r}from"../../../packem_shared/vonageProvider-BF76ca89.js";export{r as vonageProvider};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { d as BaseConfig, W as WebhookPayload } from "../../packem_shared/types.d-GUzX1jTk.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-BQAGriz6.js";
|
|
3
|
+
interface WebhookConfig extends BaseConfig {
|
|
4
|
+
/** Default headers merged into every request. */
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
/** Default HTTP method (default POST). */
|
|
7
|
+
method?: string;
|
|
8
|
+
/** Default target URL (overridable per payload). */
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generic outbound webhook provider. Edge-safe — `fetch` only. Useful for custom
|
|
13
|
+
* integrations and as a fan-out sink.
|
|
14
|
+
* @param config Optional config.
|
|
15
|
+
* @returns A webhook-channel provider.
|
|
16
|
+
*/
|
|
17
|
+
declare const webhookProvider: (config?: WebhookConfig) => Provider<WebhookConfig, WebhookPayload>;
|
|
18
|
+
export { type WebhookConfig, webhookProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{webhookProvider as e}from"../../packem_shared/webhookProvider-BALSb2pc.js";export{e as webhookProvider};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-DFCVTods.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-67TogK4k.js";
|
|
3
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
4
|
+
import "../packem_shared/types.d-GUzX1jTk.js";
|
|
5
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
6
|
+
/**
|
|
7
|
+
* A BullMQ job, narrowed to the members this adapter reads.
|
|
8
|
+
*/
|
|
9
|
+
interface BullmqJobLike {
|
|
10
|
+
attemptsMade: number;
|
|
11
|
+
data: unknown;
|
|
12
|
+
id?: string;
|
|
13
|
+
moveToDelayed: (timestamp: number) => Promise<unknown>;
|
|
14
|
+
remove: () => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The subset of a [BullMQ](https://docs.bullmq.io/) `Queue` this adapter uses. Typed structurally so
|
|
18
|
+
* the `bullmq` optional peer is never imported — pass a real `Queue` instance, which satisfies this.
|
|
19
|
+
*/
|
|
20
|
+
interface BullmqQueueLike {
|
|
21
|
+
add: (name: string, data: unknown, options?: {
|
|
22
|
+
delay?: number;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
id?: string;
|
|
25
|
+
}>;
|
|
26
|
+
count: () => Promise<number>;
|
|
27
|
+
getJob: (id: string) => Promise<BullmqJobLike | undefined>;
|
|
28
|
+
getNextJob: (token: string) => Promise<BullmqJobLike | undefined>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A {@link NotificationQueue} backed by [BullMQ](https://docs.bullmq.io/) (Redis).
|
|
32
|
+
*
|
|
33
|
+
* BullMQ is push-based: jobs are normally consumed by a BullMQ `Worker`. This adapter maps the
|
|
34
|
+
* pull-based reserve/ack model onto BullMQ's `getNextJob`-style primitives so it composes with the
|
|
35
|
+
* notification `QueueWorker`. Pass an already-configured `Queue` instance — `bullmq` is an optional
|
|
36
|
+
* peer dependency and is never instantiated here.
|
|
37
|
+
*
|
|
38
|
+
* Runtime: NODE ONLY (requires a Redis connection). Not Cloudflare Workers compatible.
|
|
39
|
+
*/
|
|
40
|
+
declare class BullMqQueue implements NotificationQueue {
|
|
41
|
+
#private;
|
|
42
|
+
constructor(queue: BullmqQueueLike, jobName?: string);
|
|
43
|
+
enqueue(message: NotificationMessage, options?: {
|
|
44
|
+
scheduledAt?: number;
|
|
45
|
+
}): Promise<string>;
|
|
46
|
+
reserve(): Promise<QueueJob | undefined>;
|
|
47
|
+
ack(id: string): Promise<void>;
|
|
48
|
+
retry(id: string, delayMs?: number): Promise<void>;
|
|
49
|
+
size(): Promise<number>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convenience factory for {@link BullMqQueue}.
|
|
53
|
+
* @param queue A configured BullMQ `Queue` instance (optional peer).
|
|
54
|
+
* @param jobName The name jobs are enqueued under.
|
|
55
|
+
* @returns A new {@link BullMqQueue}.
|
|
56
|
+
*/
|
|
57
|
+
declare const createBullMqQueue: (queue: BullmqQueueLike, jobName?: string) => BullMqQueue;
|
|
58
|
+
export { BullMqQueue, type BullmqJobLike, type BullmqQueueLike, createBullMqQueue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class s{#t;#e;constructor(e,t="notification"){this.#t=e,this.#e=t}async enqueue(e,t){let a;return t?.scheduledAt!==void 0&&(a=Math.max(0,t.scheduledAt-Date.now())),(await this.#t.add(this.#e,e,a===void 0?void 0:{delay:a})).id??""}async reserve(){const e=`notification-${String(Date.now())}`,t=await this.#t.getNextJob(e);if(t)return{attempts:t.attemptsMade+1,id:t.id??"",message:t.data,scheduledAt:0}}async ack(e){const t=await this.#t.getJob(e);t&&await t.remove()}async retry(e,t=0){const a=await this.#t.getJob(e);a&&await a.moveToDelayed(Date.now()+t)}async size(){return await this.#t.count()}}const n=(i,e)=>new s(i,e);export{s as BullMqQueue,n as createBullMqQueue};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export { BullMqQueue, createBullMqQueue } from "./bullmq-queue.js";
|
|
2
|
+
import { a as NotificationMessage, N as Notification } from "../packem_shared/notification.d-DFCVTods.js";
|
|
3
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-67TogK4k.js";
|
|
4
|
+
export { PgBossQueue, type PgBossQueueOptions, createPgBossQueue } from "./pg-boss-queue.js";
|
|
5
|
+
export { SqsQueue, type SqsQueueOptions, createSqsQueue } from "./sqs-queue.js";
|
|
6
|
+
import { c as Receipt } from "../packem_shared/types.d-GUzX1jTk.js";
|
|
7
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
8
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
9
|
+
/**
|
|
10
|
+
* In-process {@link NotificationQueue}. Suitable for single-instance apps, tests and the
|
|
11
|
+
* default worker; swap for the unstorage/BullMQ adapters for durability.
|
|
12
|
+
*/
|
|
13
|
+
declare class MemoryQueue implements NotificationQueue {
|
|
14
|
+
#private;
|
|
15
|
+
enqueue(message: NotificationMessage, options?: {
|
|
16
|
+
scheduledAt?: number;
|
|
17
|
+
}): string;
|
|
18
|
+
reserve(): QueueJob | undefined;
|
|
19
|
+
ack(id: string): void;
|
|
20
|
+
retry(id: string, delayMs?: number): void;
|
|
21
|
+
size(): number;
|
|
22
|
+
}
|
|
23
|
+
interface QueueWorkerOptions {
|
|
24
|
+
/** Backoff in ms given the attempt count (default exponential: 1s, 2s, 4s...). */
|
|
25
|
+
backoff?: (attempt: number) => number;
|
|
26
|
+
/** Maximum delivery attempts before a job is dropped (default 5). */
|
|
27
|
+
maxAttempts?: number;
|
|
28
|
+
/** Called when a job is dropped after exhausting attempts. */
|
|
29
|
+
onDrop?: (job: QueueJob, receipts: Receipt[]) => void;
|
|
30
|
+
/** Poll interval in ms when the queue is empty (default 1000). */
|
|
31
|
+
pollInterval?: number;
|
|
32
|
+
}
|
|
33
|
+
interface QueueWorker {
|
|
34
|
+
/** Processes all currently-due jobs, then resolves. */
|
|
35
|
+
drain: () => Promise<void>;
|
|
36
|
+
/** Starts the polling loop. */
|
|
37
|
+
start: () => void;
|
|
38
|
+
/** Stops the polling loop. */
|
|
39
|
+
stop: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a worker that reserves jobs from a queue and delivers them via a
|
|
43
|
+
* {@link Notification} facade, retrying with backoff and dropping after `maxAttempts`.
|
|
44
|
+
* @param queue The queue to drain.
|
|
45
|
+
* @param notification The facade used to deliver messages.
|
|
46
|
+
* @param options Behaviour tuning (max attempts, backoff curve, poll interval, drop hook).
|
|
47
|
+
* @returns A controllable worker.
|
|
48
|
+
*/
|
|
49
|
+
declare const createQueueWorker: (queue: NotificationQueue, notification: Notification, options?: QueueWorkerOptions) => QueueWorker;
|
|
50
|
+
export { MemoryQueue, type NotificationQueue, type QueueJob, type QueueWorker, type QueueWorkerOptions, createQueueWorker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BullMqQueue as r,createBullMqQueue as o}from"./bullmq-queue.js";import{default as Q}from"../packem_shared/MemoryQueue-CXgWoZoY.js";import{PgBossQueue as a,createPgBossQueue as f}from"./pg-boss-queue.js";import{SqsQueue as l,createSqsQueue as p}from"./sqs-queue.js";import{createQueueWorker as c}from"../packem_shared/createQueueWorker-DjQBxjXc.js";export{r as BullMqQueue,Q as MemoryQueue,a as PgBossQueue,l as SqsQueue,o as createBullMqQueue,f as createPgBossQueue,c as createQueueWorker,p as createSqsQueue};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-DFCVTods.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-67TogK4k.js";
|
|
3
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
4
|
+
import "../packem_shared/types.d-GUzX1jTk.js";
|
|
5
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
6
|
+
/**
|
|
7
|
+
* A pg-boss job fetched with `includeMetadata`, narrowed to the members this adapter reads.
|
|
8
|
+
*/
|
|
9
|
+
interface PgBossJobLike {
|
|
10
|
+
data: unknown;
|
|
11
|
+
id: string;
|
|
12
|
+
/** pg-boss retry count (present when fetched with `includeMetadata`). */
|
|
13
|
+
retryCount?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The subset of a [pg-boss](https://github.com/timgit/pg-boss) instance this adapter uses (v10 API).
|
|
17
|
+
* Typed structurally so the `pg-boss` optional peer is never imported — pass a started `PgBoss` instance.
|
|
18
|
+
*/
|
|
19
|
+
interface PgBossLike {
|
|
20
|
+
complete: (name: string, id: string) => Promise<unknown>;
|
|
21
|
+
fail: (name: string, id: string) => Promise<unknown>;
|
|
22
|
+
fetch: (name: string, options?: {
|
|
23
|
+
batchSize?: number;
|
|
24
|
+
includeMetadata?: boolean;
|
|
25
|
+
}) => Promise<PgBossJobLike[] | PgBossJobLike | null>;
|
|
26
|
+
getQueueSize: (name: string) => Promise<number>;
|
|
27
|
+
send: (name: string, data: object, options?: {
|
|
28
|
+
startAfter?: Date;
|
|
29
|
+
}) => Promise<null | string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for {@link createPgBossQueue}.
|
|
33
|
+
*/
|
|
34
|
+
interface PgBossQueueOptions {
|
|
35
|
+
/** The pg-boss queue name. */
|
|
36
|
+
queueName: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A {@link NotificationQueue} backed by [pg-boss](https://github.com/timgit/pg-boss) (Postgres, v10 API).
|
|
40
|
+
*
|
|
41
|
+
* Pass a started pg-boss instance — `pg-boss` is an optional peer dependency and is never started here.
|
|
42
|
+
* `reserve` uses `fetch` with `includeMetadata`, so the job's `attempts` reflects pg-boss's own
|
|
43
|
+
* `retryCount`. `retry` calls `fail`, so the retry delay is governed by the queue's pg-boss retry policy
|
|
44
|
+
* rather than the `delayMs` argument.
|
|
45
|
+
*
|
|
46
|
+
* Runtime: NODE ONLY (requires a Postgres connection). Not Cloudflare Workers compatible.
|
|
47
|
+
*/
|
|
48
|
+
declare class PgBossQueue implements NotificationQueue {
|
|
49
|
+
#private;
|
|
50
|
+
constructor(boss: PgBossLike, options: PgBossQueueOptions);
|
|
51
|
+
enqueue(message: NotificationMessage, options?: {
|
|
52
|
+
scheduledAt?: number;
|
|
53
|
+
}): Promise<string>;
|
|
54
|
+
reserve(): Promise<QueueJob | undefined>;
|
|
55
|
+
ack(id: string): Promise<void>;
|
|
56
|
+
retry(id: string): Promise<void>;
|
|
57
|
+
size(): Promise<number>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Convenience factory for {@link PgBossQueue}.
|
|
61
|
+
* @param boss A started pg-boss instance (optional peer).
|
|
62
|
+
* @param options Queue options. See {@link PgBossQueueOptions}.
|
|
63
|
+
* @returns A new {@link PgBossQueue}.
|
|
64
|
+
*/
|
|
65
|
+
declare const createPgBossQueue: (boss: PgBossLike, options: PgBossQueueOptions) => PgBossQueue;
|
|
66
|
+
export { type PgBossJobLike, type PgBossLike, PgBossQueue, PgBossQueueOptions, createPgBossQueue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class i{#e;#t;constructor(e,t){this.#e=e,this.#t=t.queueName}async enqueue(e,t){const a=t?.scheduledAt===void 0?void 0:new Date(t.scheduledAt);return await this.#e.send(this.#t,e,a===void 0?{}:{startAfter:a})??""}async reserve(){const e=await this.#e.fetch(this.#t,{batchSize:1,includeMetadata:!0}),t=Array.isArray(e)?e[0]:e;if(t)return{attempts:t.retryCount??0,id:t.id,message:t.data,scheduledAt:0}}async ack(e){await this.#e.complete(this.#t,e)}async retry(e){await this.#e.fail(this.#t,e)}async size(){return await this.#e.getQueueSize(this.#t)}}const r=(s,e)=>new i(s,e);export{i as PgBossQueue,r as createPgBossQueue};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-DFCVTods.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-67TogK4k.js";
|
|
3
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
4
|
+
import "../packem_shared/types.d-GUzX1jTk.js";
|
|
5
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
6
|
+
/**
|
|
7
|
+
* A single SQS message, narrowed to the members this adapter reads.
|
|
8
|
+
*/
|
|
9
|
+
interface SqsMessageLike {
|
|
10
|
+
Attributes?: Record<string, string>;
|
|
11
|
+
Body?: string;
|
|
12
|
+
ReceiptHandle?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The subset of the high-level `@aws-sdk/client-sqs` `SQS` operations this adapter uses. The `SQS`
|
|
16
|
+
* class exposes these operation methods directly (unlike the command-based `SQSClient.send`), keeping
|
|
17
|
+
* the adapter mockable with plain method stubs and avoiding an import of the optional peer.
|
|
18
|
+
*/
|
|
19
|
+
interface SqsClientLike {
|
|
20
|
+
changeMessageVisibility: (input: {
|
|
21
|
+
QueueUrl: string;
|
|
22
|
+
ReceiptHandle: string;
|
|
23
|
+
VisibilityTimeout: number;
|
|
24
|
+
}) => Promise<unknown>;
|
|
25
|
+
deleteMessage: (input: {
|
|
26
|
+
QueueUrl: string;
|
|
27
|
+
ReceiptHandle: string;
|
|
28
|
+
}) => Promise<unknown>;
|
|
29
|
+
getQueueAttributes: (input: {
|
|
30
|
+
AttributeNames: string[];
|
|
31
|
+
QueueUrl: string;
|
|
32
|
+
}) => Promise<{
|
|
33
|
+
Attributes?: Record<string, string>;
|
|
34
|
+
}>;
|
|
35
|
+
receiveMessage: (input: {
|
|
36
|
+
AttributeNames?: string[];
|
|
37
|
+
MaxNumberOfMessages?: number;
|
|
38
|
+
QueueUrl: string;
|
|
39
|
+
VisibilityTimeout?: number;
|
|
40
|
+
WaitTimeSeconds?: number;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
Messages?: SqsMessageLike[];
|
|
43
|
+
}>;
|
|
44
|
+
sendMessage: (input: {
|
|
45
|
+
DelaySeconds?: number;
|
|
46
|
+
MessageBody: string;
|
|
47
|
+
QueueUrl: string;
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
MessageId?: string;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Options for {@link createSqsQueue}.
|
|
54
|
+
*/
|
|
55
|
+
interface SqsQueueOptions {
|
|
56
|
+
/** The SQS queue URL. */
|
|
57
|
+
queueUrl: string;
|
|
58
|
+
/** Visibility timeout (seconds) applied when reserving a message (default 30). */
|
|
59
|
+
visibilityTimeout?: number;
|
|
60
|
+
/** Long-poll wait time (seconds) for `reserve` (default 0). */
|
|
61
|
+
waitTimeSeconds?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A {@link NotificationQueue} backed by Amazon SQS, which maps natively onto the reserve/ack/retry
|
|
65
|
+
* model (ReceiveMessage / DeleteMessage / ChangeMessageVisibility).
|
|
66
|
+
*
|
|
67
|
+
* Pass an `@aws-sdk/client-sqs` `SQS` instance — it is an optional peer dependency and is never
|
|
68
|
+
* constructed here. The reserved job `id` is the SQS `ReceiptHandle`. `scheduledAt` is honored up to
|
|
69
|
+
* the SQS 15-minute delay limit.
|
|
70
|
+
*
|
|
71
|
+
* Runtime: NODE ONLY (depends on the AWS SDK). Not Cloudflare Workers compatible.
|
|
72
|
+
*/
|
|
73
|
+
declare class SqsQueue implements NotificationQueue {
|
|
74
|
+
#private;
|
|
75
|
+
constructor(client: SqsClientLike, options: SqsQueueOptions);
|
|
76
|
+
enqueue(message: NotificationMessage, options?: {
|
|
77
|
+
scheduledAt?: number;
|
|
78
|
+
}): Promise<string>;
|
|
79
|
+
reserve(): Promise<QueueJob | undefined>;
|
|
80
|
+
ack(id: string): Promise<void>;
|
|
81
|
+
retry(id: string, delayMs?: number): Promise<void>;
|
|
82
|
+
size(): Promise<number>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Convenience factory for {@link SqsQueue}.
|
|
86
|
+
* @param client An `@aws-sdk/client-sqs` `SQS` instance (optional peer).
|
|
87
|
+
* @param options Queue options. See {@link SqsQueueOptions}.
|
|
88
|
+
* @returns A new {@link SqsQueue}.
|
|
89
|
+
*/
|
|
90
|
+
declare const createSqsQueue: (client: SqsClientLike, options: SqsQueueOptions) => SqsQueue;
|
|
91
|
+
export { type SqsClientLike, type SqsMessageLike, SqsQueue, SqsQueueOptions, createSqsQueue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a="ApproximateNumberOfMessages",r="ApproximateNumberOfMessagesNotVisible",u=(s,e)=>{if(s===void 0)return 0;const t=Math.ceil((s-e)/1e3);return Math.max(0,t)};class n{#e;#t;#s;#i;constructor(e,t){this.#e=e,this.#t=t.queueUrl,this.#s=t.visibilityTimeout??30,this.#i=t.waitTimeSeconds??0}async enqueue(e,t){const i=u(t?.scheduledAt,Date.now());if(i>900)throw new RangeError(`SQS supports a maximum scheduling delay of ${String(900)}s (15 minutes); use a scheduler for longer delays`);return(await this.#e.sendMessage({DelaySeconds:i,MessageBody:JSON.stringify(e),QueueUrl:this.#t})).MessageId??""}async reserve(){const e=(await this.#e.receiveMessage({AttributeNames:["ApproximateReceiveCount"],MaxNumberOfMessages:1,QueueUrl:this.#t,VisibilityTimeout:this.#s,WaitTimeSeconds:this.#i})).Messages?.[0];if(!e?.ReceiptHandle)return;const t=Number(e.Attributes?.ApproximateReceiveCount??"1");let i;try{i=JSON.parse(e.Body??"{}")}catch{await this.#e.deleteMessage({QueueUrl:this.#t,ReceiptHandle:e.ReceiptHandle});return}return{attempts:Math.max(0,t-1),id:e.ReceiptHandle,message:i,scheduledAt:0}}async ack(e){await this.#e.deleteMessage({QueueUrl:this.#t,ReceiptHandle:e})}async retry(e,t=0){await this.#e.changeMessageVisibility({QueueUrl:this.#t,ReceiptHandle:e,VisibilityTimeout:Math.min(900,Math.max(0,Math.ceil(t/1e3)))})}async size(){const e=await this.#e.getQueueAttributes({AttributeNames:[a,r],QueueUrl:this.#t});return Number(e.Attributes?.[a]??0)+Number(e.Attributes?.[r]??0)}}const c=(s,e)=>new n(s,e);export{n as SqsQueue,c as createSqsQueue};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { S as Storage } from "../packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.js";
|
|
2
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-DFCVTods.js";
|
|
3
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-67TogK4k.js";
|
|
4
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
5
|
+
import "../packem_shared/types.d-GUzX1jTk.js";
|
|
6
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
7
|
+
/**
|
|
8
|
+
* A {@link NotificationQueue} backed by an [unstorage](https://unstorage.unjs.io) driver,
|
|
9
|
+
* giving durable, multi-backend persistence (Redis, filesystem, KV, ...). `unstorage` is
|
|
10
|
+
* an optional peer dependency — pass a configured `Storage` instance.
|
|
11
|
+
*/
|
|
12
|
+
declare class UnstorageQueue implements NotificationQueue {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(storage: Storage, prefix?: string);
|
|
15
|
+
enqueue(message: NotificationMessage, options?: {
|
|
16
|
+
scheduledAt?: number;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
reserve(): Promise<QueueJob | undefined>;
|
|
19
|
+
ack(id: string): Promise<void>;
|
|
20
|
+
retry(id: string, delayMs?: number): Promise<void>;
|
|
21
|
+
size(): Promise<number>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convenience factory for {@link UnstorageQueue}.
|
|
25
|
+
* @param storage A configured unstorage `Storage` instance.
|
|
26
|
+
* @param prefix Key prefix under which jobs are stored.
|
|
27
|
+
* @returns A new {@link UnstorageQueue}.
|
|
28
|
+
*/
|
|
29
|
+
declare const createUnstorageQueue: (storage: Storage, prefix?: string) => UnstorageQueue;
|
|
30
|
+
export { UnstorageQueue, createUnstorageQueue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as h}from"../packem_shared/id-C_FRCsUM.js";class c{#t;#e;constructor(t,s="notification:queue"){this.#t=t,this.#e=s}async enqueue(t,s){const e={attempts:0,id:h("job"),message:t,scheduledAt:s?.scheduledAt};return await this.#t.setItem(this.#s(e.id),e),await this.#n(e.id),e.id}async reserve(){const t=Date.now(),s=await this.#i();for(const e of s){const i=await this.#t.getItem(this.#s(e));if(i&&(i.scheduledAt??0)<=t)return i.attempts+=1,await this.#t.setItem(this.#s(e),i),await this.#a(s.filter(n=>n!==e)),i}}async ack(t){await this.#t.removeItem(this.#s(t))}async retry(t,s=0){const e=await this.#t.getItem(this.#s(t));e&&(e.scheduledAt=Date.now()+s,await this.#t.setItem(this.#s(t),e),await this.#n(t))}async size(){return(await this.#i()).length}#s(t){return`${this.#e}:job:${t}`}async#i(){return await this.#t.getItem(`${this.#e}:pending`)??[]}async#a(t){await this.#t.setItem(`${this.#e}:pending`,t)}async#n(t){const s=await this.#i();s.includes(t)||(s.push(t),await this.#a(s))}}const o=(a,t)=>new c(a,t);export{c as UnstorageQueue,o as createUnstorageQueue};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { C as ChannelPayloadMap, N as Notification, a as NotificationMessage } from "../packem_shared/notification.d-DFCVTods.js";
|
|
2
|
+
import { C as ChannelType, M as MaybePromise, c as Receipt } from "../packem_shared/types.d-GUzX1jTk.js";
|
|
3
|
+
import "../packem_shared/types.d-CximoA8M.js";
|
|
4
|
+
import "../packem_shared/provider.d-BQAGriz6.js";
|
|
5
|
+
/**
|
|
6
|
+
* A gate decides whether a channel should be attempted for a given payload. Use it for
|
|
7
|
+
* preferences, capability checks, send-windows or arbitrary conditions.
|
|
8
|
+
*/
|
|
9
|
+
type ChannelGate = (channel: ChannelType, payload: ChannelPayloadMap[ChannelType]) => MaybePromise<boolean>;
|
|
10
|
+
interface RouteOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Optional gate run before each channel send. Returning false skips the channel.
|
|
13
|
+
*/
|
|
14
|
+
gate?: ChannelGate;
|
|
15
|
+
/**
|
|
16
|
+
* `"best-of"` (default) sends in `order` and stops at the first success;
|
|
17
|
+
* `"all"` broadcasts to every present, gated channel in parallel.
|
|
18
|
+
*/
|
|
19
|
+
mode?: "all" | "best-of";
|
|
20
|
+
/**
|
|
21
|
+
* Channel priority order. Channels absent from the message are skipped; channels in
|
|
22
|
+
* the message but absent from `order` are appended in object order.
|
|
23
|
+
*/
|
|
24
|
+
order?: ChannelType[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Routes a multi-channel message across channels with a priority order and an optional
|
|
28
|
+
* gate. `"best-of"` stops at the first success (channel fallback); `"all"` broadcasts.
|
|
29
|
+
* @param notification The facade used to send.
|
|
30
|
+
* @param message The multi-channel message.
|
|
31
|
+
* @param options Routing options.
|
|
32
|
+
* @returns The receipts produced (one per attempted channel).
|
|
33
|
+
*/
|
|
34
|
+
declare const route: (notification: Notification, message: NotificationMessage, options?: RouteOptions) => Promise<Receipt[]>;
|
|
35
|
+
export { ChannelGate, RouteOptions, route };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i=(n,e)=>{const t=Object.keys(n);if(!e)return t;const r=e.filter(o=>t.includes(o)),l=t.filter(o=>!e.includes(o));return[...r,...l]},f=async(n,e,t={})=>{const r=t.mode??"best-of",l=i(e,t.order),o=[];for(const s of l){const c=e[s];t.gate&&!await t.gate(s,c)||o.push(s)}if(r==="all")return Promise.all(o.map(async s=>n.sendToChannel(s,e[s])));const a=[];for(const s of o){const c=await n.sendToChannel(s,e[s]);if(a.push(c),c.successful)break}return a};export{f as route};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { T as TemplateRenderer } from "../packem_shared/types.d-td-F2Oh0.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a [Handlebars](https://handlebarsjs.com/) template to a string.
|
|
4
|
+
*
|
|
5
|
+
* `handlebars` is an optional peer, loaded lazily so a missing install surfaces here
|
|
6
|
+
* as a {@link NotificationError} rather than at import time. Pure JS — edge-safe and
|
|
7
|
+
* runnable on Cloudflare Workers.
|
|
8
|
+
* @param template The Handlebars template string.
|
|
9
|
+
* @param data The data/variables exposed to the template.
|
|
10
|
+
* @param options Handlebars compile options.
|
|
11
|
+
* @returns The rendered string.
|
|
12
|
+
* @throws {TypeError} When the template is not a string.
|
|
13
|
+
* @throws {NotificationError} When `handlebars` is not installed or rendering fails.
|
|
14
|
+
*/
|
|
15
|
+
declare const renderHandlebars: TemplateRenderer;
|
|
16
|
+
export { renderHandlebars as default, renderHandlebars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../packem_shared/NotificationError-DVfMJQ1u.js";const d=async(a,n,s)=>{if(typeof a!="string")throw new TypeError("Handlebars template must be a string");let t;try{const e=await import("handlebars");t=e.default??e}catch(e){throw new r("handlebars","handlebars is not installed. Please install it: pnpm add handlebars",{cause:e})}try{return t.compile(a,s)(n??{})}catch(e){throw new r("handlebars",`Failed to render Handlebars template: ${e.message}`,{cause:e})}};export{d as default,d as renderHandlebars};
|