@visulima/notification 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/channels/email/index.d.ts +23 -23
- package/dist/channels/email/index.js +1 -1
- package/dist/channels/inapp/index.d.ts +31 -31
- package/dist/digest/index.d.ts +55 -55
- package/dist/digest/index.js +1 -1
- package/dist/events/index.d.ts +16 -16
- package/dist/i18n/index.d.ts +21 -21
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +97 -108
- package/dist/index.js +1 -1
- package/dist/layouts/index.d.ts +28 -28
- package/dist/middleware/index.d.ts +49 -49
- package/dist/middleware/index.js +1 -1
- package/dist/packem_shared/Notification-BuS_QjJv.js +1 -0
- package/dist/packem_shared/NotificationError-B1ZZqWxL.js +1 -0
- package/dist/packem_shared/{RequiredOptionError-CuL42XRq.js → RequiredOptionError-CH4g-BZM.js} +1 -1
- package/dist/packem_shared/apnsProvider-BV5-wOvD.js +1 -0
- package/dist/packem_shared/{circuitBreakerMiddleware-BlZN7SVT.js → circuitBreakerMiddleware-o3G_6N3s.js} +1 -1
- package/dist/packem_shared/{createDigester-vMNPejGF.js → createDigester-DCwWhmpi.js} +1 -1
- package/dist/packem_shared/{createNotificationWorkflow-B70OgeED.js → createNotificationWorkflow-lseG_9fC.js} +1 -1
- package/dist/packem_shared/createQueueWorker-BIXWHJLY.js +1 -0
- package/dist/packem_shared/{createTranslator-CY91C2eS.js → createTranslator-BL2M8eeD.js} +1 -1
- package/dist/packem_shared/{discordProvider-BhfXcCcI.js → discordProvider-D4LpBljj.js} +1 -1
- package/dist/packem_shared/{emailChannel-CNDlX96Q.js → emailChannel-BoLLbyrn.js} +1 -1
- package/dist/packem_shared/{expoProvider-DsZR4sUk.js → expoProvider-BPJr9c0e.js} +1 -1
- package/dist/packem_shared/{failoverProvider-D1dAmW8U.js → failoverProvider-CJsDGjzf.js} +1 -1
- package/dist/packem_shared/fcmProvider-qIR12R9m.js +1 -0
- package/dist/packem_shared/hmacBase64-CNksyDoB.js +1 -0
- package/dist/packem_shared/{messageBirdProvider-BfiTaNLn.js → messageBirdProvider-FK9_UONf.js} +1 -1
- package/dist/packem_shared/{mockProvider-BLwTZlkw.js → mockProvider-C2hHPSVa.js} +1 -1
- package/dist/packem_shared/{msTeamsProvider-DrmL3RYX.js → msTeamsProvider-DeGPjmCt.js} +1 -1
- package/dist/packem_shared/notification.d-D0ado_cy.d.ts +104 -0
- package/dist/packem_shared/{plivoProvider-Dr8d5yD3.js → plivoProvider-DaCu7J3X.js} +1 -1
- package/dist/packem_shared/{provider.d-BQAGriz6.d.ts → provider.d-Dh32nRm9.d.ts} +10 -10
- package/dist/packem_shared/{roundRobinProvider-BetXJUUm.js → roundRobinProvider-HowYifRe.js} +1 -1
- package/dist/packem_shared/{slackProvider-DPG1IlA0.js → slackProvider-Caxbs4Pa.js} +1 -1
- package/dist/packem_shared/{slackWebhook-Cpmm_0El.js → slackWebhook-IB4mVnBk.js} +1 -1
- package/dist/packem_shared/{sms-CU-OZvNU.js → sms-BbxkOLQm.js} +1 -1
- package/dist/packem_shared/{snsProvider-C2T2UxDK.js → snsProvider-BS4D6w-i.js} +3 -3
- package/dist/packem_shared/{standardWebhook-Bk0UUeDW.js → standardWebhook-C_AQWUi5.js} +1 -1
- package/dist/packem_shared/{telegramProvider-wyx3ksVm.js → telegramProvider-BIc_GgpY.js} +1 -1
- package/dist/packem_shared/{telnyxProvider-jgpEwgPh.js → telnyxProvider-wjmTXBwh.js} +1 -1
- package/dist/packem_shared/{tracer.d-Co1s_NwG.d.ts → tracer.d-BPznIQx9.d.ts} +2 -2
- package/dist/packem_shared/{twilioProvider-DMYWqvgZ.js → twilioProvider-Bf_zsF9z.js} +1 -1
- package/dist/packem_shared/twilioWebhook-Hhf9aWV1.js +1 -0
- package/dist/packem_shared/types.d-BU-37j3S.d.ts +10 -0
- package/dist/packem_shared/{types.d-GUzX1jTk.d.ts → types.d-C7l7qdMG.d.ts} +52 -52
- package/dist/packem_shared/{types.d-CximoA8M.d.ts → types.d-CRs03TYV.d.ts} +13 -13
- package/dist/packem_shared/{types.d-C1GoEAlI.d-Bv3grfyD.d.ts → types.d-CcjfiGpo.d-DuZME7ry.d.ts} +27 -34
- package/dist/packem_shared/{types.d-67TogK4k.d.ts → types.d-r8K0ICyx.d.ts} +7 -7
- package/dist/packem_shared/{vonageProvider-CT4KoWXu.js → vonageProvider-oRg9dpS1.js} +1 -1
- package/dist/packem_shared/{webPushProvider-DwjmWASr.js → webPushProvider-BtZHb_X_.js} +1 -1
- package/dist/packem_shared/{webcrypto-bY7wJCB5.js → webcrypto-CFuQmh5-.js} +1 -1
- package/dist/packem_shared/webhookProvider-CwkDb1cZ.js +1 -0
- package/dist/preferences/index.d.ts +19 -19
- package/dist/providers/chat/discord/index.d.ts +5 -5
- package/dist/providers/chat/discord/index.js +1 -1
- package/dist/providers/chat/msteams/index.d.ts +7 -7
- package/dist/providers/chat/msteams/index.js +1 -1
- package/dist/providers/chat/slack/index.d.ts +6 -6
- package/dist/providers/chat/slack/index.js +1 -1
- package/dist/providers/chat/telegram/index.d.ts +5 -5
- package/dist/providers/chat/telegram/index.js +1 -1
- package/dist/providers/failover/index.d.ts +7 -7
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/mock/index.d.ts +5 -5
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +14 -14
- package/dist/providers/push/apns/index.d.ts +9 -9
- package/dist/providers/push/apns/index.js +1 -1
- package/dist/providers/push/expo/index.d.ts +5 -5
- package/dist/providers/push/expo/index.js +1 -1
- package/dist/providers/push/fcm/index.d.ts +13 -13
- package/dist/providers/push/fcm/index.js +1 -1
- package/dist/providers/push/web-push/index.d.ts +11 -11
- package/dist/providers/push/web-push/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +8 -8
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/sms/messagebird/index.d.ts +5 -5
- package/dist/providers/sms/messagebird/index.js +1 -1
- package/dist/providers/sms/plivo/index.d.ts +5 -5
- package/dist/providers/sms/plivo/index.js +1 -1
- package/dist/providers/sms/sns/index.d.ts +6 -6
- package/dist/providers/sms/sns/index.js +1 -1
- package/dist/providers/sms/telnyx/index.d.ts +5 -5
- package/dist/providers/sms/telnyx/index.js +1 -1
- package/dist/providers/sms/twilio/index.d.ts +5 -5
- package/dist/providers/sms/twilio/index.js +1 -1
- package/dist/providers/sms/vonage/index.d.ts +5 -5
- package/dist/providers/sms/vonage/index.js +1 -1
- package/dist/providers/webhook/index.d.ts +7 -7
- package/dist/providers/webhook/index.js +1 -1
- package/dist/queue/bullmq-queue.d.ts +24 -24
- package/dist/queue/index.d.ts +17 -15
- package/dist/queue/index.js +1 -1
- package/dist/queue/pg-boss-queue.d.ts +27 -26
- package/dist/queue/pg-boss-queue.js +1 -1
- package/dist/queue/sqs-queue.d.ts +27 -27
- package/dist/queue/sqs-queue.js +1 -1
- package/dist/queue/unstorage-queue.d.ts +21 -14
- package/dist/queue/unstorage-queue.js +1 -1
- package/dist/routing/index.d.ts +22 -22
- package/dist/template-engines/handlebars.d.ts +13 -13
- package/dist/template-engines/handlebars.js +1 -1
- package/dist/template-engines/liquid.d.ts +13 -13
- package/dist/template-engines/liquid.js +1 -1
- package/dist/template-engines/string.d.ts +17 -17
- package/dist/utils/result.d.ts +32 -32
- package/dist/utils/result.js +1 -1
- package/dist/webhooks/index.d.ts +84 -84
- package/dist/webhooks/index.js +1 -1
- package/dist/workflow/index.d.ts +42 -42
- package/dist/workflow/index.js +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/Notification-B22tuJPy.js +0 -1
- package/dist/packem_shared/NotificationError-DVfMJQ1u.js +0 -1
- package/dist/packem_shared/apnsProvider-C9WSv5sc.js +0 -1
- package/dist/packem_shared/createQueueWorker-DjQBxjXc.js +0 -1
- package/dist/packem_shared/fcmProvider-DWRx8XBv.js +0 -1
- package/dist/packem_shared/hmacBase64-BhhoX0uo.js +0 -1
- package/dist/packem_shared/notification.d-DFCVTods.d.ts +0 -104
- package/dist/packem_shared/twilioWebhook-C-Iwuv7y.js +0 -1
- package/dist/packem_shared/types.d-td-F2Oh0.d.ts +0 -10
- package/dist/packem_shared/webhookProvider-CPA1nKXJ.js +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { M as Middleware } from "./types.d-CximoA8M.js";
|
|
2
|
-
import { P as Provider } from "./provider.d-BQAGriz6.js";
|
|
3
|
-
import { b as ChatPayload, E as EmailChannelPayload, I as InAppPayload, P as PushPayload, S as SmsPayload, W as WebhookPayload, C as ChannelType, c as Receipt } from "./types.d-GUzX1jTk.js";
|
|
4
|
-
/**
|
|
5
|
-
* Maps each channel to its payload type.
|
|
6
|
-
*/
|
|
7
|
-
interface ChannelPayloadMap {
|
|
8
|
-
chat: ChatPayload;
|
|
9
|
-
email: EmailChannelPayload;
|
|
10
|
-
inapp: InAppPayload;
|
|
11
|
-
push: PushPayload;
|
|
12
|
-
sms: SmsPayload;
|
|
13
|
-
webhook: WebhookPayload;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A multi-channel message: a payload per channel to deliver on.
|
|
17
|
-
*/
|
|
18
|
-
type NotificationMessage = { [K in ChannelType]?: ChannelPayloadMap[K] };
|
|
19
|
-
/**
|
|
20
|
-
* Providers registered per channel.
|
|
21
|
-
*/
|
|
22
|
-
type NotificationProviders = { [K in ChannelType]?: Provider<unknown, ChannelPayloadMap[K]> };
|
|
23
|
-
interface SendManyOptions {
|
|
24
|
-
/** Maximum number of messages delivered concurrently (default 10). */
|
|
25
|
-
concurrency?: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The high-level multi-channel notification facade. Holds a provider per channel,
|
|
29
|
-
* a shared middleware chain and dispatches messages across channels.
|
|
30
|
-
*/
|
|
31
|
-
declare class Notification {
|
|
32
|
-
#private;
|
|
33
|
-
constructor(providers: NotificationProviders);
|
|
34
|
-
/**
|
|
35
|
-
* Registers a middleware. First registered runs outermost.
|
|
36
|
-
* @param middleware The middleware to add.
|
|
37
|
-
* @returns This instance for chaining.
|
|
38
|
-
*/
|
|
39
|
-
use(middleware: Middleware): this;
|
|
40
|
-
/**
|
|
41
|
-
* Sets a logger used by the facade.
|
|
42
|
-
* @param logger The console-like logger.
|
|
43
|
-
* @returns This instance for chaining.
|
|
44
|
-
*/
|
|
45
|
-
setLogger(logger: Console): this;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the provider registered for a channel, if any.
|
|
48
|
-
* @param channel The channel whose registered provider should be looked up.
|
|
49
|
-
* @returns The provider or undefined.
|
|
50
|
-
*/
|
|
51
|
-
getProvider(channel: ChannelType): Provider | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* Sends a payload on a single channel.
|
|
54
|
-
* @param channel The target channel.
|
|
55
|
-
* @param payload The channel-specific payload to deliver.
|
|
56
|
-
* @returns A receipt describing the outcome.
|
|
57
|
-
*/
|
|
58
|
-
sendToChannel<K extends ChannelType>(channel: K, payload: ChannelPayloadMap[K]): Promise<Receipt>;
|
|
59
|
-
/**
|
|
60
|
-
* Sends a multi-channel message, delivering each present channel in parallel.
|
|
61
|
-
* @param message The multi-channel message.
|
|
62
|
-
* @returns One receipt per attempted channel.
|
|
63
|
-
*/
|
|
64
|
-
send(message: NotificationMessage): Promise<Receipt[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Sends many messages with bounded concurrency, yielding the receipts for each.
|
|
67
|
-
* @param messages The messages to send.
|
|
68
|
-
* @param options Concurrency options.
|
|
69
|
-
* @yields The receipts for each message, in completion order.
|
|
70
|
-
*/
|
|
71
|
-
sendMany(messages: Iterable<NotificationMessage>, options?: SendManyOptions): AsyncGenerator<Receipt[]>;
|
|
72
|
-
/**
|
|
73
|
-
* Initializes every registered provider.
|
|
74
|
-
*/
|
|
75
|
-
initialize(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Shuts down every registered provider that supports it.
|
|
78
|
-
*/
|
|
79
|
-
shutdown(): Promise<void>;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates a {@link Notification} facade from a map of channel providers.
|
|
83
|
-
* @param providers Providers keyed by channel.
|
|
84
|
-
* @returns A configured notification facade.
|
|
85
|
-
*/
|
|
86
|
-
declare const createNotification: (providers: NotificationProviders) => Notification;
|
|
87
|
-
/**
|
|
88
|
-
* One-shot send through a single provider — the quickest path for a single-channel
|
|
89
|
-
* send without wiring a {@link Notification} facade. For multiple channels,
|
|
90
|
-
* middleware, routing or reuse, use {@link createNotification}.
|
|
91
|
-
* @param channel The channel to deliver on.
|
|
92
|
-
* @param provider The provider to deliver through.
|
|
93
|
-
* @param payload The channel-specific payload.
|
|
94
|
-
* @returns The send {@link Receipt}.
|
|
95
|
-
* @example
|
|
96
|
-
* ```ts
|
|
97
|
-
* import { send } from "@visulima/notification";
|
|
98
|
-
* import { twilioProvider } from "@visulima/notification/providers/twilio";
|
|
99
|
-
*
|
|
100
|
-
* await send("sms", twilioProvider({ accountSid, authToken, from }), { to: "+15555550100", text: "Hi" });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
declare const send: <ChannelT extends ChannelType>(channel: ChannelT, provider: Provider<unknown, ChannelPayloadMap[ChannelT]>, payload: ChannelPayloadMap[ChannelT]) => Promise<Receipt>;
|
|
104
|
-
export { ChannelPayloadMap as C, Notification as N, SendManyOptions as S, NotificationMessage as a, NotificationProviders as b, createNotification as c, send as s };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{hmacBase64 as u,timingSafeEqual as c}from"./hmacBase64-BhhoX0uo.js";import{getHeader as a}from"./getHeader-C_gkdnMQ.js";const m="X-Twilio-Signature",f={delivered:"delivered",failed:"failed",queued:"queued",sending:"queued",sent:"sent",undelivered:"failed"},S=(i,e)=>{const r=Object.keys(e).toSorted((o,s)=>o.localeCompare(s));let t=i;for(const o of r)t+=`${o}${e[o]??""}`;return t},n=i=>{const e={};return new URLSearchParams(i).forEach((r,t)=>{e[t]=r}),e},g={parse:i=>{const e=n(i),r=e.MessageStatus??e.SmsStatus??e.CallStatus;if(r===void 0)return;const t=f[r.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(i,e,r)=>{if(r.trim()==="")return!1;const t=a(e,m),o=a(e,"x-twilio-signature-url");if(t===void 0||o===void 0)return!1;const s=n(i),d=S(o,s),l=await u(r,d,"SHA-1");return c(l,t)}};export{g as twilioWebhook};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template render function type. Engines accept a template, optional data and
|
|
3
|
-
* engine-specific options and return the rendered string (sync or async).
|
|
4
|
-
* @param template Template content (typically a string).
|
|
5
|
-
* @param data Data/variables to pass to the template.
|
|
6
|
-
* @param options Options specific to the template engine.
|
|
7
|
-
* @returns The rendered string.
|
|
8
|
-
*/
|
|
9
|
-
type TemplateRenderer = (template: unknown, data?: Record<string, unknown>, options?: Record<string, unknown>) => string | Promise<string>;
|
|
10
|
-
export { TemplateRenderer as T };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import s from"./NotificationError-DVfMJQ1u.js";import i from"./RequiredOptionError-CuL42XRq.js";import{r as d}from"./http-DT3tyixg.js";import{n as u}from"./id-C_FRCsUM.js";const w=(t={})=>{const a=t.retries??3,n=t.timeout??3e4;return{channel:"webhook",endpoint:t.url,features:{},id:"webhook",initialize:()=>{},isAvailable:()=>!0,send:async o=>{const r=o.url??t.url;if(!r)throw new i("webhook","url");const e=await d(r,{body:typeof o.body=="string"?o.body:JSON.stringify(o.body),headers:{"Content-Type":"application/json",...t.headers,...o.headers},method:o.method??t.method??"POST",timeout:n},a);return!e.success||!e.data?{error:new s("webhook",e.error instanceof Error?e.error.message:"Request failed"),success:!1}:e.data.status>=400?{error:new s("webhook",`HTTP ${String(e.data.status)}`),success:!1}:{data:{channel:"webhook",messageId:u("webhook"),provider:"webhook",response:e.data.body,sent:!0,timestamp:new Date},success:!0}}}};export{w as webhookProvider};
|