@opencxh/domain 1.20.0 → 1.27.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.
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,55 @@
1
+ import { OwnerScope } from '../contact/types';
2
+ export type CalendarEventStatus = "confirmed" | "cancelled" | "tentative";
3
+ export type AttendeeResponse = "accepted" | "declined" | "tentative" | "none";
4
+ export interface EventAttendee {
5
+ email: string;
6
+ name?: string;
7
+ response?: AttendeeResponse;
8
+ optional?: boolean;
9
+ }
10
+ export interface EventConferencing {
11
+ provider: "teams" | "meet" | "zoom" | "other";
12
+ joinUrl: string;
13
+ conferenceId?: string;
14
+ passcode?: string;
15
+ }
16
+ export type RecurrenceFrequency = "daily" | "weekly" | "monthly" | "yearly";
17
+ /**
18
+ * RFC5545-subset. MVP: read-only — provider supplies, we display.
19
+ */
20
+ export interface RecurrenceRule {
21
+ frequency: RecurrenceFrequency;
22
+ interval?: number;
23
+ count?: number;
24
+ until?: number;
25
+ byWeekday?: ("MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU")[];
26
+ }
27
+ export interface EventReminder {
28
+ minutesBefore: number;
29
+ }
30
+ export interface CalendarEvent {
31
+ id: string;
32
+ organizationId: string;
33
+ ownerScope: OwnerScope;
34
+ title: string;
35
+ description?: string;
36
+ location?: string;
37
+ startTime: number;
38
+ endTime: number;
39
+ allDay?: boolean;
40
+ timezone?: string;
41
+ organizer?: EventAttendee;
42
+ attendees?: EventAttendee[];
43
+ /** Link to a communication Interaction (e.g. Teams meeting chat). */
44
+ interactionId?: string;
45
+ /** Channel used for external sync (provider-resolved). */
46
+ channelId?: string;
47
+ /** Provider-side IDs for dedupe (e.g. Graph event id, iCalUId). */
48
+ externalIds?: string[];
49
+ status: CalendarEventStatus;
50
+ recurrence?: RecurrenceRule;
51
+ reminders?: EventReminder[];
52
+ conferencing?: EventConferencing;
53
+ createdAt?: number;
54
+ updatedAt?: number;
55
+ }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){return t.endpoints??[]}const d=t=>!!t.assignedUserId||!!t.assignedInboxId,u=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 r=new Set(t.disabledIntents??[]),i=t.intentOverrides??{},e=n.intents.filter(s=>!r.has(s.intent)).map(s=>I(s,i[s.intent]));if(!t.extraIntents||t.extraIntents.length===0)return e;const o=new Set(e.map(s=>s.intent));for(const s of t.extraIntents)o.has(s.intent)||(e.push(s),o.add(s.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 r=[];for(const i of t){if(!i.enabled)continue;const e=n[i.providerId];if(e)for(const o of l(i,e))r.push({channel:i,description:e,capability:o})}return r}function b(t,n){return n.filter(r=>r.capability.intent===t)}function a(t,n){return n.filter(r=>r.capability.targetSchemes.includes(t))}function h(t,n){return a(t.scheme,n)}function E(t,n,r){const i=[];for(const e of t)for(const o of r)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.CALENDAR="calendar",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=d;exports.isClosed=u;exports.matchContactToIntents=E;exports.resolveChannelIntents=l;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './entities/ai-profile';
8
8
  export * from './entities/channel';
9
9
  export * from './entities/communication';
10
10
  export * from './entities/contact';
11
+ export * from './entities/calendar-event';
11
12
  export * from './entities/inbox';
12
13
  export * from './entities/interaction';
13
14
  export * from './entities/note';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- function c(t) {
1
+ function d(t) {
2
2
  return t.endpoints ?? [];
3
3
  }
4
- const d = (t) => !!t.assignedUserId || !!t.assignedInboxId, p = (t) => t.status === "closed", g = (t) => ({
4
+ const p = (t) => !!t.assignedUserId || !!t.assignedInboxId, c = (t) => t.status === "closed", g = (t) => ({
5
5
  urgent: 10,
6
6
  high: 5,
7
7
  normal: 2,
@@ -33,34 +33,34 @@ function b(t, n) {
33
33
  }
34
34
  return r;
35
35
  }
36
- function y(t, n) {
36
+ function E(t, n) {
37
37
  return n.filter((r) => r.capability.intent === t);
38
38
  }
39
39
  function a(t, n) {
40
40
  return n.filter((r) => r.capability.targetSchemes.includes(t));
41
41
  }
42
- function E(t, n) {
42
+ function y(t, n) {
43
43
  return a(t.scheme, n);
44
44
  }
45
- function T(t, n, r) {
45
+ function A(t, n, r) {
46
46
  const i = [];
47
47
  for (const e of t)
48
48
  for (const o of r)
49
49
  o.capability.intent === n && o.capability.targetSchemes.includes(e.scheme) && i.push({ channelIntent: o, endpoint: e });
50
50
  return i;
51
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 || {});
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.CALENDAR = "calendar", t))(u || {});
53
53
  export {
54
54
  u as CommunicationScheme,
55
55
  b as buildChannelIntents,
56
- E as filterByEndpoint,
57
- y as filterByIntent,
56
+ y as filterByEndpoint,
57
+ E as filterByIntent,
58
58
  a as filterByTargetScheme,
59
- c as getContactEndpoints,
59
+ d as getContactEndpoints,
60
60
  I as getShortTitle,
61
61
  g as getUrgencyScore,
62
- d as isAssigned,
63
- p as isClosed,
64
- T as matchContactToIntents,
62
+ p as isAssigned,
63
+ c as isClosed,
64
+ A as matchContactToIntents,
65
65
  f as resolveChannelIntents
66
66
  };
@@ -6,7 +6,7 @@ import { CommunicationScheme, IntentCapability, ProviderDescription, Uri } from
6
6
  * default composers). Intent itself is an open string — providers may
7
7
  * declare anything. Unknown intents render as generic actions.
8
8
  */
9
- export type CommunicationIntent = "call" | "mail" | "message" | "video";
9
+ export type CommunicationIntent = "call" | "mail" | "message" | "video" | "calendar";
10
10
  /**
11
11
  * A channel's effective intent — the resolved IntentCapability for this
12
12
  * specific channel, ready for routing/UI decisions.
@@ -55,7 +55,8 @@ export declare enum CommunicationScheme {
55
55
  VIBER = "viber",
56
56
  SMS = "sms",
57
57
  FAX = "fax",
58
- TEAMS = "teams"
58
+ TEAMS = "teams",
59
+ CALENDAR = "calendar"
59
60
  }
60
61
  /**
61
62
  * Account selector for `transport: session` intents. Tells the frontend
@@ -63,10 +64,14 @@ export declare enum CommunicationScheme {
63
64
  * - `protocol` only: pick the first registered account with this protocol
64
65
  * (acceptable when there is one UA per provider per tenant)
65
66
  * - `accountId` set: pin to a specific account (multi-trunk / multi-tenant)
67
+ * - `matcherId` set: defer to a client-registered matcher fn that picks the
68
+ * account based on dynamic context (channel, accounts). Lookup by string
69
+ * keeps the wire format JSON; fn lives in the runtime registry.
66
70
  */
67
71
  export interface AccountSelector {
68
72
  protocol: string;
69
73
  accountId?: string;
74
+ matcherId?: string;
70
75
  }
71
76
  export type TransportConfig = {
72
77
  kind: "compose";
@@ -85,6 +90,15 @@ export type TransportConfig = {
85
90
  canvas: `${string}:${string}`;
86
91
  actionTray?: `${string}:${string}`;
87
92
  };
93
+ } | {
94
+ /**
95
+ * CRUD-on-external-resource transport. Used for entities with a
96
+ * lifecycle (create/update/cancel) on the provider side — e.g.
97
+ * calendar events, tasks. Provider exposes a handler-set instead
98
+ * of a single send. Distinct from `compose` (fire-and-forget) and
99
+ * `session` (stateful realtime).
100
+ */
101
+ kind: "schedule";
88
102
  };
89
103
  /**
90
104
  * One user-facing intent a provider/channel can perform on a target.
@@ -69,6 +69,40 @@ export interface FindActivityByExternalProviderIdPayload {
69
69
  activityType: string;
70
70
  interactionId?: string;
71
71
  }
72
+ /**
73
+ * Calendar/schedule transport payloads. Providers that declare an intent
74
+ * with `transport: { kind: "schedule" }` implement `/provider/schedule/*`
75
+ * routes. Communication-server dispatches CRUD on CalendarEvents to the
76
+ * corresponding provider via these payloads.
77
+ */
78
+ export type ScheduleResponse = "accepted" | "declined" | "tentative";
79
+ export interface SchedulePayload {
80
+ channelId: string;
81
+ /** Local CalendarEvent without storage-managed fields. */
82
+ event: any;
83
+ }
84
+ export interface ScheduleUpdatePayload {
85
+ channelId: string;
86
+ externalId: string;
87
+ patch: any;
88
+ }
89
+ export interface ScheduleCancelPayload {
90
+ channelId: string;
91
+ externalId: string;
92
+ comment?: string;
93
+ }
94
+ export interface ScheduleRespondPayload {
95
+ channelId: string;
96
+ externalId: string;
97
+ response: ScheduleResponse;
98
+ comment?: string;
99
+ sendResponse?: boolean;
100
+ }
101
+ export interface ScheduleResult {
102
+ externalId?: string;
103
+ /** Provider-side echo for caller persistence (e.g. Graph event id). */
104
+ providerData?: Record<string, unknown>;
105
+ }
72
106
  export interface FileUploadPayload {
73
107
  file: Uint8Array;
74
108
  filename: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.20.0",
3
+ "version": "1.27.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",