@opencxh/domain 1.30.0 → 1.31.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.
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Uri } from '../../platform/communication';
|
|
2
|
+
import { ActivityType } from '../activity/types';
|
|
3
|
+
export interface ActivityPreview {
|
|
4
|
+
activityId: string;
|
|
5
|
+
type: ActivityType;
|
|
6
|
+
snippet: string;
|
|
7
|
+
authorName: string;
|
|
8
|
+
direction: "inbound" | "outbound" | "internal" | "none";
|
|
9
|
+
createdAt: number;
|
|
10
|
+
}
|
|
2
11
|
export interface InteractionSource {
|
|
3
12
|
activityId?: string;
|
|
4
13
|
activityType?: string;
|
|
@@ -36,4 +45,6 @@ export interface Interaction {
|
|
|
36
45
|
visibility?: "visible" | "hidden";
|
|
37
46
|
createdAt?: number;
|
|
38
47
|
updatedAt?: number;
|
|
48
|
+
lastActivityAt?: number;
|
|
49
|
+
lastActivityPreview?: ActivityPreview;
|
|
39
50
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=140;function c(e){return e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim()}function I(e){const t=e.trim();return t.length<=l?t:t.slice(0,l-1).trimEnd()+"…"}function E(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 A(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const t=e.payload,n=t.bodySnippet?.trim()||c(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?` (${E(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?` (${E(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.text??"";case"AI_MESSAGE_ADDED":return e.payload.output?.text??e.payload.input?.text??"";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?` (${E(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 i(e){return{activityId:e.id,type:e.type,snippet:I(A(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function _(e){return e.endpoints??[]}const g=e=>!!e.assignedUserId||!!e.assignedInboxId,T=e=>e.status==="closed",D=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,f=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function p(e,t){const n=new Set(e.disabledIntents??[]),s=e.intentOverrides??{},r=t.intents.filter(a=>!n.has(a.intent)).map(a=>L(a,s[a.intent]));if(!e.extraIntents||e.extraIntents.length===0)return r;const o=new Set(r.map(a=>a.intent));for(const a of e.extraIntents)o.has(a.intent)||(r.push(a),o.add(a.intent));return r}function L(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function C(e,t){const n=[];for(const s of e){if(!s.enabled)continue;const r=t[s.providerId];if(r)for(const o of p(s,r))n.push({channel:s,description:r,capability:o})}return n}function S(e,t){return t.filter(n=>n.capability.intent===e)}function d(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function N(e,t){return d(e.scheme,t)}function O(e,t,n){const s=[];for(const r of e)for(const o of n)o.capability.intent===t&&o.capability.targetSchemes.includes(r.scheme)&&s.push({channelIntent:o,endpoint:r});return s}var u=(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.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(u||{});const M=(e,t)=>({intent:e,...t}),b={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"};exports.CommunicationScheme=u;exports.UNSUPPORTED=b;exports.buildActivityPreview=i;exports.buildChannelIntents=C;exports.defineIntent=M;exports.filterByEndpoint=N;exports.filterByIntent=S;exports.filterByTargetScheme=d;exports.getContactEndpoints=_;exports.getShortTitle=f;exports.getUrgencyScore=D;exports.isAssigned=g;exports.isClosed=T;exports.matchContactToIntents=O;exports.resolveChannelIntents=p;
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,165 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function p(e) {
|
|
2
|
+
return e.replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/\s+/g, " ").trim();
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
function l(e) {
|
|
5
|
+
const t = e.trim();
|
|
6
|
+
return t.length <= 140 ? t : t.slice(0, 139).trimEnd() + "…";
|
|
7
|
+
}
|
|
8
|
+
function E(e) {
|
|
9
|
+
if (!e || e < 0) return "";
|
|
10
|
+
const t = Math.floor(e / 60), r = Math.floor(e % 60);
|
|
11
|
+
return `${t}:${r.toString().padStart(2, "0")}`;
|
|
12
|
+
}
|
|
13
|
+
function u(e) {
|
|
14
|
+
switch (e.type) {
|
|
15
|
+
case "EMAIL_RECEIVED":
|
|
16
|
+
case "EMAIL_SENT": {
|
|
17
|
+
const t = e.payload, r = t.bodySnippet?.trim() || p(t.body ?? "");
|
|
18
|
+
return t.subject ? `${t.subject} — ${r}` : r;
|
|
19
|
+
}
|
|
20
|
+
case "CHAT_MESSAGE_SENT":
|
|
21
|
+
case "CHAT_MESSAGE_RECEIVED":
|
|
22
|
+
return e.payload.text ?? "";
|
|
23
|
+
case "CHAT_RENAMED":
|
|
24
|
+
return `Hernoemd naar "${e.payload.newName}"`;
|
|
25
|
+
case "CHAT_MEMBER_JOINED":
|
|
26
|
+
return `${e.payload.members.map((t) => t.name).join(", ")} toegevoegd`;
|
|
27
|
+
case "CHAT_MEMBER_LEFT":
|
|
28
|
+
return `${e.payload.members.map((t) => t.name).join(", ")} verlaten`;
|
|
29
|
+
case "CHAT_CALL_STARTED":
|
|
30
|
+
return "Gesprek gestart";
|
|
31
|
+
case "CHAT_CALL_ENDED":
|
|
32
|
+
return `Gesprek beëindigd${e.payload.duration ? ` (${E(e.payload.duration)})` : ""}`;
|
|
33
|
+
case "CHAT_EVENT":
|
|
34
|
+
return e.payload.text ?? e.payload.eventType;
|
|
35
|
+
case "VOICE_CALL_STARTED":
|
|
36
|
+
case "VIDEO_CALL_STARTED":
|
|
37
|
+
return "Gesprek gestart";
|
|
38
|
+
case "VOICE_CALL_ANSWERED":
|
|
39
|
+
case "VIDEO_CALL_ANSWERED":
|
|
40
|
+
return "Gesprek aangenomen";
|
|
41
|
+
case "VOICE_CALL_HOLD":
|
|
42
|
+
case "VIDEO_CALL_HOLD":
|
|
43
|
+
return "In de wacht";
|
|
44
|
+
case "VOICE_CALL_UNHOLD":
|
|
45
|
+
case "VIDEO_CALL_UNHOLD":
|
|
46
|
+
return "Hervat";
|
|
47
|
+
case "VOICE_CALL_ENDED":
|
|
48
|
+
case "VIDEO_CALL_ENDED":
|
|
49
|
+
return `Gesprek beëindigd${e.payload.duration ? ` (${E(e.payload.duration)})` : ""}`;
|
|
50
|
+
case "VOICE_CALL_MISSED":
|
|
51
|
+
case "VIDEO_CALL_MISSED":
|
|
52
|
+
return "Gemiste oproep";
|
|
53
|
+
case "VOICE_CALL_FAILED":
|
|
54
|
+
case "VIDEO_CALL_FAILED":
|
|
55
|
+
return "Gesprek mislukt";
|
|
56
|
+
case "VOICE_CALL_VOICEMAIL":
|
|
57
|
+
return e.payload.transcription?.trim() ? e.payload.transcription : "Voicemail ontvangen";
|
|
58
|
+
case "TRANSCRIPT_ADDED":
|
|
59
|
+
return e.payload.text ?? "";
|
|
60
|
+
case "AI_MESSAGE_ADDED":
|
|
61
|
+
return e.payload.output?.text ?? e.payload.input?.text ?? "";
|
|
62
|
+
case "MEETING_SCHEDULED":
|
|
63
|
+
return `Vergadering gepland: ${e.payload.title}`;
|
|
64
|
+
case "MEETING_STARTED":
|
|
65
|
+
return `Vergadering gestart: ${e.payload.title}`;
|
|
66
|
+
case "MEETING_ENDED":
|
|
67
|
+
return `Vergadering beëindigd${e.payload.duration ? ` (${E(e.payload.duration)})` : ""}`;
|
|
68
|
+
case "MEETING_PARTICIPANT_JOINED":
|
|
69
|
+
return `${e.payload.name} deelgenomen`;
|
|
70
|
+
case "MEETING_PARTICIPANT_LEFT":
|
|
71
|
+
return `${e.payload.name} verlaten`;
|
|
72
|
+
case "COMMENT_ADDED":
|
|
73
|
+
return e.payload.text ?? "";
|
|
74
|
+
case "FILE_UPLOADED":
|
|
75
|
+
return `Bestand: ${e.payload.fileName}`;
|
|
76
|
+
case "INTERACTION_CREATED":
|
|
77
|
+
return "Interactie aangemaakt";
|
|
78
|
+
case "INTERACTION_STATUS_CHANGED":
|
|
79
|
+
return `Status: ${e.payload.fromStatus} → ${e.payload.toStatus}`;
|
|
80
|
+
case "INTERACTION_ASSIGNED":
|
|
81
|
+
return "Interactie toegewezen";
|
|
82
|
+
default:
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function _(e) {
|
|
87
|
+
return {
|
|
88
|
+
activityId: e.id,
|
|
89
|
+
type: e.type,
|
|
90
|
+
snippet: l(u(e)),
|
|
91
|
+
authorName: e.author?.name ?? "",
|
|
92
|
+
direction: e.direction,
|
|
93
|
+
createdAt: e.createdAt ?? Date.now()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function T(e) {
|
|
97
|
+
return e.endpoints ?? [];
|
|
98
|
+
}
|
|
99
|
+
const D = (e) => !!e.assignedUserId || !!e.assignedInboxId, g = (e) => e.status === "closed", L = (e) => ({
|
|
5
100
|
urgent: 10,
|
|
6
101
|
high: 5,
|
|
7
102
|
normal: 2,
|
|
8
103
|
low: 1
|
|
9
|
-
})[
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
13
|
-
const o = new Set(
|
|
14
|
-
for (const
|
|
15
|
-
o.has(
|
|
16
|
-
return
|
|
104
|
+
})[e.priority] || 0, f = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
|
|
105
|
+
function d(e, t) {
|
|
106
|
+
const r = new Set(e.disabledIntents ?? []), s = e.intentOverrides ?? {}, n = t.intents.filter((a) => !r.has(a.intent)).map((a) => A(a, s[a.intent]));
|
|
107
|
+
if (!e.extraIntents || e.extraIntents.length === 0) return n;
|
|
108
|
+
const o = new Set(n.map((a) => a.intent));
|
|
109
|
+
for (const a of e.extraIntents)
|
|
110
|
+
o.has(a.intent) || (n.push(a), o.add(a.intent));
|
|
111
|
+
return n;
|
|
17
112
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
-
intent:
|
|
21
|
-
targetSchemes:
|
|
22
|
-
transport:
|
|
23
|
-
} :
|
|
113
|
+
function A(e, t) {
|
|
114
|
+
return t ? {
|
|
115
|
+
intent: t.intent ?? e.intent,
|
|
116
|
+
targetSchemes: t.targetSchemes ?? e.targetSchemes,
|
|
117
|
+
transport: t.transport ?? e.transport
|
|
118
|
+
} : e;
|
|
24
119
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
for (const o of
|
|
32
|
-
|
|
120
|
+
function i(e, t) {
|
|
121
|
+
const r = [];
|
|
122
|
+
for (const s of e) {
|
|
123
|
+
if (!s.enabled) continue;
|
|
124
|
+
const n = t[s.providerId];
|
|
125
|
+
if (n)
|
|
126
|
+
for (const o of d(s, n))
|
|
127
|
+
r.push({ channel: s, description: n, capability: o });
|
|
33
128
|
}
|
|
34
|
-
return
|
|
129
|
+
return r;
|
|
35
130
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
131
|
+
function N(e, t) {
|
|
132
|
+
return t.filter((r) => r.capability.intent === e);
|
|
38
133
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
134
|
+
function I(e, t) {
|
|
135
|
+
return t.filter((r) => r.capability.targetSchemes.includes(e));
|
|
41
136
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
137
|
+
function S(e, t) {
|
|
138
|
+
return I(e.scheme, t);
|
|
44
139
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
for (const o of
|
|
49
|
-
o.capability.intent ===
|
|
50
|
-
return
|
|
140
|
+
function C(e, t, r) {
|
|
141
|
+
const s = [];
|
|
142
|
+
for (const n of e)
|
|
143
|
+
for (const o of r)
|
|
144
|
+
o.capability.intent === t && o.capability.targetSchemes.includes(n.scheme) && s.push({ channelIntent: o, endpoint: n });
|
|
145
|
+
return s;
|
|
51
146
|
}
|
|
52
|
-
var
|
|
53
|
-
const
|
|
147
|
+
var c = /* @__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.VIBER = "viber", e.SMS = "sms", e.FAX = "fax", e.TEAMS = "teams", e.CALENDAR = "calendar", e))(c || {});
|
|
148
|
+
const O = (e, t) => ({ intent: e, ...t }), M = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" };
|
|
54
149
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
150
|
+
c as CommunicationScheme,
|
|
151
|
+
M as UNSUPPORTED,
|
|
152
|
+
_ as buildActivityPreview,
|
|
153
|
+
i as buildChannelIntents,
|
|
154
|
+
O as defineIntent,
|
|
155
|
+
S as filterByEndpoint,
|
|
156
|
+
N as filterByIntent,
|
|
157
|
+
I as filterByTargetScheme,
|
|
158
|
+
T as getContactEndpoints,
|
|
159
|
+
f as getShortTitle,
|
|
160
|
+
L as getUrgencyScore,
|
|
161
|
+
D as isAssigned,
|
|
162
|
+
g as isClosed,
|
|
163
|
+
C as matchContactToIntents,
|
|
164
|
+
d as resolveChannelIntents
|
|
69
165
|
};
|