@novu/framework 2.11.1 → 2.11.2-alpha.1
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/README.md +114 -9
- package/ai-sdk/package.json +4 -0
- package/cards/package.json +4 -0
- package/dist/{esm/index-D6L0Yufw.d.ts → cjs/agent.types-Dqm2VBTO.d.cts} +410 -193
- package/dist/cjs/ai-sdk/index.cjs +1 -0
- package/dist/cjs/ai-sdk/index.d.cts +40 -0
- package/dist/cjs/cards.cjs +57 -0
- package/dist/cjs/cards.d.cts +2 -0
- package/dist/cjs/{health-check.types-D4NEyjyC.d.cts → health-check.types-B9FbzRbm.d.cts} +6 -140
- package/dist/cjs/index-1DobCKAF.d.cts +160 -0
- package/dist/cjs/index.cjs +138 -138
- package/dist/cjs/index.d.cts +5 -3
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +98 -4
- package/dist/cjs/jsx-dev-runtime.cjs +1 -1
- package/dist/cjs/jsx-runtime.cjs +1 -1
- package/dist/cjs/langchain/index.cjs +1 -0
- package/dist/cjs/langchain/index.d.cts +106 -0
- package/dist/cjs/servers/express.cjs +138 -138
- package/dist/cjs/servers/express.d.cts +6 -4
- package/dist/cjs/servers/h3.cjs +137 -137
- package/dist/cjs/servers/h3.d.cts +6 -4
- package/dist/cjs/servers/lambda.cjs +137 -137
- package/dist/cjs/servers/lambda.d.cts +6 -5
- package/dist/cjs/servers/nest.cjs +138 -138
- package/dist/cjs/servers/nest.d.cts +21 -7
- package/dist/cjs/servers/next.cjs +137 -137
- package/dist/cjs/servers/next.d.cts +6 -4
- package/dist/cjs/servers/nuxt.cjs +137 -137
- package/dist/cjs/servers/nuxt.d.cts +6 -4
- package/dist/cjs/servers/remix.cjs +137 -137
- package/dist/cjs/servers/remix.d.cts +6 -4
- package/dist/cjs/servers/sveltekit.cjs +137 -137
- package/dist/cjs/servers/sveltekit.d.cts +6 -4
- package/dist/cjs/step-resolver.cjs +1 -1
- package/dist/cjs/step-resolver.d.cts +3 -2
- package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DubxcL8q.d.cts} +18 -78
- package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
- package/dist/cjs/validators.cjs +1 -1
- package/dist/{cjs/index-BNiIiOE-.d.cts → esm/agent.types-E3sxq6xr.d.ts} +410 -193
- package/dist/esm/ai-sdk/index.d.ts +40 -0
- package/dist/esm/ai-sdk/index.js +1 -0
- package/dist/esm/cards.d.ts +2 -0
- package/dist/esm/cards.js +1 -0
- package/dist/esm/{chunk-DKQLYSZS.js → chunk-22DBAEUX.js} +1 -1
- package/dist/esm/{chunk-KLCBNFAF.js → chunk-3XT6S7TZ.js} +14 -14
- package/dist/esm/chunk-3ZWME5KT.js +0 -0
- package/dist/esm/chunk-C3P3ZH2I.js +36 -0
- package/dist/esm/{chunk-QTWEINJ4.js → chunk-CANJPWLT.js} +1 -1
- package/dist/esm/chunk-E2MET7IR.js +1 -0
- package/dist/esm/chunk-FHYMHX3T.js +1 -0
- package/dist/esm/chunk-Q6BV36LU.js +98 -0
- package/dist/esm/chunk-W6DIBD4Z.js +1 -0
- package/dist/esm/{health-check.types-C-81VaBO.d.ts → health-check.types-BNocZ4Wk.d.ts} +6 -140
- package/dist/esm/index-aVljLqR4.d.ts +160 -0
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +98 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +106 -0
- package/dist/esm/langchain/index.js +1 -0
- package/dist/esm/servers/express.d.ts +6 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +21 -7
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -4
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +3 -2
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CC7F0JO_.d.ts → subscriber.types-CmybpXhA.d.ts} +18 -78
- package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
- package/dist/esm/validators.js +1 -1
- package/package.json +56 -8
- package/dist/esm/chunk-52LSX2V5.js +0 -1
- package/dist/esm/chunk-N4PZBM53.js +0 -1
- package/dist/esm/chunk-ND6IQFTA.js +0 -133
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import{a as P,b as L,c as w,d as b,e as k,f as Z,g as Y,h as tt,i as et,j as at,k as rt,l as R,m as st,n as it,o as nt,u as _,w as y}from"./chunk-3XT6S7TZ.js";import{f as c}from"./chunk-FHYMHX3T.js";var C=Symbol.for("workflow-serialize"),x=Symbol.for("workflow-deserialize");var Ot=Object.defineProperty,$t=Object.defineProperties,Dt=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,vt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,lt=(t,e,a)=>e in t?Ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,ut=(t,e)=>{for(var a in e||(e={}))vt.call(e,a)&<(t,a,e[a]);if(ot)for(var a of ot(e))Ut.call(e,a)&<(t,a,e[a]);return t},ft=(t,e)=>$t(t,Dt(e)),p=(t,e)=>{let a=!1,r=!1;for(let s=0;s<e;s+=1){if(t[s]==="\\"&&s+1<t.length&&t[s+1]==="`"){s+=1;continue}if(t.substring(s,s+3)==="```"){r=!r,s+=2;continue}!r&&t[s]==="`"&&(a=!a)}return a||r},Pt=(t,e)=>{let a=t.substring(e,e+3)==="```",r=e>0&&t.substring(e-1,e+2)==="```",s=e>1&&t.substring(e-2,e+1)==="```";return a||r||s},Ht=t=>{let e=0;for(let a=0;a<t.length;a+=1){if(t[a]==="\\"&&a+1<t.length&&t[a+1]==="`"){a+=1;continue}t[a]==="`"&&!Pt(t,a)&&(e+=1)}return e},M=(t,e)=>{let a=!1,r=!1,s=-1;for(let i=0;i<t.length;i+=1){if(t[i]==="\\"&&i+1<t.length&&t[i+1]==="`"){i+=1;continue}if(t.substring(i,i+3)==="```"){r=!r,i+=2;continue}if(!r&&t[i]==="`")if(a){if(s<e&&e<i)return!0;a=!1,s=-1}else a=!0,s=i}return!1},Wt=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Jt=t=>!t||typeof t!="string"||!t.includes(">")?t:t.replace(Wt,(e,a,r,s)=>p(t,s)?e:`${a}\\>${r}`),jt=/(\*\*)([^*]*\*?)$/,zt=/(__)([^_]*?)$/,Bt=/(\*\*\*)([^*]*?)$/,Kt=/(\*)([^*]*?)$/,Xt=/(_)([^_]*?)$/,qt=/(`)([^`]*?)$/,Gt=/(~~)([^~]*?)$/,S=/^[\s_~*`]*$/,gt=/^[\s]*[-*+][\s]+$/,Vt=/[\p{L}\p{N}_]/u,Qt=/^```[^`\n]*```?$/,Zt=/^\*{4,}$/,Yt=/(__)([^_]+)_$/,te=/(~~)([^~]+)~$/,ct=/~~/g,I=t=>{if(!t)return!1;let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95?!0:Vt.test(t)};var ee=(t,e)=>{let a=1;for(let r=e-1;r>=0;r-=1)if(t[r]==="]")a+=1;else if(t[r]==="["&&(a-=1,a===0))return r;return-1},pt=(t,e)=>{let a=1;for(let r=e+1;r<t.length;r+=1)if(t[r]==="[")a+=1;else if(t[r]==="]"&&(a-=1,a===0))return r;return-1},$=(t,e)=>{let a=!1,r=!1;for(let s=0;s<t.length&&s<e;s+=1){if(t[s]==="\\"&&t[s+1]==="$"){s+=1;continue}t[s]==="$"&&(t[s+1]==="$"?(r=!r,s+=1,a=!1):r||(a=!a))}return a||r},ae=(t,e)=>{for(let a=e;a<t.length;a+=1){if(t[a]===")")return!0;if(t[a]===`
|
|
2
|
+
`)return!1}return!1},mt=(t,e)=>{for(let a=e-1;a>=0;a-=1){if(t[a]===")")return!1;if(t[a]==="(")return a>0&&t[a-1]==="]"?ae(t,e):!1;if(t[a]===`
|
|
3
|
+
`)return!1}return!1},re=(t,e)=>{for(let a=e-1;a>=0;a-=1){if(t[a]===">")return!1;if(t[a]==="<"){let r=a+1<t.length?t[a+1]:"";return r>="a"&&r<="z"||r>="A"&&r<="Z"||r==="/"}if(t[a]===`
|
|
4
|
+
`)return!1}return!1},W=(t,e,a)=>{let r=0;for(let l=e-1;l>=0;l-=1)if(t[l]===`
|
|
5
|
+
`){r=l+1;break}let s=t.length;for(let l=e;l<t.length;l+=1)if(t[l]===`
|
|
6
|
+
`){s=l;break}let i=t.substring(r,s),n=0,o=!1;for(let l of i)if(l===a)n+=1;else if(l!==" "&&l!==" "){o=!0;break}return n>=3&&!o},se=(t,e,a,r)=>a==="\\"||t.includes("$")&&$(t,e)?!0:a!=="*"&&r==="*"?(e<t.length-2?t[e+2]:"")!=="*":!!(a==="*"||a&&r&&I(a)&&I(r)||(!a||a===" "||a===" "||a===`
|
|
7
|
+
`)&&(!r||r===" "||r===" "||r===`
|
|
8
|
+
`)),_t=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="*")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";se(t,s,i,n)||(e+=1)}return e},ie=(t,e,a,r)=>!!(a==="\\"||t.includes("$")&&$(t,e)||mt(t,e)||re(t,e)||a==="_"||r==="_"||a&&r&&I(a)&&I(r)),ne=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="_")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";ie(t,s,i,n)||(e+=1)}return e},oe=t=>{let e=0,a=0,r=!1;for(let s=0;s<t.length;s+=1){if(t[s]==="`"&&s+2<t.length&&t[s+1]==="`"&&t[s+2]==="`"){a>=3&&(e+=Math.floor(a/3)),a=0,r=!r,s+=2;continue}r||(t[s]==="*"?a+=1:(a>=3&&(e+=Math.floor(a/3)),a=0))}return a>=3&&(e+=Math.floor(a/3)),e},J=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="*"&&r+1<t.length&&t[r+1]==="*"&&(e+=1,r+=1)}return e},dt=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="_"&&r+1<t.length&&t[r+1]==="_"&&(e+=1,r+=1)}return e},le=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
|
|
9
|
+
`),s=r===-1?0:r+1,i=t.substring(s,a);return gt.test(i)&&e.includes(`
|
|
10
|
+
`)?!0:W(t,a,"*")},ce=t=>{let e=t.match(jt);if(!e)return t;let a=e[2],r=t.lastIndexOf(e[1]);return p(t,r)||M(t,r)||le(t,a,r)?t:J(t)%2===1?a.endsWith("*")?`${t}*`:`${t}**`:t},de=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
|
|
11
|
+
`),s=r===-1?0:r+1,i=t.substring(s,a);return gt.test(i)&&e.includes(`
|
|
12
|
+
`)?!0:W(t,a,"_")},he=t=>{let e=t.match(zt);if(!e){let s=t.match(Yt);if(s){let i=t.lastIndexOf(s[1]);if(!(p(t,i)||M(t,i))&&dt(t)%2===1)return`${t}_`}return t}let a=e[2],r=t.lastIndexOf(e[1]);return p(t,r)||M(t,r)||de(t,a,r)?t:dt(t)%2===1?`${t}__`:t},ue=t=>{let e=!1;for(let a=0;a<t.length;a+=1){if(t[a]==="`"&&a+2<t.length&&t[a+1]==="`"&&t[a+2]==="`"){e=!e,a+=2;continue}if(!e&&t[a]==="*"&&t[a-1]!=="*"&&t[a+1]!=="*"&&t[a-1]!=="\\"&&!$(t,a)){let r=a>0?t[a-1]:"",s=a<t.length-1?t[a+1]:"";if((!r||r===" "||r===" "||r===`
|
|
13
|
+
`)&&(!s||s===" "||s===" "||s===`
|
|
14
|
+
`)||r&&s&&I(r)&&I(s))continue;return a}}return-1},fe=t=>{if(!t.match(Kt))return t;let e=ue(t);if(e===-1||p(t,e)||M(t,e))return t;let a=t.substring(e+1);return!a||S.test(a)?t:_t(t)%2===1?`${t}*`:t},yt=t=>{let e=!1;for(let a=0;a<t.length;a+=1){if(t[a]==="`"&&a+2<t.length&&t[a+1]==="`"&&t[a+2]==="`"){e=!e,a+=2;continue}if(!e&&t[a]==="_"&&t[a-1]!=="_"&&t[a+1]!=="_"&&t[a-1]!=="\\"&&!$(t,a)&&!mt(t,a)){let r=a>0?t[a-1]:"",s=a<t.length-1?t[a+1]:"";if(r&&s&&I(r)&&I(s))continue;return a}}return-1},ge=t=>{let e=t.length;for(;e>0&&t[e-1]===`
|
|
15
|
+
`;)e-=1;if(e<t.length){let a=t.slice(0,e),r=t.slice(e);return`${a}_${r}`}return`${t}_`},pe=t=>{if(!t.endsWith("**"))return null;let e=t.slice(0,-2);if(J(e)%2!==1)return null;let a=e.indexOf("**"),r=yt(e);return a!==-1&&r!==-1&&a<r?`${e}_**`:null},me=t=>{if(!t.match(Xt))return t;let e=yt(t);if(e===-1)return t;let a=t.substring(e+1);if(!a||S.test(a)||p(t,e)||M(t,e))return t;if(ne(t)%2===1){let r=pe(t);return r!==null?r:ge(t)}return t},_e=t=>{let e=J(t),a=_t(t);return e%2===0&&a%2===0},ye=(t,e,a)=>!e||S.test(e)||p(t,a)||M(t,a)?!0:W(t,a,"*"),we=t=>{if(Zt.test(t))return t;let e=t.match(Bt);if(!e)return t;let a=e[2],r=t.lastIndexOf(e[1]);return ye(t,a,r)?t:oe(t)%2===1?_e(t)?t:`${t}***`:t},be=/<[a-zA-Z/][^>]*$/,ke=t=>{let e=t.match(be);return!e||e.index===void 0||p(t,e.index)?t:t.substring(0,e.index).trimEnd()},Me=t=>!t.match(Qt)||t.includes(`
|
|
16
|
+
`)?null:t.endsWith("``")&&!t.endsWith("```")?`${t}\``:t,Ie=t=>(t.match(/```/g)||[]).length%2===1,Se=t=>{let e=Me(t);if(e!==null)return e;let a=t.match(qt);if(a&&!Ie(t)){let r=a[2];if(!r||S.test(r))return t;if(Ht(t)%2===1)return`${t}\``}return t},wt=(t,e)=>e>=2&&t.substring(e-2,e+1)==="```"||e>=1&&t.substring(e-1,e+2)==="```"||e<=t.length-3&&t.substring(e,e+3)==="```",Te=t=>{let e=0,a=!1;for(let r=0;r<t.length-1;r+=1)t[r]==="`"&&!wt(t,r)&&(a=!a),!a&&t[r]==="$"&&t[r+1]==="$"&&(e+=1,r+=1);return e},Ee=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="\\"){r+=1;continue}if(t[r]==="`"&&!wt(t,r)){a=!a;continue}!a&&t[r]==="$"&&(r+1<t.length&&t[r+1]==="$"?r+=1:e+=1)}return e},Ae=t=>{if(t.endsWith("$")&&!t.endsWith("$$"))return`${t}$`;let e=t.indexOf("$$");return e!==-1&&t.indexOf(`
|
|
17
|
+
`,e)!==-1&&!t.endsWith(`
|
|
18
|
+
`)?`${t}
|
|
19
|
+
$$`:`${t}$$`},Ce=t=>Te(t)%2===0?t:Ae(t),xe=t=>Ee(t)%2===1?`${t}$`:t,Fe=(t,e,a)=>{if(t.substring(e+2).includes(")"))return null;let r=ee(t,e);if(r===-1||p(t,r))return null;let s=r>0&&t[r-1]==="!",i=s?r-1:r,n=t.substring(0,i);if(s)return n;let o=t.substring(r+1,e);return a==="text-only"?`${n}${o}`:`${n}[${o}](streamdown:incomplete-link)`},ht=(t,e)=>{for(let a=0;a<e;a++)if(t[a]==="["&&!p(t,a)){if(a>0&&t[a-1]==="!")continue;let r=pt(t,a);if(r===-1)return a;if(r+1<t.length&&t[r+1]==="("){let s=t.indexOf(")",r+2);s!==-1&&(a=s)}}return e},Ne=(t,e,a)=>{let r=e>0&&t[e-1]==="!",s=r?e-1:e;if(!t.substring(e+1).includes("]")){let i=t.substring(0,s);if(r)return i;if(a==="text-only"){let n=ht(t,e);return t.substring(0,n)+t.substring(n+1)}return`${t}](streamdown:incomplete-link)`}if(pt(t,e)===-1){let i=t.substring(0,s);if(r)return i;if(a==="text-only"){let n=ht(t,e);return t.substring(0,n)+t.substring(n+1)}return`${t}](streamdown:incomplete-link)`}return null},bt=(t,e="protocol")=>{let a=t.lastIndexOf("](");if(a!==-1&&!p(t,a)){let r=Fe(t,a,e);if(r!==null)return r}for(let r=t.length-1;r>=0;r-=1)if(t[r]==="["&&!p(t,r)){let s=Ne(t,r,e);if(s!==null)return s}return t},Le=/^-{1,2}$/,Re=/^[\s]*-{1,2}[\s]+$/,Oe=/^={1,2}$/,$e=/^[\s]*={1,2}[\s]+$/,De=t=>{if(!t||typeof t!="string")return t;let e=t.lastIndexOf(`
|
|
20
|
+
`);if(e===-1)return t;let a=t.substring(e+1),r=t.substring(0,e),s=a.trim();if(Le.test(s)&&!a.match(Re)){let i=r.split(`
|
|
21
|
+
`).at(-1);if(i&&i.trim().length>0)return`${t}\u200B`}if(Oe.test(s)&&!a.match($e)){let i=r.split(`
|
|
22
|
+
`).at(-1);if(i&&i.trim().length>0)return`${t}\u200B`}return t},ve=new RegExp("(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])","gu"),Ue=t=>!t||typeof t!="string"||!t.includes("~")?t:t.replace(ve,(e,a)=>p(t,a)?e:"\\~"),Pe=t=>{var e,a;let r=t.match(Gt);if(r){let s=r[2];if(!s||S.test(s))return t;let i=t.lastIndexOf(r[1]);if(p(t,i)||M(t,i))return t;if(((e=t.match(ct))==null?void 0:e.length)%2===1)return`${t}~~`}else{let s=t.match(te);if(s){let i=t.lastIndexOf(s[0].slice(0,2));if(p(t,i)||M(t,i))return t;if(((a=t.match(ct))==null?void 0:a.length)%2===1)return`${t}~`}}return t},H=t=>t!==!1,He=t=>t===!0,g={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},We=[{handler:{name:"singleTilde",handle:Ue,priority:g.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:Jt,priority:g.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:ke,priority:g.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:De,priority:g.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:bt,priority:g.LINKS},optionKey:"links",earlyReturn:t=>t.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:we,priority:g.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:ce,priority:g.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:he,priority:g.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:fe,priority:g.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:me,priority:g.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:Se,priority:g.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:Pe,priority:g.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:Ce,priority:g.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:xe,priority:g.INLINE_KATEX},optionKey:"inlineKatex"}],Je=t=>{var e;let a=(e=t==null?void 0:t.linkMode)!=null?e:"protocol";return We.filter(({handler:r,optionKey:s})=>r.name==="links"?H(t==null?void 0:t.links)||H(t==null?void 0:t.images):r.name==="inlineKatex"?He(t==null?void 0:t.inlineKatex):H(t==null?void 0:t[s])).map(({handler:r,earlyReturn:s})=>r.name==="links"?{handler:ft(ut({},r),{handle:i=>bt(i,a)}),earlyReturn:a==="protocol"?s:void 0}:{handler:r,earlyReturn:s})},je=(t,e)=>{var a;if(!t||typeof t!="string")return t;let r=t.endsWith(" ")&&!t.endsWith(" ")?t.slice(0,-1):t,s=Je(e),i=((a=e==null?void 0:e.handlers)!=null?a:[]).map(o=>{var l;return{handler:ft(ut({},o),{priority:(l=o.priority)!=null?l:g.DEFAULT}),earlyReturn:void 0}}),n=[...s,...i].sort((o,l)=>{var h,f;return((h=o.handler.priority)!=null?h:0)-((f=l.handler.priority)!=null?f:0)});for(let{handler:o,earlyReturn:l}of n)if(r=o.handle(r),l!=null&&l(r))return r;return r},O=je;var ze="__cb:",Be="chat:callback:",Ke=720*60*60*1e3;function Xe(t){return`${ze}${t}`}function qe(){return crypto.randomUUID().replace(/-/g,"").slice(0,16)}async function Ge(t,e){return{type:"actions",children:await Promise.all(t.children.map(async a=>{if(a.type!=="button"||!a.callbackUrl)return a;let r=qe(),s={url:a.callbackUrl,originalValue:a.value};return await e.set(`${Be}${r}`,s,Ke),{type:"button",id:a.id,label:a.label,style:a.style,disabled:a.disabled,value:Xe(r),actionType:a.actionType}}))}}function At(t){for(let e of t){if(e.type==="actions"){for(let a of e.children)if(a.type==="button"&&a.callbackUrl)return!0}if(e.type==="section"&&"children"in e&&At(e.children))return!0}return!1}async function Ct(t,e){let a=[];for(let r of t)r.type==="actions"?a.push(await Ge(r,e)):r.type==="section"&&"children"in r?a.push({...r,children:await Ct(r.children,e)}):a.push(r);return a}async function D(t,e){return At(t.children)?{...t,children:await Ct(t.children,e)}:t}var kt=null;function v(){if(!kt)throw new Error("No Chat singleton registered. Call chat.registerSingleton() first.");return kt}var Ve=new Set(["markdown_text","task_update","plan_update"]);async function*xt(t){var r,s;let e=!1,a=!1;for await(let i of t){if(typeof i=="string"){yield i;continue}if(i===null||typeof i!="object"||!("type"in i))continue;let n=i;if(Ve.has(n.type)){yield i;continue}let o=(s=(r=n.text)!=null?r:n.delta)!=null?s:n.textDelta;n.type==="text-delta"&&typeof o=="string"?(e&&a&&(yield`
|
|
23
|
+
|
|
24
|
+
`),e=!1,a=!0,yield o):n.type==="finish-step"&&(e=!0)}}var Qe=new WeakMap;var T=class z{constructor(e){c(this,"id");c(this,"threadId");c(this,"text");c(this,"formatted");c(this,"raw");c(this,"author");c(this,"metadata");c(this,"attachments");c(this,"isMention");c(this,"userKey");c(this,"links");c(this,"_subjectPromise");var a;this.id=e.id,this.threadId=e.threadId,this.text=e.text,this.formatted=e.formatted,this.raw=e.raw,this.author=e.author,this.metadata=e.metadata,this.attachments=e.attachments,this.isMention=e.isMention,this.links=(a=e.links)!=null?a:[]}get subject(){if(this._subjectPromise)return this._subjectPromise;let e=Qe.get(this);return e!=null&&e.fetchSubject?(this._subjectPromise=e.fetchSubject(this.raw).catch(()=>null),this._subjectPromise):(this._subjectPromise=Promise.resolve(null),this._subjectPromise)}toJSON(){var e;return{_type:"chat:Message",id:this.id,threadId:this.threadId,text:this.text,formatted:this.formatted,raw:this.raw,author:{userId:this.author.userId,userName:this.author.userName,fullName:this.author.fullName,isBot:this.author.isBot,isMe:this.author.isMe},metadata:{dateSent:this.metadata.dateSent.toISOString(),edited:this.metadata.edited,editedAt:(e=this.metadata.editedAt)==null?void 0:e.toISOString()},attachments:this.attachments.map(a=>({type:a.type,url:a.url,name:a.name,mimeType:a.mimeType,size:a.size,width:a.width,height:a.height,fetchMetadata:a.fetchMetadata})),isMention:this.isMention,links:this.links.length>0?this.links.map(a=>({url:a.url,title:a.title,description:a.description,imageUrl:a.imageUrl,siteName:a.siteName})):void 0}}static fromJSON(e){return new z({id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:{dateSent:new Date(e.metadata.dateSent),edited:e.metadata.edited,editedAt:e.metadata.editedAt?new Date(e.metadata.editedAt):void 0},attachments:e.attachments,isMention:e.isMention,links:e.links})}static[C](e){return e.toJSON()}static[x](e){return z.fromJSON(e)}},Ze=Symbol.for("chat.postable");function Ft(t){return typeof t=="object"&&t!==null&&t.$$typeof===Ze}async function Nt(t,e,a,r,s){let i=n=>{var o;return{adapter:e,logger:s,messageId:n.id,threadId:(o=n.threadId)!=null?o:a}};if(t.isSupported(e)&&e.postObject){let n=await e.postObject(a,t.kind,t.getPostData());t.onPosted(i(n))}else{let n=await r(a,t.getFallbackText());t.onPosted(i(n))}}var Ye=class extends Error{constructor(e,a,r){super(e);c(this,"code");c(this,"cause");this.name="ChatError",this.code=a,this.cause=r}};var Lt=class extends Ye{constructor(e,a,r){super(e,"NOT_IMPLEMENTED",r);c(this,"feature");this.name="NotImplementedError",this.feature=a}};var U=720*60*60*1e3,Mt="channel-state:";function ta(t){return"adapterName"in t&&!("adapter"in t)}function ea(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var aa=class B{constructor(e){c(this,"id");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_name",null);c(this,"_threadHistory");var a,r;this.id=e.id,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",ta(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory)}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Channel has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get name(){return this._name}get state(){return this._stateAdapter.get(`${Mt}${this.id}`)}async setState(e,a){let r=`${Mt}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n={cursor:s,direction:"backward"},o=e.fetchChannelMessages?await e.fetchChannelMessages(a,n):await e.fetchMessages(a,n),l=[...o.messages].reverse();for(let h of l)i=!0,yield h;if(!o.nextCursor||o.messages.length===0)break;s=o.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}threads(){let e=this.adapter,a=this.id;return{async*[Symbol.asyncIterator](){if(!e.listThreads)return;let r;for(;;){let s=await e.listThreads(a,{cursor:r});for(let i of s.threads)yield i;if(!s.nextCursor||s.threads.length===0)break;r=s.nextCursor}}}}async fetchMetadata(){var e;if(this.adapter.fetchChannelInfo){let a=await this.adapter.fetchChannelInfo(this.id);return this._name=(e=a.name)!=null?e:null,a}return{id:this.id,isDM:this.isDM,metadata:{}}}async post(e){if(Ft(e))return await this.handlePostableObject(e),e;if(ea(e)){let r="";for await(let s of xt(e))typeof s=="string"?r+=s:s.type==="markdown_text"&&(r+=s.text);return this.postSingleMessage({markdown:r})}let a=e;if(y(e)){let r=_(e);if(!r)throw new Error("Invalid JSX element: must be a Card element");a=r}return a=await this.processCallbackUrls(a),this.postSingleMessage(a)}async handlePostableObject(e){await Nt(e,this.adapter,this.id,(a,r)=>this.adapter.postChannelMessage?this.adapter.postChannelMessage(a,r):this.adapter.postMessage(a,r))}async postSingleMessage(e){let a=this.adapter.postChannelMessage?await this.adapter.postChannelMessage(this.id,e):await this.adapter.postMessage(this.id,e),r=this.createSentMessage(a.id,e,a.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(r)),r}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(y(a)){let o=_(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async schedule(e,a){let r;if(y(e)){let s=_(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Lt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async startTyping(e){await this.adapter.startTyping(this.id,e)}mentionUser(e){return`<@${e}>`}toJSON(){var e;return{_type:"chat:Channel",id:this.id,adapterName:(e=this._adapterName)!=null?e:this.adapter.name,channelVisibility:this.channelVisibility,isDM:this.isDM}}static fromJSON(e,a){let r=new B({id:e.id,adapterName:e.adapterName,channelVisibility:e.channelVisibility,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return B.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=sa(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,links:[],toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(y(d)){let m=_(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}};function ra(t,e){return t.channelIdFromThreadId(e)}function sa(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var ia=class{constructor(t={}){c(this,"accumulated","");c(this,"dirty",!0);c(this,"cachedRender","");c(this,"finished",!1);c(this,"fenceToggles",0);c(this,"incompleteLine","");c(this,"options");var e;this.options={wrapTablesForAppend:(e=t.wrapTablesForAppend)!=null?e:!0}}push(t){var a;this.accumulated+=t,this.dirty=!0,this.incompleteLine+=t;let e=this.incompleteLine.split(`
|
|
25
|
+
`);this.incompleteLine=(a=e.pop())!=null?a:"";for(let r of e){let s=r.trimStart();(s.startsWith("```")||s.startsWith("~~~"))&&this.fenceToggles++}}isAccumulatedInsideFence(){let t=this.fenceToggles%2===1,e=this.incompleteLine.trimStart();return(e.startsWith("```")||e.startsWith("~~~"))&&(t=!t),t}render(){if(!this.dirty)return this.cachedRender;if(this.dirty=!1,this.finished)return this.cachedRender=O(this.accumulated),this.cachedRender;if(this.isAccumulatedInsideFence())return this.cachedRender=O(this.accumulated),this.cachedRender;let t=St(this.accumulated);return this.cachedRender=O(t),this.cachedRender}getCommittableText(){if(this.finished)return this.formatAppendOnlyText(this.accumulated,!0);let t=this.accumulated;if(t.length>0&&!t.endsWith(`
|
|
26
|
+
`)){let r=t.lastIndexOf(`
|
|
27
|
+
`),s=r>=0?t.slice(0,r+1):"";if(j(s))return this.formatAppendOnlyText(t);t=s}if(j(t))return this.formatAppendOnlyText(t);let e=St(t),a=this.formatAppendOnlyText(e);return j(a)?a:oa(a)}getText(){return this.accumulated}finish(){return this.finished=!0,this.dirty=!0,this.render()}formatAppendOnlyText(t,e=!1){return this.options.wrapTablesForAppend?la(t,e):t}},na=new Set(["*","~","`","["]);function It(t){return O(t).length<=t.length}function oa(t){if(t.length===0||It(t))return t;for(let e=t.length-1;e>=0;e--)if(na.has(t[e])){for(;e>0&&t[e-1]===t[e];)e--;let a=t.slice(0,e);if(It(a))return a}return""}var K=/^\|.*\|$/,X=/^\|[\s:]*-{1,}[\s:]*(\|[\s:]*-{1,}[\s:]*)*\|$/;function j(t){let e=!1;for(let a of t.split(`
|
|
28
|
+
`)){let r=a.trimStart();(r.startsWith("```")||r.startsWith("~~~"))&&(e=!e)}return e}function St(t){let e=t.endsWith(`
|
|
29
|
+
`),a=t.split(`
|
|
30
|
+
`);!e&&a.length>0&&a.pop(),e&&a.length>0&&a.at(-1)===""&&a.pop();let r=0,s=!1;for(let l=a.length-1;l>=0;l--){let h=a[l].trim();if(h==="")break;if(X.test(h)){s=!0;break}if(K.test(h))r++;else break}if(s||r===0)return t;let i=a.length-r,n=a.slice(0,i),o=n.join(`
|
|
31
|
+
`);return n.length>0&&(o+=`
|
|
32
|
+
`),o}function la(t,e=!1){let a=t.endsWith(`
|
|
33
|
+
`),r=t.split(`
|
|
34
|
+
`);a&&r.length>0&&r.at(-1)===""&&r.pop();let s=[],i=!1,n=!1;for(let l=0;l<r.length;l++){let h=r[l].trim();if(!i&&(h.startsWith("```")||h.startsWith("~~~"))){n=!n,s.push(r[l]);continue}if(n){s.push(r[l]);continue}let f=h!==""&&(K.test(h)||X.test(h));if(f&&!i){let d=!1;for(let u=l;u<r.length;u++){let m=r[u].trim();if(X.test(m)){d=!0;break}if(m===""||!K.test(m))break}d&&(s.push("```"),i=!0)}else!f&&i&&(s.push("```"),i=!1);s.push(r[l])}i&&e&&s.push("```");let o=s.join(`
|
|
35
|
+
`);return a&&(o+=`
|
|
36
|
+
`),o}function ca(t){return"adapterName"in t&&!("adapter"in t)}var Tt="thread-state:";function da(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var mr=class q{constructor(e){c(this,"id");c(this,"channelId");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_recentMessages",[]);c(this,"_isSubscribedContext");c(this,"_currentMessage");c(this,"_streamingUpdateIntervalMs");c(this,"_fallbackStreamingPlaceholderText");c(this,"_channel");c(this,"_threadHistory");c(this,"_logger");var a,r,s,i;this.id=e.id,this.channelId=e.channelId,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",this._isSubscribedContext=(s=e.isSubscribedContext)!=null?s:!1,this._currentMessage=e.currentMessage,this._logger=e.logger,this._streamingUpdateIntervalMs=(i=e.streamingUpdateIntervalMs)!=null?i:500,this._fallbackStreamingPlaceholderText=e.fallbackStreamingPlaceholderText!==void 0?e.fallbackStreamingPlaceholderText:"...",ca(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory),e.initialMessage&&(this._recentMessages=[e.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(e){this._recentMessages=e}get state(){return this._stateAdapter.get(`${Tt}${this.id}`)}async setState(e,a){let r=`${Tt}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get channel(){if(!this._channel){let e=ra(this.adapter,this.id);this._channel=new aa({id:e,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,threadHistory:this._threadHistory})}return this._channel}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{cursor:s,direction:"backward"}),o=[...n.messages].reverse();for(let l of o)i=!0,yield l;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}get allMessages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{limit:100,cursor:s,direction:"forward"});for(let o of n.messages)i=!0,yield o;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o of n)yield o}}}}async getParticipants(){let e=new Map;this._currentMessage&&!this._currentMessage.author.isMe&&!this._currentMessage.author.isBot&&e.set(this._currentMessage.author.userId,this._currentMessage.author);for await(let a of this.allMessages)a.author.isMe||a.author.isBot||e.has(a.author.userId)||e.set(a.author.userId,a.author);return[...e.values()]}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(e){if(Ft(e)){if(e.kind==="stream"){let i=e.getPostData(),n={...i.options.updateIntervalMs?{updateIntervalMs:i.options.updateIntervalMs}:{},...i.options.groupTasks?{taskDisplayMode:i.options.groupTasks}:{},...i.options.endWith?{stopBlocks:i.options.endWith}:{}};return await this.handleStream(i.stream,n),e}return await this.handlePostableObject(e),e}if(da(e))return this.handleStream(e);let a=e;if(y(e)){let i=_(e);if(!i)throw new Error("Invalid JSX element: must be a Card element");a=i}a=await this.processCallbackUrls(a);let r=await this.adapter.postMessage(this.id,a),s=this.createSentMessage(r.id,a,r.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(s)),s}async handlePostableObject(e){await Nt(e,this.adapter,this.id,(a,r)=>this.adapter.postMessage(a,r),this._logger)}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(y(a)){let o=_(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async schedule(e,a){let r;if(y(e)){let s=_(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Lt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async handleStream(e,a){let r=xt(e),s={updateIntervalMs:this._streamingUpdateIntervalMs,...a};if(this._currentMessage&&(s.recipientUserId=this._currentMessage.author.userId,s.recipientTeamId=this.extractSlackRecipientTeamId(this._currentMessage.raw)),this.adapter.stream){let n="",o={[Symbol.asyncIterator]:()=>{let h=r[Symbol.asyncIterator]();return{async next(){let f=await h.next();if(!f.done){let d=f.value;typeof d=="string"?n+=d:d.type==="markdown_text"&&(n+=d.text)}return f}}}},l=await this.adapter.stream(this.id,o,s);if(l){let h=this.createSentMessage(l.id,{markdown:n},l.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(h)),h}}let i={[Symbol.asyncIterator]:()=>{let n=r[Symbol.asyncIterator]();return{async next(){for(;;){let o=await n.next();if(o.done)return{value:void 0,done:!0};let l=o.value;if(typeof l=="string")return{value:l,done:!1};if(l.type==="markdown_text")return{value:l.text,done:!1}}}}}};return this.fallbackStream(i,s)}extractSlackRecipientTeamId(e){var r;if(!e||typeof e!="object")return;let a=e;if(typeof a.team_id=="string"&&a.team_id)return a.team_id;if(typeof a.team=="string"&&a.team)return a.team;if(a.team&&typeof a.team=="object"&&typeof a.team.id=="string"&&a.team.id)return a.team.id;if(typeof((r=a.user)==null?void 0:r.team_id)=="string"&&a.user.team_id)return a.user.team_id}async startTyping(e){await this.adapter.startTyping(this.id,e)}async fallbackStream(e,a){var Q;let r=(Q=a==null?void 0:a.updateIntervalMs)!=null?Q:this._streamingUpdateIntervalMs,s=this._fallbackStreamingPlaceholderText,i=s===null?null:await this.adapter.postMessage(this.id,s),n=this.id,o=new ia,l="",h=!1,f=null,d=null;i&&(n=i.threadId||this.id,l=s!=null?s:"");let u=()=>{d=setTimeout(()=>{f=m()},r)},m=async()=>{var A;if(h||!i)return;let E=o.render();if(E.trim()&&E!==l)try{await this.adapter.editMessage(n,i.id,{markdown:E}),l=E}catch(Rt){(A=this._logger)==null||A.warn("fallbackStream edit failed",Rt)}h||u()};i&&u();try{for await(let E of e)if(o.push(E),!i){let A=o.render();A.trim()&&(i=await this.adapter.postMessage(this.id,{markdown:A}),n=i.threadId||this.id,l=A,u())}}finally{h=!0,d&&(clearTimeout(d),d=null)}f&&await f;let N=o.getText(),G=o.finish();i||(i=await this.adapter.postMessage(this.id,{markdown:N.trim()?N:" "}),n=i.threadId||this.id,l=N),G.trim()&&G!==l&&await this.adapter.editMessage(n,i.id,{markdown:N});let V=this.createSentMessage(i.id,{markdown:N},n);return this._threadHistory&&await this._threadHistory.append(this.id,new T(V)),V}async refresh(){let e=await this.adapter.fetchMessages(this.id,{limit:50});e.messages.length>0?this._recentMessages=e.messages:this._threadHistory?this._recentMessages=await this._threadHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(e){return`<@${e}>`}toJSON(){var e,a;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(e=this._currentMessage)==null?void 0:e.toJSON(),isDM:this.isDM,adapterName:(a=this._adapterName)!=null?a:this.adapter.name}}static fromJSON(e,a){let r=new q({id:e.id,adapterName:e.adapterName,channelId:e.channelId,channelVisibility:e.channelVisibility,currentMessage:e.currentMessage?T.fromJSON(e.currentMessage):void 0,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return q.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=ha(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,links:[],author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(y(d)){let m=_(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}createSentMessageFromMessage(e){let a=this.adapter,r=this.id,s=e.id,i=this;return{id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:e.metadata,attachments:e.attachments,links:e.links,isMention:e.isMention,toJSON(){return e.toJSON()},async edit(n){let o=n;if(y(n)){let l=_(n);if(!l)throw new Error("Invalid JSX element: must be a Card element");o=l}return o=await i.processCallbackUrls(o),await a.editMessage(r,s,o),i.createSentMessage(s,o,r)},async delete(){await a.deleteMessage(r,s)},async addReaction(n){await a.addReaction(r,s,n)},async removeReaction(n){await a.removeReaction(r,s,n)}}}};function ha(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var _r=10080*60*1e3;var yr=300*1e3,wr=1440*60*1e3;var Et=new Map;function F(t){let e=Et.get(t);return e||(e=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),Et.set(t,e)),e}var ua={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},fa=class{constructor(t){c(this,"emojiMap");c(this,"slackToNormalized");c(this,"gchatToNormalized");this.emojiMap={...ua,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,e]of Object.entries(this.emojiMap)){let a=Array.isArray(e.slack)?e.slack:[e.slack];for(let s of a)this.slackToNormalized.set(s.toLowerCase(),t);let r=Array.isArray(e.gchat)?e.gchat:[e.gchat];for(let s of r)this.gchatToNormalized.set(s,t)}}fromSlack(t){var r;let e=t.replace(/^:|:$/g,"").toLowerCase(),a=(r=this.slackToNormalized.get(e))!=null?r:t;return F(a)}fromGChat(t){var a;let e=(a=this.gchatToNormalized.get(t))!=null?a:t;return F(e)}fromTeams(t){var r;let a=(r={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?r:t;return F(a)}toSlack(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.slack)?a.slack[0]:a.slack:e}toGChat(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.gchat)?a.gchat[0]:a.gchat:e}toDiscord(t){return this.toGChat(t)}matches(t,e){let a=typeof e=="string"?e:e.name,r=this.emojiMap[a];if(!r)return t===a;let s=Array.isArray(r.slack)?r.slack:[r.slack],i=Array.isArray(r.gchat)?r.gchat:[r.gchat],n=t.replace(/^:|:$/g,"").toLowerCase();return s.some(o=>o.toLowerCase()===n)||i.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},ga=new fa;function pa(t){let e=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],a={custom:r=>F(r)};for(let r of e)a[r]=F(r);if(t){for(let r of Object.keys(t))a[r]=F(r);ga.extend(t)}return a}var br=pa(),kr=et,Mr=at,Ir=Z;var Sr=rt,Tr=Y,Er=tt;var Ar=it,Cr=nt,xr=st;export{kr as a,Mr as b,Ir as c,Sr as d,Tr as e,Er as f,Ar as g,Cr as h,xr as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e={output:{type:"object",properties:{},required:[],additionalProperties:!0}};var M={type:"object",properties:{webhookUrl:{type:"string",format:"uri"},text:{type:"string"},blocks:{type:"array",items:{type:"object",properties:{type:{enum:["image","context","actions","divider","section","input","file","header","video","rich_text"]}},required:["type"],additionalProperties:!0}}},additionalProperties:!0},s={output:M};var o={"chat-webhook":e,discord:e,getstream:e,"grafana-on-call":e,mattermost:e,msteams:e,"rocket-chat":e,ryver:e,slack:s,"whatsapp-business":e,zulip:e,telegram:e};var L={type:"object",properties:{to:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:'Email address of the recipient(s). Example: "Bob bob@host.com". You can use commas to separate multiple recipients (e.g.: "test@example.com,test@example.com" or ["test@example.com", "test@example.com"]).'},from:{type:"string"},subject:{type:"string",description:"Subject of the message."},text:{type:"string",description:"Text version of the message."},html:{type:"string",description:"HTML version of the message."},message:{type:"string",description:"MIME string of the message. Make sure to use multipart/form-data to send this as a file upload."},cc:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Same as To but for carbon copy"},bcc:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Same as To but for blind carbon copy"},ampHtml:{type:"string"},tVersion:{type:"string"},tText:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},oTag:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Tag string. See Tagging for more information."},oDkim:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Enables/disabled DKIM signatures on per-message basis. Pass yes or no"},oDeliverytime:{type:"string",description:"Desired time of delivery. See Date Format. Note: Messages can be scheduled for a maximum of 3 days in the future."},oDeliverytimeOptimizePeriod:{type:"string"},oTimeZoneLocalize:{type:"string"},oTestmode:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Enables sending in test mode. Pass yes if needed. See Sending in Test Mode"},oTracking:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Toggles tracking on a per-message basis, see Tracking Messages for details. Pass yes or no."},oTrackingClicks:{anyOf:[{type:"string",enum:["yes","no","htmlonly"]},{type:"boolean"}],description:"Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes, no or htmlonly."},oTrackingOpens:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes or no."},oRequireTls:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},oSkipVerification:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},recipientVariables:{type:"string"}},required:[],additionalProperties:!0},a={output:L};var i={type:"object",properties:{name:{type:"string"},email:{type:"string"}},description:'JSON object, containing 2 properties: Name and Email address of a previously validated and active sender. Including the Name property in the JSON is optional. This property is not mandatory in case you use TemplateID and you specified a From address for the template. Format : { "Email":"value", "Name":"value" }.',required:["Email"],additionalProperties:!0},R={type:"object",properties:{contentType:{type:"string"},filename:{type:"string"},base64Content:{type:"string"}},required:["ContentType","Filename","Base64Content"],additionalProperties:!0},U={type:"object",properties:{filename:{type:"string"},contentType:{type:"string"},contentId:{type:"string"},base64Content:{type:"string"}},required:["ContentType","Filename","Base64Content"],additionalProperties:!0},D={type:"object",properties:{from:i,sender:i,to:{type:"array",items:i},cc:{type:"array",items:i},bcc:{type:"array",items:i},replyTo:i,subject:{type:"string"},textPart:{type:"string",description:"Content of the message, sent in Text and/or HTML format. At least one of these content types needs to be specified. When the HTML part is the only part provided, Mailjet will not generate a Text-part from the HTML version. The property can't be set when you use TemplateID"},htmlPart:{type:"string",description:"Content of the message, sent in Text and/or HTML format. At least one of these content types needs to be specified. When the HTML part is the only part provided, Mailjet will not generate a Text-part from the HTML version. The property can't be set when you use TemplateID"},templateId:{type:"number",description:"an ID for a template that is previously created and stored in Mailjet's system. It is mandatory when From and TextPart and/or HtmlPart are not provided. "},templateLanguage:{type:"boolean"},templateErrorReporting:i,templateErrorDeliver:{type:"boolean"},attachments:{type:"array",items:R},inlineAttachments:{type:"array",items:U},priority:{type:"number"},customCampaign:{type:"string"},deduplicateCampaign:{type:"boolean"},trackOpens:{type:"string",enum:["account_default","disabled","enabled"]},trackClicks:{type:"string",enum:["account_default","disabled","enabled"]},customId:{type:"string"},eventPayload:{type:"string"},urlTags:{type:"string"},headers:{type:"object",additionalProperties:!0},variables:{type:"object",additionalProperties:!0}},required:[],additionalProperties:!0},r={output:D};var t={type:"object",properties:{address:{type:"string"},name:{type:"string"}},additionalProperties:!0},n={type:"object",properties:{content:{type:"string"},path:{type:"string"}},additionalProperties:!0},J={type:"object",properties:{from:{anyOf:[{type:"string"},t]},sender:{anyOf:[{type:"string"},t]},to:{anyOf:[{type:"string"},t,{type:"array",items:t}]},cc:{anyOf:[{type:"string"},t,{type:"array",items:t}]},bcc:{anyOf:[{type:"string"},t,{type:"array",items:t}]},replyTo:{anyOf:[{type:"string"},t,{type:"array",items:t}]},inReplyTo:{anyOf:[{type:"string"},t]},references:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},subject:{type:"string"},text:{anyOf:[{type:"string"},n]},html:{anyOf:[{type:"string"},n]},watchHtml:{anyOf:[{type:"string"},n]},amp:{anyOf:[{type:"string"},{type:"object",properties:{content:{type:"string"},path:{type:"string"},href:{type:"string"},encoding:{type:"string"},contentType:{type:"string"},raw:{anyOf:[{type:"string"},n]}}}]},icalEvent:{anyOf:[{type:"string"},{type:"object",properties:{content:{type:"string"},path:{type:"string"},method:{type:"string"},filename:{anyOf:[{type:"string"},{type:"boolean"}]},href:{type:"string"},encoding:{type:"string"}}}]},headers:{anyOf:[{type:"object",additionalProperties:!0},{type:"array",items:{type:"object",additionalProperties:!0}}]},list:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},attachments:{type:"array",items:{type:"object",properties:{content:{type:"string"},path:{type:"string"}},additionalProperties:!0}}},required:[],additionalProperties:!0},p={output:J};var q={type:"object",properties:{},required:[],additionalProperties:!1},l={output:q};var F={type:"object",properties:{personalizations:{type:"array",description:"An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled. See our [Personalizations documentation](https://sendgrid.com/docs/for-developers/sending-email/personalizations/) for examples.",uniqueItems:!1,maxItems:1e3,items:{type:"object",properties:{from:{title:"From Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The 'From' email address used to deliver the message. This address should be a verified sender in your Twilio SendGrid account."},name:{type:"string",description:"A name or title associated with the sending email address."}},required:["email"]},to:{title:"To Email Array",type:"array",items:{type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},cc:{type:"array",description:"An array of recipients who will receive a copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name.",maxItems:1e3,items:{title:"CC BCC Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},bcc:{type:"array",description:"An array of recipients who will receive a blind carbon copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name.",maxItems:1e3,items:{title:"CC BCC Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},subject:{type:"string",description:"The subject of your email. See character length requirements according to [RFC 2822](http://stackoverflow.com/questions/1592291/what-is-the-email-subject-length-limit#answer-1592310).",minLength:1},headers:{type:"object",description:"A collection of JSON key/value pairs allowing you to specify handling instructions for your email. You may not overwrite the following headers: `x-sg-id`, `x-sg-eid`, `received`, `dkim-signature`, `Content-Type`, `Content-Transfer-Encoding`, `To`, `From`, `Subject`, `Reply-To`, `CC`, `BCC`"},substitutions:{type:"object",description:'Substitutions allow you to insert data without using Dynamic Transactional Templates. This field should **not** be used in combination with a Dynamic Transactional Template, which can be identified by a `templateId` starting with `d-`. This field is a collection of key/value pairs following the pattern "substitutionTag":"value to substitute". The key/value pairs must be strings. These substitutions will apply to the text and html content of the body of your email, in addition to the `subject` and `reply-to` parameters. The total collective size of your substitutions may not exceed 10,000 bytes per personalization object.',maxProperties:1e4},dynamicTemplateData:{type:"object",description:'Dynamic template data is available using Handlebars syntax in Dynamic Transactional Templates. This field should be used in combination with a Dynamic Transactional Template, which can be identified by a `templateId` starting with `d-`. This field is a collection of key/value pairs following the pattern "variable_name":"value to insert".'},customArgs:{type:"object",description:"Values that are specific to this personalization that will be carried along with the email and its activity data. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This field may not exceed 10,000 bytes.",maxProperties:1e4},sendAt:{type:"integer",description:"A unix timestamp allowing you to specify when your email should be delivered. Scheduling delivery more than 72 hours in advance is forbidden."}},required:["to"]}},from:{title:"From Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The 'From' email address used to deliver the message. This address should be a verified sender in your Twilio SendGrid account."},name:{type:"string",description:"A name or title associated with the sending email address."}},required:["email"]},replyTo:{title:"Reply_to Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The email address where any replies or bounces will be returned."},name:{type:"string",description:"A name or title associated with the `replyTo` email address."}},required:["email"]},replyToList:{type:"array",description:"An array of recipients who will receive replies and/or bounces. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name. You can either choose to use \u201CreplyTo\u201D field or \u201CreplyToList\u201D but not both.",uniqueItems:!0,maxItems:1e3,items:{type:"object",properties:{email:{type:"string",description:"The email address where any replies or bounces will be returned.",format:"email"},name:{type:"string",description:"A name or title associated with the `replyToList` email address."}},required:["email"]}},subject:{type:"string",description:"The global or 'message level' subject of your email. This may be overridden by subject lines set in personalizations.",minLength:1},content:{type:"array",description:"An array where you can specify the content of your email. You can include multiple [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of content, but you must specify at least one MIME type. To include more than one MIME type, add another object to the array containing the `type` and `value` parameters.",items:{type:"object",properties:{type:{type:"string",description:"The MIME type of the content you are including in your email (e.g., `\u201Ctext/plain\u201D` or `\u201Ctext/html\u201D`).",minLength:1},value:{type:"string",description:"The actual content of the specified MIME type that you are including in your email.",minLength:1}},required:["type","value"]}},attachments:{type:"array",description:"An array of objects where you can specify any attachments you want to include.",items:{type:"object",properties:{content:{type:"string",description:"The Base64 encoded content of the attachment.",minLength:1},type:{type:"string",description:"The MIME type of the content you are attaching (e.g., `\u201Ctext/plain\u201D` or `\u201Ctext/html\u201D`).",minLength:1},filename:{type:"string",description:"The attachment's filename."},disposition:{type:"string",default:"attachment",description:"The attachment's content-disposition, specifying how you would like the attachment to be displayed. For example, `\u201Cinline\u201D` results in the attached file are displayed automatically within the message while `\u201Cattachment\u201D` results in the attached file require some action to be taken before it is displayed, such as opening or downloading the file.",enum:["inline","attachment"]},contentId:{type:"string",description:"The attachment's content ID. This is used when the disposition is set to `\u201Cinline\u201D` and the attachment is an image, allowing the file to be displayed within the body of your email."}},required:["content","filename"]}},templateId:{type:"string",description:"An email template ID. A template that contains a subject and content \u2014 either text or html \u2014 will override any subject and content values specified at the personalizations or message level."},headers:{description:"An object containing key/value pairs of header names and the value to substitute for them. The key/value pairs must be strings. You must ensure these are properly encoded if they contain unicode characters. These headers cannot be one of the reserved headers.",type:"object"},categories:{type:"array",description:"An array of category names for this message. Each category name may not exceed 255 characters. ",uniqueItems:!0,maxItems:10,items:{type:"string",maxLength:255}},customArgs:{description:"Values that are specific to the entire send that will be carried along with the email and its activity data. Key/value pairs must be strings. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This parameter is overridden by `customArgs` set at the personalizations level. Total `customArgs` size may not exceed 10,000 bytes.",type:"string"},sendAt:{type:"integer",description:"A unix timestamp allowing you to specify when you want your email to be delivered. This may be overridden by the `sendAt` parameter set at the personalizations level. Delivery cannot be scheduled more than 72 hours in advance. If you have the flexibility, it's better to schedule mail for off-peak times. Most emails are scheduled and sent at the top of the hour or half hour. Scheduling email to avoid peak times \u2014 for example, scheduling at 10:53 \u2014 can result in lower deferral rates due to the reduced traffic during off-peak times."},batchId:{type:"string",description:"An ID representing a batch of emails to be sent at the same time. Including a `batchId` in your request allows you include this email in that batch. It also enables you to cancel or pause the delivery of that batch. For more information, see the [Cancel Scheduled Sends API](https://sendgrid.com/docs/api-reference/)."},asm:{type:"object",description:"An object allowing you to specify how to handle unsubscribes.",properties:{groupId:{type:"integer",description:"The unsubscribe group to associate with this email."},groupsToDisplay:{type:"array",description:"An array containing the unsubscribe groups that you would like to be displayed on the unsubscribe preferences page.",maxItems:25,items:{type:"integer"}}},required:["groupId"]},ipPoolName:{type:"string",description:"The IP Pool that you would like to send this email from.",minLength:2,maxLength:64},mailSettings:{type:"object",description:"A collection of different mail settings that you can use to specify how you would like this email to be handled.",properties:{bypassListManagement:{type:"object",description:"Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email. This filter cannot be combined with any other bypass filters. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassSpamManagement:{type:"object",description:"Allows you to bypass the spam report list to ensure that the email is delivered to recipients. Bounce and unsubscribe lists will still be checked; addresses on these other lists will not receive the message. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassBounceManagement:{type:"object",description:"Allows you to bypass the bounce list to ensure that the email is delivered to recipients. Spam report and unsubscribe lists will still be checked; addresses on these other lists will not receive the message. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassUnsubscribeManagement:{type:"object",description:"Allows you to bypass the global unsubscribe list to ensure that the email is delivered to recipients. Bounce and spam report lists will still be checked; addresses on these other lists will not receive the message. This filter applies only to global unsubscribes and will not bypass group unsubscribes. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},footer:{type:"object",description:"The default footer that you would like included on every email.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},text:{type:"string",description:"The plain text content of your footer."},html:{type:"string",description:"The HTML content of your footer."}}},sandboxMode:{type:"object",description:"Sandbox Mode allows you to send a test email to ensure that your request body is valid and formatted correctly.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}}}},trackingSettings:{type:"object",description:"Settings to determine how you would like to track the metrics of how your recipients interact with your email.",properties:{clickTracking:{type:"object",description:"Allows you to track if a recipient clicked a link in your email.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},enableText:{type:"boolean",description:"Indicates if this setting should be included in the `text/plain` portion of your email."}}},openTracking:{type:"object",description:"Allows you to track if the email was opened by including a single pixel image in the body of the content. When the pixel is loaded, Twilio SendGrid can log that the email was opened.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},substitutionTag:{type:"string",description:"Allows you to specify a substitution tag that you can insert in the body of your email at a location that you desire. This tag will be replaced by the open tracking pixel."}}},subscriptionTracking:{type:"object",description:"Allows you to insert a subscription management link at the bottom of the text and HTML bodies of your email. If you would like to specify the location of the link within your email, you may use the `substitutionTag`.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},text:{type:"string",description:"Text to be appended to the email with the subscription tracking link. You may control where the link is by using the tag <% %>"},html:{type:"string",description:"HTML to be appended to the email with the subscription tracking link. You may control where the link is by using the tag <% %>"},substitutionTag:{type:"string",description:"A tag that will be replaced with the unsubscribe URL. for example: `[unsubscribe_url]`. If this parameter is used, it will override both the `text` and `html` parameters. The URL of the link will be placed at the substitution tag\u2019s location with no additional formatting."}}},ganalytics:{type:"object",description:"Allows you to enable tracking provided by Google Analytics.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},utmSource:{type:"string",description:"Name of the referrer source. (e.g. Google, SomeDomain.com, or Marketing Email)"},utmMedium:{type:"string",description:"Name of the marketing medium. (e.g. Email)"},utmTerm:{type:"string",description:"Used to identify any paid keywords."},utmContent:{type:"string",description:"Used to differentiate your campaign from advertisements."},utmCampaign:{type:"string",description:"The name of the campaign."}}}}}},required:[],additionalProperties:!1},d={output:F};var c={braze:e,clickatell:e,nodemailer:p,emailjs:e,"email-webhook":e,"infobip-email":e,mailersend:e,mailgun:a,mailjet:r,mailtrap:e,mandrill:e,netcore:e,"novu-email":l,outlook365:e,plunk:e,postmark:e,resend:e,sendgrid:d,sendinblue:e,ses:e,sparkpost:e};var H={type:"object",properties:{},required:[],additionalProperties:!1},u={output:H};var h={novu:u};var m={anyOf:[{type:"string"},{type:"object",additionalProperties:!0,properties:{name:{type:"string"},volume:{type:"number"},critical:{type:"number"}},required:["name","volume","critical"]}]},z={type:"object",properties:{topic:{type:"string",description:"The destination topic for the notification."},id:{type:"string",description:"A UUID to identify the notification with APNS. If an id is not supplied, APNS will generate one automatically. If an error occurs the response will contain the id. This property populates the apns-id header."},expiry:{type:"number",description:"A UNIX timestamp when the notification should expire. If the notification cannot be delivered to the device, APNS will retry until it expires. An expiry of 0 indicates that the notification expires immediately, therefore no retries will be attempted."},priority:{type:"number",description:`Provide one of the following values:
|
|
1
|
+
var e={output:{type:"object",properties:{},required:[],additionalProperties:!0}};var M={type:"object",properties:{webhookUrl:{type:"string",format:"uri"},text:{type:"string"},blocks:{type:"array",items:{type:"object",properties:{type:{enum:["image","context","actions","divider","section","input","file","header","video","rich_text"]}},required:["type"],additionalProperties:!0}}},additionalProperties:!0},s={output:M};var o={"chat-webhook":e,discord:e,getstream:e,"grafana-on-call":e,mattermost:e,msteams:e,"rocket-chat":e,ryver:e,sendblue:e,slack:s,"whatsapp-business":e,zulip:e,telegram:e};var L={type:"object",properties:{to:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:'Email address of the recipient(s). Example: "Bob bob@host.com". You can use commas to separate multiple recipients (e.g.: "test@example.com,test@example.com" or ["test@example.com", "test@example.com"]).'},from:{type:"string"},subject:{type:"string",description:"Subject of the message."},text:{type:"string",description:"Text version of the message."},html:{type:"string",description:"HTML version of the message."},message:{type:"string",description:"MIME string of the message. Make sure to use multipart/form-data to send this as a file upload."},cc:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Same as To but for carbon copy"},bcc:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Same as To but for blind carbon copy"},ampHtml:{type:"string"},tVersion:{type:"string"},tText:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},oTag:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}],description:"Tag string. See Tagging for more information."},oDkim:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Enables/disabled DKIM signatures on per-message basis. Pass yes or no"},oDeliverytime:{type:"string",description:"Desired time of delivery. See Date Format. Note: Messages can be scheduled for a maximum of 3 days in the future."},oDeliverytimeOptimizePeriod:{type:"string"},oTimeZoneLocalize:{type:"string"},oTestmode:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Enables sending in test mode. Pass yes if needed. See Sending in Test Mode"},oTracking:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Toggles tracking on a per-message basis, see Tracking Messages for details. Pass yes or no."},oTrackingClicks:{anyOf:[{type:"string",enum:["yes","no","htmlonly"]},{type:"boolean"}],description:"Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes, no or htmlonly."},oTrackingOpens:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}],description:"Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes or no."},oRequireTls:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},oSkipVerification:{anyOf:[{type:"string",enum:["yes","no"]},{type:"boolean"}]},recipientVariables:{type:"string"}},required:[],additionalProperties:!0},a={output:L};var i={type:"object",properties:{name:{type:"string"},email:{type:"string"}},description:'JSON object, containing 2 properties: Name and Email address of a previously validated and active sender. Including the Name property in the JSON is optional. This property is not mandatory in case you use TemplateID and you specified a From address for the template. Format : { "Email":"value", "Name":"value" }.',required:["Email"],additionalProperties:!0},R={type:"object",properties:{contentType:{type:"string"},filename:{type:"string"},base64Content:{type:"string"}},required:["ContentType","Filename","Base64Content"],additionalProperties:!0},U={type:"object",properties:{filename:{type:"string"},contentType:{type:"string"},contentId:{type:"string"},base64Content:{type:"string"}},required:["ContentType","Filename","Base64Content"],additionalProperties:!0},D={type:"object",properties:{from:i,sender:i,to:{type:"array",items:i},cc:{type:"array",items:i},bcc:{type:"array",items:i},replyTo:i,subject:{type:"string"},textPart:{type:"string",description:"Content of the message, sent in Text and/or HTML format. At least one of these content types needs to be specified. When the HTML part is the only part provided, Mailjet will not generate a Text-part from the HTML version. The property can't be set when you use TemplateID"},htmlPart:{type:"string",description:"Content of the message, sent in Text and/or HTML format. At least one of these content types needs to be specified. When the HTML part is the only part provided, Mailjet will not generate a Text-part from the HTML version. The property can't be set when you use TemplateID"},templateId:{type:"number",description:"an ID for a template that is previously created and stored in Mailjet's system. It is mandatory when From and TextPart and/or HtmlPart are not provided. "},templateLanguage:{type:"boolean"},templateErrorReporting:i,templateErrorDeliver:{type:"boolean"},attachments:{type:"array",items:R},inlineAttachments:{type:"array",items:U},priority:{type:"number"},customCampaign:{type:"string"},deduplicateCampaign:{type:"boolean"},trackOpens:{type:"string",enum:["account_default","disabled","enabled"]},trackClicks:{type:"string",enum:["account_default","disabled","enabled"]},customId:{type:"string"},eventPayload:{type:"string"},urlTags:{type:"string"},headers:{type:"object",additionalProperties:!0},variables:{type:"object",additionalProperties:!0}},required:[],additionalProperties:!0},r={output:D};var t={type:"object",properties:{address:{type:"string"},name:{type:"string"}},additionalProperties:!0},n={type:"object",properties:{content:{type:"string"},path:{type:"string"}},additionalProperties:!0},J={type:"object",properties:{from:{anyOf:[{type:"string"},t]},sender:{anyOf:[{type:"string"},t]},to:{anyOf:[{type:"string"},t,{type:"array",items:t}]},cc:{anyOf:[{type:"string"},t,{type:"array",items:t}]},bcc:{anyOf:[{type:"string"},t,{type:"array",items:t}]},replyTo:{anyOf:[{type:"string"},t,{type:"array",items:t}]},inReplyTo:{anyOf:[{type:"string"},t]},references:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},subject:{type:"string"},text:{anyOf:[{type:"string"},n]},html:{anyOf:[{type:"string"},n]},watchHtml:{anyOf:[{type:"string"},n]},amp:{anyOf:[{type:"string"},{type:"object",properties:{content:{type:"string"},path:{type:"string"},href:{type:"string"},encoding:{type:"string"},contentType:{type:"string"},raw:{anyOf:[{type:"string"},n]}}}]},icalEvent:{anyOf:[{type:"string"},{type:"object",properties:{content:{type:"string"},path:{type:"string"},method:{type:"string"},filename:{anyOf:[{type:"string"},{type:"boolean"}]},href:{type:"string"},encoding:{type:"string"}}}]},headers:{anyOf:[{type:"object",additionalProperties:!0},{type:"array",items:{type:"object",additionalProperties:!0}}]},list:{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},attachments:{type:"array",items:{type:"object",properties:{content:{type:"string"},path:{type:"string"}},additionalProperties:!0}}},required:[],additionalProperties:!0},p={output:J};var q={type:"object",properties:{},required:[],additionalProperties:!1},l={output:q};var F={type:"object",properties:{personalizations:{type:"array",description:"An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled. See our [Personalizations documentation](https://sendgrid.com/docs/for-developers/sending-email/personalizations/) for examples.",uniqueItems:!1,maxItems:1e3,items:{type:"object",properties:{from:{title:"From Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The 'From' email address used to deliver the message. This address should be a verified sender in your Twilio SendGrid account."},name:{type:"string",description:"A name or title associated with the sending email address."}},required:["email"]},to:{title:"To Email Array",type:"array",items:{type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},cc:{type:"array",description:"An array of recipients who will receive a copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name.",maxItems:1e3,items:{title:"CC BCC Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},bcc:{type:"array",description:"An array of recipients who will receive a blind carbon copy of your email. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name.",maxItems:1e3,items:{title:"CC BCC Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The intended recipient's email address."},name:{type:"string",description:"The intended recipient's name."}},required:["email"]}},subject:{type:"string",description:"The subject of your email. See character length requirements according to [RFC 2822](http://stackoverflow.com/questions/1592291/what-is-the-email-subject-length-limit#answer-1592310).",minLength:1},headers:{type:"object",description:"A collection of JSON key/value pairs allowing you to specify handling instructions for your email. You may not overwrite the following headers: `x-sg-id`, `x-sg-eid`, `received`, `dkim-signature`, `Content-Type`, `Content-Transfer-Encoding`, `To`, `From`, `Subject`, `Reply-To`, `CC`, `BCC`"},substitutions:{type:"object",description:'Substitutions allow you to insert data without using Dynamic Transactional Templates. This field should **not** be used in combination with a Dynamic Transactional Template, which can be identified by a `templateId` starting with `d-`. This field is a collection of key/value pairs following the pattern "substitutionTag":"value to substitute". The key/value pairs must be strings. These substitutions will apply to the text and html content of the body of your email, in addition to the `subject` and `reply-to` parameters. The total collective size of your substitutions may not exceed 10,000 bytes per personalization object.',maxProperties:1e4},dynamicTemplateData:{type:"object",description:'Dynamic template data is available using Handlebars syntax in Dynamic Transactional Templates. This field should be used in combination with a Dynamic Transactional Template, which can be identified by a `templateId` starting with `d-`. This field is a collection of key/value pairs following the pattern "variable_name":"value to insert".'},customArgs:{type:"object",description:"Values that are specific to this personalization that will be carried along with the email and its activity data. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This field may not exceed 10,000 bytes.",maxProperties:1e4},sendAt:{type:"integer",description:"A unix timestamp allowing you to specify when your email should be delivered. Scheduling delivery more than 72 hours in advance is forbidden."}},required:["to"]}},from:{title:"From Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The 'From' email address used to deliver the message. This address should be a verified sender in your Twilio SendGrid account."},name:{type:"string",description:"A name or title associated with the sending email address."}},required:["email"]},replyTo:{title:"Reply_to Email Object",type:"object",properties:{email:{type:"string",format:"email",description:"The email address where any replies or bounces will be returned."},name:{type:"string",description:"A name or title associated with the `replyTo` email address."}},required:["email"]},replyToList:{type:"array",description:"An array of recipients who will receive replies and/or bounces. Each object in this array must contain the recipient's email address. Each object in the array may optionally contain the recipient's name. You can either choose to use \u201CreplyTo\u201D field or \u201CreplyToList\u201D but not both.",uniqueItems:!0,maxItems:1e3,items:{type:"object",properties:{email:{type:"string",description:"The email address where any replies or bounces will be returned.",format:"email"},name:{type:"string",description:"A name or title associated with the `replyToList` email address."}},required:["email"]}},subject:{type:"string",description:"The global or 'message level' subject of your email. This may be overridden by subject lines set in personalizations.",minLength:1},content:{type:"array",description:"An array where you can specify the content of your email. You can include multiple [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of content, but you must specify at least one MIME type. To include more than one MIME type, add another object to the array containing the `type` and `value` parameters.",items:{type:"object",properties:{type:{type:"string",description:"The MIME type of the content you are including in your email (e.g., `\u201Ctext/plain\u201D` or `\u201Ctext/html\u201D`).",minLength:1},value:{type:"string",description:"The actual content of the specified MIME type that you are including in your email.",minLength:1}},required:["type","value"]}},attachments:{type:"array",description:"An array of objects where you can specify any attachments you want to include.",items:{type:"object",properties:{content:{type:"string",description:"The Base64 encoded content of the attachment.",minLength:1},type:{type:"string",description:"The MIME type of the content you are attaching (e.g., `\u201Ctext/plain\u201D` or `\u201Ctext/html\u201D`).",minLength:1},filename:{type:"string",description:"The attachment's filename."},disposition:{type:"string",default:"attachment",description:"The attachment's content-disposition, specifying how you would like the attachment to be displayed. For example, `\u201Cinline\u201D` results in the attached file are displayed automatically within the message while `\u201Cattachment\u201D` results in the attached file require some action to be taken before it is displayed, such as opening or downloading the file.",enum:["inline","attachment"]},contentId:{type:"string",description:"The attachment's content ID. This is used when the disposition is set to `\u201Cinline\u201D` and the attachment is an image, allowing the file to be displayed within the body of your email."}},required:["content","filename"]}},templateId:{type:"string",description:"An email template ID. A template that contains a subject and content \u2014 either text or html \u2014 will override any subject and content values specified at the personalizations or message level."},headers:{description:"An object containing key/value pairs of header names and the value to substitute for them. The key/value pairs must be strings. You must ensure these are properly encoded if they contain unicode characters. These headers cannot be one of the reserved headers.",type:"object"},categories:{type:"array",description:"An array of category names for this message. Each category name may not exceed 255 characters. ",uniqueItems:!0,maxItems:10,items:{type:"string",maxLength:255}},customArgs:{description:"Values that are specific to the entire send that will be carried along with the email and its activity data. Key/value pairs must be strings. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This parameter is overridden by `customArgs` set at the personalizations level. Total `customArgs` size may not exceed 10,000 bytes.",type:"string"},sendAt:{type:"integer",description:"A unix timestamp allowing you to specify when you want your email to be delivered. This may be overridden by the `sendAt` parameter set at the personalizations level. Delivery cannot be scheduled more than 72 hours in advance. If you have the flexibility, it's better to schedule mail for off-peak times. Most emails are scheduled and sent at the top of the hour or half hour. Scheduling email to avoid peak times \u2014 for example, scheduling at 10:53 \u2014 can result in lower deferral rates due to the reduced traffic during off-peak times."},batchId:{type:"string",description:"An ID representing a batch of emails to be sent at the same time. Including a `batchId` in your request allows you include this email in that batch. It also enables you to cancel or pause the delivery of that batch. For more information, see the [Cancel Scheduled Sends API](https://sendgrid.com/docs/api-reference/)."},asm:{type:"object",description:"An object allowing you to specify how to handle unsubscribes.",properties:{groupId:{type:"integer",description:"The unsubscribe group to associate with this email."},groupsToDisplay:{type:"array",description:"An array containing the unsubscribe groups that you would like to be displayed on the unsubscribe preferences page.",maxItems:25,items:{type:"integer"}}},required:["groupId"]},ipPoolName:{type:"string",description:"The IP Pool that you would like to send this email from.",minLength:2,maxLength:64},mailSettings:{type:"object",description:"A collection of different mail settings that you can use to specify how you would like this email to be handled.",properties:{bypassListManagement:{type:"object",description:"Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email. This filter cannot be combined with any other bypass filters. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassSpamManagement:{type:"object",description:"Allows you to bypass the spam report list to ensure that the email is delivered to recipients. Bounce and unsubscribe lists will still be checked; addresses on these other lists will not receive the message. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassBounceManagement:{type:"object",description:"Allows you to bypass the bounce list to ensure that the email is delivered to recipients. Spam report and unsubscribe lists will still be checked; addresses on these other lists will not receive the message. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},bypassUnsubscribeManagement:{type:"object",description:"Allows you to bypass the global unsubscribe list to ensure that the email is delivered to recipients. Bounce and spam report lists will still be checked; addresses on these other lists will not receive the message. This filter applies only to global unsubscribes and will not bypass group unsubscribes. This filter cannot be combined with the `bypassListManagement` filter. See our [documentation](https://sendgrid.com/docs/ui/sending-email/index-suppressions/#bypass-suppressions) for more about bypass filters.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}},footer:{type:"object",description:"The default footer that you would like included on every email.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},text:{type:"string",description:"The plain text content of your footer."},html:{type:"string",description:"The HTML content of your footer."}}},sandboxMode:{type:"object",description:"Sandbox Mode allows you to send a test email to ensure that your request body is valid and formatted correctly.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."}}}}},trackingSettings:{type:"object",description:"Settings to determine how you would like to track the metrics of how your recipients interact with your email.",properties:{clickTracking:{type:"object",description:"Allows you to track if a recipient clicked a link in your email.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},enableText:{type:"boolean",description:"Indicates if this setting should be included in the `text/plain` portion of your email."}}},openTracking:{type:"object",description:"Allows you to track if the email was opened by including a single pixel image in the body of the content. When the pixel is loaded, Twilio SendGrid can log that the email was opened.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},substitutionTag:{type:"string",description:"Allows you to specify a substitution tag that you can insert in the body of your email at a location that you desire. This tag will be replaced by the open tracking pixel."}}},subscriptionTracking:{type:"object",description:"Allows you to insert a subscription management link at the bottom of the text and HTML bodies of your email. If you would like to specify the location of the link within your email, you may use the `substitutionTag`.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},text:{type:"string",description:"Text to be appended to the email with the subscription tracking link. You may control where the link is by using the tag <% %>"},html:{type:"string",description:"HTML to be appended to the email with the subscription tracking link. You may control where the link is by using the tag <% %>"},substitutionTag:{type:"string",description:"A tag that will be replaced with the unsubscribe URL. for example: `[unsubscribe_url]`. If this parameter is used, it will override both the `text` and `html` parameters. The URL of the link will be placed at the substitution tag\u2019s location with no additional formatting."}}},ganalytics:{type:"object",description:"Allows you to enable tracking provided by Google Analytics.",properties:{enable:{type:"boolean",description:"Indicates if this setting is enabled."},utmSource:{type:"string",description:"Name of the referrer source. (e.g. Google, SomeDomain.com, or Marketing Email)"},utmMedium:{type:"string",description:"Name of the marketing medium. (e.g. Email)"},utmTerm:{type:"string",description:"Used to identify any paid keywords."},utmContent:{type:"string",description:"Used to differentiate your campaign from advertisements."},utmCampaign:{type:"string",description:"The name of the campaign."}}}}}},required:[],additionalProperties:!1},d={output:F};var c={anypost:e,braze:e,clickatell:e,nodemailer:p,emailjs:e,"email-webhook":e,"infobip-email":e,mailersend:e,mailgun:a,mailjet:r,mailtrap:e,mandrill:e,netcore:e,"novu-email":l,outlook365:e,plunk:e,postmark:e,resend:e,sendgrid:d,sendinblue:e,ses:e,sparkpost:e};var H={type:"object",properties:{},required:[],additionalProperties:!1},u={output:H};var h={novu:u};var m={anyOf:[{type:"string"},{type:"object",additionalProperties:!0,properties:{name:{type:"string"},volume:{type:"number"},critical:{type:"number"}},required:["name","volume","critical"]}]},z={type:"object",properties:{topic:{type:"string",description:"The destination topic for the notification."},id:{type:"string",description:"A UUID to identify the notification with APNS. If an id is not supplied, APNS will generate one automatically. If an error occurs the response will contain the id. This property populates the apns-id header."},expiry:{type:"number",description:"A UNIX timestamp when the notification should expire. If the notification cannot be delivered to the device, APNS will retry until it expires. An expiry of 0 indicates that the notification expires immediately, therefore no retries will be attempted."},priority:{type:"number",description:`Provide one of the following values:
|
|
2
2
|
|
|
3
3
|
10 - The push notification is sent to the device immediately. (Default)
|
|
4
4
|
The push notification must trigger an alert, sound, or badge on the device. It is an error to use this priority for a push notification that contains only the content-available key.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as N,g,i as U,q as D,r as F,s as c,t as h,u as T,v as M}from"./chunk-FRWG7YTE.js";import{a as $,c as L,f as H}from"./chunk-W6DIBD4Z.js";var B=class extends T{constructor(n){super("Unknown BridgeError",{cause:n});this.statusCode=500;this.code="BridgeError"}};var W=class extends c{constructor(n,o){super(`Workflow with id: \`${n}\` has a corrupt state. Step with id: \`${o}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:n,stepId:o}}},q=class extends c{constructor(n,o){super(`Workflow with id: \`${n}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=o}},V=class extends c{constructor(n,o){super(`Workflow with id: \`${n}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=o}},G=class extends c{constructor(n,o,r){super(`Workflow with id: \`${n}\` has an invalid state. Step with id: \`${o}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=r}},X=class extends c{constructor(n,o,r){super(`Workflow with id: \`${n}\` has an invalid state. Step with id: \`${o}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=r}},K=class extends c{constructor(n,o,r){super(`Workflow with id: \`${n}\` has an invalid state. Step with id: \`${o}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=r}},z=class extends c{constructor(n,o,r){super(`Workflow with id: \`${n}\` has invalid controls syntax in step with id: \`${o}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=r}},Y=class extends c{constructor(n,o,r,s){super(`Workflow with id: \`${n}\` has an invalid state. Step with id: \`${o}\` and provider with id: \`${r}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=s}},Q=class extends c{constructor(n,o){super(`Workflow with id: \`${n}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=o}};var Z=e=>Object.values(g).includes(e==null?void 0:e.code),it=e=>!Z(e)&&typeof e.statusCode=="number"&&e.statusCode>=400&&e.statusCode<500;var b=e=>Object.values(e).map(t=>`\`${t}\``).join(", "),E=e=>e.replaceAll(/(\w)(\w*)/g,(t,n,o)=>n.toUpperCase()+o.toLowerCase()).replaceAll(/[\s-]+/g,"");var J=class extends D{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${b(U)}`}},ee=class extends c{constructor(n,o){super(`Invalid query string: \`action\`=\`${n}\`. Please use one of ${b(o)}`);this.code="InvalidActionError"}},te=class extends c{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var ne=class extends Error{constructor(t,n,o){super(),this.data={message:o},this.statusCode=t,this.code=n}};var y=class extends M{constructor(t,n){super(`${E(t)} with id: \`${n}\` already exists. Please use a different id.`)}},m=class extends F{constructor(t,n){super(`${E(t)} with id: \`${n}\` does not exist. Please provide a valid id.`)}},R=class extends T{constructor(n,o,r,s){super(`Failed to ${r} ${E(n)} with id: \`${o}\``,{cause:s});this.statusCode=502}};var re=class extends m{constructor(n){super("provider",n);this.code="ProviderNotFoundError"}},oe=class extends R{constructor(n,o,r){super("provider",n,o,r);this.code="ProviderExecutionFailedError"}};var ae=class extends h{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},ie=class extends h{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},le=class extends h{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},pe=class extends h{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},de=class extends h{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},ce=class extends h{constructor(){super("Signature version is invalid. Please provide a signature version with version `v1` in the `novu-signature` header");this.code="SignatureVersionInvalidError"}};var ue=class extends m{constructor(n){super("step",n);this.code="StepNotFoundError"}},ge=class extends y{constructor(n){super("step",n);this.code="StepAlreadyExistsError"}},me=class extends R{constructor(n,o,r){super("step",n,o,r);this.code="StepExecutionFailedError"}};var fe=class extends m{constructor(n){super("workflow",n);this.code="WorkflowNotFoundError"}},he=class extends y{constructor(n){super("workflow",n);this.code="WorkflowAlreadyExistsError"}};function Fe(e,t){let n={...e};for(let o of Object.keys(t)){let r=t[o];r&&typeof r=="object"&&!Array.isArray(r)?n[o]=Fe(n[o]||{},r):(Array.isArray(r),n[o]=r)}return n}function C(e,t){let n=t.split(".").reduce((o,r)=>{if(o&&typeof o=="object")return o[r]},e);if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);if(typeof n=="object"){let o=JSON.stringify(n);return o==="{}"?"":o}return""}function ye(e,t=2,n,o=", "){if(!Array.isArray(e)||e.length===0)return"";let r=n?e.map(i=>typeof i!="object"||!i?"":C(i,n)):e;if(r.length===1)return r[0];if(r.length===2)return`${r[0]} and ${r[1]}`;if(r.length===3&&t>=3)return`${r[0]}, ${o}${r[1]} and ${r[2]}`;let s=r.slice(0,t),p=r.length-t;return`${s.join(o)} and ${p} ${p===1?"other":"others"}`}import Me from"pluralize";function Re(e,t="",n="",o="true"){if(e==null)return"";let r=0;if(Array.isArray(e)?r=e.length:typeof e=="object"?r=Object.keys(e).length:typeof e=="string"?r=+e:typeof e=="number"?r=e:r=Number(e),Number.isNaN(r)&&(r=0),r<=0)return"";let s;return n?s=r===1?t:n:s=Me(t,r),o==="true"?`${r} ${s}`:s}import{TokenKind as Ae}from"liquidjs";import $e from"pluralize";import{z as f}from"zod";var xe="",_e=2,ve="other",Te=", ",Ee=" and ",Ce=", and ",Se={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function we(e,t=xe,n=_e,o=ve,r=Te,s=Ee,p=Ce){if(!Array.isArray(e)||e.length===0)return"";let i=t?e.map(u=>typeof u!="object"||!u?"":C(u,t)):e,l=i.length;if(l===1)return i[0];if(l===2)return`${i[0]}${s}${i[1]}`;if(n>=l){let u=i.slice(0,l-1),k=i[l-1];return`${u.join(r)}${p}${k}`}let a=i.slice(0,n),d=l-n,v=n===1?s:p;return`${a.join(r)}${v}${d} ${$e(o,d)}`}function on(e={},...t){let{requireKeyPath:n=!1}=e,o=[];if(t.length<1)return o.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),o;let r=f.object({keyPath:n?f.string().min(1,"must be non-empty"):f.string().optional().default(xe),limit:f.number().optional().default(_e).refine(i=>i>=0,"must be greater than or equal to 0"),overflowSuffix:f.string().optional().default(ve),wordsConnector:f.string().optional().default(Te),twoWordsConnector:f.string().optional().default(Ee),lastWordConnector:f.string().optional().default(Ce)}),s={};t.forEach((i,l)=>{if(!Array.isArray(i)){let a=i.getText();(i.kind===Ae.Quoted||i.kind===Ae.Number)&&(a=i.content);let d=Se[l];s[d]=a}});let p=r.safeParse(s);if(!p.success)for(let i of p.error.issues){let l="string";"type"in i&&(l=i.type);let a=i.path[0],d=Object.entries(Se).find(([k,De])=>De===a),v=d?parseInt(d[0],10):null,u=typeof v=="number"?t[v]:null;u&&!Array.isArray(u)&&o.push({message:`"toSentence" expects a ${l}${i.message?` that ${i.message}`:""} for argument "${a}"`,begin:u.begin,end:u.end,value:u.getText()})}return o}import{Liquid as Le}from"liquidjs";function He(e){return Array.isArray(e)||typeof e=="object"&&e!==null?Oe(e):typeof e=="string"?e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):e==null?"":String(e)}var Oe=(e,t=0)=>Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e,null,t).replace(/"/g,"'").replace(/\n/g,"\\n"):e==null?"":String(e);function un(e){let t=new Le({outputEscape:He,...e});return t.registerFilter("json",(n,o)=>Oe(n,o)),t.registerFilter("digest",ye),t.registerFilter("toSentence",we),t.registerFilter("pluralize",Re),t}var Be={400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",408:"Request Timeout",409:"Conflict",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function w(e){return typeof e=="string"&&e.trim()?e:!e||typeof e!="object"?null:w(e.message)}function je(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;let n=t,o=w(n.message);if(o)return o;let r=w(n.error);if(r)return r;let s=n.errors;return Array.isArray(s)?w(s[0]):null}function We(e,t){var r;let n=(r=Be[e])!=null?r:e,o=je(t);return o?`Delivery failed: ${n}: ${o}`:`Delivery failed: ${n}`}var A=class extends Error{constructor(t,n){super(t),this.name="AgentError",this.cause=n==null?void 0:n.cause,this.delivery=n==null?void 0:n.delivery}},O=class extends A{constructor(t,n){let o={statusCode:t,responseBody:n};super(We(t,n),{delivery:o}),this.name="AgentDeliveryError",this.statusCode=t,this.responseBody=n}};function mn(e){return e instanceof A?e:e instanceof Error?new A(e.message,{cause:e}):new A("Turn failed",{cause:e})}var qe=(r=>(r.ON_MESSAGE="onMessage",r.ON_ACTION="onAction",r.ON_RESOLVE="onResolve",r.ON_REACTION="onReaction",r))(qe||{}),I=class{constructor(){this.__novuPendingApproval=!0}};function hn(e){return typeof e=="object"&&e!==null&&"suppress"in e&&e.suppress===!0}var Ve=5*1024*1024,Ge=5*1024*1024,Ie=32768,Xe=/^[A-Za-z0-9+/]*={0,2}$/;function _(e,t){return e.filename?`"${e.filename}"`:`at index ${t}`}function ke(){return globalThis.Buffer}function Ke(e){var t,n,o;return(o=(n=(t=ke())==null?void 0:t.isBuffer)==null?void 0:n.call(t,e))!=null?o:!1}function ze(e){return typeof Blob!="undefined"&&e instanceof Blob}function P(e){let t=ke();if(t)return t.from(e).toString("base64");if(typeof btoa!="function")throw new Error("Unable to encode file data: base64 encoding is not available in this runtime.");let n="";for(let o=0;o<e.length;o+=Ie){let r=e.subarray(o,o+Ie);n+=String.fromCharCode(...r)}return btoa(n)}function Ne(e){let t=e.replace(/\s/g,""),n=t.length%4;if(!t||n===1||!Xe.test(t))return null;let o=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.floor(t.length*3/4)-o}function S(e,t,n){if(e>Ve)throw new Error(`Invalid file ${_(t,n)}: inline data must be 5 MB or smaller. Use a publicly-accessible URL for larger files.`)}async function Ye(e,t,n){if(typeof e=="string"){let o=Ne(e);if(o===null)throw new Error(`Invalid file ${_(t,n)}: data must be a base64-encoded string.`);return S(o,t,n),e}if(Ke(e))return S(e.byteLength,t,n),e.toString("base64");if(e instanceof Uint8Array)return S(e.byteLength,t,n),P(e);if(e instanceof ArrayBuffer)return S(e.byteLength,t,n),P(new Uint8Array(e));if(ze(e))return S(e.size,t,n),P(new Uint8Array(await e.arrayBuffer()));throw new Error(`Invalid file ${_(t,n)}: data must be a base64 string, Buffer, Uint8Array, ArrayBuffer, or Blob.`)}async function Qe(e){if(!(e!=null&&e.length))return;let t=[],n=0;for(let[o,r]of e.entries()){let s=r.data,p=r.url,i=s!=null,l=p!=null;if(i===l)throw new Error(`Invalid file ${_(r,o)}: provide exactly one of data or url.`);if(i){let a=await Ye(s,r,o),d=Ne(a);if(n+=d!=null?d:0,n>Ge)throw new Error("Invalid files: total inline data must be 5 MB or smaller. Use publicly-accessible URLs for larger files.");t.push({...r,data:a});continue}if(l&&typeof p!="string")throw new Error(`Invalid file ${_(r,o)}: url must be a string.`);t.push(r)}return t}async function Ue(e,t){let n=await Qe(t);if(typeof e=="string")return n?{markdown:e,files:n}:{markdown:e};let{isJSX:o,toCardElement:r}=await import("./jsx-runtime-7EPQR56T.js");if(o(e)){let s=r(e);if(s)return n?{card:s,files:n}:{card:s}}if(L(e))return n?{card:e,files:n}:{card:e};throw new Error("Invalid message content \u2014 expected string or CardElement")}var x=class{constructor(t,n,o,r,s){this.conversationId=o;this.integrationIdentifier=r;this.poster=s;this.editedByHandler=!1;this.messageId=t,this.platformThreadId=n}async edit(t,n){this.editedByHandler=!0;let o=await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,edit:{messageId:this.messageId,content:await Ue(t,n==null?void 0:n.files)}});if(!o)throw new Error("Agent edit did not return a message handle");return this.messageId=o.messageId,this.platformThreadId=o.platformThreadId,this}async delete(){await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,deleteMessages:[{messageId:this.messageId}]})}},Pe;Pe=$;var be=class{constructor(t,n,o){this[Pe]=!0;this._signals=[];this._toolResults=[];this._pendingToolApprovalRequest=null;this._pendingReactions=[];this._pendingDeletes=[];this._resolveSignal=null;var i,l;this.event=t.event,this.action=(i=t.action)!=null?i:null,this.message=t.message,this.reaction=t.reaction,this.conversation=t.conversation,this.subscriber=t.subscriber,this.history=t.history,this.platform=t.platform,this.platformContext=t.platformContext,this._replyUrl=t.replyUrl,this._conversationId=t.conversationId,this._integrationIdentifier=t.integrationIdentifier,this._secretKey=n,this._poster={post:a=>this._post(a)},this._toolApprovalConfig=o,this._metadataState={...(l=t.conversation.metadata)!=null?l:{}};let r=this;this.metadata={get(a){return r._metadataState[a]},set(a,d){r._metadataState[a]=d,r._signals.push({type:"metadata",action:"set",key:a,value:d})},delete(a){delete r._metadataState[a],r._signals.push({type:"metadata",action:"delete",key:a})},clear(){r._metadataState={},r._signals.push({type:"metadata",action:"clear"})},get current(){return{...r._metadataState}}};let s=a=>this._post({conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,typing:a}).then(()=>{}),p=(a=>s(a===void 0?{}:{status:a}));p.stop=()=>s("stop"),this.typing=p,this.toolApproval={request:async a=>(await H(this,a,this._toolApprovalConfig),new I)}}asMessageContext(){return this}async reply(t,n){let o=await Ue(t,n==null?void 0:n.files),r={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:o};this._drainSideEffects(r);let s=await this._post(r);if(!s)throw new Error("Agent reply did not return a message handle");return new x(s.messageId,s.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}async replyApprovalCard(t){let n={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:{toolApprovalCard:t}};this._drainSideEffects(n);let o=await this._post(n);if(!o)throw new Error("Agent approval card reply did not return a message handle");return new x(o.messageId,o.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}createReplyHandle(t){return new x(t,"",this._conversationId,this._integrationIdentifier,this._poster)}resolve(t){this._resolveSignal={summary:t}}trigger(t,n){this._signals.push({...n,type:"trigger",workflowId:t})}emitToolApprovalRequest(t){if(this._pendingToolApprovalRequest)throw new Error("Only one tool approval request can be queued before the next reply");this._pendingToolApprovalRequest=t}emitToolResult(t){this._toolResults.push(t)}addReaction(t,n){this._pendingReactions.push({messageId:t,emojiName:n})}deleteMessage(t){this._pendingDeletes.push({messageId:t})}async reportTurnError(){try{await this._post({conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,error:!0})}catch(t){console.error("[agent] Failed to report turn error:",t)}}async flush(){if(!this._hasPendingSideEffects())return;let t={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier};this._drainSideEffects(t),await this._post(t)}_hasPendingSideEffects(){return!!(this._pendingToolApprovalRequest||this._signals.length||this._toolResults.length||this._resolveSignal||this._pendingReactions.length||this._pendingDeletes.length)}_drainSideEffects(t){this._pendingToolApprovalRequest&&(t.toolApprovalRequest=this._pendingToolApprovalRequest,this._pendingToolApprovalRequest=null),this._signals.length&&(t.signals=this._signals,this._signals=[]),this._toolResults.length&&(t.toolResults=this._toolResults,this._toolResults=[]),this._pendingReactions.length&&(t.addReactions=this._pendingReactions,this._pendingReactions=[]),this._pendingDeletes.length&&(t.deleteMessages=this._pendingDeletes,this._pendingDeletes=[]),this._resolveSignal&&(t.resolve=this._resolveSignal,this._resolveSignal=null)}async _post(t){let n=await fetch(this._replyUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${this._secretKey}`},body:JSON.stringify(t)});if(!n.ok){let r=await n.text().catch(()=>"");throw new O(n.status,r)}let o=await n.text().catch(()=>"");if(!o)return null;try{let r=JSON.parse(o),s=r&&typeof r=="object"&&"data"in r?r.data:r;if(s&&typeof s.messageId=="string"&&typeof s.platformThreadId=="string")return{messageId:s.messageId,platformThreadId:s.platformThreadId}}catch{}return null}};var En={type:"object",properties:{},required:[],additionalProperties:!1};var Ze=(a=>(a.PENDING="pending",a.QUEUED="queued",a.RUNNING="running",a.COMPLETED="completed",a.FAILED="failed",a.DELAYED="delayed",a.CANCELED="canceled",a.MERGED="merged",a.SKIPPED="skipped",a))(Ze||{});var Je=(r=>(r.NONE="none",r.LOW="low",r.MEDIUM="medium",r.HIGH="high",r))(Je||{});export{B as a,W as b,q as c,V as d,G as e,X as f,K as g,z as h,Y as i,Q as j,Z as k,it as l,J as m,ee as n,te as o,ne as p,y as q,m as r,R as s,re as t,oe as u,ae as v,ie as w,le as x,pe as y,de as z,ce as A,ue as B,ge as C,me as D,fe as E,he as F,Fe as G,ye as H,Re as I,we as J,on as K,un as L,A as M,O as N,mn as O,qe as P,I as Q,hn as R,be as S,En as T,Ze as U,Je as V};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=Object.create;var f=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var n=(b,a,c)=>a in b?f(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var p=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}},q=(b,a)=>{for(var c in a)f(b,c,{get:a[c],enumerable:!0})},o=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of k(a))!m.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=i(a,d))||e.enumerable});return b};var r=(b,a,c)=>(c=b!=null?j(l(b)):{},o(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));var s=(b,a,c,e)=>{for(var d=e>1?void 0:e?i(a,c):a,g=b.length-1,h;g>=0;g--)(h=b[g])&&(d=(e?h(a,c,d):h(d))||d);return e&&d&&f(a,c,d),d},t=(b,a)=>(c,e)=>a(c,e,b);var u=(b,a,c)=>n(b,typeof a!="symbol"?a+"":a,c);export{p as a,q as b,r as c,s as d,t as e,u as f};
|