@opencxh/domain 1.39.0 → 1.42.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=140;function i(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 I(e){const t=e.trim();return t.length<=u?t:t.slice(0,u-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 A(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?` (${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"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 g(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 f(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function _(e){return e.endpoints??[]}const T=e=>!!e.assignedUserId||!!e.assignedInboxId,D=e=>e.status==="closed",L=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,C=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function S(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}function E(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},s=t.intents.filter(a=>!n.has(a.intent)).map(a=>b(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 d(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=d(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function b(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 E(r,s))n.push({channel:r,description:s,capability:o})}return n}function M(e,t){return t.filter(n=>n.capability.intent===e)}function p(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function y(e,t){return p(e.scheme,t)}function R(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.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(c||{});const V=(e,t)=>({intent:e,...t}),h={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"};exports.CommunicationScheme=c;exports.UNSUPPORTED=h;exports.buildActivityPreview=g;exports.buildChannelIntents=O;exports.defineIntent=V;exports.disabledIntentsFromCapabilities=N;exports.filterByEndpoint=y;exports.filterByIntent=M;exports.filterByTargetScheme=p;exports.getContactEndpoints=_;exports.getShortTitle=C;exports.getUrgencyScore=L;exports.isAssigned=T;exports.isClosed=D;exports.isInteractionUnseen=S;exports.matchContactToIntents=R;exports.resolveAccountCapabilities=d;exports.resolveChannelIntents=E;exports.resolveSignature=f;exports.stripHtml=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=140;function i(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 A(e){const t=e.trim();return t.length<=u?t:t.slice(0,u-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 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?` (${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"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 g(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 f(e,t){const n=e.settings?.signatures?.[t];return!n||!n.enabled||!n.body||n.body.trim()===""?null:n}function _(e){return e.endpoints??[]}const T=e=>!!e.assignedUserId||!!e.assignedInboxId,D=e=>e.status==="closed",L=e=>({urgent:10,high:5,normal:2,low:1})[e.priority]||0,C=(e,t=30)=>e.title?.length<=t?e.title:`${e.title.substring(0,t)}...`;function S(e,t){return e.lastActivityAt?!(e.seenBy??[]).includes(t):!1}function E(e,t){const n=new Set(e.disabledIntents??[]),r=e.intentOverrides??{},s=t.intents.filter(a=>!n.has(a.intent)).map(a=>b(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 d(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=d(e,t);return Object.entries(n).filter(([,r])=>!r).map(([r])=>r)}function b(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 E(r,s))n.push({channel:r,description:s,capability:o})}return n}function M(e,t){return t.filter(n=>n.capability.intent===e)}function p(e,t){return t.filter(n=>n.capability.targetSchemes.includes(e))}function R(e,t){return p(e.scheme,t)}function y(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.VIBER="viber",e.SMS="sms",e.FAX="fax",e.TEAMS="teams",e.CALENDAR="calendar",e))(c||{});const V=(e,t)=>({intent:e,...t}),h={ok:!1,code:"UNSUPPORTED",message:"Provider does not support this op"},m="installation-id";exports.CommunicationScheme=c;exports.INSTALLATION_HEADER=m;exports.UNSUPPORTED=h;exports.buildActivityPreview=g;exports.buildChannelIntents=O;exports.defineIntent=V;exports.disabledIntentsFromCapabilities=N;exports.filterByEndpoint=R;exports.filterByIntent=M;exports.filterByTargetScheme=p;exports.getContactEndpoints=_;exports.getShortTitle=C;exports.getUrgencyScore=L;exports.isAssigned=T;exports.isClosed=D;exports.isInteractionUnseen=S;exports.matchContactToIntents=y;exports.resolveAccountCapabilities=d;exports.resolveChannelIntents=E;exports.resolveSignature=f;exports.stripHtml=i;
package/dist/index.d.ts CHANGED
@@ -36,4 +36,6 @@ export * from './platform/services';
36
36
  export * from './platform/ui';
37
37
  export * from './platform/media';
38
38
  export * from './platform/provider';
39
+ export * from './platform/push';
40
+ export * from './platform/installation';
39
41
  export * from './platform/storage';
package/dist/index.js CHANGED
@@ -105,8 +105,8 @@ const T = (e) => !!e.assignedUserId || !!e.assignedInboxId, D = (e) => e.status
105
105
  high: 5,
106
106
  normal: 2,
107
107
  low: 1
108
- })[e.priority] || 0, C = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
109
- function N(e, t) {
108
+ })[e.priority] || 0, N = (e, t = 30) => e.title?.length <= t ? e.title : `${e.title.substring(0, t)}...`;
109
+ function C(e, t) {
110
110
  return e.lastActivityAt ? !(e.seenBy ?? []).includes(t) : !1;
111
111
  }
112
112
  function d(e, t) {
@@ -165,9 +165,10 @@ function R(e, t, n) {
165
165
  return r;
166
166
  }
167
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 V = (e, t) => ({ intent: e, ...t }), P = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" };
168
+ const V = (e, t) => ({ intent: e, ...t }), P = { ok: !1, code: "UNSUPPORTED", message: "Provider does not support this op" }, $ = "installation-id";
169
169
  export {
170
170
  I as CommunicationScheme,
171
+ $ as INSTALLATION_HEADER,
171
172
  P as UNSUPPORTED,
172
173
  _ as buildActivityPreview,
173
174
  O as buildChannelIntents,
@@ -177,11 +178,11 @@ export {
177
178
  b as filterByIntent,
178
179
  A as filterByTargetScheme,
179
180
  g as getContactEndpoints,
180
- C as getShortTitle,
181
+ N as getShortTitle,
181
182
  L as getUrgencyScore,
182
183
  T as isAssigned,
183
184
  D as isClosed,
184
- N as isInteractionUnseen,
185
+ C as isInteractionUnseen,
185
186
  R as matchContactToIntents,
186
187
  c as resolveAccountCapabilities,
187
188
  d as resolveChannelIntents,
@@ -6,6 +6,7 @@ export interface InvokeOptions {
6
6
  body?: any;
7
7
  timeout?: number;
8
8
  transport?: "ws" | "http";
9
+ headers?: Record<string, string>;
9
10
  manifest?: AppManifest;
10
11
  }
11
12
  export type SSEMessage<Payload = {
@@ -0,0 +1,29 @@
1
+ export interface Installation {
2
+ id: string;
3
+ userId: string;
4
+ organizationId: string;
5
+ label: string;
6
+ userAgent: string;
7
+ platform: string;
8
+ appVersion?: string;
9
+ createdAt: number;
10
+ lastSeenAt: number;
11
+ revokedAt?: number;
12
+ }
13
+ export interface InstallationClaimInput {
14
+ userAgent: string;
15
+ platform: string;
16
+ label?: string;
17
+ appVersion?: string;
18
+ }
19
+ export interface InstallationUpdateInput {
20
+ label?: string;
21
+ }
22
+ export interface InstallationSetting<V = unknown> {
23
+ installationId: string;
24
+ key: string;
25
+ value: V;
26
+ updatedAt?: number;
27
+ }
28
+ export declare const INSTALLATION_HEADER = "installation-id";
29
+ export type PushPrefKey = `push.pref.${string}`;
@@ -0,0 +1,59 @@
1
+ export type PushTransport = "webpush" | "apns" | "apns-voip" | "fcm" | "tauri";
2
+ export type PushPlatform = "web" | "ios" | "android" | "desktop";
3
+ export interface PushSubscription {
4
+ id: string;
5
+ userId: string;
6
+ installationId: string;
7
+ transport: PushTransport;
8
+ token: string;
9
+ keys?: {
10
+ p256dh: string;
11
+ auth: string;
12
+ };
13
+ platform: PushPlatform;
14
+ appVersion: string;
15
+ providerId?: string;
16
+ createdAt: number;
17
+ lastSeenAt: number;
18
+ }
19
+ export type PushKind = "wake" | "incoming-call" | "message" | "presence" | "notification" | "custom";
20
+ export interface PushDisplay {
21
+ title: string;
22
+ body?: string;
23
+ icon?: string;
24
+ tag?: string;
25
+ actions?: {
26
+ id: string;
27
+ title: string;
28
+ }[];
29
+ url?: string;
30
+ }
31
+ export interface PushEnvelope<P = unknown> {
32
+ providerId: string;
33
+ accountId?: string;
34
+ kind: PushKind;
35
+ display?: PushDisplay;
36
+ payload: P;
37
+ ts: number;
38
+ ttl?: number;
39
+ voip?: boolean;
40
+ }
41
+ export type PushSubscribeInput = Omit<PushSubscription, "id" | "userId" | "installationId" | "createdAt" | "lastSeenAt">;
42
+ export interface PushSendRequest<P = unknown> {
43
+ to: {
44
+ userIds: string[];
45
+ } | {
46
+ userId: string;
47
+ };
48
+ installationIds?: string[];
49
+ envelope: Omit<PushEnvelope<P>, "ts">;
50
+ platforms?: PushPlatform[];
51
+ collapseKey?: string;
52
+ }
53
+ export interface PushSendResult {
54
+ delivered: number;
55
+ }
56
+ export interface IPushChannel {
57
+ readonly providerId: string;
58
+ handle(env: PushEnvelope): Promise<void>;
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.39.0",
3
+ "version": "1.42.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",