@opencxh/domain 1.100.1 → 1.112.0

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/dist/index.cjs CHANGED
@@ -1,8 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=140;function p(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function b(e){const t=e.trim();return t.length<=E?t:t.slice(0,E-1).trimEnd()+"…"}function l(e){if(!e||e<0)return"";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}function D(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const t=e.payload,n=t.bodySnippet?.trim()||p(t.body??"");return t.subject?`${t.subject} — ${n}`:n}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(t=>t.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(t=>t.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(t=>t.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function N(e){return{activityId:e.id,type:e.type,snippet:b(D(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function O(e,t,n=[]){const r=e.createdAt;if(!r)return[];const a=new Set(n);return e.author.type==="user"&&e.author.id&&a.add(e.author.id),Object.entries(t).filter(([s,o])=>o>=r&&!a.has(s)).map(([s])=>s)}const R=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function C(e){const t=[];for(const n of Object.keys(e))for(const r of Object.keys(e[n]))t.push({lang:n,key:r,value:e[n][r]});return t}function i(e){return e<10?`0${e}`:`${e}`}function A(e,t){const n=new Date(e),r=`${n.getUTCFullYear()}-${i(n.getUTCMonth()+1)}-${i(n.getUTCDate())}`;return t==="day"?r:`${r}T${i(n.getUTCHours())}`}function g(e,t){const n=new Date(e);return n.setUTCMinutes(0,0,0),t==="day"&&n.setUTCHours(0),n.getTime()}const L=36e5,M=864e5;function m(e,t,n){const r=n==="hour"?L:M,a=[];for(let s=g(e,n);s<=t;s+=r)a.push(A(s,n));return a}const P=new Set(["mail","message"]);function T(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function y(e,t,n,r="html"){if(!e)return n;const a=T(e,t);return a?`${n}${r==="text"?`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=140;function A(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/\s+/g," ").trim()}function D(e){const t=e.trim();return t.length<=c?t:t.slice(0,c-1).trimEnd()+"…"}function l(e){if(!e||e<0)return"";const t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${n.toString().padStart(2,"0")}`}function O(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const t=e.payload,n=t.bodySnippet?.trim()||A(t.body??"");return t.subject?`${t.subject} — ${n}`:n}case"CHAT_MESSAGE_SENT":case"CHAT_MESSAGE_RECEIVED":return e.payload.text??"";case"CHAT_RENAMED":return`Hernoemd naar "${e.payload.newName}"`;case"CHAT_MEMBER_JOINED":return`${e.payload.members.map(t=>t.name).join(", ")} toegevoegd`;case"CHAT_MEMBER_LEFT":return`${e.payload.members.map(t=>t.name).join(", ")} verlaten`;case"CHAT_CALL_STARTED":return"Gesprek gestart";case"CHAT_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"CHAT_EVENT":return e.payload.text??e.payload.eventType;case"VOICE_CALL_STARTED":case"VIDEO_CALL_STARTED":return"Gesprek gestart";case"VOICE_CALL_ANSWERED":case"VIDEO_CALL_ANSWERED":return"Gesprek aangenomen";case"VOICE_CALL_HOLD":case"VIDEO_CALL_HOLD":return"In de wacht";case"VOICE_CALL_UNHOLD":case"VIDEO_CALL_UNHOLD":return"Hervat";case"VOICE_CALL_ENDED":case"VIDEO_CALL_ENDED":return`Gesprek beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"VOICE_CALL_MISSED":case"VIDEO_CALL_MISSED":return"Gemiste oproep";case"VOICE_CALL_FAILED":case"VIDEO_CALL_FAILED":return"Gesprek mislukt";case"VOICE_CALL_VOICEMAIL":return e.payload.transcription?.trim()?e.payload.transcription:"Voicemail ontvangen";case"TRANSCRIPT_ADDED":return(e.payload.segments??[]).map(t=>t.text).join(" ");case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";case"AI_ACTION_PROPOSED":return`Voorstel wacht op goedkeuring (${e.payload.actions?.length??0} actie(s))`;case"PLAYBOOK_STARTED":return`Playbook gestart${e.payload.playbookName?`: ${e.payload.playbookName}`:""}`;case"PLAYBOOK_COMPLETED":return"Playbook afgerond";case"PLAYBOOK_ESCALATED":return"Playbook geëscaleerd naar een mens";case"MEETING_SCHEDULED":return`Vergadering gepland: ${e.payload.title}`;case"MEETING_STARTED":return`Vergadering gestart: ${e.payload.title}`;case"MEETING_ENDED":return`Vergadering beëindigd${e.payload.duration?` (${l(e.payload.duration)})`:""}`;case"MEETING_PARTICIPANT_JOINED":return`${e.payload.name} deelgenomen`;case"MEETING_PARTICIPANT_LEFT":return`${e.payload.name} verlaten`;case"COMMENT_ADDED":return e.payload.text??"";case"FILE_UPLOADED":return`Bestand: ${e.payload.fileName}`;case"INTERACTION_CREATED":return"Interactie aangemaakt";case"INTERACTION_STATUS_CHANGED":return`Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;case"INTERACTION_ASSIGNED":return"Interactie toegewezen";default:return""}}function L(e){return{activityId:e.id,type:e.type,snippet:D(O(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function M(e,t,n=[]){const r=e.createdAt;if(!r)return[];const s=new Set(n);return e.author.type==="user"&&e.author.id&&s.add(e.author.id),Object.entries(t).filter(([a,o])=>o>=r&&!s.has(a)).map(([a])=>a)}const C=[{id:"agent",label:"Agent",labelSource:"user"},{id:"team",label:"Team",labelSource:"team"},{id:"inbox",label:"Inbox",labelSource:"inbox"},{id:"channel",label:"Kanaal",labelSource:"channel"},{id:"provider",label:"Provider",labelSource:"raw"},{id:"status",label:"Status",labelSource:"raw"},{id:"handledBy",label:"Afhandelaar",labelSource:"raw"},{id:"time",label:"Tijd",labelSource:"raw"}];function m(e){const t=[];for(const n of Object.keys(e))for(const r of Object.keys(e[n]))t.push({lang:n,key:r,value:e[n][r]});return t}function i(e){return e<10?`0${e}`:`${e}`}function g(e,t){const n=new Date(e),r=`${n.getUTCFullYear()}-${i(n.getUTCMonth()+1)}-${i(n.getUTCDate())}`;return t==="day"?r:`${r}T${i(n.getUTCHours())}`}function _(e,t){const n=new Date(e);return n.setUTCMinutes(0,0,0),t==="day"&&n.setUTCHours(0),n.getTime()}const h=36e5,y=864e5;function P(e,t,n){const r=n==="hour"?h:y,s=[];for(let a=_(e,n);a<=t;a+=r)s.push(g(a,n));return s}const U=new Set(["mail","message"]);function I(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function $(e,t,n,r="html"){if(!e)return n;const s=I(e,t);return s?`${n}${r==="text"?`
2
2
 
3
- `:t==="mail"?"<br><br>-- <br>":"<br><br>"}${a.body}`:n}function h(e){return e.endpoints??[]}const U=e=>!!e.assignedUserId||!!e.assignedInboxId,$=e=>e.status==="closed",G=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,H=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function V(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}const F=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i];function c(e){let t=e;return t=t.replace(/<(script|style)[\s\S]*?<\/\1>/gi,""),t=t.replace(/<br\s*\/?>/gi,`
3
+ `:t==="mail"?"<br><br>-- <br>":"<br><br>"}${s.body}`:n}function G(e){return e.endpoints??[]}const H=e=>!!e.assignedUserId||!!e.assignedInboxId,V=e=>e.status==="closed",k=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,w=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function B(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}const F=[/<blockquote/i,/class="?gmail_quote/i,/id="?[^"]*divRplyFwdMsg/i,/id="?[^"]*mail-editor-reference-message-container/i,/-{3,}\s*Original Message\s*-{3,}/i,/\n_{5,}\s*\n/,/\bOn\b[\s\S]{0,200}?\bwrote:/i],u=/^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i,x=/^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;function j(e){const t=e.split(`
4
+ `);for(let n=0;n<t.length;n++)if(x.test(t[n])||u.test(t[n])&&t.slice(n+1,n+4).some(r=>u.test(r)))return t.slice(0,n).join(`
5
+ `).trim();return e}function E(e){let t=e;return t=t.replace(/<(script|style)[\s\S]*?<\/\1>/gi,""),t=t.replace(/<br\s*\/?>/gi,`
4
6
  `),t=t.replace(/<\/(p|div|li|tr|h[1-6]|ul|ol|table)>/gi,`
5
- `),t=t.replace(/<[^>]+>/g,""),t=t.replace(/<[^>]*$/,""),t}function u(e){return e.replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&#(\d+);/g,(t,n)=>String.fromCharCode(Number(n))).replace(/&amp;/gi,"&")}function d(e){return e.replace(/\r/g,"").replace(/[ \t]+/g," ").replace(/ *\n */g,`
7
+ `),t=t.replace(/<[^>]+>/g,""),t=t.replace(/<[^>]*$/,""),t}function d(e){return e.replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&#(\d+);/g,(t,n)=>String.fromCharCode(Number(n))).replace(/&amp;/gi,"&")}function p(e){return e.replace(/\r/g,"").replace(/[ \t]+/g," ").replace(/ *\n */g,`
6
8
  `).replace(/\n{3,}/g,`
7
9
 
8
- `).trim()}function k(e){if(typeof e!="string"||!e)return"";let t=e.length;for(const a of F){const s=e.search(a);s>=0&&s<t&&(t=s)}const n=e.slice(0,t);let r=d(u(c(n)));return r||(r=d(u(c(e)))),r}function I(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},a=t.intents.filter(o=>!n.has(o.intent)).map(o=>x(o,r[o.intent]));if(!e.extraIntents||e.extraIntents.length===0)return a;const s=new Set(a.map(o=>o.intent));for(const o of e.extraIntents)s.has(o.intent)||(a.push(o),s.add(o.intent));return a}function _(e,t){const n={};for(const r of e.intents){if(!r.togglable)continue;const a=t?.[r.intent];n[r.intent]=a??r.defaultEnabled??!0}return n}function w(e,t){const n=_(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function x(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function B(e,t){const n=[];for(const r of e){if(!r.enabled)continue;const a=t[r.providerId];if(a)for(const s of I(r,a))n.push({channel:r,description:a,capability:s})}return n}function W(e,t){return t.filter(n=>n.capability.intent===e)}function f(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function j(e,t){return f(e.scheme,t)}function K(e,t,n){const r=[];for(const a of e)for(const s of n)s.capability.intent===t&&s.capability.targetSchemes.includes(a.scheme)&&r.push({channelIntent:s,endpoint:a});return r}var S=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(S||{});const Y="message_window",q="message_templates",z={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},J=(e,t)=>({intent:e,...t}),X="folder_management",Q="remote_search",Z={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},v=9e4,ee="installation-id";exports.CORE_DIMENSIONS=R;exports.CommunicationScheme=S;exports.FEATURE_FOLDER_MANAGEMENT=X;exports.FEATURE_REMOTE_SEARCH=Q;exports.INSTALLATION_HEADER=ee;exports.InteractionParticipantRole=z;exports.PRESENCE_ONLINE_WINDOW_MS=v;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=q;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=Y;exports.SIGNATURE_INTENTS=P;exports.UNSUPPORTED=Z;exports.applySignature=y;exports.buildActivityPreview=N;exports.buildChannelIntents=B;exports.cleanMessageText=k;exports.defineIntent=J;exports.disabledIntentsFromCapabilities=w;exports.filterByEndpoint=j;exports.filterByIntent=W;exports.filterByTargetScheme=f;exports.flattenLocales=C;exports.floorToPeriod=g;exports.formatPeriod=A;exports.getActivitySeenUserIds=O;exports.getContactEndpoints=h;exports.getShortTitle=H;exports.getUrgencyScore=G;exports.isAssigned=U;exports.isClosed=$;exports.isInteractionUnseen=V;exports.matchContactToIntents=K;exports.periodsInRange=m;exports.resolveAccountCapabilities=_;exports.resolveChannelIntents=I;exports.resolveSignature=T;exports.stripHtml=p;
10
+ `).trim()}function W(e){if(typeof e!="string"||!e)return"";let t=e.length;for(const a of F){const o=e.search(a);o>=0&&o<t&&(t=o)}const n=e.slice(0,t);let r=p(d(E(n)));return r||(r=p(d(E(e)))),j(r)||r}const Y=/(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i,K=/\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;function q(e,t){return!!(e&&Y.test(e)||t&&K.test(t))}const T=3,f=600;function z(e,t){return e>=T||t>=f}function S(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},s=t.intents.filter(o=>!n.has(o.intent)).map(o=>Q(o,r[o.intent]));if(!e.extraIntents||e.extraIntents.length===0)return s;const a=new Set(s.map(o=>o.intent));for(const o of e.extraIntents)a.has(o.intent)||(s.push(o),a.add(o.intent));return s}function b(e,t){const n={};for(const r of e.intents){if(!r.togglable)continue;const s=t?.[r.intent];n[r.intent]=s??r.defaultEnabled??!0}return n}function J(e,t){const n=b(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function Q(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function X(e,t){const n=[];for(const r of e){if(!r.enabled)continue;const s=t[r.providerId];if(s)for(const a of S(r,s))n.push({channel:r,description:s,capability:a})}return n}function Z(e,t){return t.filter(n=>n.capability.intent===e)}function N(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function v(e,t){return N(e.scheme,t)}function ee(e,t,n){const r=[];for(const s of e)for(const a of n)a.capability.intent===t&&a.capability.targetSchemes.includes(s.scheme)&&r.push({channelIntent:a,endpoint:s});return r}var R=(e=>(e.MAILTO="mailto",e.SIP="sip",e.TEL="tel",e.WEBHOOK="webhook",e.USERNAME="username",e.ID="id",e.CUSTOM="custom",e.URL="url",e.TELEGRAM="telegram",e.WHATSAPP="whatsapp",e.MESSENGER="messenger",e.INSTAGRAM="instagram",e.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(R||{});const te="message_window",ne="message_templates",re={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},se=(e,t)=>({intent:e,...t}),ae="folder_management",oe="remote_search",le={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},ie=9e4,ce="installation-id";exports.CORE_DIMENSIONS=C;exports.CommunicationScheme=R;exports.FEATURE_FOLDER_MANAGEMENT=ae;exports.FEATURE_REMOTE_SEARCH=oe;exports.INSTALLATION_HEADER=ce;exports.InteractionParticipantRole=re;exports.PRESENCE_ONLINE_WINDOW_MS=ie;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=ne;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=te;exports.SIGNATURE_INTENTS=U;exports.SUMMARY_MIN_LAST_CHARS=f;exports.SUMMARY_MIN_MESSAGES=T;exports.UNSUPPORTED=le;exports.applySignature=$;exports.buildActivityPreview=L;exports.buildChannelIntents=X;exports.cleanMessageText=W;exports.defineIntent=se;exports.disabledIntentsFromCapabilities=J;exports.filterByEndpoint=v;exports.filterByIntent=Z;exports.filterByTargetScheme=N;exports.flattenLocales=m;exports.floorToPeriod=_;exports.formatPeriod=g;exports.getActivitySeenUserIds=M;exports.getContactEndpoints=G;exports.getShortTitle=w;exports.getUrgencyScore=k;exports.isAssigned=H;exports.isClosed=V;exports.isInteractionUnseen=B;exports.isLikelyBulk=q;exports.isThreadLongEnough=z;exports.matchContactToIntents=ee;exports.periodsInRange=P;exports.resolveAccountCapabilities=b;exports.resolveChannelIntents=S;exports.resolveSignature=I;exports.stripHtml=A;
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from './entities/transcript';
28
28
  export * from './entities/user';
29
29
  export * from './entities/webhook';
30
30
  export * from './text/message';
31
+ export * from './text/triage';
31
32
  export * from './platform/ai-tools';
32
33
  export * from './platform/api';
33
34
  export * from './platform/author';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function p(e) {
2
2
  return e.replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/\s+/g, " ").trim();
3
3
  }
4
- function d(e) {
4
+ function g(e) {
5
5
  const t = e.trim();
6
6
  return t.length <= 140 ? t : t.slice(0, 139).trimEnd() + "…";
7
7
  }
@@ -91,23 +91,23 @@ function A(e) {
91
91
  return "";
92
92
  }
93
93
  }
94
- function C(e) {
94
+ function $(e) {
95
95
  return {
96
96
  activityId: e.id,
97
97
  type: e.type,
98
- snippet: d(A(e)),
98
+ snippet: g(A(e)),
99
99
  authorName: e.author?.name ?? "",
100
100
  direction: e.direction,
101
101
  createdAt: e.createdAt ?? Date.now()
102
102
  };
103
103
  }
104
- function R(e, t, n = []) {
104
+ function U(e, t, n = []) {
105
105
  const r = e.createdAt;
106
106
  if (!r) return [];
107
- const a = new Set(n);
108
- return e.author.type === "user" && e.author.id && a.add(e.author.id), Object.entries(t).filter(([s, o]) => o >= r && !a.has(s)).map(([s]) => s);
107
+ const s = new Set(n);
108
+ return e.author.type === "user" && e.author.id && s.add(e.author.id), Object.entries(t).filter(([a, o]) => o >= r && !s.has(a)).map(([a]) => a);
109
109
  }
110
- const M = [
110
+ const H = [
111
111
  { id: "agent", label: "Agent", labelSource: "user" },
112
112
  { id: "team", label: "Team", labelSource: "team" },
113
113
  { id: "inbox", label: "Inbox", labelSource: "inbox" },
@@ -117,67 +117,78 @@ const M = [
117
117
  { id: "handledBy", label: "Afhandelaar", labelSource: "raw" },
118
118
  { id: "time", label: "Tijd", labelSource: "raw" }
119
119
  ];
120
- function m(e) {
120
+ function G(e) {
121
121
  const t = [];
122
122
  for (const n of Object.keys(e))
123
123
  for (const r of Object.keys(e[n]))
124
124
  t.push({ lang: n, key: r, value: e[n][r] });
125
125
  return t;
126
126
  }
127
- function u(e) {
127
+ function i(e) {
128
128
  return e < 10 ? `0${e}` : `${e}`;
129
129
  }
130
- function g(e, t) {
131
- const n = new Date(e), r = `${n.getUTCFullYear()}-${u(n.getUTCMonth() + 1)}-${u(n.getUTCDate())}`;
132
- return t === "day" ? r : `${r}T${u(n.getUTCHours())}`;
130
+ function f(e, t) {
131
+ const n = new Date(e), r = `${n.getUTCFullYear()}-${i(n.getUTCMonth() + 1)}-${i(n.getUTCDate())}`;
132
+ return t === "day" ? r : `${r}T${i(n.getUTCHours())}`;
133
133
  }
134
- function T(e, t) {
134
+ function _(e, t) {
135
135
  const n = new Date(e);
136
136
  return n.setUTCMinutes(0, 0, 0), t === "day" && n.setUTCHours(0), n.getTime();
137
137
  }
138
- const f = 36e5, _ = 864e5;
139
- function P(e, t, n) {
140
- const r = n === "hour" ? f : _, a = [];
141
- for (let s = T(e, n); s <= t; s += r)
142
- a.push(g(s, n));
143
- return a;
138
+ const T = 36e5, I = 864e5;
139
+ function V(e, t, n) {
140
+ const r = n === "hour" ? T : I, s = [];
141
+ for (let a = _(e, n); a <= t; a += r)
142
+ s.push(f(a, n));
143
+ return s;
144
144
  }
145
- const $ = /* @__PURE__ */ new Set(["mail", "message"]);
146
- function I(e, t) {
145
+ const w = /* @__PURE__ */ new Set(["mail", "message"]);
146
+ function S(e, t) {
147
147
  const n = e.settings?.signatures?.[t];
148
148
  return !n || !n.enabled || !n.body || n.body.trim() === "" ? null : n;
149
149
  }
150
- function h(e, t, n, r = "html") {
150
+ function k(e, t, n, r = "html") {
151
151
  if (!e) return n;
152
- const a = I(e, t);
153
- return a ? `${n}${r === "text" ? `
152
+ const s = S(e, t);
153
+ return s ? `${n}${r === "text" ? `
154
154
 
155
- ` : t === "mail" ? "<br><br>-- <br>" : "<br><br>"}${a.body}` : n;
155
+ ` : t === "mail" ? "<br><br>-- <br>" : "<br><br>"}${s.body}` : n;
156
156
  }
157
- function y(e) {
157
+ function x(e) {
158
158
  return e.endpoints ?? [];
159
159
  }
160
- const U = (e) => !!e.assignedUserId || !!e.assignedInboxId, H = (e) => e.status === "closed", V = (e) => ({
160
+ const B = (e) => !!e.assignedUserId || !!e.assignedInboxId, F = (e) => e.status === "closed", j = (e) => ({
161
161
  urgent: 10,
162
162
  high: 5,
163
163
  normal: 2,
164
164
  low: 1
165
- })[e.priority] || 0, G = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
166
- function k(e, t) {
165
+ })[e.priority] || 0, W = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
166
+ function K(e, t) {
167
167
  return e.lastActivityAt ? !(e.seenBy ?? []).includes(t) : !1;
168
168
  }
169
- const S = [
169
+ const b = [
170
170
  /<blockquote/i,
171
171
  /class="?gmail_quote/i,
172
172
  // Gmail quote container
173
173
  /id="?[^"]*divRplyFwdMsg/i,
174
174
  // Outlook web reply/forward header
175
+ /id="?[^"]*mail-editor-reference-message-container/i,
176
+ // Outlook new/"mail editor" quote container
175
177
  /-{3,}\s*Original Message\s*-{3,}/i,
176
178
  /\n_{5,}\s*\n/,
177
179
  // Outlook underscore separator before "From:"
178
180
  /\bOn\b[\s\S]{0,200}?\bwrote:/i
179
181
  // Gmail "On <date> <name> wrote:"
180
- ];
182
+ ], u = /^\s*(?:>+\s*)?(?:from|van|sent|verzonden|to|aan|cc|subject|onderwerp|date|datum)\s*:/i, D = /^\s*(?:on|op)\b.{0,200}?\b(?:wrote|schreef|geschreven)\s*:?\s*$/i;
183
+ function N(e) {
184
+ const t = e.split(`
185
+ `);
186
+ for (let n = 0; n < t.length; n++)
187
+ if (D.test(t[n]) || u.test(t[n]) && t.slice(n + 1, n + 4).some((r) => u.test(r)))
188
+ return t.slice(0, n).join(`
189
+ `).trim();
190
+ return e;
191
+ }
181
192
  function c(e) {
182
193
  let t = e;
183
194
  return t = t.replace(/<(script|style)[\s\S]*?<\/\1>/gi, ""), t = t.replace(/<br\s*\/?>/gi, `
@@ -187,80 +198,88 @@ function c(e) {
187
198
  function E(e) {
188
199
  return e.replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#39;/gi, "'").replace(/&#(\d+);/g, (t, n) => String.fromCharCode(Number(n))).replace(/&amp;/gi, "&");
189
200
  }
190
- function i(e) {
201
+ function d(e) {
191
202
  return e.replace(/\r/g, "").replace(/[ \t]+/g, " ").replace(/ *\n */g, `
192
203
  `).replace(/\n{3,}/g, `
193
204
 
194
205
  `).trim();
195
206
  }
196
- function w(e) {
207
+ function Y(e) {
197
208
  if (typeof e != "string" || !e) return "";
198
209
  let t = e.length;
199
- for (const a of S) {
200
- const s = e.search(a);
201
- s >= 0 && s < t && (t = s);
210
+ for (const a of b) {
211
+ const o = e.search(a);
212
+ o >= 0 && o < t && (t = o);
202
213
  }
203
214
  const n = e.slice(0, t);
204
- let r = i(E(c(n)));
205
- return r || (r = i(E(c(e)))), r;
215
+ let r = d(E(c(n)));
216
+ return r || (r = d(E(c(e)))), N(r) || r;
217
+ }
218
+ const L = /(^|[._+-])(no-?reply|noreply|donotreply|do-not-reply|newsletter|nieuwsbrief|mailer|mailing|notifications?|bounce|postmaster|marketing)@/i, O = /\b(unsubscribe|afmelden|uitschrijven|opt[\s-]?out|manage (your )?preferences|geen (e-?mails?|nieuwsbrief|berichten) meer)\b/i;
219
+ function q(e, t) {
220
+ return !!(e && L.test(e) || t && O.test(t));
221
+ }
222
+ const R = 3, m = 600;
223
+ function X(e, t) {
224
+ return e >= R || t >= m;
206
225
  }
207
- function b(e, t) {
208
- const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, a = t.intents.filter((o) => !n.has(o.intent)).map((o) => O(o, r[o.intent]));
209
- if (!e.extraIntents || e.extraIntents.length === 0) return a;
210
- const s = new Set(a.map((o) => o.intent));
226
+ function C(e, t) {
227
+ const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, s = t.intents.filter((o) => !n.has(o.intent)).map((o) => h(o, r[o.intent]));
228
+ if (!e.extraIntents || e.extraIntents.length === 0) return s;
229
+ const a = new Set(s.map((o) => o.intent));
211
230
  for (const o of e.extraIntents)
212
- s.has(o.intent) || (a.push(o), s.add(o.intent));
213
- return a;
231
+ a.has(o.intent) || (s.push(o), a.add(o.intent));
232
+ return s;
214
233
  }
215
- function D(e, t) {
234
+ function M(e, t) {
216
235
  const n = {};
217
236
  for (const r of e.intents) {
218
237
  if (!r.togglable) continue;
219
- const a = t?.[r.intent];
220
- n[r.intent] = a ?? r.defaultEnabled ?? !0;
238
+ const s = t?.[r.intent];
239
+ n[r.intent] = s ?? r.defaultEnabled ?? !0;
221
240
  }
222
241
  return n;
223
242
  }
224
- function x(e, t) {
225
- const n = D(e, t);
243
+ function z(e, t) {
244
+ const n = M(e, t);
226
245
  return Object.entries(n).filter(([, r]) => !r).map(([r]) => r);
227
246
  }
228
- function O(e, t) {
247
+ function h(e, t) {
229
248
  return t ? {
230
249
  intent: t.intent ?? e.intent,
231
250
  targetSchemes: t.targetSchemes ?? e.targetSchemes,
232
251
  transport: t.transport ?? e.transport
233
252
  } : e;
234
253
  }
235
- function F(e, t) {
254
+ function J(e, t) {
236
255
  const n = [];
237
256
  for (const r of e) {
238
257
  if (!r.enabled) continue;
239
- const a = t[r.providerId];
240
- if (a)
241
- for (const s of b(r, a))
242
- n.push({ channel: r, description: a, capability: s });
258
+ const s = t[r.providerId];
259
+ if (s)
260
+ for (const a of C(r, s))
261
+ n.push({ channel: r, description: s, capability: a });
243
262
  }
244
263
  return n;
245
264
  }
246
- function B(e, t) {
265
+ function Q(e, t) {
247
266
  return t.filter((n) => n.capability.intent === e);
248
267
  }
249
- function N(e, t) {
268
+ function P(e, t) {
250
269
  return t.filter((n) => n.capability.targetSchemes.includes(e));
251
270
  }
252
- function j(e, t) {
253
- return N(e.scheme, t);
271
+ function Z(e, t) {
272
+ return P(e.scheme, t);
254
273
  }
255
- function W(e, t, n) {
274
+ function v(e, t, n) {
256
275
  const r = [];
257
- for (const a of e)
258
- for (const s of n)
259
- s.capability.intent === t && s.capability.targetSchemes.includes(a.scheme) && r.push({ channelIntent: s, endpoint: a });
276
+ for (const s of e)
277
+ for (const a of n)
278
+ a.capability.intent === t && a.capability.targetSchemes.includes(s.scheme) && r.push({ channelIntent: a, endpoint: s });
260
279
  return r;
261
280
  }
262
- var L = /* @__PURE__ */ ((e) => (e.MAILTO = "mailto", e.SIP = "sip", e.TEL = "tel", e.WEBHOOK = "webhook", e.USERNAME = "username", e.ID = "id", e.CUSTOM = "custom", e.URL = "url", e.TELEGRAM = "telegram", e.WHATSAPP = "whatsapp", e.MESSENGER = "messenger", e.INSTAGRAM = "instagram", e.VIBER = "viber", e.SMS = "sms", e.FAX = "fax", e.TEAMS = "teams", e.CALENDAR = "calendar", e))(L || {});
263
- const K = "message_window", Y = "message_templates", q = {
281
+ var y = /* @__PURE__ */ ((e) => (e.MAILTO = "mailto", e.SIP = "sip", e.TEL = "tel", e.WEBHOOK = "webhook", e.USERNAME = "username", e.ID = "id", e.CUSTOM = "custom", e.URL = "url", e.TELEGRAM = "telegram", e.WHATSAPP = "whatsapp", e.MESSENGER = "messenger", e.INSTAGRAM = "instagram", e.VIBER = "viber", e.SMS = "sms", e.FAX = "fax", e.TEAMS = "teams", e.CALENDAR = "calendar", e))(y || {});
282
+ const ee = "message_window", te = "message_templates", ne = {
264
283
  // E-mail
265
284
  FROM: "from",
266
285
  TO: "to",
@@ -277,42 +296,46 @@ const K = "message_window", Y = "message_templates", q = {
277
296
  // Voice/conference
278
297
  HOST: "host",
279
298
  PARTICIPANT: "participant"
280
- }, X = (e, t) => ({ intent: e, ...t }), z = "folder_management", J = "remote_search", Q = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, Z = 9e4, v = "installation-id";
299
+ }, re = (e, t) => ({ intent: e, ...t }), se = "folder_management", ae = "remote_search", oe = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, le = 9e4, ie = "installation-id";
281
300
  export {
282
- M as CORE_DIMENSIONS,
283
- L as CommunicationScheme,
284
- z as FEATURE_FOLDER_MANAGEMENT,
285
- J as FEATURE_REMOTE_SEARCH,
286
- v as INSTALLATION_HEADER,
287
- q as InteractionParticipantRole,
288
- Z as PRESENCE_ONLINE_WINDOW_MS,
289
- Y as PROVIDER_FEATURE_MESSAGE_TEMPLATES,
290
- K as PROVIDER_FEATURE_MESSAGE_WINDOW,
291
- $ as SIGNATURE_INTENTS,
292
- Q as UNSUPPORTED,
293
- h as applySignature,
294
- C as buildActivityPreview,
295
- F as buildChannelIntents,
296
- w as cleanMessageText,
297
- X as defineIntent,
298
- x as disabledIntentsFromCapabilities,
299
- j as filterByEndpoint,
300
- B as filterByIntent,
301
- N as filterByTargetScheme,
302
- m as flattenLocales,
303
- T as floorToPeriod,
304
- g as formatPeriod,
305
- R as getActivitySeenUserIds,
306
- y as getContactEndpoints,
307
- G as getShortTitle,
308
- V as getUrgencyScore,
309
- U as isAssigned,
310
- H as isClosed,
311
- k as isInteractionUnseen,
312
- W as matchContactToIntents,
313
- P as periodsInRange,
314
- D as resolveAccountCapabilities,
315
- b as resolveChannelIntents,
316
- I as resolveSignature,
301
+ H as CORE_DIMENSIONS,
302
+ y as CommunicationScheme,
303
+ se as FEATURE_FOLDER_MANAGEMENT,
304
+ ae as FEATURE_REMOTE_SEARCH,
305
+ ie as INSTALLATION_HEADER,
306
+ ne as InteractionParticipantRole,
307
+ le as PRESENCE_ONLINE_WINDOW_MS,
308
+ te as PROVIDER_FEATURE_MESSAGE_TEMPLATES,
309
+ ee as PROVIDER_FEATURE_MESSAGE_WINDOW,
310
+ w as SIGNATURE_INTENTS,
311
+ m as SUMMARY_MIN_LAST_CHARS,
312
+ R as SUMMARY_MIN_MESSAGES,
313
+ oe as UNSUPPORTED,
314
+ k as applySignature,
315
+ $ as buildActivityPreview,
316
+ J as buildChannelIntents,
317
+ Y as cleanMessageText,
318
+ re as defineIntent,
319
+ z as disabledIntentsFromCapabilities,
320
+ Z as filterByEndpoint,
321
+ Q as filterByIntent,
322
+ P as filterByTargetScheme,
323
+ G as flattenLocales,
324
+ _ as floorToPeriod,
325
+ f as formatPeriod,
326
+ U as getActivitySeenUserIds,
327
+ x as getContactEndpoints,
328
+ W as getShortTitle,
329
+ j as getUrgencyScore,
330
+ B as isAssigned,
331
+ F as isClosed,
332
+ K as isInteractionUnseen,
333
+ q as isLikelyBulk,
334
+ X as isThreadLongEnough,
335
+ v as matchContactToIntents,
336
+ V as periodsInRange,
337
+ M as resolveAccountCapabilities,
338
+ C as resolveChannelIntents,
339
+ S as resolveSignature,
317
340
  p as stripHtml
318
341
  };
@@ -124,6 +124,13 @@ export interface ExtensionConfig {
124
124
  icon?: string | IconDefinition;
125
125
  priority?: number;
126
126
  contexts?: ExtensionContext[];
127
+ /**
128
+ * Sit apart from the rest of the slot, ahead of them and separated by a
129
+ * rule. For a tool that is always there and always first — the assistant —
130
+ * rather than one more entry in the list. Declared by the app so the host
131
+ * does not have to know which extension is special.
132
+ */
133
+ pinned?: boolean;
127
134
  conditions?: {
128
135
  [key: string]: any;
129
136
  };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Cheap, no-LLM triage heuristics for deciding whether an interaction is worth
3
+ * auto-summarising in focus mode. Deliberately conservative: a false negative
4
+ * (summarising a newsletter) only wastes one cheap call, while a false positive
5
+ * (skipping a real 1-to-1 mail) hurts the user — so we only flag CLEAR bulk.
6
+ */
7
+ /** True when a message looks like a newsletter / automated bulk send. */
8
+ export declare function isLikelyBulk(fromEmail?: string, body?: string): boolean;
9
+ /** A conversation is "worth summarising" once it has real back-and-forth or a long message. */
10
+ export declare const SUMMARY_MIN_MESSAGES = 3;
11
+ export declare const SUMMARY_MIN_LAST_CHARS = 600;
12
+ /** True when the thread is long enough that a summary saves the reader scrolling. */
13
+ export declare function isThreadLongEnough(messageCount: number, lastMessageChars: number): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.100.1",
3
+ "version": "1.112.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",