@opencxh/domain 1.18.1 → 1.19.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,6 +1,2 @@
|
|
|
1
1
|
import { Contact, ContactEndpoint } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the contact's communication endpoints, synthesising them from
|
|
4
|
-
* legacy phone/email fields when `endpoints` is not populated yet.
|
|
5
|
-
*/
|
|
6
2
|
export declare function getContactEndpoints(contact: Contact): ContactEndpoint[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommunicationScheme } from '../../platform/communication';
|
|
2
|
+
import { Contact, OwnerScope } from './types';
|
|
3
|
+
export interface ContactSearchQuery {
|
|
4
|
+
text?: string;
|
|
5
|
+
scope?: OwnerScope[];
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ContactProvider {
|
|
9
|
+
id: string;
|
|
10
|
+
searchContacts(q: ContactSearchQuery): Promise<Contact[]>;
|
|
11
|
+
resolveByEndpoint(scheme: CommunicationScheme, resource: string): Promise<Contact | null>;
|
|
12
|
+
listContacts?(scope: OwnerScope): Promise<Contact[]>;
|
|
13
|
+
}
|
|
@@ -5,17 +5,29 @@ export interface ContactEndpoint {
|
|
|
5
5
|
label?: string;
|
|
6
6
|
primary?: boolean;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export type OwnerScope = {
|
|
9
|
+
kind: "personal";
|
|
10
|
+
userId: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "team";
|
|
13
|
+
teamId: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "org";
|
|
16
|
+
organizationId: string;
|
|
17
|
+
};
|
|
18
|
+
export interface ContactSource {
|
|
19
|
+
providerId: string;
|
|
20
|
+
externalId?: string;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
}
|
|
11
23
|
export interface Contact {
|
|
12
24
|
id: string;
|
|
13
25
|
organizationId: string;
|
|
26
|
+
ownerScope: OwnerScope;
|
|
27
|
+
source: ContactSource;
|
|
14
28
|
firstName: string;
|
|
15
29
|
lastName?: string;
|
|
16
30
|
company?: string;
|
|
17
|
-
email?: string;
|
|
18
|
-
phone?: string;
|
|
19
31
|
address?: string;
|
|
20
32
|
endpoints?: ContactEndpoint[];
|
|
21
33
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){return t.endpoints??[]}const u=t=>!!t.assignedUserId||!!t.assignedInboxId,d=t=>t.status==="closed",g=t=>({urgent:10,high:5,normal:2,low:1})[t.priority]||0,p=(t,n=30)=>t.title?.length<=n?t.title:`${t.title.substring(0,n)}...`;function l(t,n){const s=new Set(t.disabledIntents??[]),i=t.intentOverrides??{},e=n.intents.filter(r=>!s.has(r.intent)).map(r=>I(r,i[r.intent]));if(!t.extraIntents||t.extraIntents.length===0)return e;const o=new Set(e.map(r=>r.intent));for(const r of t.extraIntents)o.has(r.intent)||(e.push(r),o.add(r.intent));return e}function I(t,n){return n?{intent:n.intent??t.intent,targetSchemes:n.targetSchemes??t.targetSchemes,transport:n.transport??t.transport}:t}function y(t,n){const s=[];for(const i of t){if(!i.enabled)continue;const e=n[i.providerId];if(e)for(const o of l(i,e))s.push({channel:i,description:e,capability:o})}return s}function b(t,n){return n.filter(s=>s.capability.intent===t)}function a(t,n){return n.filter(s=>s.capability.targetSchemes.includes(t))}function h(t,n){return a(t.scheme,n)}function T(t,n,s){const i=[];for(const e of t)for(const o of s)o.capability.intent===n&&o.capability.targetSchemes.includes(e.scheme)&&i.push({channelIntent:o,endpoint:e});return i}var f=(t=>(t.MAILTO="mailto",t.SIP="sip",t.TEL="tel",t.WEBHOOK="webhook",t.USERNAME="username",t.ID="id",t.CUSTOM="custom",t.URL="url",t.TELEGRAM="telegram",t.WHATSAPP="whatsapp",t.VIBER="viber",t.SMS="sms",t.FAX="fax",t.TEAMS="teams",t))(f||{});exports.CommunicationScheme=f;exports.buildChannelIntents=y;exports.filterByEndpoint=h;exports.filterByIntent=b;exports.filterByTargetScheme=a;exports.getContactEndpoints=c;exports.getShortTitle=p;exports.getUrgencyScore=g;exports.isAssigned=u;exports.isClosed=d;exports.matchContactToIntents=T;exports.resolveChannelIntents=l;
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (t.endpoints && t.endpoints.length > 0)
|
|
4
|
-
return t.endpoints;
|
|
5
|
-
const e = [];
|
|
6
|
-
return t.phone && e.push({ scheme: f.TEL, resource: t.phone, primary: !0 }), t.email && e.push({ scheme: f.MAILTO, resource: t.email, primary: !t.phone }), e;
|
|
1
|
+
function c(t) {
|
|
2
|
+
return t.endpoints ?? [];
|
|
7
3
|
}
|
|
8
|
-
const d = (t) => !!t.assignedUserId || !!t.assignedInboxId,
|
|
4
|
+
const d = (t) => !!t.assignedUserId || !!t.assignedInboxId, p = (t) => t.status === "closed", g = (t) => ({
|
|
9
5
|
urgent: 10,
|
|
10
6
|
high: 5,
|
|
11
7
|
normal: 2,
|
|
12
8
|
low: 1
|
|
13
|
-
})[t.priority] || 0,
|
|
14
|
-
function
|
|
15
|
-
const r = new Set(t.disabledIntents ?? []), i = t.intentOverrides ?? {},
|
|
16
|
-
if (!t.extraIntents || t.extraIntents.length === 0) return
|
|
17
|
-
const o = new Set(
|
|
9
|
+
})[t.priority] || 0, I = (t, n = 30) => t.title?.length <= n ? t.title : `${t.title.substring(0, n)}...`;
|
|
10
|
+
function f(t, n) {
|
|
11
|
+
const r = new Set(t.disabledIntents ?? []), i = t.intentOverrides ?? {}, e = n.intents.filter((s) => !r.has(s.intent)).map((s) => l(s, i[s.intent]));
|
|
12
|
+
if (!t.extraIntents || t.extraIntents.length === 0) return e;
|
|
13
|
+
const o = new Set(e.map((s) => s.intent));
|
|
18
14
|
for (const s of t.extraIntents)
|
|
19
|
-
o.has(s.intent) || (
|
|
20
|
-
return
|
|
15
|
+
o.has(s.intent) || (e.push(s), o.add(s.intent));
|
|
16
|
+
return e;
|
|
21
17
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
intent:
|
|
25
|
-
targetSchemes:
|
|
26
|
-
transport:
|
|
18
|
+
function l(t, n) {
|
|
19
|
+
return n ? {
|
|
20
|
+
intent: n.intent ?? t.intent,
|
|
21
|
+
targetSchemes: n.targetSchemes ?? t.targetSchemes,
|
|
22
|
+
transport: n.transport ?? t.transport
|
|
27
23
|
} : t;
|
|
28
24
|
}
|
|
29
|
-
function
|
|
25
|
+
function b(t, n) {
|
|
30
26
|
const r = [];
|
|
31
27
|
for (const i of t) {
|
|
32
28
|
if (!i.enabled) continue;
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
for (const o of
|
|
36
|
-
r.push({ channel: i, description:
|
|
29
|
+
const e = n[i.providerId];
|
|
30
|
+
if (e)
|
|
31
|
+
for (const o of f(i, e))
|
|
32
|
+
r.push({ channel: i, description: e, capability: o });
|
|
37
33
|
}
|
|
38
34
|
return r;
|
|
39
35
|
}
|
|
40
|
-
function y(t,
|
|
41
|
-
return
|
|
36
|
+
function y(t, n) {
|
|
37
|
+
return n.filter((r) => r.capability.intent === t);
|
|
42
38
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
39
|
+
function a(t, n) {
|
|
40
|
+
return n.filter((r) => r.capability.targetSchemes.includes(t));
|
|
45
41
|
}
|
|
46
|
-
function
|
|
47
|
-
return
|
|
42
|
+
function E(t, n) {
|
|
43
|
+
return a(t.scheme, n);
|
|
48
44
|
}
|
|
49
|
-
function
|
|
45
|
+
function T(t, n, r) {
|
|
50
46
|
const i = [];
|
|
51
|
-
for (const
|
|
47
|
+
for (const e of t)
|
|
52
48
|
for (const o of r)
|
|
53
|
-
o.capability.intent ===
|
|
49
|
+
o.capability.intent === n && o.capability.targetSchemes.includes(e.scheme) && i.push({ channelIntent: o, endpoint: e });
|
|
54
50
|
return i;
|
|
55
51
|
}
|
|
52
|
+
var u = /* @__PURE__ */ ((t) => (t.MAILTO = "mailto", t.SIP = "sip", t.TEL = "tel", t.WEBHOOK = "webhook", t.USERNAME = "username", t.ID = "id", t.CUSTOM = "custom", t.URL = "url", t.TELEGRAM = "telegram", t.WHATSAPP = "whatsapp", t.VIBER = "viber", t.SMS = "sms", t.FAX = "fax", t.TEAMS = "teams", t))(u || {});
|
|
56
53
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
u as CommunicationScheme,
|
|
55
|
+
b as buildChannelIntents,
|
|
56
|
+
E as filterByEndpoint,
|
|
60
57
|
y as filterByIntent,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
a as filterByTargetScheme,
|
|
59
|
+
c as getContactEndpoints,
|
|
60
|
+
I as getShortTitle,
|
|
61
|
+
g as getUrgencyScore,
|
|
65
62
|
d as isAssigned,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
p as isClosed,
|
|
64
|
+
T as matchContactToIntents,
|
|
65
|
+
f as resolveChannelIntents
|
|
69
66
|
};
|