@stacksjs/chat 0.72.38 → 0.72.39

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- var w=Object.defineProperty;var h=(q)=>q;function f(q,z){this[q]=h.bind(null,z)}var B=(q,z)=>{for(var F in z)w(q,F,{get:z[F],enumerable:!0,configurable:!0,set:f.bind(z,F)})};var j={};B(j,{sendWebhook:()=>P,sendEmbed:()=>S,send:()=>Z,driver:()=>u,default:()=>k,configure:()=>N,Driver:()=>O,DiscordDriver:()=>O});import{log as R}from"@stacksjs/logging";import{log as D}from"@stacksjs/logging";class K{config;constructor(q){this.config={maxRetries:q?.maxRetries||3,retryTimeout:q?.retryTimeout||1000,...q}}configure(q){this.config={...this.config,...q}}validateMessage(q){if(!q.to)throw Error("Message recipient is required");if(!q.content&&!q.template)throw Error("Either message content or template is required");return!0}async handleError(q,z){let F=q instanceof Error?q:Error(String(q));D.error(`[${this.name}] Message sending failed`,{error:F.message,stack:F.stack?.replace(/https?:\/\/[^\s)\]"']+/g,"[REDACTED-URL]"),to:z.to,subject:z.subject});let G={message:`Message sending failed: ${F.message}`,success:!1,provider:this.name};if(z.onError){let H=z.onError(F),J=H instanceof Promise?await H:H;G={...G,...J,success:!1,provider:this.name}}return G}async handleSuccess(q,z){let F={message:"Message sent successfully",success:!0,provider:this.name,messageId:z};try{if(q.handle){let G=q.handle(),H=G instanceof Promise?await G:G;F={...F,...H,success:!0,provider:this.name,messageId:z}}if(q.onSuccess){let G=q.onSuccess(),H=G instanceof Promise?await G:G;F={...F,...H,success:!0,provider:this.name,messageId:z}}}catch(G){return this.handleError(G,q)}return F}}var L={};function N(q){if(q.webhookUrl){let z;try{z=new URL(q.webhookUrl)}catch{throw Error(`[chat/discord] webhookUrl is not a valid URL: ${q.webhookUrl}`)}if(z.protocol!=="https:")throw Error("[chat/discord] webhookUrl must use https://");if(!/(?:^|\.)discord(?:app)?\.com$/i.test(z.hostname))throw Error(`[chat/discord] webhookUrl host "${z.hostname}" is not a Discord-owned domain.`)}L={...L,...q}}class O extends K{name="discord";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)N(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};R.info("Sending message via Discord...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{let G=await this.sendMessage(q,z);return this.handleSuccess(q,G.id)}catch(G){if(F<this.config.maxRetries)return R.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){if(L.webhookUrl)return this.sendViaWebhook(q);if(L.botToken)return this.sendViaBotToken(q);throw Error("Discord not configured: provide webhookUrl or botToken")}async sendViaWebhook(q){let z={content:q.content,username:q.from};if(q.subject||q.template)z.embeds=[this.buildEmbed(q)];let F=await fetch(L.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(!F.ok){let H=await F.text();throw Error(`Discord webhook failed: ${F.status} - ${H}`)}if(F.status===204)return{};return{id:(await F.json()).id}}async sendViaBotToken(q){let z=q.to,F={content:q.content};if(q.subject||q.template)F.embeds=[this.buildEmbed(q)];let G=await fetch(`https://discord.com/api/v10/channels/${z}/messages`,{method:"POST",headers:{Authorization:`Bot ${L.botToken}`,"Content-Type":"application/json"},body:JSON.stringify(F)});if(!G.ok){let J=await G.json();throw Error(`Discord API failed: ${G.status} - ${J.message}`)}return{id:(await G.json()).id}}buildEmbed(q){let z={};if(q.subject)z.title=q.subject;if(q.content)z.description=q.content;return z.color=5793266,z.timestamp=new Date().toISOString(),z}}async function Z(q,z){return new O().send(q,z)}async function P(q,z,F){try{let G={content:z,...F},H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();return{success:!1,provider:"discord",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"discord",message:"Message sent successfully"}}catch(G){return{success:!1,provider:"discord",message:(G instanceof Error?G:Error(String(G))).message}}}async function S(q,z,F){return P(q,"",{...F,embeds:[z]})}var u=new O,k={send:Z,sendWebhook:P,sendEmbed:S,configure:N,DiscordDriver:O};var W={};B(W,{sendWebhook:()=>$,send:()=>_,driver:()=>b,default:()=>v,configure:()=>Q,SlackDriver:()=>V,Driver:()=>V});import{log as y}from"@stacksjs/logging";var M={};function Q(q){if(q.webhookUrl){let z;try{z=new URL(q.webhookUrl)}catch{throw Error(`[chat/slack] webhookUrl is not a valid URL: ${q.webhookUrl}`)}if(z.protocol!=="https:")throw Error("[chat/slack] webhookUrl must use https:// \u2014 Slack does not accept plain HTTP webhooks.");if(!/(?:^|\.)slack\.com$/i.test(z.hostname))throw Error(`[chat/slack] webhookUrl host "${z.hostname}" is not a Slack-owned domain.`)}M={...M,...q}}class V extends K{name="slack";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)Q(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};y.info("Sending message via Slack...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{let G=await this.sendMessage(q,z);return this.handleSuccess(q,G.ts)}catch(G){if(F<this.config.maxRetries)return y.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){if(M.webhookUrl)return this.sendViaWebhook(q);if(M.botToken)return this.sendViaBotToken(q);throw Error("Slack not configured: provide webhookUrl or botToken")}async sendViaWebhook(q){let F=q.content||q.subject||"",H={text:F.length>40000?`${F.slice(0,39986)}\u2026 [truncated]`:F,username:q.from,mrkdwn:!0};if(q.template)H.blocks=this.buildBlocks(q);let J=await fetch(M.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!J.ok){let x=await J.text();throw Error(`Slack webhook failed: ${J.status} - ${x}`)}return{}}async sendViaBotToken(q){let z={channel:q.to,text:q.content||q.subject,mrkdwn:!0};if(q.template)z.blocks=this.buildBlocks(q);let F=await fetch("https://slack.com/api/chat.postMessage",{method:"POST",headers:{Authorization:`Bearer ${M.botToken}`,"Content-Type":"application/json"},body:JSON.stringify(z)});if(!F.ok)throw Error(`Slack API failed: ${F.status}`);let G=await F.json();if(!G.ok)throw Error(`Slack API error: ${G.error}`);return{ts:G.ts}}buildBlocks(q){let z=[];if(q.subject)z.push({type:"header",text:{type:"plain_text",text:q.subject,emoji:!0}});if(q.content)z.push({type:"section",text:{type:"mrkdwn",text:q.content}});return z}}async function _(q,z){return new V().send(q,z)}async function $(q,z,F){try{let G={text:z,...F},H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();return{success:!1,provider:"slack",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"slack",message:"Message sent successfully"}}catch(G){return{success:!1,provider:"slack",message:(G instanceof Error?G:Error(String(G))).message}}}var b=new V,v={send:_,sendWebhook:$,configure:Q,SlackDriver:V};var C={};B(C,{sendWebhook:()=>E,sendCard:()=>T,send:()=>A,driver:()=>d,default:()=>c,configure:()=>X,TeamsDriver:()=>Y,Driver:()=>Y});import{log as U}from"@stacksjs/logging";var I={};function X(q){I={...I,...q}}class Y extends K{name="teams";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)X(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};U.info("Sending message via Microsoft Teams...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{return await this.sendMessage(q,z),this.handleSuccess(q)}catch(G){if(F<this.config.maxRetries)return U.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){let F=I.webhookUrl||q.to;if(!F||!F.includes("webhook.office.com"))throw Error("Teams webhook URL not configured or invalid");let G=this.buildPayload(q),H=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();throw Error(`Teams webhook failed: ${H.status} - ${J}`)}}buildPayload(q){if(!q.subject&&!q.template)return{type:"message",text:q.content||""};let z=this.buildAdaptiveCard(q);return{type:"message",summary:q.subject||q.content?.substring(0,50)||"Notification",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",content:z}]}}buildAdaptiveCard(q){let z=[];if(q.subject)z.push({type:"TextBlock",text:q.subject,size:"Large",weight:"Bolder",wrap:!0});if(q.content)z.push({type:"TextBlock",text:q.content,wrap:!0});return z.push({type:"TextBlock",text:new Date().toLocaleString(),size:"Small",color:"Dark",wrap:!0}),{type:"AdaptiveCard",version:"1.4",$schema:"http://adaptivecards.io/schemas/adaptive-card.json",body:z}}}async function A(q,z){return new Y().send(q,z)}async function E(q,z){try{let G=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"message",text:z})});if(!G.ok){let H=await G.text();return{success:!1,provider:"teams",message:`Webhook failed: ${G.status} - ${H}`}}return{success:!0,provider:"teams",message:"Message sent successfully"}}catch(F){return{success:!1,provider:"teams",message:(F instanceof Error?F:Error(String(F))).message}}}async function T(q,z,F){try{let H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"message",summary:F||"Notification",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",content:z}]})});if(!H.ok){let J=await H.text();return{success:!1,provider:"teams",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"teams",message:"Card sent successfully"}}catch(G){return{success:!1,provider:"teams",message:(G instanceof Error?G:Error(String(G))).message}}}var d=new Y,c={send:A,sendWebhook:E,sendCard:T,configure:X,TeamsDriver:Y};async function o(q,z={}){let F=z.driver??"slack";switch(F){case"slack":return _(q);case"discord":return Z(q);case"teams":return A(q);default:return{success:!1,provider:F,message:`Unknown chat driver: ${F}`}}}async function s(q,z,F){return $(q,z,F)}async function e(q,z,F){return P(q,z,F)}async function qq(q,z){return E(q,z)}function zq(q){Q(q)}function Fq(q){N(q)}function Gq(q){X(q)}export{C as teams,W as slack,qq as sendToTeams,s as sendToSlack,e as sendToDiscord,o as send,j as discord,Gq as configureTeams,zq as configureSlack,Fq as configureDiscord};
2
+ var w=Object.defineProperty;var h=(q)=>q;function f(q,z){this[q]=h.bind(null,z)}var B=(q,z)=>{for(var F in z)w(q,F,{get:z[F],enumerable:!0,configurable:!0,set:f.bind(z,F)})};var j={};B(j,{sendWebhook:()=>P,sendEmbed:()=>S,send:()=>Z,driver:()=>u,default:()=>k,configure:()=>N,Driver:()=>O,DiscordDriver:()=>O});import{log as R}from"@stacksjs/logging";import{log as D}from"@stacksjs/logging";class K{config;constructor(q){this.config={maxRetries:q?.maxRetries||3,retryTimeout:q?.retryTimeout||1000,...q}}configure(q){this.config={...this.config,...q}}validateMessage(q){if(!q.to)throw Error("Message recipient is required");if(!q.content&&!q.template)throw Error("Either message content or template is required");return!0}async handleError(q,z){let F=q instanceof Error?q:Error(String(q));D.error(`[${this.name}] Message sending failed`,{error:F.message,stack:F.stack?.replace(/https?:\/\/[^\s)\]"']+/g,"[REDACTED-URL]"),to:z.to,subject:z.subject});let G={message:`Message sending failed: ${F.message}`,success:!1,provider:this.name};if(z.onError){let H=z.onError(F),J=H instanceof Promise?await H:H;G={...G,...J,success:!1,provider:this.name}}return G}async handleSuccess(q,z){let F={message:"Message sent successfully",success:!0,provider:this.name,messageId:z};try{if(q.handle){let G=q.handle(),H=G instanceof Promise?await G:G;F={...F,...H,success:!0,provider:this.name,messageId:z}}if(q.onSuccess){let G=q.onSuccess(),H=G instanceof Promise?await G:G;F={...F,...H,success:!0,provider:this.name,messageId:z}}}catch(G){return this.handleError(G,q)}return F}}var L={};function N(q){if(q.webhookUrl){let z;try{z=new URL(q.webhookUrl)}catch{throw Error(`[chat/discord] webhookUrl is not a valid URL: ${q.webhookUrl}`)}if(z.protocol!=="https:")throw Error("[chat/discord] webhookUrl must use https://");if(!/(?:^|\.)discord(?:app)?\.com$/i.test(z.hostname))throw Error(`[chat/discord] webhookUrl host "${z.hostname}" is not a Discord-owned domain.`)}L={...L,...q}}class O extends K{name="discord";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)N(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};R.info("Sending message via Discord...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{let G=await this.sendMessage(q,z);return this.handleSuccess(q,G.id)}catch(G){if(F<this.config.maxRetries)return R.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){if(L.webhookUrl)return this.sendViaWebhook(q);if(L.botToken)return this.sendViaBotToken(q);throw Error("Discord not configured: provide webhookUrl or botToken")}async sendViaWebhook(q){let z={content:q.content,username:q.from};if(q.subject||q.template)z.embeds=[this.buildEmbed(q)];let F=await fetch(L.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(!F.ok){let H=await F.text();throw Error(`Discord webhook failed: ${F.status} - ${H}`)}if(F.status===204)return{};return{id:(await F.json()).id}}async sendViaBotToken(q){let z=q.to,F={content:q.content};if(q.subject||q.template)F.embeds=[this.buildEmbed(q)];let G=await fetch(`https://discord.com/api/v10/channels/${z}/messages`,{method:"POST",headers:{Authorization:`Bot ${L.botToken}`,"Content-Type":"application/json"},body:JSON.stringify(F)});if(!G.ok){let J=await G.json();throw Error(`Discord API failed: ${G.status} - ${J.message}`)}return{id:(await G.json()).id}}buildEmbed(q){let z={};if(q.subject)z.title=q.subject;if(q.content)z.description=q.content;return z.color=5793266,z.timestamp=new Date().toISOString(),z}}async function Z(q,z){return new O().send(q,z)}async function P(q,z,F){try{let G={content:z,...F},H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();return{success:!1,provider:"discord",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"discord",message:"Message sent successfully"}}catch(G){return{success:!1,provider:"discord",message:(G instanceof Error?G:Error(String(G))).message}}}async function S(q,z,F){return P(q,"",{...F,embeds:[z]})}var u=new O,k={send:Z,sendWebhook:P,sendEmbed:S,configure:N,DiscordDriver:O};var W={};B(W,{sendWebhook:()=>$,send:()=>_,driver:()=>b,default:()=>v,configure:()=>Q,SlackDriver:()=>V,Driver:()=>V});import{log as y}from"@stacksjs/logging";var M={};function Q(q){if(q.webhookUrl){let z;try{z=new URL(q.webhookUrl)}catch{throw Error(`[chat/slack] webhookUrl is not a valid URL: ${q.webhookUrl}`)}if(z.protocol!=="https:")throw Error("[chat/slack] webhookUrl must use https:// - Slack does not accept plain HTTP webhooks.");if(!/(?:^|\.)slack\.com$/i.test(z.hostname))throw Error(`[chat/slack] webhookUrl host "${z.hostname}" is not a Slack-owned domain.`)}M={...M,...q}}class V extends K{name="slack";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)Q(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};y.info("Sending message via Slack...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{let G=await this.sendMessage(q,z);return this.handleSuccess(q,G.ts)}catch(G){if(F<this.config.maxRetries)return y.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){if(M.webhookUrl)return this.sendViaWebhook(q);if(M.botToken)return this.sendViaBotToken(q);throw Error("Slack not configured: provide webhookUrl or botToken")}async sendViaWebhook(q){let F=q.content||q.subject||"",H={text:F.length>40000?`${F.slice(0,39986)}\u2026 [truncated]`:F,username:q.from,mrkdwn:!0};if(q.template)H.blocks=this.buildBlocks(q);let J=await fetch(M.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!J.ok){let x=await J.text();throw Error(`Slack webhook failed: ${J.status} - ${x}`)}return{}}async sendViaBotToken(q){let z={channel:q.to,text:q.content||q.subject,mrkdwn:!0};if(q.template)z.blocks=this.buildBlocks(q);let F=await fetch("https://slack.com/api/chat.postMessage",{method:"POST",headers:{Authorization:`Bearer ${M.botToken}`,"Content-Type":"application/json"},body:JSON.stringify(z)});if(!F.ok)throw Error(`Slack API failed: ${F.status}`);let G=await F.json();if(!G.ok)throw Error(`Slack API error: ${G.error}`);return{ts:G.ts}}buildBlocks(q){let z=[];if(q.subject)z.push({type:"header",text:{type:"plain_text",text:q.subject,emoji:!0}});if(q.content)z.push({type:"section",text:{type:"mrkdwn",text:q.content}});return z}}async function _(q,z){return new V().send(q,z)}async function $(q,z,F){try{let G={text:z,...F},H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();return{success:!1,provider:"slack",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"slack",message:"Message sent successfully"}}catch(G){return{success:!1,provider:"slack",message:(G instanceof Error?G:Error(String(G))).message}}}var b=new V,v={send:_,sendWebhook:$,configure:Q,SlackDriver:V};var C={};B(C,{sendWebhook:()=>E,sendCard:()=>T,send:()=>A,driver:()=>d,default:()=>c,configure:()=>X,TeamsDriver:()=>Y,Driver:()=>Y});import{log as U}from"@stacksjs/logging";var I={};function X(q){I={...I,...q}}class Y extends K{name="teams";constructor(q){super({maxRetries:q?.maxRetries??3,retryTimeout:q?.retryTimeout??1000});if(q)X(q)}async send(q,z){let F={provider:this.name,to:q.to,subject:q.subject||"No subject"};U.info("Sending message via Microsoft Teams...",F);try{return this.validateMessage(q),await this.sendWithRetry(q,z)}catch(G){return this.handleError(G,q)}}async sendWithRetry(q,z,F=1){try{return await this.sendMessage(q,z),this.handleSuccess(q)}catch(G){if(F<this.config.maxRetries)return U.warn(`[${this.name}] Message send failed, retrying (${F}/${this.config.maxRetries})`),await new Promise((H)=>setTimeout(H,this.config.retryTimeout)),this.sendWithRetry(q,z,F+1);throw G}}async sendMessage(q,z){let F=I.webhookUrl||q.to;if(!F||!F.includes("webhook.office.com"))throw Error("Teams webhook URL not configured or invalid");let G=this.buildPayload(q),H=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok){let J=await H.text();throw Error(`Teams webhook failed: ${H.status} - ${J}`)}}buildPayload(q){if(!q.subject&&!q.template)return{type:"message",text:q.content||""};let z=this.buildAdaptiveCard(q);return{type:"message",summary:q.subject||q.content?.substring(0,50)||"Notification",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",content:z}]}}buildAdaptiveCard(q){let z=[];if(q.subject)z.push({type:"TextBlock",text:q.subject,size:"Large",weight:"Bolder",wrap:!0});if(q.content)z.push({type:"TextBlock",text:q.content,wrap:!0});return z.push({type:"TextBlock",text:new Date().toLocaleString(),size:"Small",color:"Dark",wrap:!0}),{type:"AdaptiveCard",version:"1.4",$schema:"http://adaptivecards.io/schemas/adaptive-card.json",body:z}}}async function A(q,z){return new Y().send(q,z)}async function E(q,z){try{let G=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"message",text:z})});if(!G.ok){let H=await G.text();return{success:!1,provider:"teams",message:`Webhook failed: ${G.status} - ${H}`}}return{success:!0,provider:"teams",message:"Message sent successfully"}}catch(F){return{success:!1,provider:"teams",message:(F instanceof Error?F:Error(String(F))).message}}}async function T(q,z,F){try{let H=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"message",summary:F||"Notification",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",content:z}]})});if(!H.ok){let J=await H.text();return{success:!1,provider:"teams",message:`Webhook failed: ${H.status} - ${J}`}}return{success:!0,provider:"teams",message:"Card sent successfully"}}catch(G){return{success:!1,provider:"teams",message:(G instanceof Error?G:Error(String(G))).message}}}var d=new Y,c={send:A,sendWebhook:E,sendCard:T,configure:X,TeamsDriver:Y};async function o(q,z={}){let F=z.driver??"slack";switch(F){case"slack":return _(q);case"discord":return Z(q);case"teams":return A(q);default:return{success:!1,provider:F,message:`Unknown chat driver: ${F}`}}}async function s(q,z,F){return $(q,z,F)}async function e(q,z,F){return P(q,z,F)}async function qq(q,z){return E(q,z)}function zq(q){Q(q)}function Fq(q){N(q)}function Gq(q){X(q)}export{C as teams,W as slack,qq as sendToTeams,s as sendToSlack,e as sendToDiscord,o as send,j as discord,Gq as configureTeams,zq as configureSlack,Fq as configureDiscord};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/chat",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.72.38",
5
+ "version": "0.72.39",
6
6
  "description": "Easily interact with chat APIs.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -58,10 +58,10 @@
58
58
  "prepublishOnly": "bun run build"
59
59
  },
60
60
  "devDependencies": {
61
- "@stacksjs/cli": "0.72.38",
62
- "@stacksjs/config": "0.72.38",
61
+ "@stacksjs/cli": "0.72.39",
62
+ "@stacksjs/config": "0.72.39",
63
63
  "better-dx": "^0.2.24",
64
- "@stacksjs/error-handling": "0.72.38",
65
- "@stacksjs/types": "0.72.38"
64
+ "@stacksjs/error-handling": "0.72.39",
65
+ "@stacksjs/types": "0.72.39"
66
66
  }
67
67
  }