@opencxh/domain 1.53.0 → 1.54.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/entities/interaction/types.d.ts +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +31 -29
- package/dist/platform/communication.d.ts +58 -0
- package/package.json +1 -1
|
@@ -8,6 +8,19 @@ export interface ActivityPreview {
|
|
|
8
8
|
direction: "inbound" | "outbound" | "internal" | "none";
|
|
9
9
|
createdAt: number;
|
|
10
10
|
}
|
|
11
|
+
/** Query for the interaction search endpoint (POST /search/interaction). */
|
|
12
|
+
export interface InteractionSearchQuery {
|
|
13
|
+
/** Match the counterparty subdocument (exact). */
|
|
14
|
+
remoteParty?: {
|
|
15
|
+
scheme?: string;
|
|
16
|
+
resource?: string;
|
|
17
|
+
};
|
|
18
|
+
status?: string;
|
|
19
|
+
/** Only interactions with activity since this epoch-ms; null = no lower bound. */
|
|
20
|
+
since?: number | null;
|
|
21
|
+
page?: number;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}
|
|
11
24
|
export interface InteractionSource {
|
|
12
25
|
activityId?: string;
|
|
13
26
|
activityType?: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=140;function i(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 A(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 I(e){switch(e.type){case"EMAIL_RECEIVED":case"EMAIL_SENT":{const t=e.payload,n=t.bodySnippet?.trim()||i(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.segments??[]).map(t=>t.text).join(" ");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 T(e){return{activityId:e.id,type:e.type,snippet:A(I(e)),authorName:e.author?.name??"",direction:e.direction,createdAt:e.createdAt??Date.now()}}function _(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function g(e){return e.endpoints??[]}const f=e=>!!e.assignedUserId||!!e.assignedInboxId,D=e=>e.status==="closed",S=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,L=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function C(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}function u(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},s=t.intents.filter(a=>!n.has(a.intent)).map(a=>R(a,r[a.intent]));if(!e.extraIntents||e.extraIntents.length===0)return s;const o=new Set(s.map(a=>a.intent));for(const a of e.extraIntents)o.has(a.intent)||(s.push(a),o.add(a.intent));return s}function p(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 N(e,t){const n=p(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function R(e,t){return t?{intent:t.intent??e.intent,targetSchemes:t.targetSchemes??e.targetSchemes,transport:t.transport??e.transport}:e}function O(e,t){const n=[];for(const r of e){if(!r.enabled)continue;const s=t[r.providerId];if(s)for(const o of u(r,s))n.push({channel:r,description:s,capability:o})}return n}function b(e,t){return t.filter(n=>n.capability.intent===e)}function d(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function M(e,t){return d(e.scheme,t)}function P(e,t,n){const r=[];for(const s of e)for(const o of n)o.capability.intent===t&&o.capability.targetSchemes.includes(s.scheme)&&r.push({channelIntent:o,endpoint:s});return r}var c=(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))(c||{});const V="message_window",y="message_templates",G={FROM:"from",TO:"to",CC:"cc",BCC:"bcc",ORGANIZER:"organizer",PRESENTER:"presenter",ATTENDEE:"attendee",OWNER:"owner",MEMBER:"member",GUEST:"guest",HOST:"host",PARTICIPANT:"participant"},m=(e,t)=>({intent:e,...t}),U={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},H="installation-id";exports.CommunicationScheme=c;exports.INSTALLATION_HEADER=H;exports.InteractionParticipantRole=G;exports.PROVIDER_FEATURE_MESSAGE_TEMPLATES=y;exports.PROVIDER_FEATURE_MESSAGE_WINDOW=V;exports.UNSUPPORTED=U;exports.buildActivityPreview=T;exports.buildChannelIntents=O;exports.defineIntent=m;exports.disabledIntentsFromCapabilities=N;exports.filterByEndpoint=M;exports.filterByIntent=b;exports.filterByTargetScheme=d;exports.getContactEndpoints=g;exports.getShortTitle=L;exports.getUrgencyScore=S;exports.isAssigned=f;exports.isClosed=D;exports.isInteractionUnseen=C;exports.matchContactToIntents=P;exports.resolveAccountCapabilities=p;exports.resolveChannelIntents=u;exports.resolveSignature=_;exports.stripHtml=i;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(e) {
|
|
2
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
|
-
function
|
|
4
|
+
function u(e) {
|
|
5
5
|
const t = e.trim();
|
|
6
6
|
return t.length <= 140 ? t : t.slice(0, 139).trimEnd() + "…";
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ function p(e) {
|
|
|
14
14
|
switch (e.type) {
|
|
15
15
|
case "EMAIL_RECEIVED":
|
|
16
16
|
case "EMAIL_SENT": {
|
|
17
|
-
const t = e.payload, n = t.bodySnippet?.trim() ||
|
|
17
|
+
const t = e.payload, n = t.bodySnippet?.trim() || l(t.body ?? "");
|
|
18
18
|
return t.subject ? `${t.subject} — ${n}` : n;
|
|
19
19
|
}
|
|
20
20
|
case "CHAT_MESSAGE_SENT":
|
|
@@ -83,17 +83,17 @@ function p(e) {
|
|
|
83
83
|
return "";
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function _(e) {
|
|
87
87
|
return {
|
|
88
88
|
activityId: e.id,
|
|
89
89
|
type: e.type,
|
|
90
|
-
snippet:
|
|
90
|
+
snippet: u(p(e)),
|
|
91
91
|
authorName: e.author?.name ?? "",
|
|
92
92
|
direction: e.direction,
|
|
93
93
|
createdAt: e.createdAt ?? Date.now()
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function T(e, t) {
|
|
97
97
|
const n = e.settings?.signatures?.[t];
|
|
98
98
|
return !n || !n.enabled || !n.body || n.body.trim() === "" ? null : n;
|
|
99
99
|
}
|
|
@@ -106,11 +106,11 @@ const f = (e) => !!e.assignedUserId || !!e.assignedInboxId, D = (e) => e.status
|
|
|
106
106
|
normal: 2,
|
|
107
107
|
low: 1
|
|
108
108
|
})[e.priority] || 0, N = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
|
|
109
|
-
function
|
|
109
|
+
function S(e, t) {
|
|
110
110
|
return e.lastActivityAt ? !(e.seenBy ?? []).includes(t) : !1;
|
|
111
111
|
}
|
|
112
112
|
function d(e, t) {
|
|
113
|
-
const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, s = t.intents.filter((a) => !n.has(a.intent)).map((a) =>
|
|
113
|
+
const n = new Set(e.disabledIntents ?? []), r = e.intentOverrides ?? {}, s = t.intents.filter((a) => !n.has(a.intent)).map((a) => A(a, r[a.intent]));
|
|
114
114
|
if (!e.extraIntents || e.extraIntents.length === 0) return s;
|
|
115
115
|
const o = new Set(s.map((a) => a.intent));
|
|
116
116
|
for (const a of e.extraIntents)
|
|
@@ -126,11 +126,11 @@ function c(e, t) {
|
|
|
126
126
|
}
|
|
127
127
|
return n;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function C(e, t) {
|
|
130
130
|
const n = c(e, t);
|
|
131
131
|
return Object.entries(n).filter(([, r]) => !r).map(([r]) => r);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function A(e, t) {
|
|
134
134
|
return t ? {
|
|
135
135
|
intent: t.intent ?? e.intent,
|
|
136
136
|
targetSchemes: t.targetSchemes ?? e.targetSchemes,
|
|
@@ -151,21 +151,21 @@ function O(e, t) {
|
|
|
151
151
|
function R(e, t) {
|
|
152
152
|
return t.filter((n) => n.capability.intent === e);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function i(e, t) {
|
|
155
155
|
return t.filter((n) => n.capability.targetSchemes.includes(e));
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
157
|
+
function M(e, t) {
|
|
158
|
+
return i(e.scheme, t);
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function b(e, t, n) {
|
|
161
161
|
const r = [];
|
|
162
162
|
for (const s of e)
|
|
163
163
|
for (const o of n)
|
|
164
164
|
o.capability.intent === t && o.capability.targetSchemes.includes(s.scheme) && r.push({ channelIntent: o, endpoint: s });
|
|
165
165
|
return r;
|
|
166
166
|
}
|
|
167
|
-
var I = /* @__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))(I || {});
|
|
168
|
-
const P = {
|
|
167
|
+
var I = /* @__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))(I || {});
|
|
168
|
+
const P = "message_window", V = "message_templates", G = {
|
|
169
169
|
// E-mail
|
|
170
170
|
FROM: "from",
|
|
171
171
|
TO: "to",
|
|
@@ -182,28 +182,30 @@ const P = {
|
|
|
182
182
|
// Voice/conference
|
|
183
183
|
HOST: "host",
|
|
184
184
|
PARTICIPANT: "participant"
|
|
185
|
-
},
|
|
185
|
+
}, H = (e, t) => ({ intent: e, ...t }), $ = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, y = "installation-id";
|
|
186
186
|
export {
|
|
187
187
|
I as CommunicationScheme,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
y as INSTALLATION_HEADER,
|
|
189
|
+
G as InteractionParticipantRole,
|
|
190
|
+
V as PROVIDER_FEATURE_MESSAGE_TEMPLATES,
|
|
191
|
+
P as PROVIDER_FEATURE_MESSAGE_WINDOW,
|
|
192
|
+
$ as UNSUPPORTED,
|
|
193
|
+
_ as buildActivityPreview,
|
|
192
194
|
O as buildChannelIntents,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
H as defineIntent,
|
|
196
|
+
C as disabledIntentsFromCapabilities,
|
|
197
|
+
M as filterByEndpoint,
|
|
196
198
|
R as filterByIntent,
|
|
197
|
-
|
|
199
|
+
i as filterByTargetScheme,
|
|
198
200
|
g as getContactEndpoints,
|
|
199
201
|
N as getShortTitle,
|
|
200
202
|
L as getUrgencyScore,
|
|
201
203
|
f as isAssigned,
|
|
202
204
|
D as isClosed,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
S as isInteractionUnseen,
|
|
206
|
+
b as matchContactToIntents,
|
|
205
207
|
c as resolveAccountCapabilities,
|
|
206
208
|
d as resolveChannelIntents,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
T as resolveSignature,
|
|
210
|
+
l as stripHtml
|
|
209
211
|
};
|
|
@@ -57,6 +57,8 @@ export declare enum CommunicationScheme {
|
|
|
57
57
|
URL = "url",
|
|
58
58
|
TELEGRAM = "telegram",
|
|
59
59
|
WHATSAPP = "whatsapp",
|
|
60
|
+
MESSENGER = "messenger",
|
|
61
|
+
INSTAGRAM = "instagram",
|
|
60
62
|
VIBER = "viber",
|
|
61
63
|
SMS = "sms",
|
|
62
64
|
FAX = "fax",
|
|
@@ -141,6 +143,62 @@ export interface ProviderDescription {
|
|
|
141
143
|
/** Provider feature flags — separate from routing. */
|
|
142
144
|
features: ProviderFeature[];
|
|
143
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Provider-feature names die de composer generiek interpreteert (geen
|
|
148
|
+
* hardcoding per-provider). Een provider die `message_window` adverteert
|
|
149
|
+
* heeft een tijdgebonden messaging-venster; `message_templates` betekent dat
|
|
150
|
+
* er pre-approved templates beschikbaar zijn buiten dat venster.
|
|
151
|
+
*/
|
|
152
|
+
export declare const PROVIDER_FEATURE_MESSAGE_WINDOW = "message_window";
|
|
153
|
+
export declare const PROVIDER_FEATURE_MESSAGE_TEMPLATES = "message_templates";
|
|
154
|
+
/**
|
|
155
|
+
* Eén variabele in een provider-template (bv. WhatsApp HSM body-param `{{1}}`).
|
|
156
|
+
*/
|
|
157
|
+
export interface ProviderMessageTemplateVariable {
|
|
158
|
+
/** Stabiele key — voor WhatsApp de 1-based index als string ("1", "2", …). */
|
|
159
|
+
key: string;
|
|
160
|
+
/** Optioneel voorbeeld/placeholder uit de provider. */
|
|
161
|
+
example?: string;
|
|
162
|
+
label?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Pre-approved provider-template (WhatsApp HSM). De composer rendert per
|
|
166
|
+
* `variables` een invoerveld; submit stuurt `templateId` + ingevulde waarden
|
|
167
|
+
* mee. Los van de user-gemaakte canned-reply {@link MessageTemplate}.
|
|
168
|
+
*/
|
|
169
|
+
export interface ProviderMessageTemplate {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
language?: string;
|
|
173
|
+
/** Voorbeeld van de samengestelde body (variabelen als placeholders). */
|
|
174
|
+
bodyPreview?: string;
|
|
175
|
+
category?: string;
|
|
176
|
+
variables: ProviderMessageTemplateVariable[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Geldige tag waarmee buiten het standaard-venster tóch een vrij-tekst bericht
|
|
180
|
+
* verstuurd mag worden (Messenger/Instagram message-tags, human-agent-tag).
|
|
181
|
+
*/
|
|
182
|
+
export interface MessageTag {
|
|
183
|
+
id: string;
|
|
184
|
+
label: string;
|
|
185
|
+
description?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Antwoord van `provider/message-context` (read-route op een dispatch-provider
|
|
189
|
+
* met `message_window`/`message_templates`-features). Per interaction vertelt
|
|
190
|
+
* dit de composer of vrij-tekst mag, en zo niet welke templates/tags er zijn.
|
|
191
|
+
*/
|
|
192
|
+
export interface MessageContext {
|
|
193
|
+
/** Vrij-tekst toegestaan? false ⇒ composer forceert template of tag. */
|
|
194
|
+
windowOpen: boolean;
|
|
195
|
+
/** Epoch-ms waarop het venster sluit (indien open en bekend). */
|
|
196
|
+
windowExpiresAt?: number;
|
|
197
|
+
/** Beschikbare pre-approved templates (WhatsApp). */
|
|
198
|
+
templates?: ProviderMessageTemplate[];
|
|
199
|
+
/** Geldige message-tags (Messenger/Instagram). */
|
|
200
|
+
tags?: MessageTag[];
|
|
201
|
+
}
|
|
144
202
|
export interface PersonalAuthOption {
|
|
145
203
|
id: string;
|
|
146
204
|
label: string;
|