@visulima/notification 1.0.12 → 1.0.14
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 +14 -0
- package/dist/channels/email/index.js +1 -1
- package/dist/channels/inapp/index.js +1 -1
- package/dist/digest/index.js +1 -1
- package/dist/events/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/layouts/index.js +1 -1
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/MemoryDigestStore-BDavAEpi.js +1 -0
- package/dist/packem_shared/{MemoryInAppStore-48qlrDCx.js → MemoryInAppStore-B-j6qUql.js} +1 -1
- package/dist/packem_shared/MemoryQueue-6z5qeFnj.js +1 -0
- package/dist/packem_shared/Notification-BjqFrFwT.js +1 -0
- package/dist/packem_shared/NotificationError-tZsXfB7V.js +1 -0
- package/dist/packem_shared/NotificationMessageBuilder-InFFCs8J.js +1 -0
- package/dist/packem_shared/RequiredOptionError-CAuRlc0R.js +1 -0
- package/dist/packem_shared/UnstorageDigestStore-CmCl_gjY.js +1 -0
- package/dist/packem_shared/UnstorageInAppStore-ygHFsRM3.js +1 -0
- package/dist/packem_shared/apnsProvider-Dfgwt-6Z.js +1 -0
- package/dist/packem_shared/circuitBreakerMiddleware-B56jCgAH.js +1 -0
- package/dist/packem_shared/composeMiddleware-B3RCDFsy.js +1 -0
- package/dist/packem_shared/createDigester-g8Iqc2o3.js +1 -0
- package/dist/packem_shared/createNotificationWorkflow-C0ggMc1C.js +1 -0
- package/dist/packem_shared/createQueueWorker-BU-pYjrf.js +1 -0
- package/dist/packem_shared/createTranslator-DAi__AX0.js +1 -0
- package/dist/packem_shared/credentials-D9KXFoo0.js +1 -0
- package/dist/packem_shared/dedupeMiddleware-CRqssoJS.js +1 -0
- package/dist/packem_shared/defineLayout-BU6DLIGc.js +1 -0
- package/dist/packem_shared/discordProvider-B9rc2nrV.js +1 -0
- package/dist/packem_shared/emailChannel-CnmD8yb2.js +1 -0
- package/dist/packem_shared/expoProvider-DofT1sEf.js +1 -0
- package/dist/packem_shared/failoverProvider-CyYOOitI.js +1 -0
- package/dist/packem_shared/fcmProvider-86S6m7zk.js +1 -0
- package/dist/packem_shared/getHeader-BF9s-Tgp.js +1 -0
- package/dist/packem_shared/hmacBase64-Dtvoq4Ry.js +1 -0
- package/dist/packem_shared/http-YFt2eXXy.js +1 -0
- package/dist/packem_shared/id-FYdbBSpb.js +1 -0
- package/dist/packem_shared/inAppProvider-DWO4D6VN.js +1 -0
- package/dist/packem_shared/loggingMiddleware-BWgqUAe_.js +1 -0
- package/dist/packem_shared/messageBirdProvider-CnsBOuY6.js +1 -0
- package/dist/packem_shared/mockProvider-OaWdPlKU.js +1 -0
- package/dist/packem_shared/msTeamsProvider-BAgW_ba5.js +1 -0
- package/dist/packem_shared/otelProvider-DdnT7q6B.js +1 -0
- package/dist/packem_shared/plivoProvider-C27zpwI3.js +1 -0
- package/dist/packem_shared/rateLimitMiddleware-D5dvn-t9.js +1 -0
- package/dist/packem_shared/retryMiddleware-CxmRthT8.js +1 -0
- package/dist/packem_shared/roundRobinProvider-BrujhDY6.js +1 -0
- package/dist/packem_shared/{slackProvider-Caxbs4Pa.js → slackProvider-CP35fu9-.js} +1 -1
- package/dist/packem_shared/slackWebhook-CGbFBgpo.js +1 -0
- package/dist/packem_shared/{sms-BbxkOLQm.js → sms-CT04IxF8.js} +1 -1
- package/dist/packem_shared/snsProvider-BtlNUN7u.js +4 -0
- package/dist/packem_shared/snsWebhook-eOX1eh23.js +1 -0
- package/dist/packem_shared/standardWebhook-DV_fVNtX.js +1 -0
- package/dist/packem_shared/suppressionMiddleware-DsmnFP8W.js +1 -0
- package/dist/packem_shared/telegramProvider-CyaUiWkh.js +1 -0
- package/dist/packem_shared/telemetryMiddleware-CpyLbJHB.js +1 -0
- package/dist/packem_shared/telnyxProvider-M23jXIyu.js +1 -0
- package/dist/packem_shared/twilioProvider-CaoTEqz-.js +1 -0
- package/dist/packem_shared/twilioWebhook-DScQeZta.js +1 -0
- package/dist/packem_shared/vonageProvider-CYNivc-x.js +1 -0
- package/dist/packem_shared/webPushProvider-CUDMDRKw.js +1 -0
- package/dist/packem_shared/webcrypto-Cz40u9vp.js +1 -0
- package/dist/packem_shared/webhookProvider-C13EqjLL.js +1 -0
- package/dist/preferences/index.js +1 -1
- package/dist/providers/chat/discord/index.js +1 -1
- package/dist/providers/chat/msteams/index.js +1 -1
- package/dist/providers/chat/slack/index.js +1 -1
- package/dist/providers/chat/telegram/index.js +1 -1
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +1 -1
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/push/apns/index.js +1 -1
- package/dist/providers/push/expo/index.js +1 -1
- package/dist/providers/push/fcm/index.js +1 -1
- package/dist/providers/push/web-push/index.js +1 -1
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/sms/messagebird/index.js +1 -1
- package/dist/providers/sms/plivo/index.js +1 -1
- package/dist/providers/sms/sns/index.js +1 -1
- package/dist/providers/sms/telnyx/index.js +1 -1
- package/dist/providers/sms/twilio/index.js +1 -1
- package/dist/providers/sms/vonage/index.js +1 -1
- package/dist/providers/webhook/index.js +1 -1
- package/dist/queue/bullmq-queue.js +1 -1
- package/dist/queue/index.js +1 -1
- package/dist/queue/pg-boss-queue.js +1 -1
- package/dist/queue/sqs-queue.js +1 -1
- package/dist/queue/unstorage-queue.js +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/liquid.js +1 -1
- package/dist/template-engines/string.js +1 -1
- package/dist/utils/result.js +1 -1
- package/dist/webhooks/index.js +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.js +1 -1
- package/package.json +17 -17
- package/dist/packem_shared/MemoryDigestStore-Bw-sE5MI.js +0 -1
- package/dist/packem_shared/MemoryQueue-CXgWoZoY.js +0 -1
- package/dist/packem_shared/Notification-BuS_QjJv.js +0 -1
- package/dist/packem_shared/NotificationError-B1ZZqWxL.js +0 -1
- package/dist/packem_shared/NotificationMessageBuilder-Br_aZusY.js +0 -1
- package/dist/packem_shared/RequiredOptionError-CH4g-BZM.js +0 -1
- package/dist/packem_shared/UnstorageDigestStore-QAcO3Vb_.js +0 -1
- package/dist/packem_shared/UnstorageInAppStore-Bq2LoDMO.js +0 -1
- package/dist/packem_shared/apnsProvider-BV5-wOvD.js +0 -1
- package/dist/packem_shared/circuitBreakerMiddleware-o3G_6N3s.js +0 -1
- package/dist/packem_shared/composeMiddleware-D6dR8DUS.js +0 -1
- package/dist/packem_shared/createDigester-DCwWhmpi.js +0 -1
- package/dist/packem_shared/createNotificationWorkflow-lseG_9fC.js +0 -1
- package/dist/packem_shared/createQueueWorker-BIXWHJLY.js +0 -1
- package/dist/packem_shared/createTranslator-BL2M8eeD.js +0 -1
- package/dist/packem_shared/credentials-CG0zkn-W.js +0 -1
- package/dist/packem_shared/dedupeMiddleware-CQmPJd_h.js +0 -1
- package/dist/packem_shared/defineLayout-73TNxYPq.js +0 -1
- package/dist/packem_shared/discordProvider-D4LpBljj.js +0 -1
- package/dist/packem_shared/emailChannel-BoLLbyrn.js +0 -1
- package/dist/packem_shared/expoProvider-BPJr9c0e.js +0 -1
- package/dist/packem_shared/failoverProvider-CJsDGjzf.js +0 -1
- package/dist/packem_shared/fcmProvider-qIR12R9m.js +0 -1
- package/dist/packem_shared/getHeader-C_gkdnMQ.js +0 -1
- package/dist/packem_shared/hmacBase64-CNksyDoB.js +0 -1
- package/dist/packem_shared/http-DT3tyixg.js +0 -1
- package/dist/packem_shared/id-C_FRCsUM.js +0 -1
- package/dist/packem_shared/inAppProvider-ElbahgSj.js +0 -1
- package/dist/packem_shared/loggingMiddleware-Cs6EDLcL.js +0 -1
- package/dist/packem_shared/messageBirdProvider-FK9_UONf.js +0 -1
- package/dist/packem_shared/mockProvider-C2hHPSVa.js +0 -1
- package/dist/packem_shared/msTeamsProvider-DeGPjmCt.js +0 -1
- package/dist/packem_shared/otelProvider-b6LVo0BS.js +0 -1
- package/dist/packem_shared/plivoProvider-DaCu7J3X.js +0 -1
- package/dist/packem_shared/rateLimitMiddleware-DWmEYq-m.js +0 -1
- package/dist/packem_shared/retryMiddleware-uUJDcUoP.js +0 -1
- package/dist/packem_shared/roundRobinProvider-HowYifRe.js +0 -1
- package/dist/packem_shared/slackWebhook-IB4mVnBk.js +0 -1
- package/dist/packem_shared/snsProvider-BS4D6w-i.js +0 -4
- package/dist/packem_shared/snsWebhook-BKBTQyEW.js +0 -1
- package/dist/packem_shared/standardWebhook-C_AQWUi5.js +0 -1
- package/dist/packem_shared/suppressionMiddleware-CY-Qo1A_.js +0 -1
- package/dist/packem_shared/telegramProvider-BIc_GgpY.js +0 -1
- package/dist/packem_shared/telemetryMiddleware-B1N4k171.js +0 -1
- package/dist/packem_shared/telnyxProvider-wjmTXBwh.js +0 -1
- package/dist/packem_shared/twilioProvider-Bf_zsF9z.js +0 -1
- package/dist/packem_shared/twilioWebhook-Hhf9aWV1.js +0 -1
- package/dist/packem_shared/vonageProvider-oRg9dpS1.js +0 -1
- package/dist/packem_shared/webPushProvider-BtZHb_X_.js +0 -1
- package/dist/packem_shared/webcrypto-CFuQmh5-.js +0 -1
- package/dist/packem_shared/webhookProvider-CwkDb1cZ.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## @visulima/notification [1.0.14](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.13...%40visulima%2Fnotification%401.0.14) (2026-08-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/email:** upgraded to 3.0.0
|
|
7
|
+
|
|
8
|
+
## @visulima/notification [1.0.13](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.12...%40visulima%2Fnotification%401.0.13) (2026-08-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* **@visulima/email:** upgraded to 2.1.9
|
|
14
|
+
|
|
1
15
|
## @visulima/notification [1.0.12](https://github.com/visulima/visulima/compare/%40visulima%2Fnotification%401.0.11...%40visulima%2Fnotification%401.0.12) (2026-08-08)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{emailChannel as l}from"../../packem_shared/emailChannel-
|
|
1
|
+
import{emailChannel as l}from"../../packem_shared/emailChannel-CnmD8yb2.js";export{l as emailChannel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inAppProvider as e}from"../../packem_shared/inAppProvider-
|
|
1
|
+
import{inAppProvider as e}from"../../packem_shared/inAppProvider-DWO4D6VN.js";import{MemoryInAppStore as t}from"../../packem_shared/MemoryInAppStore-B-j6qUql.js";import{UnstorageInAppStore as m,createUnstorageInAppStore as A}from"../../packem_shared/UnstorageInAppStore-ygHFsRM3.js";export{t as MemoryInAppStore,m as UnstorageInAppStore,A as createUnstorageInAppStore,e as inAppProvider};
|
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-g8Iqc2o3.js";import{default as a}from"../packem_shared/MemoryDigestStore-BDavAEpi.js";import{default as f}from"../packem_shared/UnstorageDigestStore-CmCl_gjY.js";export{a as MemoryDigestStore,f as UnstorageDigestStore,r as createDigester};
|
package/dist/events/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as f}from"../packem_shared/MemoryEventStore-BGD_xRxu.js";class
|
|
1
|
+
import{default as f}from"../packem_shared/MemoryEventStore-BGD_xRxu.js";class r{#t=new Map;on(t,e){const s=this.#t.get(t)??new Set;return s.add(e),this.#t.set(t,s),()=>s.delete(e)}emit(t){for(const e of this.#t.get(t.type)??[])e(t);for(const e of this.#t.get("*")??[])e(t)}}export{f as MemoryEventStore,r as NotificationEventBus};
|
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-DAi__AX0.js";export{e as createTranslator};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"./packem_shared/NotificationError-
|
|
1
|
+
import{default as r}from"./packem_shared/NotificationError-tZsXfB7V.js";import{default as t}from"./packem_shared/RequiredOptionError-CAuRlc0R.js";import{composeMiddleware as f}from"./packem_shared/composeMiddleware-B3RCDFsy.js";import{Notification as c,createNotification as n,send as p}from"./packem_shared/Notification-BjqFrFwT.js";import{NotificationMessageBuilder as m,createNotificationMessage as x}from"./packem_shared/NotificationMessageBuilder-InFFCs8J.js";import{defineProvider as l}from"./packem_shared/defineProvider-C9q-7iwt.js";export{c as Notification,r as NotificationError,m as NotificationMessageBuilder,t as RequiredOptionError,f as composeMiddleware,n as createNotification,x as createNotificationMessage,l as defineProvider,p as send};
|
package/dist/layouts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as f}from"../packem_shared/defineLayout-
|
|
1
|
+
import{default as f}from"../packem_shared/defineLayout-BU6DLIGc.js";export{f as defineLayout};
|
package/dist/middleware/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-
|
|
1
|
+
import{circuitBreakerMiddleware as o}from"../packem_shared/circuitBreakerMiddleware-B56jCgAH.js";import{dedupeMiddleware as i}from"../packem_shared/dedupeMiddleware-CRqssoJS.js";import{loggingMiddleware as p}from"../packem_shared/loggingMiddleware-BWgqUAe_.js";import{rateLimitMiddleware as a}from"../packem_shared/rateLimitMiddleware-D5dvn-t9.js";import{retryMiddleware as f}from"../packem_shared/retryMiddleware-CxmRthT8.js";import{suppressionMiddleware as x}from"../packem_shared/suppressionMiddleware-DsmnFP8W.js";import{telemetryMiddleware as s}from"../packem_shared/telemetryMiddleware-CpyLbJHB.js";import{composeMiddleware as g}from"../packem_shared/composeMiddleware-B3RCDFsy.js";export{o as circuitBreakerMiddleware,g as composeMiddleware,i as dedupeMiddleware,p as loggingMiddleware,a as rateLimitMiddleware,f as retryMiddleware,x as suppressionMiddleware,s as telemetryMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class a{#e=new Map;append(e,t,o){const r=this.#e.get(e);return r===void 0?(this.#e.set(e,{events:[t],key:e,wakeAt:o}),Promise.resolve(!0)):(r.events.push(t),Promise.resolve(!1))}read(e){return Promise.resolve(this.#e.get(e))}remove(e){return this.#e.delete(e),Promise.resolve()}due(e,t){const r=[...this.#e.values()].filter(s=>s.wakeAt<=e).toSorted((s,i)=>s.wakeAt-i.wakeAt).slice(0,t).map(s=>s.key);return Promise.resolve(r)}}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as a}from"./id-FYdbBSpb.js";class l{#e=new Map;add(r){const e={...r,createdAt:Date.now(),id:r.id??a("inapp"),read:!1};return this.#e.set(e.id,e),Promise.resolve(e)}list(r,e={}){let t=[...this.#e.values()].filter(s=>s.subscriberId===r);return e.unreadOnly&&(t=t.filter(s=>!s.read)),t.sort((s,i)=>i.createdAt-s.createdAt),Promise.resolve(e.limit?t.slice(0,e.limit):t)}markRead(r){const e=this.#e.get(r);return e&&(e.read=!0),Promise.resolve()}markAllRead(r){for(const e of this.#e.values())e.subscriberId===r&&(e.read=!0);return Promise.resolve()}unreadCount(r){let e=0;for(const t of this.#e.values())t.subscriberId===r&&!t.read&&(e+=1);return Promise.resolve(e)}remove(r){return this.#e.delete(r),Promise.resolve()}}export{l as MemoryInAppStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as r}from"./id-FYdbBSpb.js";class o{#e=[];#t=new Map;enqueue(t,s){const e={attempts:0,id:r("job"),message:t,scheduledAt:s?.scheduledAt};return this.#e.push(e),e.id}reserve(){const t=Date.now(),s=this.#e.findIndex(n=>(n.scheduledAt??0)<=t);if(s===-1)return;const e=this.#e.splice(s,1)[0];return e.attempts+=1,this.#t.set(e.id,e),e}ack(t){this.#t.delete(t)}retry(t,s=0){const e=this.#t.get(t);e&&(this.#t.delete(t),e.scheduledAt=Date.now()+s,this.#e.push(e))}size(){return this.#e.length}}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./NotificationError-tZsXfB7V.js";import{composeMiddleware as f}from"./composeMiddleware-B3RCDFsy.js";const c=(i,s,t)=>{if(i.success&&i.data)return{channel:s,messageId:i.data.messageId,provider:i.data.provider??t,response:i.data.response,successful:!0,timestamp:i.data.timestamp};const{error:e}=i;let r;return e instanceof Error?r=e.message:e==null?r="Unknown error":typeof e=="string"?r=e:r=JSON.stringify(e),{channel:s,errorMessages:[r],provider:t,successful:!1}};class d{#s;#t=[];#e=new Map;#i;constructor(s){this.#s=s}use(s){return this.#t.push(s),this}setLogger(s){return this.#i=s,this}getProvider(s){return this.#s[s]}async sendToChannel(s,t){const e=this.#s[s];if(!e)return{channel:s,errorMessages:[`No provider registered for channel "${s}"`],successful:!1};try{await this.#r(e)}catch(a){return c({error:a,success:!1},s,e.id)}const r=async a=>e.send(a.payload),n=f(this.#t,r);try{const a=await n({channel:s,payload:t,provider:e.id});return c(a,s,e.id)}catch(a){return c({error:a,success:!1},s,e.id)}}async send(s){const t=Object.keys(s);if(t.length===0)throw new u("notification","send() called with an empty message");return Promise.all(t.map(async e=>this.sendToChannel(e,s[e])))}async*sendMany(s,t={}){const e=Math.max(1,t.concurrency??10),r=[...s];let n=0;for(;n<r.length;){const a=r.slice(n,n+e);n+=e;const l=await Promise.all(a.map(async o=>this.send(o)));for(const o of l)yield o}}async initialize(){await Promise.all(Object.values(this.#s).map(async s=>this.#r(s)))}async shutdown(){await Promise.all(Object.values(this.#s).map(async s=>{const{shutdown:t}=s;t&&await t()}))}async#r(s){const t=this.#e.get(s.id);if(t){await t;return}const e=(async()=>{await s.initialize(),this.#i?.debug(`[@visulima/notification] initialized provider "${s.id}"`)})();this.#e.set(s.id,e);try{await e}catch(r){throw this.#e.delete(s.id),r}}}const y=i=>new d(i),w=async(i,s,t)=>new d({[i]:s}).sendToChannel(i,t);export{d as Notification,y as createNotification,w as send};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class n extends Error{loc;title;hint;type="VisulimaError";constructor({cause:t,hint:i,location:s,message:a,name:c,stack:o,title:r}){super(a,{cause:t}),this.title=r,this.name=c,this.stack=o??this.stack,this.loc=s,this.hint=i}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}class h extends n{component;code;constructor(t,i,s){super({cause:s?.cause,hint:s?.hint,message:`[@visulima/notification] [${t}] ${i}`,name:"NotificationError",title:`Notification ${t} Error`}),this.component=t,this.code=s?.code}}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class o{#t={};#e;#s;sms(t){return this.#t.sms=t,this}push(t){return this.#t.push=t,this}chat(t){return this.#t.chat=t,this}inApp(t){return this.#t.inapp=t,this}webhook(t){return this.#t.webhook=t,this}email(t){return this.#t.email=t,this}metadata(t){return this.#e=t,this}idempotencyKey(t){return this.#s=t,this}build(){const t=this.#e,s=this.#s;if(t===void 0&&s===void 0)return{...this.#t};const i={},h=Object.keys(this.#t);for(const n of h){const a=this.#t[n];if(a!==void 0){const e={};t!==void 0&&(e.metadata=t),s!==void 0&&(e.idempotencyKey=s),Object.assign(e,a),i[n]=e}}return i}}const c=()=>new o;export{o as NotificationMessageBuilder,c as createNotificationMessage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"./NotificationError-tZsXfB7V.js";class n extends s{constructor(o,r){const e=Array.isArray(r)?`Missing required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Missing required option: '${r}'`;super(o,e,{hint:Array.isArray(r)?`Please provide the following required options: ${r.map(i=>`'${i}'`).join(", ")}`:`Please provide the required option: '${r}'`}),this.name="RequiredOptionError"}}export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s="digest:w:";class c{#t;constructor(t){this.#t=t}async append(t,a,i){const n=await this.#t.getItem(s+t);return n!==null?(n.events.push(a),await this.#t.setItem(s+t,n),!1):(await this.#t.setItem(s+t,{events:[a],key:t,wakeAt:i}),!0)}async read(t){return await this.#t.getItem(s+t)??void 0}async remove(t){await this.#t.removeItem(s+t)}async due(t,a){const i=await this.#t.getKeys(s);return(await Promise.all(i.map(async e=>this.#t.getItem(e)))).filter(e=>e!==null&&e.wakeAt<=t).toSorted((e,o)=>e.wakeAt-o.wakeAt).slice(0,a).map(e=>e.key)}}export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as d}from"./id-FYdbBSpb.js";class h{#t;#i;constructor(t,e="notification:inapp"){this.#t=t,this.#i=e}async add(t){const e={...t,createdAt:Date.now(),id:t.id??d("inapp"),read:!1};return await this.#t.setItem(this.#e(e.id),e),await this.#n(e.subscriberId,e.id),e}async list(t,e={}){const s=await this.#r(t),a=(e.unreadOnly?s.filter(r=>!r.read):s).toSorted((r,c)=>c.createdAt-r.createdAt);return e.limit?a.slice(0,e.limit):a}async markRead(t){const e=await this.#t.getItem(this.#e(t));e&&(e.read=!0,await this.#t.setItem(this.#e(t),e))}async markAllRead(t){const e=await this.#s(t);await Promise.all(e.map(async s=>this.markRead(s)))}async unreadCount(t){return(await this.#r(t)).filter(s=>!s.read).length}async remove(t){const e=await this.#t.getItem(this.#e(t));await this.#t.removeItem(this.#e(t)),e&&await this.#c(e.subscriberId,t)}#e(t){return`${this.#i}:item:${t}`}#a(t){return`${this.#i}:index:${t}`}async#s(t){return await this.#t.getItem(this.#a(t))??[]}async#r(t){const e=await this.#s(t);return(await Promise.all(e.map(async i=>await this.#t.getItem(this.#e(i))))).filter(i=>i!==null)}async#n(t,e){const s=await this.#s(t);s.includes(e)||(s.push(e),await this.#t.setItem(this.#a(t),s))}async#c(t,e){const i=(await this.#s(t)).filter(a=>a!==e);await this.#t.setItem(this.#a(t),i)}}const m=(n,t)=>new h(n,t);export{h as UnstorageInAppStore,m as createUnstorageInAppStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as w}from"node:module";import l from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as N}from"./defineProvider-C9q-7iwt.js";import{t as R}from"./credentials-D9KXFoo0.js";import{a as $}from"./sms-CT04IxF8.js";let O;const I=n=>(O??=w(import.meta.url))(n),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,i]=f.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return f.getBuiltinModule(n)}return I(n)},{sign:v,createPrivateKey:P}=b("node:crypto"),{connect:K}=b("node:http2"),j="https://api.push.apple.com",k="https://api.sandbox.push.apple.com",q=3e3*1e3,B=200,h=n=>Buffer.from(n,"utf8").toString("base64url"),E=(n,t,i)=>{const g=h(JSON.stringify({alg:"ES256",kid:n.keyId,typ:"JWT"})),u=h(JSON.stringify({iat:i,iss:n.teamId})),p=`${g}.${u}`,s=v("sha256",Buffer.from(p,"utf8"),{dsaEncoding:"ieee-p1363",key:t}).toString("base64url");return`${p}.${s}`},z=N(n=>{const t=n??{};if(!t.teamId)throw new l("apns","teamId");if(!t.keyId)throw new l("apns","keyId");if(!t.signingKey)throw new l("apns","signingKey");if(!t.bundleId)throw new l("apns","bundleId");const i=t.production?j:k;let g,u,p=0,s;const T=()=>(g??=P({format:"pem",key:t.signingKey}),g),y=()=>{const e=Date.now();return(!u||e-p>q)&&(u=E(t,T(),Math.floor(e/1e3)),p=e),u},_=()=>((!s||s.closed||s.destroyed)&&(s=K(i),s.on("error",e=>{t.logger?.warn(`[@visulima/notification] [apns] HTTP/2 session error: ${e.message}`)})),s),S=async(e,m)=>new Promise(a=>{const r=_().request({":method":"POST",":path":`/3/device/${e}`,"apns-topic":t.bundleId,authorization:`bearer ${y()}`,"content-type":"application/json"});let c=0,d="";r.setEncoding("utf8"),r.on("response",o=>{c=o[":status"]??0}),r.on("data",o=>{d+=o}),r.on("error",o=>{a({error:o.message,id:e,status:"failed"})}),r.on("end",()=>{if(c===B){a({id:e,messageId:e,status:"sent"});return}let o=`HTTP ${String(c)}`;if(d)try{o=JSON.parse(d).reason??o}catch{o=d}a({error:o,id:e,status:"failed"})}),r.end(m)});return{channel:"push",endpoint:i,features:{batchSending:!1,media:!0,richContent:!0},id:"apns",initialize:()=>{},isAvailable:()=>!0,options:t,send:async e=>{const m=R(e.to),a={alert:{body:e.body,title:e.title}};e.sound!==void 0&&(a.sound=e.sound),e.badge!==void 0&&(a.badge=e.badge);const r=JSON.stringify({...e.data,aps:a}),c=[];for(const d of m)c.push(await S(d,r));return $("push","apns",c)},shutdown:()=>{s&&!s.closed&&s.close(),s=void 0}}});export{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"./NotificationError-tZsXfB7V.js";const f=(t={})=>{const c=t.threshold??5,n=t.resetTimeout??3e4;let r=0,o=0,e="closed";return async(s,l)=>{if(e==="open")if(Date.now()-o>=n)e="half-open";else return{error:new a("circuit-breaker",`Circuit open for "${s.provider}"`),success:!1};const i=await l(s);return i.success?(r=0,e="closed"):(r+=1,r>=c&&(e="open",o=Date.now())),i}};export{f as circuitBreakerMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const d=(o,t)=>{let e=t;for(const r of o.toReversed()){const n=e;e=c=>r(c,n)}return e};export{d as composeMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"./NotificationError-tZsXfB7V.js";import m from"./MemoryDigestStore-BDavAEpi.js";const f={days:864e5,hours:36e5,milliseconds:1,minutes:6e4,ms:1,seconds:1e3,weeks:6048e5},l=async(e,t)=>{if(typeof e=="number"){if(!Number.isFinite(e))throw new o("digest",`Window must be a finite number of milliseconds. Received: ${String(e)}.`);return t+Math.max(0,e)}if("cron"in e){let a;try{a=await import("croner")}catch(n){throw new o("digest","croner is not installed (required for cron windows). Please install it: pnpm add croner",{cause:n})}const c=new a.Cron(e.cron,e.tz?{timezone:e.tz}:{}).nextRun(new Date(t));if(c===null)throw new o("digest",`Cron expression "${e.cron}" has no future occurrence.`);return c.getTime()}if(!Number.isFinite(e.amount))throw new o("digest",`Window amount must be a finite number. Received: ${String(e.amount)}.`);return t+Math.max(0,e.amount)*f[e.unit]},g=()=>globalThis.crypto.randomUUID(),y=e=>{const t=e.store??new m;return{add:async n=>{const r=e.key(n),u=typeof e.window=="function"?e.window(n):e.window,s={id:g(),payload:n,time:Date.now()};return t.append(r,s,await l(u,Date.now()))},sweep:async(n=Date.now(),r=100)=>{if(!Number.isInteger(r)||r<=0)throw new o("digest",`sweep limit must be a positive integer. Received: ${String(r)}.`);const u=await t.due(n,r);let s=0;for(const d of u){const i=await t.read(d);i!==void 0&&i.events.length>0&&(await e.onFlush(i.events,d),s+=1),i!==void 0&&await t.remove(d)}return s}}};export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineWorkflow as y}from"@visulima/workflow";import w from"./NotificationError-tZsXfB7V.js";const h=(t,p)=>{const l=o=>{const e=async(a,s,r,i)=>o.step(s,async()=>{if(i?.skip?await i.skip({payload:o.payload}):!1)return;const u=await r({payload:o.payload}),d=await t.sendToChannel(a,u);if(i?.throwOnFailure&&!d.successful)throw new w(a,d.errorMessages.join("; "));return d}),n={chat:(a,s,r)=>e("chat",a,s,r),custom:(a,s)=>o.step(a,s),delay:(a,s)=>o.sleep(a,s),email:(a,s,r)=>e("email",a,s,r),inApp:(a,s,r)=>e("inapp",a,s,r),push:(a,s,r)=>e("push",a,s,r),sms:(a,s,r)=>e("sms",a,s,r),webhook:(a,s,r)=>e("webhook",a,s,r)};return p.run({payload:o.payload,runId:o.runId,step:n})};return y({id:p.id,payload:p.payload,run:l,tags:p.tags})};export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=async e=>new Promise(c=>{setTimeout(c,e)}),d=(e,c,r={})=>{const l=r.maxAttempts??5,f=r.pollInterval??1e3,n=r.backoff??(t=>Math.min(3e4,1e3*2**(t-1)));let s=!1;const o=async()=>{const t=await e.reserve();if(!t)return!1;try{const a=await c.send(t.message);a.some(w=>!w.successful)?t.attempts>=l?(await e.ack(t.id),r.onDrop?.(t,a)):await e.retry(t.id,n(t.attempts)):await e.ack(t.id)}catch(a){r.onError?.(a,t);try{await e.retry(t.id,n(t.attempts))}catch(i){r.onError?.(i,t)}}return!0},m=async()=>{for(;s;){let t=!1;try{t=await o()}catch(a){r.onError?.(a)}t||await y(f)}};return{drain:async()=>{for(;await o(););},start:()=>{s||(s=!0,m().catch(()=>{s=!1}))},stop:()=>{s=!1}}};export{d as createQueueWorker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IntlMessageFormat as m}from"intl-messageformat";import g from"./NotificationError-tZsXfB7V.js";const d=/[-_]/u,f=a=>a.split(d)[0]??a,$=a=>{const c=new Map,n=(t,e)=>{for(const o of[t,f(t),a.fallbackLocale,f(a.fallbackLocale)]){const r=a.messages[o]?.[e];if(r!==void 0)return{locale:o,message:r}}};return{has:(t,e)=>n(t,e)!==void 0,translate:(t,e,o)=>{const r=n(t,e);if(r===void 0)return a.onMissing?a.onMissing(t,e):e;const l=`${r.locale}\0${e}`;let s=c.get(l);s===void 0&&(s=new m(r.message,r.locale.replaceAll("_","-")),c.set(l,s));try{return String(s.format(o))}catch(i){throw new g("i18n",`Failed to format message "${e}" for locale "${r.locale}": ${i.message}`,{cause:i})}}}};export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=(r,t)=>`Basic ${btoa(`${r}:${t}`)}`,a=r=>Array.isArray(r)?r:[r];export{s as b,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=(r={})=>{const i=r.ttl??6e4,s=new Map;return async(e,a)=>{const n=r.keyFn?r.keyFn(e):e.payload.idempotencyKey;if(!n)return a(e);const t=Date.now();for(const[c,u]of s)u<t&&s.delete(c);if(s.has(n))return{data:{channel:e.channel,messageId:`deduped:${n}`,provider:e.provider,sent:!1,timestamp:new Date},success:!0};const d=await a(e);return d.success&&s.set(n,t+i),d}};export{l as dedupeMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../template-engines/string.js";const c=e=>{const r=e.render??o,t=e.slot??"content";return{render:async(n,d={})=>r(e.template,{...d,[t]:n})}};export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"./NotificationError-tZsXfB7V.js";import c from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as u}from"./defineProvider-C9q-7iwt.js";import{r as l}from"./http-YFt2eXXy.js";import{g as h}from"./id-FYdbBSpb.js";const g=u(i=>{const e=i??{};if(!e.webhookUrl)throw new c("discord","webhookUrl");const a=e.retries??3,n=e.timeout??3e4,d=e.webhookUrl.includes("?")?`${e.webhookUrl}&wait=true`:`${e.webhookUrl}?wait=true`;return{channel:"chat",endpoint:e.webhookUrl,features:{batchSending:!1,richContent:!0},id:"discord",initialize:()=>{},isAvailable:()=>!!e.webhookUrl,options:e,send:async t=>{const o={content:t.text,embeds:t.blocks,username:e.username};t.threadId&&(o.thread_id=t.threadId);const r=await l(d,{body:JSON.stringify(o),headers:{"Content-Type":"application/json"},method:"POST",timeout:n},a);return!r.success||!r.data?{error:new s("discord",r.error instanceof Error?r.error.message:"Request failed"),success:!1}:r.data.status>=400?{error:new s("discord",r.data.body.message??`HTTP ${String(r.data.status)}`),success:!1}:{data:{channel:"chat",messageId:r.data.body.id??h("discord"),provider:"discord",sent:!0,timestamp:new Date},success:!0}},validateCredentials:()=>!!e.webhookUrl}});export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"./NotificationError-tZsXfB7V.js";const o=(a,r={})=>{const t=r.id??"email";return{channel:"email",features:{attachments:!0,batchSending:!0,richContent:!0,templates:!0,tracking:!0},id:t,initialize:()=>{},isAvailable:()=>!0,send:async s=>{const e=await a.send(s);return!e.success||!e.data?{error:new n(t,e.error instanceof Error?e.error.message:"Email send failed",{cause:e.error}),success:!1}:{data:{channel:"email",messageId:e.data.messageId,provider:e.data.provider??t,response:e.data.response,sent:e.data.sent??!0,timestamp:e.data.timestamp??new Date},success:!0}}}};export{o as emailChannel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import c from"./NotificationError-tZsXfB7V.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{t as k}from"./credentials-D9KXFoo0.js";import{r as A}from"./http-YFt2eXXy.js";import{g as v}from"./id-FYdbBSpb.js";const w="https://exp.host",R=T(m=>{const t=m??{},u=t.endpoint??w,l=t.retries??3,g=t.timeout??3e4,h=`${u}/--/api/v2/push/send`;return{channel:"push",endpoint:u,features:{batchSending:!0,media:!0,richContent:!0},id:"expo",initialize:()=>{},isAvailable:()=>!0,options:t,send:async s=>{const d=k(s.to),x=d.map(r=>({badge:s.badge,body:s.body,data:s.data,sound:s.sound??"default",title:s.title,to:r})),p={"Content-Type":"application/json"};t.accessToken&&(p.Authorization=`Bearer ${t.accessToken}`);const e=await A(h,{body:JSON.stringify(x),headers:p,method:"POST",timeout:g},l);if(!e.success||!e.data)return{error:new c("expo",e.error instanceof Error?e.error.message:"Request failed"),success:!1};if(e.data.status>=400)return{error:new c("expo",`HTTP ${String(e.data.status)}`),success:!1};const i=e.data.body.data;let o;Array.isArray(i)?o=i:o=i?[i]:[];const a=d.map((r,b)=>{const n=o[b];return n?.status==="error"?{error:n.details?.error??n.message??"error",id:r,status:"failed"}:{id:r,messageId:n?.id,status:"sent"}}),f=a.filter(r=>r.status==="sent");return f.length===0?{error:new c("expo",a[0]?.error??"All tokens failed"),success:!1}:{data:{channel:"push",messageId:f[0]?.messageId??v("expo"),provider:"expo",recipients:a,sent:!0,timestamp:new Date},success:!0}}}});export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./NotificationError-tZsXfB7V.js";const m=(r,o={})=>{if(r.length===0)throw new t("failover","At least one provider is required");const a=o.id??"failover";return{channel:r[0].channel,id:a,initialize:async()=>{await Promise.all(r.map(async i=>i.initialize()))},isAvailable:async()=>(await Promise.all(r.map(async n=>n.isAvailable()))).some(Boolean),send:async i=>{const n=[];for(const s of r){const e=await s.send(i);if(e.success)return e;const l=e.error instanceof Error?e.error.message:String(e.error);n.push(`${s.id}: ${l}`),o.logger?.warn(`[@visulima/notification] [${a}] provider "${s.id}" failed, trying next`)}return{error:new t(a,`All ${String(r.length)} providers failed: ${n.join("; ")}`),success:!1}}}};export{m as failoverProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import g from"./NotificationError-tZsXfB7V.js";import c from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as l}from"./defineProvider-C9q-7iwt.js";import{t as h}from"./credentials-D9KXFoo0.js";import{r as T}from"./http-YFt2eXXy.js";import{a as b}from"./sms-CT04IxF8.js";const R=l(a=>{const e=a??{};if(!e.projectId)throw new c("fcm","projectId");if(!e.accessToken&&!e.getAccessToken)throw new c("fcm",["accessToken","getAccessToken"]);const n=e.endpoint??"https://fcm.googleapis.com",f=e.retries??3,d=e.timeout??3e4,m=`${n}/v1/projects/${e.projectId}/messages:send`,u=s=>{if(s)return Object.fromEntries(Object.entries(s).map(([r,o])=>[r,typeof o=="string"?o:JSON.stringify(o)]))},p=async(s,r,o)=>{const i={data:u(r.data),notification:{body:r.body,image:r.imageUrl,title:r.title},token:s},t=await T(m,{body:JSON.stringify({message:i}),headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},method:"POST",timeout:d},f);return!t.success||!t.data?{error:t.error instanceof Error?t.error.message:"Request failed",id:s,status:"failed"}:t.data.status>=400?{error:t.data.body.error?.message??`HTTP ${String(t.data.status)}`,id:s,status:"failed"}:{id:s,messageId:t.data.body.name,status:"sent"}};return{channel:"push",endpoint:n,features:{batchSending:!1,media:!0,richContent:!0},id:"fcm",initialize:()=>{},isAvailable:()=>!!(e.projectId&&(e.accessToken??e.getAccessToken)),options:e,send:async s=>{let r;try{r=e.getAccessToken?await e.getAccessToken():e.accessToken}catch(t){return{error:new g("fcm","Failed to obtain access token",{cause:t}),success:!1}}const o=h(s.to),i=[];for(const t of o)i.push(await p(t,s,r));return b("push","fcm",i)}}});export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=t=>{try{const r=JSON.parse(t);return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}catch{return}},a=(t,r)=>{const n=r.toLowerCase();for(const o of Object.keys(t))if(o.toLowerCase()===n){const e=t[o];return Array.isArray(e)?e[0]:e}};export{a as getHeader,s as tryParseObject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as s,h as o,a as i}from"./webcrypto-Cz40u9vp.js";const r=300,h=async(t,n,e)=>i(await o(t,n,e)),l=async(t,n,e)=>s(await o(t,n,e)),f=(t,n)=>{if(t.length!==n.length)return!1;let e=0;for(let a=0;a<t.length;a+=1)e|=(t.codePointAt(a)??0)^(n.codePointAt(a)??0);return e===0},m=(t,n)=>{if(t===void 0)return!1;const e=Number.parseInt(t,10);if(Number.isNaN(e))return!1;const a=Math.floor(Date.now()/1e3);return Math.abs(a-e)<=n};export{r as REPLAY_WINDOW_SECONDS,l as hmacBase64,h as hmacHex,m as isWithinReplayWindow,f as timingSafeEqual};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u=async(e,s={})=>{const c=new AbortController,n=s.timeout??3e4,a=setTimeout(()=>{c.abort()},n);try{const t=await fetch(e,{body:s.body,headers:s.headers,method:s.method??"GET",signal:c.signal}),r=await t.text();let o=r;if(r.length>0)try{o=JSON.parse(r)}catch{o=r}const l={};return t.headers.forEach((d,i)=>{l[i]=d}),{data:{body:o,headers:l,status:t.status,statusText:t.statusText},success:!0}}catch(t){return{error:t,success:!1}}finally{clearTimeout(a)}},h=e=>e===408||e===429||e>=500,m=async(e,s={},c=3,n=250)=>{let a=await u(e,s);for(let t=0;t<c;t+=1){if(!(!a.success||a.data!==void 0&&h(a.data.status)))return a;const o=n*2**t+Math.floor(Math.random()*n);await new Promise(l=>setTimeout(l,o)),a=await u(e,s)}return a};export{u as m,m as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let r=0;const n=t=>{r+=1;const o=globalThis.crypto;return o?.randomUUID?`${t}-${o.randomUUID()}`:`${t}-${String(r)}-${Math.floor(Math.random()*1e9).toString(36)}`};export{n as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MemoryInAppStore as s}from"./MemoryInAppStore-B-j6qUql.js";const o=(e={})=>{const n=e.id??"inapp",r=e.store??new s;return{channel:"inapp",features:{richContent:!0},getInstance:()=>r,id:n,initialize:()=>{},isAvailable:()=>!0,send:async t=>{const i=await r.add({actions:t.actions,body:t.body,data:t.data,subscriberId:t.to,title:t.title});return{data:{channel:"inapp",messageId:i.id,provider:n,sent:!0,timestamp:new Date(i.createdAt)},success:!0}}}};export{o as inAppProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=(s={})=>{const e=s.logger??console;return async(r,a)=>{e.debug(`[@visulima/notification] sending via "${r.provider}" (${r.channel})`);const i=await a(r);if(i.success)e.debug(`[@visulima/notification] sent ${i.data?.messageId??""} via "${r.provider}"`);else{const n=i.error instanceof Error?i.error.message:String(i.error);e.warn(`[@visulima/notification] send failed via "${r.provider}": ${n}`)}return i}};export{o as loggingMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./NotificationError-tZsXfB7V.js";import g from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as l}from"./defineProvider-C9q-7iwt.js";import{t as b}from"./credentials-D9KXFoo0.js";import{r as y}from"./http-YFt2eXXy.js";import{b as h}from"./sms-CT04IxF8.js";const v="https://rest.messagebird.com",S=l(n=>{const e=n??{};if(!e.accessKey)throw new g("messagebird","accessKey");const i=e.endpoint??v,c=e.retries??3,d=e.timeout??3e4,m=`${i}/messages`;return{channel:"sms",endpoint:i,features:{batchSending:!0,deliveryReceipts:!0,media:!1},id:"messagebird",initialize:()=>{},isAvailable:()=>!!e.accessKey,options:e,send:async r=>{const o=b(r.to),a=r.from??e.from;if(!a)return{error:new t("messagebird","Missing originator: provide `from` on the payload or provider config"),success:!1};const s=await y(m,{body:JSON.stringify({body:r.text,originator:a,recipients:o}),headers:{Authorization:`AccessKey ${e.accessKey}`,"Content-Type":"application/json"},method:"POST",timeout:d},c);if(!s.success||!s.data)return{error:new t("messagebird",s.error instanceof Error?s.error.message:"Request failed"),success:!1};if(s.data.status>=400)return{error:new t("messagebird",s.data.body.errors?.[0]?.description??`HTTP ${String(s.data.status)}`),success:!1};const u=s.data.body.id??"",f=o.map(p=>({id:p,messageId:u,status:"sent"}));return h("messagebird",f)},validateCredentials:()=>!!e.accessKey}});export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import l from"./NotificationError-tZsXfB7V.js";import{defineProvider as d}from"./defineProvider-C9q-7iwt.js";let a=0;const h=d((e={})=>{const t=[],s=e.channel??"sms",r=e.id??"mock",o={clear:()=>{t.length=0},last:()=>t.at(-1),sent:t};return{channel:s,getInstance:()=>o,id:r,initialize:()=>{},isAvailable:()=>!0,send:c=>{if(e.failWith!==void 0)return{error:new l(r,e.failWith),success:!1};a+=1;const n=new Date,i=`mock-${String(a)}`;return t.push({messageId:i,payload:c,timestamp:n}),{data:{channel:s,messageId:i,provider:r,sent:!0,timestamp:n},success:!0}},validateCredentials:()=>!0}});export{h as mockProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"./NotificationError-tZsXfB7V.js";import m from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as c}from"./defineProvider-C9q-7iwt.js";import{r as d}from"./http-YFt2eXXy.js";import{g as l}from"./id-FYdbBSpb.js";const w=c(o=>{const e=o??{};if(!e.webhookUrl)throw new m("msteams","webhookUrl");const a=e.retries??3,n=e.timeout??3e4;return{channel:"chat",endpoint:e.webhookUrl,features:{batchSending:!1,richContent:!0},id:"msteams",initialize:()=>{},isAvailable:()=>!!e.webhookUrl,options:e,send:async r=>{const i=r.blocks??{"@context":"https://schema.org/extensions","@type":"MessageCard",text:r.text},t=await d(e.webhookUrl,{body:JSON.stringify(i),headers:{"Content-Type":"application/json"},method:"POST",timeout:n},a);return!t.success||!t.data?{error:new s("msteams",t.error instanceof Error?t.error.message:"Request failed"),success:!1}:t.data.status>=400?{error:new s("msteams",`HTTP ${String(t.data.status)}: ${t.data.body}`),success:!1}:{data:{channel:"chat",messageId:l("msteams"),provider:"msteams",sent:!0,timestamp:new Date},success:!0}},validateCredentials:()=>!!e.webhookUrl}});export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a="notification.send";const i=(r,n={})=>{const{tracer:s}=n;return{...r,send:async o=>{if(!s)return r.send(o);const e=s.startSpan(a,{attributes:{"notification.channel":r.channel,"notification.provider":r.id}});try{const t=await r.send(o);if(!t.success){const c=t.error instanceof Error?t.error.message:String(t.error);e.setStatus({code:2,message:c})}return t}catch(t){throw e.recordException(t),e.setStatus({code:2,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}}}};export{i as otelProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"./NotificationError-tZsXfB7V.js";import d from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{b as I,t as b}from"./credentials-D9KXFoo0.js";import{r as w}from"./http-YFt2eXXy.js";import{b as y}from"./sms-CT04IxF8.js";const R="https://api.plivo.com",O=T(c=>{const t=c??{};if(!t.authId)throw new d("plivo","authId");if(!t.authToken)throw new d("plivo","authToken");const i=t.endpoint??R,p=t.retries??3,m=t.timeout??3e4,l=`${i}/v1/Account/${t.authId}/Message/`,f=I(t.authId,t.authToken);return{channel:"sms",endpoint:i,features:{batchSending:!0,deliveryReceipts:!0,media:!0},id:"plivo",initialize:()=>{},isAvailable:()=>!!(t.authId&&t.authToken),options:t,send:async o=>{const r=b(o.to),n=o.from??t.from;if(!n)return{error:new s("plivo","Missing sender: provide `from` on the payload or provider config"),success:!1};const e=await w(l,{body:JSON.stringify({dst:r.join("<"),src:n,text:o.text}),headers:{Authorization:f,"Content-Type":"application/json"},method:"POST",timeout:m},p);if(!e.success||!e.data)return{error:new s("plivo",e.error instanceof Error?e.error.message:"Request failed"),success:!1};if(e.data.status>=400)return{error:new s("plivo",e.data.body.error??`HTTP ${String(e.data.status)}`),success:!1};const{body:a}=e.data,h=a.message_uuid?.[0]??"",u=r.map((v,g)=>({id:v,messageId:a.message_uuid?.[g],status:"sent"}));return y("plivo",u.length>0?u:[{id:r[0]??"",messageId:h,status:"sent"}])},validateCredentials:()=>!!(t.authId&&t.authToken)}});export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=async t=>new Promise(e=>{setTimeout(e,t)}),r=t=>{const e=t.interval??1e3,a=Math.max(1,t.rate);let n=a,i=Date.now();const l=()=>{const s=Date.now(),c=s-i;n=Math.min(a,n+c/e*a),i=s};return async(s,c)=>{for(l();n<1;)await o(Math.ceil(e/a)),l();return n-=1,c(s)}};export{r as rateLimitMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=async e=>new Promise(a=>{setTimeout(a,e)}),y=(e={})=>{const a=e.retries??3,s=e.baseDelay??250;return async(l,c)=>{let r=await c(l);for(let t=0;t<a&&!r.success&&!(e.shouldRetry&&!e.shouldRetry(r.error));t+=1)await o(s*2**t+Math.floor(Math.random()*s)),r=await c(l);return r}};export{y as retryMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./NotificationError-tZsXfB7V.js";const w=(e,a={})=>{if(e.length===0)throw new u("roundrobin","At least one provider is required");const i=a.id??"roundrobin",f=a.failover??!0,h=e[0];let t=0;return{channel:h.channel,id:i,initialize:async()=>{await Promise.all(e.map(async r=>r.initialize()))},isAvailable:async()=>(await Promise.all(e.map(async o=>o.isAvailable()))).some(Boolean),send:async r=>{const o=t;t=(t+1)%e.length;const c=[],m=f?e.length:1;for(let s=0;s<m;s+=1){const l=e[(o+s)%e.length],n=await l.send(r);if(n.success)return n;c.push(`${l.id}: ${n.error instanceof Error?n.error.message:String(n.error)}`)}return{error:new u(i,`Send failed: ${c.join("; ")}`),success:!1}}}};export{w as roundRobinProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"./NotificationError-
|
|
1
|
+
import r from"./NotificationError-tZsXfB7V.js";import{defineProvider as p}from"./defineProvider-C9q-7iwt.js";import{r as m}from"./http-YFt2eXXy.js";import{g as d}from"./id-FYdbBSpb.js";const w="https://slack.com/api",I=p(h=>{const e=h??{};if(!e.token&&!e.webhookUrl)throw new r("slack","Provide either `token` (Web API) or `webhookUrl`",{hint:"Set one of token/webhookUrl in the provider config"});const n=e.endpoint??w,k=e.retries??3,u=e.timeout??3e4;return{channel:"chat",endpoint:n,features:{batchSending:!1,richContent:!0},id:"slack",initialize:()=>{},isAvailable:()=>!!(e.token??e.webhookUrl),options:e,send:async s=>{const o=!!e.webhookUrl,f=o?e.webhookUrl:`${n}/chat.postMessage`,i=s.to??e.defaultChannel;if(!o&&!i)return{error:new r("slack","Missing channel: provide `to` or `defaultChannel`"),success:!1};const c={blocks:s.blocks,text:s.text,thread_ts:s.threadId};o||(c.channel=i);const l={"Content-Type":"application/json"};o||(l.Authorization=`Bearer ${e.token??""}`);const t=await m(f,{body:JSON.stringify(c),headers:l,method:"POST",timeout:u},k);if(!t.success||!t.data)return{error:new r("slack",t.error instanceof Error?t.error.message:"Request failed"),success:!1};if(o){if(t.data.status>=400||t.data.body!=="ok"){const b=typeof t.data.body=="string"?t.data.body:JSON.stringify(t.data.body);return{error:new r("slack",`Webhook failed: ${b}`),success:!1}}return{data:{channel:"chat",messageId:d("slack"),provider:"slack",sent:!0,timestamp:new Date},success:!0}}const a=t.data.body;return a.ok?{data:{channel:"chat",messageId:a.ts??d("slack"),provider:"slack",response:a,sent:!0,timestamp:new Date},success:!0}:{error:new r("slack",a.error??"Slack API error"),success:!1}},validateCredentials:()=>!!(e.token??e.webhookUrl)}});export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isWithinReplayWindow as o,REPLAY_WINDOW_SECONDS as c,hmacHex as d,timingSafeEqual as l}from"./hmacBase64-Dtvoq4Ry.js";import{getHeader as r,tryParseObject as p}from"./getHeader-BF9s-Tgp.js";const f="X-Slack-Signature",m="X-Slack-Request-Timestamp",u={parse:s=>{const e=p(s);if(e===void 0)return;const t=e.event??e,i=typeof t.channel=="string"?t.channel:void 0,n=typeof t.ts=="string"?t.ts:"";return{channel:"chat",messageId:typeof e.event_id=="string"?e.event_id:n,provider:"slack",recipient:i,timestamp:new Date,type:"delivered"}},verify:async(s,e,t)=>{if(t.trim()==="")return!1;const i=r(e,f),n=r(e,m);if(i===void 0||n===void 0||!o(n,c))return!1;const a=await d(t,`v0:${n}:${s}`,"SHA-256");return l(`v0=${a}`,i)}};export{u as slackWebhook};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"./NotificationError-
|
|
1
|
+
import n from"./NotificationError-tZsXfB7V.js";const o=(t,e,s)=>{const r=s.filter(a=>a.status==="sent");return r.length===0?{error:new n(e,s[0]?.error??"All recipients failed"),success:!1}:{data:{channel:t,messageId:r[0]?.messageId??"",provider:e,recipients:s,sent:!0,timestamp:new Date},success:!0}},i=(t,e)=>o("sms",t,e),u=async(t,e)=>{const s=[];for(const r of t)s.push(await e(r));return s};export{o as a,i as b,u as s};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import H from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as K}from"./defineProvider-C9q-7iwt.js";import{t as T}from"./credentials-D9KXFoo0.js";import{r as $}from"./http-YFt2eXXy.js";import{g as E}from"./id-FYdbBSpb.js";import{s as x,b as z}from"./sms-CT04IxF8.js";import{a as w,g as I,u as c,i as g}from"./webcrypto-Cz40u9vp.js";const R="sns",C="us-east-1",D=/<Message>([\s\S]*?)<\/Message>/,q=/<MessageId>([\s\S]*?)<\/MessageId>/,v=t=>{const e=t.toISOString().replaceAll(/[:-]|\.\d{3}/g,"");return{amzDate:e,dateStamp:e.slice(0,8)}},O=async(t,e,o)=>{const i=await g(c(`AWS4${t}`),c(e)),m=await g(i,c(o)),d=await g(m,c(R));return g(d,c("aws4_request"))},P=t=>{const{pathname:e}=new URL(t);return e===""||e==="/"?"/":e.split("/").map(o=>encodeURIComponent(o).replaceAll("*","%2A").replaceAll("'","%27").replaceAll("(","%28").replaceAll(")","%29").replaceAll("!","%21")).join("/")},j=async(t,e,o,i,m)=>{const{amzDate:d,dateStamp:S}=v(new Date),p=w(await I(c(m))),a={"Content-Type":"application/x-www-form-urlencoded",host:o,"x-amz-content-sha256":p,"x-amz-date":d};t.sessionToken&&(a["x-amz-security-token"]=t.sessionToken);const r={};for(const[l,y]of Object.entries(a))r[l.toLowerCase()]=y.trim();const s=Object.keys(r).toSorted((l,y)=>l.localeCompare(y)),u=s.join(";"),A=s.map(l=>`${l}:${r[l]??""}
|
|
2
|
+
`).join(""),n=["POST",P(i),"",A,u,p].join(`
|
|
3
|
+
`),f=`${S}/${e}/${R}/aws4_request`,h=["AWS4-HMAC-SHA256",d,f,w(await I(c(n)))].join(`
|
|
4
|
+
`),M=await O(t.secretAccessKey,S,e),b=w(await g(M,c(h)));return a.Authorization=`AWS4-HMAC-SHA256 Credential=${t.accessKeyId}/${f}, SignedHeaders=${u}, Signature=${b}`,{headers:a,url:i}},W=K(t=>{const e=t??{};if(!e.accessKeyId||!e.secretAccessKey)throw new H("sns",["accessKeyId","secretAccessKey"]);const o=e.region??C,i=e.endpoint??`https://sns.${o}.amazonaws.com/`,{host:m}=new URL(i),d=e.retries??3,S=e.timeout??3e4,p=async(a,r)=>{const s=new URLSearchParams;s.set("Action","Publish"),s.set("Version","2010-03-31"),s.set("PhoneNumber",a),s.set("Message",r.text),r.from&&(s.set("MessageAttributes.entry.1.Name","AWS.SNS.SMS.SenderID"),s.set("MessageAttributes.entry.1.Value.DataType","String"),s.set("MessageAttributes.entry.1.Value.StringValue",r.from));const u=s.toString(),A=await j(e,o,m,i,u),n=await $(A.url,{body:u,headers:A.headers,method:"POST",timeout:S},d);if(!n.success||!n.data)return{error:n.error instanceof Error?n.error.message:"Request failed",id:a,status:"failed"};if(n.data.status>=400)return{error:D.exec(n.data.body)?.[1]??`HTTP ${String(n.data.status)}`,id:a,status:"failed"};const f=q.exec(n.data.body)?.[1];return{id:a,messageId:f??E("sns"),status:"sent"}};return{channel:"sms",endpoint:i,features:{batchSending:!1,deliveryReceipts:!1,media:!1,scheduling:!1},id:"sns",initialize:()=>{},isAvailable:()=>!!(e.accessKeyId&&e.secretAccessKey),options:e,send:async a=>{const r=await x(T(a.to),async s=>p(s,a));return z("sns",r)},validateCredentials:()=>!!(e.accessKeyId&&e.secretAccessKey)}});export{W as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tryParseObject as r}from"./getHeader-BF9s-Tgp.js";const o=s=>r(s),a={parse:s=>{const e=o(s);if(e?.Type===void 0)return;const i={type:e.Type};return e.Type==="SubscriptionConfirmation"||e.Type==="UnsubscribeConfirmation"?i.subscribeUrl=e.SubscribeURL:e.Message!==void 0&&(i.message=e.Message),{messageId:e.MessageId??"",metadata:i,provider:"sns",timestamp:e.Timestamp===void 0?new Date:new Date(e.Timestamp),type:"delivered"}},verify:()=>Promise.resolve(!1)};export{a as snsWebhook};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isWithinReplayWindow as m,REPLAY_WINDOW_SECONDS as w,hmacBase64 as E,hmacHex as h,timingSafeEqual as f}from"./hmacBase64-Dtvoq4Ry.js";import{getHeader as r,tryParseObject as v}from"./getHeader-BF9s-Tgp.js";const g="webhook-id",b="webhook-timestamp",A="webhook-signature",H=new Set(["bounced","clicked","delivered","failed","interacted","queued","read","sent"]),S=i=>{const e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.codePointAt(n)??0;return t},D={parse:i=>{const e=v(i);if(e===void 0)return;const t=typeof e.type=="string"?e.type:void 0,o=t!==void 0&&H.has(t)?t:"delivered";return{messageId:typeof e.id=="string"?e.id:"",provider:"standard-webhooks",recipient:typeof e.recipient=="string"?e.recipient:void 0,timestamp:new Date,type:o}},verify:async(i,e,t)=>{if(t.trim()==="")return!1;const n=r(e,g),o=r(e,b),a=r(e,A);if(n===void 0||o===void 0||a===void 0||!m(o,w))return!1;const d=t.startsWith("whsec_")?S(t.slice(6)):t,c=`${n}.${o}.${i}`,l=await E(d,c,"SHA-256"),u=await h(d,c,"SHA-256"),y=a.split(" ");for(const s of y){const p=s.includes(",")?s.split(",")[1]??"":s;if(f(l,p)||f(u,p))return!0}return!1}};export{D as standardWebhook};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=e=>typeof e=="string"?e:JSON.stringify(e),p=e=>{const{to:s}=e;if(s!=null)return Array.isArray(s)?s.map(r=>t(r)).join(","):t(s)},u=e=>{const s=e.resolveRecipient??p;return async(r,n)=>{const i=s(r.payload);return i===void 0?n(r):await e.isSuppressed(i,r.channel)?{data:{channel:r.channel,messageId:`suppressed:${i}`,provider:r.provider,sent:!1,timestamp:new Date},success:!0}:n(r)}};export{u as suppressionMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"./NotificationError-tZsXfB7V.js";import u from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as m}from"./defineProvider-C9q-7iwt.js";import{r as f}from"./http-YFt2eXXy.js";const p="https://api.telegram.org",y=m(i=>{const e=i??{};if(!e.botToken)throw new u("telegram","botToken");const o=e.endpoint??p,d=e.retries??3,c=e.timeout??3e4,l=`${o}/bot${e.botToken}/sendMessage`;return{channel:"chat",endpoint:o,features:{batchSending:!1,richContent:!0},id:"telegram",initialize:()=>{},isAvailable:()=>!!e.botToken,options:e,send:async s=>{const a=s.to??e.defaultChatId;if(a===void 0)return{error:new r("telegram","Missing chat id: provide `to` or `defaultChatId`"),success:!1};const n={chat_id:a,text:s.text};e.parseMode&&(n.parse_mode=e.parseMode);const t=await f(l,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST",timeout:c},d);return!t.success||!t.data?{error:new r("telegram",t.error instanceof Error?t.error.message:"Request failed"),success:!1}:t.data.body.ok?{data:{channel:"chat",messageId:String(t.data.body.result?.message_id??""),provider:"telegram",response:t.data.body,sent:!0,timestamp:new Date},success:!0}:{error:new r("telegram",t.data.body.description??`HTTP ${String(t.data.status)}`),success:!1}},validateCredentials:()=>!!e.botToken}});export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l="notification.send";const S=(d={})=>{const{meter:n,tracer:u}=d;let r,i;return n&&(r=n.createCounter("notification.send.count",{description:"Number of notification send attempts"}),i=n.createHistogram("notification.send.duration",{description:"Notification send duration in milliseconds",unit:"ms"})),async(s,f)=>{const e={"notification.channel":s.channel,"notification.provider":s.provider},o=u?.startSpan(l,{attributes:e}),c=Date.now();try{const t=await f(s),a=t.success?"success":"failure";if(!t.success&&o){const m=t.error instanceof Error?t.error.message:String(t.error);o.setStatus({code:2,message:m})}return r?.add(1,{...e,"notification.outcome":a}),i?.record(Date.now()-c,{...e,"notification.outcome":a}),t}catch(t){throw o&&(o.recordException(t),o.setStatus({code:2,message:t instanceof Error?t.message:String(t)})),r?.add(1,{...e,"notification.outcome":"error"}),i?.record(Date.now()-c,{...e,"notification.outcome":"error"}),t}finally{o?.end()}}};export{S as telemetryMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as c}from"./defineProvider-C9q-7iwt.js";import{t as g}from"./credentials-D9KXFoo0.js";import{r as p}from"./http-YFt2eXXy.js";import{s as y,b as h}from"./sms-CT04IxF8.js";const P="https://api.telnyx.com",S=c(o=>{const e=o??{};if(!e.apiKey)throw new u("telnyx","apiKey");const a=e.endpoint??P,d=e.retries??3,m=e.timeout??3e4,f=`${a}/v2/messages`,l=async(t,s)=>{const i=s.from??e.from;if(!i&&!e.messagingProfileId)return{error:"Missing sender: provide `from`, provider `from`, or `messagingProfileId`",id:t,status:"failed"};const n={text:s.text,to:t};i&&(n.from=i),e.messagingProfileId&&(n.messaging_profile_id=e.messagingProfileId),s.mediaUrls&&s.mediaUrls.length>0&&(n.media_urls=s.mediaUrls);const r=await p(f,{body:JSON.stringify(n),headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json"},method:"POST",timeout:m},d);return!r.success||!r.data?{error:r.error instanceof Error?r.error.message:"Request failed",id:t,status:"failed"}:r.data.status>=400?{error:r.data.body.errors?.[0]?.detail??`HTTP ${String(r.data.status)}`,id:t,status:"failed"}:{id:t,messageId:r.data.body.data?.id,status:"sent"}};return{channel:"sms",endpoint:a,features:{batchSending:!1,deliveryReceipts:!0,media:!0,scheduling:!0},id:"telnyx",initialize:()=>{},isAvailable:()=>!!e.apiKey,options:e,send:async t=>{const s=await y(g(t.to),async i=>l(i,t));return h("telnyx",s)},validateCredentials:()=>!!e.apiKey}});export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as h}from"./defineProvider-C9q-7iwt.js";import{b as p,t as S}from"./credentials-D9KXFoo0.js";import{r as w}from"./http-YFt2eXXy.js";import{s as T,b as v}from"./sms-CT04IxF8.js";const b="https://api.twilio.com",q=h(d=>{const e=d??{};if(!e.accountSid)throw new n("twilio","accountSid");if(!e.authToken)throw new n("twilio","authToken");const o=e.endpoint??b,c=e.retries??3,u=e.timeout??3e4,m=`${o}/2010-04-01/Accounts/${e.accountSid}/Messages.json`,l=p(e.accountSid,e.authToken),f=async(t,s)=>{const i=new URLSearchParams;i.set("To",t),i.set("Body",s.text);const a=s.from??e.from;if(e.messagingServiceSid)i.set("MessagingServiceSid",e.messagingServiceSid);else if(a)i.set("From",a);else return{error:"Missing sender: provide `from` on the payload or provider config",id:t,status:"failed"};for(const g of s.mediaUrls??[])i.append("MediaUrl",g);const r=await w(m,{body:i.toString(),headers:{Authorization:l,"Content-Type":"application/x-www-form-urlencoded"},method:"POST",timeout:u},c);return!r.success||!r.data?{error:r.error instanceof Error?r.error.message:"Request failed",id:t,status:"failed"}:r.data.status>=400?{error:r.data.body.error_message??`HTTP ${String(r.data.status)}`,id:t,status:"failed"}:{id:t,messageId:r.data.body.sid,status:"sent"}};return{channel:"sms",endpoint:o,features:{batchSending:!1,deliveryReceipts:!0,media:!0,scheduling:!0},id:"twilio",initialize:()=>{},isAvailable:()=>!!(e.accountSid&&e.authToken),options:e,send:async t=>{const s=await T(S(t.to),async i=>f(i,t));return v("twilio",s)},validateCredentials:()=>!!(e.accountSid&&e.authToken)}});export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hmacBase64 as u,timingSafeEqual as l}from"./hmacBase64-Dtvoq4Ry.js";import{getHeader as a}from"./getHeader-BF9s-Tgp.js";const m="X-Twilio-Signature",S={delivered:"delivered",failed:"failed",queued:"queued",sending:"queued",sent:"sent",undelivered:"failed"},f=(o,e)=>{const s=Object.keys(e).toSorted();let t=o;for(const r of s)t+=`${r}${e[r]??""}`;return t},i=o=>{const e={};return new URLSearchParams(o).forEach((t,r)=>{e[r]=t}),e},g={parse:o=>{const e=i(o),s=e.MessageStatus??e.SmsStatus??e.CallStatus;if(s===void 0)return;const t=S[s.toLowerCase()];return t===void 0?void 0:{channel:"sms",messageId:e.MessageSid??e.SmsSid??e.CallSid??"",provider:"twilio",recipient:e.To,timestamp:new Date,type:t}},verify:async(o,e,s)=>{if(s.trim()==="")return!1;const t=a(e,m),r=a(e,"x-twilio-signature-url");if(t===void 0||r===void 0)return!1;const n=i(o),d=f(r,n),c=await u(s,d,"SHA-1");return l(c,t)}};export{g as twilioWebhook};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as l}from"./defineProvider-C9q-7iwt.js";import{t as g}from"./credentials-D9KXFoo0.js";import{r as y}from"./http-YFt2eXXy.js";import{s as v,b as w}from"./sms-CT04IxF8.js";const S="https://rest.nexmo.com",P=l(d=>{const e=d??{};if(!e.apiKey)throw new n("vonage","apiKey");if(!e.apiSecret)throw new n("vonage","apiSecret");const i=e.endpoint??S,c=e.retries??3,m=e.timeout??3e4,p=`${i}/sms/json`,u=async(t,s)=>{const a=s.from??e.from;if(!a)return{error:"Missing sender: provide `from` on the payload or provider config",id:t,status:"failed"};const f=new URLSearchParams({api_key:e.apiKey,api_secret:e.apiSecret,from:a,text:s.text,to:t}),r=await y(p,{body:f.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",timeout:m},c);if(!r.success||!r.data)return{error:r.error instanceof Error?r.error.message:"Request failed",id:t,status:"failed"};const o=r.data.body.messages?.[0];return o?.status!=="0"?{error:o?.["error-text"]??`Vonage status ${o?.status??"unknown"}`,id:t,status:"failed"}:{id:t,messageId:o["message-id"],status:"sent"}};return{channel:"sms",endpoint:i,features:{batchSending:!1,deliveryReceipts:!0,media:!1},id:"vonage",initialize:()=>{},isAvailable:()=>!!(e.apiKey&&e.apiSecret),options:e,send:async t=>{const s=await v(g(t.to),async a=>u(a,t));return w("vonage",s)},validateCredentials:()=>!!(e.apiKey&&e.apiSecret)}});export{P as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import K from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{t as E}from"./credentials-D9KXFoo0.js";import{m as A}from"./http-YFt2eXXy.js";import{g as k}from"./id-FYdbBSpb.js";import{a as T}from"./sms-CT04IxF8.js";import{u as y,f as S,b as g,s as c,r as U,c as f,d as P,e as B}from"./webcrypto-Cz40u9vp.js";const R=2419200,$=i=>{let e=i;if(typeof i=="string")try{e=JSON.parse(i)}catch{return}const t=e;if(!(!t||typeof t.endpoint!="string"||typeof t.keys?.p256dh!="string"||typeof t.keys.auth!="string"))return t},j=async(i,e)=>{const t=S(e),d=g(t.slice(1,33)),a=g(t.slice(33,65));return c().importKey("jwk",{crv:"P-256",d:i,ext:!0,key_ops:["sign"],kty:"EC",x:d,y:a},{name:"ECDSA",namedCurve:"P-256"},!1,["sign"])},x=async(i,e,t)=>{const d=g(y(JSON.stringify({alg:"ES256",typ:"JWT"}))),a=g(y(JSON.stringify({aud:i,exp:Math.floor(Date.now()/1e3)+720*60,sub:e}))),u=`${d}.${a}`,n=await c().sign({hash:"SHA-256",name:"ECDSA"},t,y(u));return`${u}.${g(new Uint8Array(n))}`},D=async(i,e)=>{const t=S(i.keys.p256dh),d=S(i.keys.auth),a=U(16),u=await c().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),n=new Uint8Array(await c().exportKey("raw",u.publicKey)),s=await c().importKey("raw",t,{name:"ECDH",namedCurve:"P-256"},!1,[]),m=new Uint8Array(await c().deriveBits({name:"ECDH",public:s},u.privateKey,256)),r=f(y("WebPush: info\0"),t,n),l=await P(d,m,r,32),b=await P(a,l,y("Content-Encoding: aes128gcm\0"),16),v=await P(a,l,y("Content-Encoding: nonce\0"),12),w=await c().importKey("raw",b,{name:"AES-GCM"},!1,["encrypt"]),h=f(e,new Uint8Array([2])),o=new Uint8Array(await c().encrypt({iv:v,name:"AES-GCM"},w,h)),p=f(a,B(4096,4),new Uint8Array([n.length]),n);return f(p,o)},q=C(i=>{const e=i??{};if(!e.vapidPublicKey||!e.vapidPrivateKey||!e.vapidSubject)throw new K("web-push",["vapidPublicKey","vapidPrivateKey","vapidSubject"]);const t=e.ttl??R,d=e.urgency??"normal",a=e.timeout??3e4,u=async(n,s,m)=>{const r=$(n);if(!r)return{error:"Invalid push subscription (expected { endpoint, keys: { p256dh, auth } })",id:n,status:"failed"};const{origin:l}=new URL(r.endpoint),b=await x(l,e.vapidSubject,m),v=JSON.stringify({badge:s.badge,body:s.body,data:s.data,image:s.imageUrl,title:s.title}),w=await D(r,y(v)),h={Authorization:`vapid t=${b},k=${e.vapidPublicKey}`,"Content-Encoding":"aes128gcm","Content-Type":"application/octet-stream",TTL:String(t),Urgency:d},o=await A(r.endpoint,{body:w,headers:h,method:"POST",timeout:a});if(!o.success||!o.data)return{error:o.error instanceof Error?o.error.message:"Request failed",id:n,status:"failed"};const{status:p}=o.data;return p===404||p===410?{error:`Subscription gone (HTTP ${String(p)}) — remove this subscription`,id:n,status:"failed"}:p>=400?{error:`HTTP ${String(p)}: ${typeof o.data.body=="string"?o.data.body:""}`.trim(),id:n,status:"failed"}:{id:n,messageId:k("web-push"),status:"sent"}};return{channel:"push",features:{batchSending:!1,media:!1,richContent:!0},id:"web-push",initialize:()=>{},isAvailable:()=>!!(e.vapidPublicKey&&e.vapidPrivateKey&&e.vapidSubject),options:e,send:async n=>{const s=E(n.to),m=await j(e.vapidPrivateKey,e.vapidPublicKey),r=[];for(const l of s)r.push(await u(l,n,m));return T("push","web-push",r)},validateCredentials:()=>!!(e.vapidPublicKey&&e.vapidPrivateKey&&e.vapidSubject)}});export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const c=e=>new Uint8Array(new ArrayBuffer(e)),i=e=>{if(e.buffer instanceof ArrayBuffer)return e;const t=c(e.length);return t.set(e),t},r=()=>globalThis.crypto.subtle,d=e=>{const t=c(e);return globalThis.crypto.getRandomValues(t),t},l=e=>{const t=new TextEncoder().encode(e),n=c(t.length);return n.set(t),n},h=(...e)=>{let t=0;for(const o of e)t+=o.length;const n=c(t);let s=0;for(const o of e)n.set(o,s),s+=o.length;return n},u=e=>{let t="";for(const n of e)t+=n.toString(16).padStart(2,"0");return t},f=e=>{let t="";for(const n of e)t+=String.fromCodePoint(n);return btoa(t)},g=e=>{let t=f(e).replaceAll("+","-").replaceAll("/","_");for(;t.endsWith("=");)t=t.slice(0,-1);return t},A=e=>{const t=e.replaceAll("-","+").replaceAll("_","/"),n=t.padEnd(t.length+(4-t.length%4)%4,"="),s=atob(n),o=c(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.codePointAt(a)??0;return o},b=(e,t)=>{const n=c(t);let s=e;for(let o=t-1;o>=0;o-=1)n[o]=s%256,s=Math.floor(s/256);return n},p=async e=>{const t=await r().digest("SHA-256",e);return new Uint8Array(t)},w=async(e,t)=>{const n=await r().importKey("raw",e,{hash:"SHA-256",name:"HMAC"},!1,["sign"]),s=await r().sign("HMAC",n,t);return new Uint8Array(s)},m=async(e,t,n)=>{const s=typeof e=="string"?l(e):i(e),o=typeof t=="string"?l(t):i(t),a=await r().importKey("raw",s,{hash:n,name:"HMAC"},!1,["sign"]),y=await r().sign("HMAC",a,o);return new Uint8Array(y)},B=async(e,t,n,s)=>{const o=await r().importKey("raw",t,"HKDF",!1,["deriveBits"]),a=await r().deriveBits({hash:"SHA-256",info:n,name:"HKDF",salt:e},o,s*8);return new Uint8Array(a)};export{u as a,g as b,h as c,B as d,b as e,A as f,p as g,m as h,w as i,d as r,r as s,f as t,l as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"./NotificationError-tZsXfB7V.js";import a from"./RequiredOptionError-CAuRlc0R.js";import{r as u}from"./http-YFt2eXXy.js";import{g as d}from"./id-FYdbBSpb.js";const w=(r={})=>{const i=r.retries??3,n=r.timeout??3e4;return{channel:"webhook",endpoint:r.url,features:{},id:"webhook",initialize:()=>{},isAvailable:()=>!0,send:async t=>{const s=t.url??r.url;if(!s)return{error:new a("webhook","url"),success:!1};const e=await u(s,{body:typeof t.body=="string"?t.body:JSON.stringify(t.body),headers:{"Content-Type":"application/json",...r.headers,...t.headers},method:t.method??r.method??"POST",timeout:n},i);return!e.success||!e.data?{error:new o("webhook",e.error instanceof Error?e.error.message:"Request failed"),success:!1}:e.data.status>=400?{error:new o("webhook",`HTTP ${String(e.data.status)}`),success:!1}:{data:{channel:"webhook",messageId:d("webhook"),provider:"webhook",response:e.data.body,sent:!0,timestamp:new Date},success:!0}}}};export{w as webhookProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class l{#e=new Map;get(e){return this.#e.get(e)??{channels:{}}}set(e,
|
|
1
|
+
class l{#e=new Map;get(e){return this.#e.get(e)??{channels:{}}}set(e,t){this.#e.set(e,t)}isAllowed(e,t,s={}){return s.critical?!0:this.get(e).channels[t]!==!1}}const o=(i,e={})=>{const t=n=>{const{to:r}=n;if(r!=null)return typeof r=="string"?r:JSON.stringify(r)},s=e.subscriberId??t;return async(n,r)=>{const c=s(r);return c?i.isAllowed(c,n,{critical:e.critical}):!0}};export{l as MemoryPreferenceStore,o as preferencesGate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../../packem_shared/discordProvider-
|
|
1
|
+
import{default as o}from"../../../packem_shared/discordProvider-B9rc2nrV.js";export{o as discordProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../../packem_shared/msTeamsProvider-
|
|
1
|
+
import{default as a}from"../../../packem_shared/msTeamsProvider-BAgW_ba5.js";export{a as msTeamsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../../packem_shared/slackProvider-
|
|
1
|
+
import{default as e}from"../../../packem_shared/slackProvider-CP35fu9-.js";export{e as slackProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../../packem_shared/telegramProvider-
|
|
1
|
+
import{default as a}from"../../../packem_shared/telegramProvider-CyaUiWkh.js";export{a as telegramProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{failoverProvider as e}from"../../packem_shared/failoverProvider-
|
|
1
|
+
import{failoverProvider as e}from"../../packem_shared/failoverProvider-CyYOOitI.js";export{e as failoverProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mockProvider as e}from"../../packem_shared/mockProvider-
|
|
1
|
+
import{mockProvider as e}from"../../packem_shared/mockProvider-OaWdPlKU.js";export{e as mockProvider};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as Tracer } from "../../packem_shared/tracer.d-BPznIQx9.js";
|
|
2
1
|
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-C7l7qdMG.js";
|
|
3
2
|
import { P as Provider } from "../../packem_shared/provider.d-Dh32nRm9.js";
|
|
3
|
+
import { T as Tracer } from "../../packem_shared/tracer.d-BPznIQx9.js";
|
|
4
4
|
interface OtelProviderConfig {
|
|
5
5
|
/**
|
|
6
6
|
* The OpenTelemetry {@link Tracer} used to create spans. When omitted, a no-op tracer is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{otelProvider as e}from"../../packem_shared/otelProvider-
|
|
1
|
+
import{otelProvider as e}from"../../packem_shared/otelProvider-DdnT7q6B.js";export{e as otelProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../../packem_shared/apnsProvider-
|
|
1
|
+
import{default as e}from"../../../packem_shared/apnsProvider-Dfgwt-6Z.js";export{e as apnsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../../packem_shared/expoProvider-
|
|
1
|
+
import{default as r}from"../../../packem_shared/expoProvider-DofT1sEf.js";export{r as expoProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as f}from"../../../packem_shared/fcmProvider-
|
|
1
|
+
import{default as f}from"../../../packem_shared/fcmProvider-86S6m7zk.js";export{f as fcmProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../../packem_shared/webPushProvider-
|
|
1
|
+
import{default as o}from"../../../packem_shared/webPushProvider-CUDMDRKw.js";export{o as webPushProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{roundRobinProvider as d}from"../../packem_shared/roundRobinProvider-
|
|
1
|
+
import{roundRobinProvider as d}from"../../packem_shared/roundRobinProvider-BrujhDY6.js";export{d as roundRobinProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as a}from"../../../packem_shared/messageBirdProvider-
|
|
1
|
+
import{default as a}from"../../../packem_shared/messageBirdProvider-CnsBOuY6.js";export{a as messageBirdProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../../packem_shared/plivoProvider-
|
|
1
|
+
import{default as e}from"../../../packem_shared/plivoProvider-C27zpwI3.js";export{e as plivoProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../../packem_shared/snsProvider-
|
|
1
|
+
import{default as o}from"../../../packem_shared/snsProvider-BtlNUN7u.js";export{o as snsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../../../packem_shared/telnyxProvider-
|
|
1
|
+
import{default as o}from"../../../packem_shared/telnyxProvider-M23jXIyu.js";export{o as telnyxProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"../../../packem_shared/twilioProvider-
|
|
1
|
+
import{default as e}from"../../../packem_shared/twilioProvider-CaoTEqz-.js";export{e as twilioProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"../../../packem_shared/vonageProvider-
|
|
1
|
+
import{default as r}from"../../../packem_shared/vonageProvider-CYNivc-x.js";export{r as vonageProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{webhookProvider as e}from"../../packem_shared/webhookProvider-
|
|
1
|
+
import{webhookProvider as e}from"../../packem_shared/webhookProvider-C13EqjLL.js";export{e as webhookProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class o{#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 o(i,e);export{o as BullMqQueue,n as createBullMqQueue};
|
package/dist/queue/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BullMqQueue as r,createBullMqQueue as o}from"./bullmq-queue.js";import{default as Q}from"../packem_shared/MemoryQueue-
|
|
1
|
+
import{BullMqQueue as r,createBullMqQueue as o}from"./bullmq-queue.js";import{default as Q}from"../packem_shared/MemoryQueue-6z5qeFnj.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-BU-pYjrf.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};
|
|
@@ -1 +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)+1,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
|
|
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)+1,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 c=(s,e)=>new i(s,e);export{i as PgBossQueue,c as createPgBossQueue};
|
package/dist/queue/sqs-queue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const r="ApproximateNumberOfMessages",u="ApproximateNumberOfMessagesNotVisible",n=(s,e)=>{if(s===void 0)return 0;const t=Math.ceil((s-e)/1e3);return Math.max(0,t)};class c{#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=n(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 t=(await this.#e.receiveMessage({AttributeNames:["ApproximateReceiveCount"],MaxNumberOfMessages:1,QueueUrl:this.#t,VisibilityTimeout:this.#s,WaitTimeSeconds:this.#i})).Messages?.[0];if(!t?.ReceiptHandle)return;const i=Number(t.Attributes?.ApproximateReceiveCount??"1");let a;try{a=JSON.parse(t.Body??"{}")}catch{await this.#e.deleteMessage({QueueUrl:this.#t,ReceiptHandle:t.ReceiptHandle});return}return{attempts:Math.max(1,i),id:t.ReceiptHandle,message:a,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:[r,u],QueueUrl:this.#t});return Number(e.Attributes?.[r]??0)+Number(e.Attributes?.[u]??0)}}const o=(s,e)=>new c(s,e);export{c as SqsQueue,o as createSqsQueue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as r}from"../packem_shared/id-FYdbBSpb.js";class n{#e;#a;constructor(e,a="notification:queue"){this.#e=e,this.#a=a}async enqueue(e,a){const t={attempts:0,id:r("job"),message:e,scheduledAt:a?.scheduledAt};return await this.#e.setItem(this.#t(t.id),t),t.id}async reserve(){const e=Date.now(),a=await this.#e.getKeys(this.#s());for(const t of a){const s=await this.#e.getItem(t);if(s&&!s.reserved&&(s.scheduledAt??0)<=e)return s.attempts+=1,s.reserved=!0,await this.#e.setItem(t,s),{attempts:s.attempts,id:s.id,message:s.message,scheduledAt:s.scheduledAt}}}async ack(e){await this.#e.removeItem(this.#t(e))}async retry(e,a=0){const t=await this.#e.getItem(this.#t(e));t&&(t.scheduledAt=Date.now()+a,t.reserved=!1,await this.#e.setItem(this.#t(e),t))}async size(){const e=await this.#e.getKeys(this.#s());return(await Promise.all(e.map(async t=>this.#e.getItem(t)))).filter(t=>t!==null&&!t.reserved).length}#s(){return`${this.#a}:job:`}#t(e){return`${this.#s()}${e}`}}const c=(i,e)=>new n(i,e);export{n as UnstorageQueue,c as createUnstorageQueue};
|
package/dist/routing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const d=(r,n)=>{const t=Object.keys(r);if(!n)return t;const o=n.filter(c=>t.includes(c)),l=t.filter(c=>!n.includes(c));return[...o,...l]},u=async(r,n,t={})=>{const o=t.mode??"best-of",l=d(n,t.order),c=[];for(const e of l){const s=n[e];t.gate&&!await t.gate(e,s)||c.push(e)}if(o==="all")return Promise.all(c.map(async e=>r.sendToChannel(e,n[e])));const a=[];for(const e of c){const s=await r.sendToChannel(e,n[e]);if(a.push(s),s.successful)break}return a};export{u as route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"../packem_shared/NotificationError-tZsXfB7V.js";const l=async(r,n,s)=>{if(typeof r!="string")throw new TypeError("Handlebars template must be a string");let a;try{const e=await import("handlebars");a=e.default??e}catch(e){throw new t("handlebars","handlebars is not installed. Please install it: pnpm add handlebars",{cause:e})}try{return a.compile(r,s)(n??{})}catch(e){throw new t("handlebars",`Failed to render Handlebars template: ${e.message}`,{cause:e})}};export{l as default,l as renderHandlebars};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"../packem_shared/NotificationError-tZsXfB7V.js";const o=async(e,n,a)=>{if(typeof e!="string")throw new TypeError("Liquid template must be a string");let r;try{r=await import("liquidjs")}catch(i){throw new t("liquid","liquidjs is not installed. Please install it: pnpm add liquidjs",{cause:i})}try{return await new r.Liquid(a??{}).parseAndRender(e,n??{})}catch(i){throw new t("liquid",`Failed to render Liquid template: ${i.message}`,{cause:i})}};export{o as default,o as renderLiquid};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const i=(n
|
|
1
|
+
const i=(r,n)=>{const o=n.split(".");let e=r;for(const s of o){if(e===null||typeof e!="object")return;e=e[s]}return e},f=(r,n)=>{if(typeof r!="string")throw new TypeError("String template must be a string");const o=n??{};return r.replaceAll(/\{\{\s*([\w.]+)\s*\}\}/g,(e,s)=>{const t=i(o,s);return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):JSON.stringify(t)})};export{f as default,f as renderString};
|