@opencxh/domain 1.32.0 → 1.35.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,5 @@
|
|
|
1
1
|
import { AIMessageInput, AIMessageOutput } from '../ai-message/types';
|
|
2
|
+
import { TranscriptSegment } from '../../platform/media';
|
|
2
3
|
export type CallStatus = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
|
|
3
4
|
export type CallDirection = "inbound" | "outbound";
|
|
4
5
|
export type CallType = "audio" | "video" | "data" | "screen-share";
|
|
@@ -122,16 +123,8 @@ export type ChatEventPayload = {
|
|
|
122
123
|
initiator?: ChatMember;
|
|
123
124
|
raw?: any;
|
|
124
125
|
};
|
|
125
|
-
export type TranscriptAddedSegment = {
|
|
126
|
-
speaker: 'local' | 'remote';
|
|
127
|
-
speakerLabel?: string;
|
|
128
|
-
text: string;
|
|
129
|
-
startedAt: number;
|
|
130
|
-
endedAt: number;
|
|
131
|
-
};
|
|
132
126
|
export type TranscriptAddedPayload = {
|
|
133
|
-
|
|
134
|
-
segments?: TranscriptAddedSegment[];
|
|
127
|
+
segments: TranscriptSegment[];
|
|
135
128
|
finalized: boolean;
|
|
136
129
|
};
|
|
137
130
|
export type MeetingPayload = {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=140;function p(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()||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?` (${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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=140;function p(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()||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?` (${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 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 d(e,t){const n=new Set(e.disabledIntents??[]),a=e.intentOverrides??{},r=t.intents.filter(s=>!n.has(s.intent)).map(s=>L(s,a[s.intent]));if(!e.extraIntents||e.extraIntents.length===0)return r;const o=new Set(r.map(s=>s.intent));for(const s of e.extraIntents)o.has(s.intent)||(r.push(s),o.add(s.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 a of e){if(!a.enabled)continue;const r=t[a.providerId];if(r)for(const o of d(a,r))n.push({channel:a,description:r,capability:o})}return n}function S(e,t){return t.filter(n=>n.capability.intent===e)}function u(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function N(e,t){return u(e.scheme,t)}function O(e,t,n){const a=[];for(const r of e)for(const o of n)o.capability.intent===t&&o.capability.targetSchemes.includes(r.scheme)&&a.push({channelIntent:o,endpoint:r});return a}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.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(c||{});const M=(e,t)=>({intent:e,...t}),b={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"};exports.CommunicationScheme=c;exports.UNSUPPORTED=b;exports.buildActivityPreview=i;exports.buildChannelIntents=C;exports.defineIntent=M;exports.filterByEndpoint=N;exports.filterByIntent=S;exports.filterByTargetScheme=u;exports.getContactEndpoints=_;exports.getShortTitle=f;exports.getUrgencyScore=D;exports.isAssigned=g;exports.isClosed=T;exports.matchContactToIntents=O;exports.resolveChannelIntents=d;exports.stripHtml=p;
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function u(e) {
|
|
|
56
56
|
case "VOICE_CALL_VOICEMAIL":
|
|
57
57
|
return e.payload.transcription?.trim() ? e.payload.transcription : "Voicemail ontvangen";
|
|
58
58
|
case "TRANSCRIPT_ADDED":
|
|
59
|
-
return e.payload.
|
|
59
|
+
return (e.payload.segments ?? []).map((t) => t.text).join(" ");
|
|
60
60
|
case "AI_MESSAGE_ADDED":
|
|
61
61
|
return e.payload.output?.text ?? e.payload.input?.text ?? "";
|
|
62
62
|
case "MEETING_SCHEDULED":
|
|
@@ -101,7 +101,7 @@ const D = (e) => !!e.assignedUserId || !!e.assignedInboxId, g = (e) => e.status
|
|
|
101
101
|
high: 5,
|
|
102
102
|
normal: 2,
|
|
103
103
|
low: 1
|
|
104
|
-
})[e.priority] || 0,
|
|
104
|
+
})[e.priority] || 0, i = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
|
|
105
105
|
function d(e, t) {
|
|
106
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
107
|
if (!e.extraIntents || e.extraIntents.length === 0) return n;
|
|
@@ -117,7 +117,7 @@ function A(e, t) {
|
|
|
117
117
|
transport: t.transport ?? e.transport
|
|
118
118
|
} : e;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function f(e, t) {
|
|
121
121
|
const r = [];
|
|
122
122
|
for (const s of e) {
|
|
123
123
|
if (!s.enabled) continue;
|
|
@@ -150,13 +150,13 @@ export {
|
|
|
150
150
|
c as CommunicationScheme,
|
|
151
151
|
M as UNSUPPORTED,
|
|
152
152
|
_ as buildActivityPreview,
|
|
153
|
-
|
|
153
|
+
f as buildChannelIntents,
|
|
154
154
|
O as defineIntent,
|
|
155
155
|
S as filterByEndpoint,
|
|
156
156
|
N as filterByIntent,
|
|
157
157
|
I as filterByTargetScheme,
|
|
158
158
|
T as getContactEndpoints,
|
|
159
|
-
|
|
159
|
+
i as getShortTitle,
|
|
160
160
|
L as getUrgencyScore,
|
|
161
161
|
D as isAssigned,
|
|
162
162
|
g as isClosed,
|
|
@@ -10,6 +10,13 @@ export interface Session {
|
|
|
10
10
|
hasVideo: boolean;
|
|
11
11
|
isMuted: boolean;
|
|
12
12
|
actions: SessionAction[];
|
|
13
|
+
/**
|
|
14
|
+
* Provider-supplied externalId the transcript persistence should bind to.
|
|
15
|
+
* Server resolves this against `interaction.externalIds` (with an activity
|
|
16
|
+
* fallback). Lets providers point at the right interaction without the
|
|
17
|
+
* server needing to know their id shape.
|
|
18
|
+
*/
|
|
19
|
+
externalId?: string;
|
|
13
20
|
ui: {
|
|
14
21
|
canvas: `${string}:${string}`;
|
|
15
22
|
actionTray?: `${string}:${string}`;
|
|
@@ -29,10 +36,7 @@ export interface ITransportProvider {
|
|
|
29
36
|
readonly id: string;
|
|
30
37
|
subscribeSessions(callback: (sessions: Session[]) => void): () => void;
|
|
31
38
|
subscribeAccounts(callback: (accounts: CommsAccount[]) => void): () => void;
|
|
32
|
-
subscribeStreams(callback: (data:
|
|
33
|
-
sessionId: string;
|
|
34
|
-
stream: MediaStream;
|
|
35
|
-
}) => void): () => void;
|
|
39
|
+
subscribeStreams(callback: (data: RemoteStreamEvent) => void): () => void;
|
|
36
40
|
registerAccount(orgId: string, userId: string, config: any): Promise<CommsAccount>;
|
|
37
41
|
unregisterAccount(accountId: string): Promise<void>;
|
|
38
42
|
/**
|
|
@@ -178,6 +182,7 @@ export interface RemoteStreamEvent {
|
|
|
178
182
|
sessionId: string;
|
|
179
183
|
streamId: string;
|
|
180
184
|
stream: MediaStream | null;
|
|
185
|
+
speaker?: 'local' | 'remote';
|
|
181
186
|
label?: string;
|
|
182
187
|
}
|
|
183
188
|
/**
|
package/dist/platform/sdk.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export interface InternalSDK<LocalServices extends ServiceMap = {}, TranslationK
|
|
|
84
84
|
configureAudioPipeline(opts: Partial<AudioPipelineOptions>): void;
|
|
85
85
|
setAudioPipelineEnabled(enabled: boolean): void;
|
|
86
86
|
setInputDevice(deviceId: string): Promise<void>;
|
|
87
|
+
acquireMicStream(deviceId?: string): Promise<MediaStream>;
|
|
88
|
+
deviceChanges$: Observable<string>;
|
|
87
89
|
toggleMute(mute?: boolean): void;
|
|
88
90
|
attachProviderStream(sessionId: string, stream: MediaStream): void;
|
|
89
91
|
detachStream(sessionId: string): void;
|