@opencxh/domain 1.1.4

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.
Files changed (47) hide show
  1. package/dist/entities/activity/index.d.ts +1 -0
  2. package/dist/entities/activity/types.d.ts +212 -0
  3. package/dist/entities/ai-account/index.d.ts +1 -0
  4. package/dist/entities/ai-account/types.d.ts +6 -0
  5. package/dist/entities/ai-message/index.d.ts +1 -0
  6. package/dist/entities/ai-message/types.d.ts +35 -0
  7. package/dist/entities/ai-profile/index.d.ts +1 -0
  8. package/dist/entities/ai-profile/types.d.ts +15 -0
  9. package/dist/entities/channel/index.d.ts +1 -0
  10. package/dist/entities/channel/types.d.ts +17 -0
  11. package/dist/entities/communication/index.d.ts +1 -0
  12. package/dist/entities/communication/types.d.ts +84 -0
  13. package/dist/entities/contact/index.d.ts +1 -0
  14. package/dist/entities/contact/types.d.ts +15 -0
  15. package/dist/entities/inbox/index.d.ts +1 -0
  16. package/dist/entities/inbox/types.d.ts +9 -0
  17. package/dist/entities/interaction/index.d.ts +2 -0
  18. package/dist/entities/interaction/logic.d.ts +18 -0
  19. package/dist/entities/interaction/types.d.ts +36 -0
  20. package/dist/entities/note/index.d.ts +1 -0
  21. package/dist/entities/note/types.d.ts +14 -0
  22. package/dist/entities/organization/index.d.ts +1 -0
  23. package/dist/entities/organization/types.d.ts +11 -0
  24. package/dist/entities/transcript/index.d.ts +1 -0
  25. package/dist/entities/transcript/types.d.ts +10 -0
  26. package/dist/entities/user/index.d.ts +1 -0
  27. package/dist/entities/user/types.d.ts +6 -0
  28. package/dist/index.cjs +1 -0
  29. package/dist/index.d.ts +28 -0
  30. package/dist/index.js +14 -0
  31. package/dist/platform/api.d.ts +19 -0
  32. package/dist/platform/common.d.ts +7 -0
  33. package/dist/platform/communication.d.ts +75 -0
  34. package/dist/platform/federated.d.ts +10 -0
  35. package/dist/platform/intents.d.ts +10 -0
  36. package/dist/platform/kernel.d.ts +17 -0
  37. package/dist/platform/lifecycle.d.ts +13 -0
  38. package/dist/platform/localization.d.ts +7 -0
  39. package/dist/platform/manifest.d.ts +157 -0
  40. package/dist/platform/menu.d.ts +22 -0
  41. package/dist/platform/reactive.d.ts +13 -0
  42. package/dist/platform/routing.d.ts +16 -0
  43. package/dist/platform/sdk.d.ts +46 -0
  44. package/dist/platform/service-registry.d.ts +14 -0
  45. package/dist/platform/services.d.ts +42 -0
  46. package/dist/platform/ui.d.ts +29 -0
  47. package/package.json +23 -0
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,212 @@
1
+ import { AIMessage } from '../ai-message/types';
2
+ import { Transcript } from '../transcript/types';
3
+
4
+ export type CallStatus = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
5
+ export type CallDirection = "inbound" | "outbound";
6
+ export type CallType = "audio" | "video" | "data" | "screen-share";
7
+ export type ActivityType = "VOICE_CALL_STARTED" | "VOICE_CALL_ANSWERED" | "VOICE_CALL_HOLD" | "VOICE_CALL_UNHOLD" | "VOICE_CALL_ENDED" | "VOICE_CALL_MISSED" | "VOICE_CALL_VOICEMAIL" | "VIDEO_CALL_STARTED" | "VIDEO_CALL_ANSWERED" | "VIDEO_CALL_HOLD" | "VIDEO_CALL_UNHOLD" | "VIDEO_CALL_ENDED" | "VIDEO_CALL_MISSED" | "EMAIL_RECEIVED" | "EMAIL_SENT" | "CHAT_MESSAGE_SENT" | "CHAT_MESSAGE_RECEIVED" | "AI_MESSAGE_ADDED" | "MEETING_SCHEDULED" | "MEETING_STARTED" | "MEETING_ENDED" | "MEETING_PARTICIPANT_JOINED" | "MEETING_PARTICIPANT_LEFT" | "COMMENT_ADDED" | "FILE_UPLOADED" | "INTERACTION_CREATED" | "INTERACTION_STATUS_CHANGED" | "INTERACTION_ASSIGNED" | "VOICE_CALL_FAILED" | "VIDEO_CALL_FAILED" | "TRANSCRIPT_ADDED";
8
+ export interface BaseActivity {
9
+ id: string;
10
+ interactionId: string;
11
+ organizationId: string;
12
+ createdAt: number;
13
+ provider: {
14
+ id?: string;
15
+ name?: string;
16
+ externalId?: string;
17
+ };
18
+ author: {
19
+ type: "user" | "contact" | "system";
20
+ id?: string;
21
+ name: string;
22
+ };
23
+ direction: "inbound" | "outbound" | "internal" | "none";
24
+ }
25
+ export type VoiceCallPayload = {
26
+ from: string;
27
+ to: string;
28
+ callId: string;
29
+ type: CallType;
30
+ direction: CallDirection;
31
+ status: CallStatus;
32
+ accountId: string;
33
+ };
34
+ export type VoiceCallEndedPayload = VoiceCallPayload & {
35
+ duration: number;
36
+ recordingUrl?: string;
37
+ quality?: "good" | "average" | "poor";
38
+ };
39
+ export type VoiceCallVoicemailPayload = VoiceCallPayload & {
40
+ voicemailUrl: string;
41
+ transcription?: string;
42
+ duration: number;
43
+ };
44
+ export type VideoCallPayload = VoiceCallPayload & {
45
+ type: "video";
46
+ callId: string;
47
+ status: CallStatus;
48
+ direction: CallDirection;
49
+ accountId: string;
50
+ };
51
+ export type VideoCallEndedPayload = VideoCallPayload & {
52
+ duration: number;
53
+ recordingUrl?: string;
54
+ quality?: "good" | "average" | "poor";
55
+ };
56
+ export type EmailPayload = {
57
+ from: {
58
+ email: string;
59
+ name?: string;
60
+ };
61
+ to: {
62
+ email: string;
63
+ name?: string;
64
+ }[];
65
+ cc?: {
66
+ email: string;
67
+ name?: string;
68
+ }[];
69
+ subject: string;
70
+ body: string;
71
+ bodySnippet?: string;
72
+ attachmentCount: number;
73
+ emailId: string;
74
+ };
75
+ export type ChatMessagePayload = {
76
+ text: string;
77
+ conversationId: string;
78
+ };
79
+ export type TranscriptAddedPayload = {
80
+ transcript: Transcript;
81
+ };
82
+ export type MeetingPayload = {
83
+ title: string;
84
+ meetingId: string;
85
+ participants: {
86
+ id?: string;
87
+ name: string;
88
+ }[];
89
+ };
90
+ export type MeetingEndedPayload = MeetingPayload & {
91
+ duration: number;
92
+ recordingUrl?: string;
93
+ };
94
+ export type CommentAddedPayload = {
95
+ text: string;
96
+ mentions?: string[];
97
+ };
98
+ export type FileUploadedPayload = {
99
+ fileName: string;
100
+ fileUrl: string;
101
+ fileType: string;
102
+ size: number;
103
+ };
104
+ export type InteractionStatusChangedPayload = {
105
+ fromStatus: "open" | "pending" | "closed";
106
+ toStatus: "open" | "pending" | "closed";
107
+ };
108
+ export type InteractionAssignedPayload = {
109
+ userId: string;
110
+ teamId?: string;
111
+ };
112
+ export type MeetingParticipantPayload = {
113
+ name: string;
114
+ id?: string;
115
+ };
116
+ export type AIMessageAddedPayload = {
117
+ message: AIMessage;
118
+ };
119
+ export type Activity = (BaseActivity & {
120
+ type: "VOICE_CALL_STARTED";
121
+ payload: VoiceCallPayload;
122
+ }) | (BaseActivity & {
123
+ type: "VOICE_CALL_ANSWERED";
124
+ payload: VoiceCallPayload;
125
+ }) | (BaseActivity & {
126
+ type: "VOICE_CALL_HOLD";
127
+ payload: VoiceCallPayload;
128
+ }) | (BaseActivity & {
129
+ type: "VOICE_CALL_UNHOLD";
130
+ payload: VoiceCallPayload;
131
+ }) | (BaseActivity & {
132
+ type: "VOICE_CALL_ENDED";
133
+ payload: VoiceCallEndedPayload;
134
+ }) | (BaseActivity & {
135
+ type: "VOICE_CALL_MISSED";
136
+ payload: VoiceCallPayload;
137
+ }) | (BaseActivity & {
138
+ type: "VOICE_CALL_FAILED";
139
+ payload: VoiceCallPayload;
140
+ }) | (BaseActivity & {
141
+ type: "VOICE_CALL_VOICEMAIL";
142
+ payload: VoiceCallVoicemailPayload;
143
+ }) | (BaseActivity & {
144
+ type: "VIDEO_CALL_STARTED";
145
+ payload: VideoCallPayload;
146
+ }) | (BaseActivity & {
147
+ type: "VIDEO_CALL_ANSWERED";
148
+ payload: VideoCallPayload;
149
+ }) | (BaseActivity & {
150
+ type: "VIDEO_CALL_HOLD";
151
+ payload: VideoCallPayload;
152
+ }) | (BaseActivity & {
153
+ type: "VIDEO_CALL_UNHOLD";
154
+ payload: VideoCallPayload;
155
+ }) | (BaseActivity & {
156
+ type: "VIDEO_CALL_ENDED";
157
+ payload: VideoCallEndedPayload;
158
+ }) | (BaseActivity & {
159
+ type: "VIDEO_CALL_FAILED";
160
+ payload: VideoCallPayload;
161
+ }) | (BaseActivity & {
162
+ type: "VIDEO_CALL_MISSED";
163
+ payload: VideoCallPayload;
164
+ }) | (BaseActivity & {
165
+ type: "EMAIL_RECEIVED";
166
+ payload: EmailPayload;
167
+ }) | (BaseActivity & {
168
+ type: "EMAIL_SENT";
169
+ payload: EmailPayload;
170
+ }) | (BaseActivity & {
171
+ type: "CHAT_MESSAGE_SENT";
172
+ payload: ChatMessagePayload;
173
+ }) | (BaseActivity & {
174
+ type: "CHAT_MESSAGE_RECEIVED";
175
+ payload: ChatMessagePayload;
176
+ }) | (BaseActivity & {
177
+ type: "TRANSCRIPT_ADDED";
178
+ payload: TranscriptAddedPayload;
179
+ }) | (BaseActivity & {
180
+ type: "AI_MESSAGE_ADDED";
181
+ payload: AIMessageAddedPayload;
182
+ }) | (BaseActivity & {
183
+ type: "MEETING_SCHEDULED";
184
+ payload: MeetingPayload;
185
+ }) | (BaseActivity & {
186
+ type: "MEETING_STARTED";
187
+ payload: MeetingPayload;
188
+ }) | (BaseActivity & {
189
+ type: "MEETING_ENDED";
190
+ payload: MeetingEndedPayload;
191
+ }) | (BaseActivity & {
192
+ type: "MEETING_PARTICIPANT_JOINED";
193
+ payload: MeetingParticipantPayload;
194
+ }) | (BaseActivity & {
195
+ type: "MEETING_PARTICIPANT_LEFT";
196
+ payload: MeetingParticipantPayload;
197
+ }) | (BaseActivity & {
198
+ type: "COMMENT_ADDED";
199
+ payload: CommentAddedPayload;
200
+ }) | (BaseActivity & {
201
+ type: "FILE_UPLOADED";
202
+ payload: FileUploadedPayload;
203
+ }) | (BaseActivity & {
204
+ type: "INTERACTION_CREATED";
205
+ payload: {};
206
+ }) | (BaseActivity & {
207
+ type: "INTERACTION_STATUS_CHANGED";
208
+ payload: InteractionStatusChangedPayload;
209
+ }) | (BaseActivity & {
210
+ type: "INTERACTION_ASSIGNED";
211
+ payload: InteractionAssignedPayload;
212
+ });
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,6 @@
1
+ export interface AiAccount {
2
+ id: string;
3
+ organizationId: string;
4
+ vendor: string;
5
+ apiKey: string;
6
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,35 @@
1
+ export interface AIMessageInput {
2
+ text: string;
3
+ type: "text";
4
+ }
5
+ export interface AIMessageOutput {
6
+ text: string;
7
+ type: "text";
8
+ }
9
+ export interface AIMessage {
10
+ id: string;
11
+ organizationId: string;
12
+ interactionId: string;
13
+ sender: "user" | "assistant" | "system";
14
+ timestamp: number;
15
+ input: AIMessageInput;
16
+ output: AIMessageOutput;
17
+ accountId?: string;
18
+ model?: string;
19
+ externalId?: string;
20
+ }
21
+ export interface AIMessageAskPayload {
22
+ interactionId: string;
23
+ input: AIMessageInput;
24
+ model: string;
25
+ accountId: string;
26
+ previousExternalId?: string;
27
+ providerConfig?: Record<string, any>;
28
+ instructions?: string;
29
+ systemPrompt?: string;
30
+ context?: Record<string, any>;
31
+ }
32
+ export interface AIMessageAskResponse {
33
+ output: AIMessageOutput;
34
+ externalId: string;
35
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,15 @@
1
+ export interface PredefinedPrompt {
2
+ name: string;
3
+ prompt: string;
4
+ }
5
+ export interface AIProfile<T extends Record<string, any> = Record<string, any>> {
6
+ id: string;
7
+ organizationId: string;
8
+ name: string;
9
+ description?: string;
10
+ accountId: string;
11
+ model: string;
12
+ providerConfig?: T;
13
+ systemPrompt: string;
14
+ predefinedPrompts?: PredefinedPrompt[];
15
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,17 @@
1
+ import { Uri } from '../communication/types';
2
+
3
+ export interface Channel {
4
+ id: string;
5
+ organizationId: string;
6
+ providerId: string;
7
+ name: string;
8
+ description?: string;
9
+ icon?: string;
10
+ color?: string;
11
+ addressUri: Uri;
12
+ inboxId?: string;
13
+ ownerId: string;
14
+ settings: Record<string, any>;
15
+ enabled: boolean;
16
+ verified: boolean;
17
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,84 @@
1
+ export type CommunicationProtocol = "sip" | "webrtc" | "custom";
2
+ export type SessionType = "audio" | "video" | "data" | "screen-share";
3
+ export type SessionDirection = "inbound" | "outbound";
4
+ export type SessionState = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
5
+ export type AccountStatus = "registering" | "registered" | "unregistered" | "failed";
6
+ export type AuthType = "password" | "token" | "certificate" | "custom";
7
+ export interface Participant {
8
+ id: string;
9
+ user?: string;
10
+ displayName?: string;
11
+ avatar?: string;
12
+ status?: "connected" | "ringing" | "held" | "disconnected";
13
+ isMuted?: boolean;
14
+ isSpeaking?: boolean;
15
+ metadata?: Record<string, any>;
16
+ isLocal?: boolean;
17
+ }
18
+ export interface Account<TProviderData = any> {
19
+ id: string;
20
+ displayName: string;
21
+ uri: string;
22
+ status: AccountStatus;
23
+ providerId: string;
24
+ providerData: TProviderData;
25
+ organizationId: string;
26
+ userId: string;
27
+ domain?: string;
28
+ registeredAt?: Date;
29
+ metadata: Record<string, any>;
30
+ }
31
+ export interface AccountConfig<TProviderConfig = any> {
32
+ id?: string;
33
+ displayName: string;
34
+ uri: string;
35
+ domain?: string;
36
+ auth: {
37
+ type: AuthType;
38
+ credentials: Record<string, any>;
39
+ };
40
+ endpoints?: string[];
41
+ providerConfig?: TProviderConfig;
42
+ metadata?: Record<string, any>;
43
+ targetFormatter?: (target: string, account: Account) => string;
44
+ rtcConfiguration?: any;
45
+ }
46
+ export interface SessionOptions {
47
+ id?: string;
48
+ type: SessionType;
49
+ target: string;
50
+ accountId: string;
51
+ iceServers?: RTCIceServer[];
52
+ mediaConstraints?: MediaStreamConstraints;
53
+ metadata?: Record<string, any>;
54
+ }
55
+ export interface Transcription {
56
+ startTime: number;
57
+ endTime: number;
58
+ text: string;
59
+ speaker?: string;
60
+ }
61
+ export interface SessionMetadata {
62
+ [custom: string]: unknown;
63
+ }
64
+ export interface Session<TProviderData = any> {
65
+ id: string;
66
+ type: SessionType;
67
+ direction: SessionDirection;
68
+ state: SessionState;
69
+ participants: Participant[];
70
+ collaborators: string[];
71
+ accountId: string;
72
+ organizationId: string;
73
+ userId: string;
74
+ providerId: string;
75
+ providerData: TProviderData;
76
+ startTime: Date;
77
+ endTime?: Date;
78
+ metadata: SessionMetadata;
79
+ }
80
+ export type CommunicationScheme = "sip" | "tel" | "mailto" | "chat" | "internal" | "webhook" | "username" | "id" | "custom" | "url";
81
+ export interface Uri {
82
+ scheme: CommunicationScheme;
83
+ resource: string;
84
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Data model for a single Contact.
3
+ */
4
+ export interface Contact {
5
+ id: string;
6
+ organizationId: string;
7
+ firstName: string;
8
+ lastName?: string;
9
+ company?: string;
10
+ email?: string;
11
+ phone?: string;
12
+ address?: string;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,9 @@
1
+ export interface Inbox {
2
+ id: string;
3
+ organizationId: string;
4
+ displayName: string;
5
+ description: string;
6
+ members: string[];
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './logic';
@@ -0,0 +1,18 @@
1
+ import { Interaction } from './types';
2
+
3
+ /**
4
+ * Checks if the interaction is currently assigned to a user or an inbox.
5
+ */
6
+ export declare const isAssigned: (interaction: Interaction) => boolean;
7
+ /**
8
+ * Checks if the interaction is closed.
9
+ */
10
+ export declare const isClosed: (interaction: Interaction) => boolean;
11
+ /**
12
+ * Gets a numerical urgency score based on priority.
13
+ */
14
+ export declare const getUrgencyScore: (interaction: Interaction) => number;
15
+ /**
16
+ * Returns a shortened version of the interaction title.
17
+ */
18
+ export declare const getShortTitle: (interaction: Interaction, maxLength?: number) => string;
@@ -0,0 +1,36 @@
1
+ import { Uri } from '../communication/types';
2
+
3
+ export interface InteractionSource {
4
+ activityId?: string;
5
+ activityType?: string;
6
+ initiator: "user" | "contact" | "system";
7
+ initiatorId?: string;
8
+ provider: {
9
+ id?: string;
10
+ name?: string;
11
+ externalId?: string;
12
+ };
13
+ }
14
+ export interface InteractionLink {
15
+ url?: string;
16
+ providerId?: string;
17
+ externalId?: string;
18
+ title: string;
19
+ }
20
+ export interface Interaction {
21
+ id: string;
22
+ organizationId: string;
23
+ assignedInboxId?: string;
24
+ channelId?: string;
25
+ title: string;
26
+ status: "open" | "pending" | "closed" | "snoozed";
27
+ priority: "urgent" | "high" | "normal" | "low";
28
+ remoteParty: Uri;
29
+ source?: InteractionSource;
30
+ tags: string[];
31
+ links: InteractionLink[];
32
+ collaborators: string[];
33
+ assignedUserId?: string;
34
+ createdAt: number;
35
+ updatedAt: number;
36
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Data model for a single Note.
3
+ */
4
+ export interface Note {
5
+ id: string;
6
+ organizationId: string;
7
+ interactionId: string;
8
+ serviceName: string;
9
+ authorId: string;
10
+ authorDisplayName: string;
11
+ content: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ export interface Organization {
2
+ id: string;
3
+ name: string;
4
+ displayName: string;
5
+ enabledApps: string[];
6
+ roles: string[];
7
+ scopes: string[];
8
+ domain: string;
9
+ defaultApp?: string;
10
+ permissions?: string[];
11
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,10 @@
1
+ export interface Transcript {
2
+ id: string;
3
+ organizationId: string;
4
+ interactionId: string;
5
+ serviceName: string;
6
+ text: string;
7
+ speaker?: string;
8
+ startTime?: number;
9
+ endTime?: number;
10
+ }
@@ -0,0 +1 @@
1
+ export * from './types';
@@ -0,0 +1,6 @@
1
+ export interface User {
2
+ id: string;
3
+ name: string;
4
+ email: string;
5
+ availableOrganizations: string[];
6
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=s=>!!s.assignedUserId||!!s.assignedInboxId,l=s=>s.status==="closed",g=s=>({urgent:10,high:5,normal:2,low:1})[s.priority]||0,d=(s,r=30)=>s.title.length<=r?s.title:`${s.title.substring(0,r)}...`;var t=(s=>(s.MAILTO="mailto",s.SIP="sip",s.TEL="tel",s.WEBHOOK="webhook",s.USERNAME="username",s.ID="id",s.CUSTOM="custom",s.URL="url",s.TELEGRAM="telegram",s.WHATSAPP="whatsapp",s.VIBER="viber",s.SMS="sms",s.FAX="fax",s))(t||{});exports.CommunicationScheme=t;exports.getShortTitle=d;exports.getUrgencyScore=g;exports.isAssigned=e;exports.isClosed=l;
@@ -0,0 +1,28 @@
1
+ export * from './entities/activity';
2
+ export * from './entities/ai-account';
3
+ export * from './entities/ai-message';
4
+ export * from './entities/ai-profile';
5
+ export * from './entities/channel';
6
+ export * from './entities/contact';
7
+ export * from './entities/inbox';
8
+ export * from './entities/interaction';
9
+ export * from './entities/note';
10
+ export * from './entities/organization';
11
+ export * from './entities/transcript';
12
+ export * from './entities/user';
13
+ export * from './platform/api';
14
+ export * from './platform/common';
15
+ export * from './platform/communication';
16
+ export * from './platform/federated';
17
+ export * from './platform/intents';
18
+ export * from './platform/kernel';
19
+ export * from './platform/lifecycle';
20
+ export * from './platform/localization';
21
+ export * from './platform/manifest';
22
+ export * from './platform/menu';
23
+ export * from './platform/reactive';
24
+ export * from './platform/routing';
25
+ export * from './platform/sdk';
26
+ export * from './platform/service-registry';
27
+ export * from './platform/services';
28
+ export * from './platform/ui';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ const l = (s) => !!s.assignedUserId || !!s.assignedInboxId, g = (s) => s.status === "closed", d = (s) => ({
2
+ urgent: 10,
3
+ high: 5,
4
+ normal: 2,
5
+ low: 1
6
+ })[s.priority] || 0, A = (s, r = 30) => s.title.length <= r ? s.title : `${s.title.substring(0, r)}...`;
7
+ var t = /* @__PURE__ */ ((s) => (s.MAILTO = "mailto", s.SIP = "sip", s.TEL = "tel", s.WEBHOOK = "webhook", s.USERNAME = "username", s.ID = "id", s.CUSTOM = "custom", s.URL = "url", s.TELEGRAM = "telegram", s.WHATSAPP = "whatsapp", s.VIBER = "viber", s.SMS = "sms", s.FAX = "fax", s))(t || {});
8
+ export {
9
+ t as CommunicationScheme,
10
+ A as getShortTitle,
11
+ d as getUrgencyScore,
12
+ l as isAssigned,
13
+ g as isClosed
14
+ };
@@ -0,0 +1,19 @@
1
+ import { AppManifest } from './manifest';
2
+
3
+ export interface InvokeOptions {
4
+ action: string;
5
+ params?: Record<string, any>;
6
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
7
+ body?: any;
8
+ timeout?: number;
9
+ transport?: "ws" | "http";
10
+ manifest?: AppManifest;
11
+ }
12
+ export type SSEMessage<Payload = {
13
+ event: string;
14
+ payload: any;
15
+ }> = {
16
+ tenant: string;
17
+ app: string;
18
+ payload: Payload;
19
+ };
@@ -0,0 +1,7 @@
1
+ export interface IconDefinition {
2
+ type: "emoji" | "resource" | "iconName";
3
+ content: string;
4
+ className?: string;
5
+ fill?: string;
6
+ color?: string;
7
+ }
@@ -0,0 +1,75 @@
1
+ import { Uri } from '../entities/communication/types';
2
+
3
+ export type SessionState = 'idle' | 'ringing' | 'connecting' | 'connected' | 'on_hold' | 'ended' | 'failed';
4
+ export interface Session {
5
+ id: string;
6
+ accountId: string;
7
+ providerId: string;
8
+ direction: 'inbound' | 'outbound';
9
+ remoteIdentity: string;
10
+ state: SessionState;
11
+ startTime?: number;
12
+ hasVideo: boolean;
13
+ isMuted: boolean;
14
+ ui: {
15
+ canvas: `${string}:${string}`;
16
+ actionTray?: `${string}:${string}`;
17
+ };
18
+ }
19
+ export interface CommsAccount<T = any> {
20
+ id: string;
21
+ providerId: string;
22
+ label: string;
23
+ protocol: string;
24
+ organizationId: string;
25
+ userId: string;
26
+ config: T;
27
+ status: 'registered' | 'unregistered' | 'error';
28
+ }
29
+ export interface ITransportProvider {
30
+ readonly id: string;
31
+ subscribeSessions(callback: (sessions: Session[]) => void): () => void;
32
+ subscribeAccounts(callback: (accounts: CommsAccount[]) => void): () => void;
33
+ subscribeStreams(callback: (data: {
34
+ sessionId: string;
35
+ stream: MediaStream;
36
+ }) => void): () => void;
37
+ createSession(target: string, accountId: string): Promise<void>;
38
+ hangupSession(sessionId: string): Promise<void>;
39
+ registerAccount(orgId: string, userId: string, config: any): Promise<CommsAccount>;
40
+ unregisterAccount(accountId: string): Promise<void>;
41
+ setOutgoingStream(sessionId: string, stream: MediaStream | null): Promise<void>;
42
+ }
43
+ export interface ComposePayload {
44
+ body: string;
45
+ channelId: string;
46
+ recipientUri: Uri;
47
+ subject?: string;
48
+ interactionId?: string;
49
+ }
50
+ export interface Capability {
51
+ scheme: string;
52
+ key: string;
53
+ value: boolean;
54
+ }
55
+ export declare enum CommunicationScheme {
56
+ MAILTO = "mailto",
57
+ SIP = "sip",
58
+ TEL = "tel",
59
+ WEBHOOK = "webhook",
60
+ USERNAME = "username",
61
+ ID = "id",
62
+ CUSTOM = "custom",
63
+ URL = "url",
64
+ TELEGRAM = "telegram",
65
+ WHATSAPP = "whatsapp",
66
+ VIBER = "viber",
67
+ SMS = "sms",
68
+ FAX = "fax"
69
+ }
70
+ export interface ProviderDescription {
71
+ id?: string;
72
+ displayName: string;
73
+ capabilities: Capability[];
74
+ supportedSchemes: CommunicationScheme[];
75
+ }
@@ -0,0 +1,10 @@
1
+ export interface MountOptions {
2
+ container: HTMLElement;
3
+ props?: Record<string, any>;
4
+ }
5
+ export type MountFn = (options: MountOptions) => void;
6
+ export type UnmountFn = (container: HTMLElement) => void;
7
+ export interface FederatedResource {
8
+ mount: MountFn;
9
+ unmount?: UnmountFn;
10
+ }
@@ -0,0 +1,10 @@
1
+ export interface IntentRequest {
2
+ protocol: string;
3
+ value: string;
4
+ metadata?: Record<string, any>;
5
+ }
6
+ export interface IntentHandler {
7
+ id: string;
8
+ protocols: string[];
9
+ handle: (request: IntentRequest) => Promise<boolean | string>;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { Organization } from '../entities/organization/types';
2
+ import { User } from '../entities/user/types';
3
+
4
+ export interface PlatformContext {
5
+ user: User | null;
6
+ activeOrg: Organization | null;
7
+ env: 'production' | 'staging' | 'dev';
8
+ locale: string;
9
+ isAuthenticated: boolean;
10
+ isOrgSelected: boolean;
11
+ }
12
+ export interface PlatformConfig {
13
+ httpUrl: string;
14
+ wsUrl: string;
15
+ registryUrl: string;
16
+ shellVersion: string;
17
+ }
@@ -0,0 +1,13 @@
1
+ export interface AppLifecycle {
2
+ /** * On-load: Registreer services, menu-items en andere metadata.
3
+ * Wordt éénmalig uitgevoerd bij het laden van de JS.
4
+ */
5
+ setup: () => void;
6
+ /** * On-mount: Render de UI in de meegeleverde container.
7
+ * Wordt uitgevoerd wanneer de gebruiker naar de app navigeert.
8
+ */
9
+ mount: (container: HTMLElement, props?: any) => void;
10
+ /** * On-unmount: Ruim eventuele listeners of DOM-elementen op.
11
+ */
12
+ unmount: (container: HTMLElement) => void;
13
+ }
@@ -0,0 +1,7 @@
1
+ export type LocaleTranslations = Record<string, string>;
2
+ export type Translations = Record<string, LocaleTranslations>;
3
+ type Prev = [never, 0, 1, 2, 3, 4, 5, ...0[]];
4
+ export type Paths<T, D extends number = 5> = [D] extends [never] ? never : T extends object ? {
5
+ [K in keyof T]-?: K extends string | number ? T[K] extends object ? `${K}` | `${K}.${Paths<T[K], Prev[D]>}` : `${K}` : never;
6
+ }[keyof T] : "";
7
+ export {};
@@ -0,0 +1,157 @@
1
+ import { IconDefinition } from './common';
2
+ import { Translations } from './localization';
3
+ import { MenuItem } from './menu';
4
+ import { RouteDefinition } from './routing';
5
+
6
+ export interface ActionDefinition {
7
+ displayName: string;
8
+ description: string;
9
+ }
10
+ export interface Modules {
11
+ sidebar?: ModuleDefinition;
12
+ tools?: ModuleDefinition[];
13
+ assets?: ModuleDefinition[];
14
+ services?: ModuleDefinition[];
15
+ composers?: ModuleDefinition[];
16
+ activities?: ModuleDefinition[];
17
+ modals?: ModuleDefinition[];
18
+ }
19
+ export interface ModuleDefinition {
20
+ id?: string;
21
+ displayName: string;
22
+ description?: string;
23
+ icon?: IconDefinition;
24
+ resource?: string;
25
+ alwaysVisible?: boolean;
26
+ visibility?: {
27
+ paths?: string[];
28
+ permissions?: string[];
29
+ };
30
+ actions?: {
31
+ [key: string]: ActionDefinition[];
32
+ };
33
+ }
34
+ export type ResourceDefinition<T = any> = T;
35
+ /**
36
+ * The AppManifest is the central contract between an application and the shell.
37
+ * It defines the app's identity, its components, its UI contributions,
38
+ * and most importantly, its security sandbox via the permissions block.
39
+ */
40
+ export interface AppManifest<TSDK = any> {
41
+ /**
42
+ * The namespace of the application.
43
+ */
44
+ name: string;
45
+ /**
46
+ * The human-readable name of the application.
47
+ */
48
+ displayName: string;
49
+ /**
50
+ * Version of the application, following semantic versioning.
51
+ */
52
+ version: string;
53
+ /**
54
+ * The framework of the application.
55
+ */
56
+ framework?: 'react' | 'svelte' | 'other';
57
+ /**
58
+ * Optional short description of the application.
59
+ */
60
+ shortDescription?: string;
61
+ /**
62
+ * A brief description of what the application does.
63
+ */
64
+ description?: string;
65
+ /**
66
+ * Optional icon for the application.
67
+ */
68
+ icon?: IconDefinition;
69
+ /**
70
+ * Optional default route for the application.
71
+ */
72
+ defaultRoute?: string;
73
+ /**
74
+ * Optional priority for the application.
75
+ */
76
+ priority?: number;
77
+ /**
78
+ * Optional author of the application.
79
+ */
80
+ author?: string;
81
+ /**
82
+ * Optional categories for the application.
83
+ */
84
+ categories?: string[];
85
+ /**
86
+ * Optional tags for the application.
87
+ */
88
+ tags?: string[];
89
+ /**
90
+ * Optional support URL for the application.
91
+ */
92
+ supportUrl?: string;
93
+ /**
94
+ * Optional documentation URL for the application.
95
+ */
96
+ visibility?: 'public' | 'private';
97
+ /**
98
+ * Defines the security permissions for this app. The SDK will deny any
99
+ * action not explicitly granted here, following the principle of least privilege.
100
+ */
101
+ permissions?: {
102
+ /**
103
+ * Glob patterns for storage keys the app can access.
104
+ * @example ['settings', 'drafts_*', 'user-preferences']
105
+ */
106
+ storage?: string[];
107
+ /**
108
+ * Names of services the app is allowed to execute commands on.
109
+ * @example ['transcription-service', 'ai-summary']
110
+ */
111
+ services?: string[];
112
+ /**
113
+ * Names of remote functions (remotes) the app is allowed to invoke.
114
+ * @example ['fetch-customer-data']
115
+ */
116
+ remotes?: string[];
117
+ /**
118
+ * Glob patterns for store slices the app can create/access.
119
+ * @example ['session-state', 'ui-slice']
120
+ */
121
+ store?: string[];
122
+ /**
123
+ * Defines which communication actions the app is allowed to perform.
124
+ * @example ['session:create', 'session:read', 'account:read']
125
+ */
126
+ communication?: string[];
127
+ };
128
+ /**
129
+ * All resources that are being exported by this app.
130
+ */
131
+ resources?: Record<string, ResourceDefinition>;
132
+ /**
133
+ * All modules that are being used by this app.
134
+ */
135
+ modules?: Modules;
136
+ /**
137
+ * Routes this app contributes to the shell's router.
138
+ * Paths will be automatically prefixed with `/apps/{appName}`.
139
+ */
140
+ routes?: RouteDefinition[];
141
+ /** An array of menu items provided by this application. */
142
+ menu?: MenuItem[];
143
+ /** An array of translations provided by this application. */
144
+ translations?: Translations;
145
+ /**
146
+ * A function that will be called when the application is initialized.
147
+ */
148
+ initialize?: () => void;
149
+ }
150
+ export interface RemoteApp {
151
+ app: string;
152
+ version: string;
153
+ }
154
+ export interface RemoteAppRegistryResponse {
155
+ url: string;
156
+ apps: RemoteApp[];
157
+ }
@@ -0,0 +1,22 @@
1
+ import { IconDefinition } from './common';
2
+
3
+ export interface MenuItem {
4
+ /** The label of the menu item. */
5
+ label: string;
6
+ /** The description of the menu item. */
7
+ description?: string;
8
+ /** The path of the menu item. */
9
+ path: string;
10
+ /** The icon of the menu item. */
11
+ icon?: IconDefinition;
12
+ /** The group of the menu item. */
13
+ group?: string;
14
+ /** The required capabilities of the menu item. */
15
+ requiredCapabilities?: string[];
16
+ }
17
+ export interface NamespacedMenuItem extends MenuItem {
18
+ /** The namespace of the menu item. */
19
+ namespace: string;
20
+ /** The absolute path of the menu item. */
21
+ absolutePath: string;
22
+ }
@@ -0,0 +1,13 @@
1
+ export interface Subscriber<T> {
2
+ next: (value?: T) => void;
3
+ error?: (err: any) => void;
4
+ complete?: () => void;
5
+ }
6
+ export interface Observable<T> {
7
+ subscribe(subscriber: Subscriber<T>): () => void;
8
+ }
9
+ export interface Result<T> {
10
+ success: boolean;
11
+ value?: T;
12
+ error?: any;
13
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Defines a route handled by the application.
3
+ */
4
+ export interface RouteDefinition {
5
+ /** The path for the route (e.g., "/settings"). */
6
+ path: string;
7
+ /** The resource to render for this route. */
8
+ resource: string;
9
+ /** If true, the path must match exactly. */
10
+ exact?: boolean;
11
+ }
12
+ export interface NamespacedRouteDefinition extends RouteDefinition {
13
+ appName: string;
14
+ /** The full, namespaced path, e.g., /apps/my-app/settings */
15
+ absolutePath: string;
16
+ }
@@ -0,0 +1,46 @@
1
+ import { Observable } from 'rxjs';
2
+ import { InvokeOptions, SSEMessage } from './api';
3
+ import { PlatformConfig, PlatformContext } from './kernel';
4
+ import { ServiceCallOptions, ServiceMap } from './services';
5
+ import { ExtensionConfig, ToastConfig } from './ui';
6
+
7
+ type ServiceKey<S extends ServiceMap> = keyof S;
8
+ export type ParamsOf<S extends ServiceMap, K extends ServiceKey<S>> = S[K]['params'];
9
+ export type PayloadOf<S extends ServiceMap, K extends ServiceKey<S>> = S[K]['payload'];
10
+ export type ResponseOf<S extends ServiceMap, K extends ServiceKey<S>> = S[K]['response'];
11
+ export type SSEHandlerOf<S extends ServiceMap, K extends ServiceKey<S>> = (payload: SSEMessage<PayloadOf<S, K>>) => Promise<void>;
12
+ export interface InternalSDK<LocalServices extends ServiceMap = {}, TranslationKeys extends string = string, ModalKeys extends string = string, ExtensionKeys extends string = string> {
13
+ readonly context: PlatformContext;
14
+ readonly config: PlatformConfig;
15
+ readonly services: {
16
+ execute<K extends ServiceKey<LocalServices>>(key: K, options: ServiceCallOptions<ParamsOf<LocalServices, K>, PayloadOf<LocalServices, K>>): Promise<ResponseOf<LocalServices, K>>;
17
+ observe<K extends ServiceKey<LocalServices>>(key: K, options: ServiceCallOptions<ParamsOf<LocalServices, K>, PayloadOf<LocalServices, K>>): Observable<ResponseOf<LocalServices, K>>;
18
+ };
19
+ readonly http: {
20
+ invoke<R = any>(options: InvokeOptions): Promise<R>;
21
+ };
22
+ readonly router: {
23
+ navigate(path: string, options?: any): void;
24
+ currentPath: string;
25
+ };
26
+ readonly resources: {
27
+ get<T = any>(appName: string, resourceKey: string): Promise<T>;
28
+ };
29
+ readonly localization: {
30
+ t(key: TranslationKeys, params?: Record<string, any>): string;
31
+ };
32
+ readonly ui: {
33
+ modals: {
34
+ open(key: ModalKeys, props?: any): void;
35
+ close(key: ModalKeys): void;
36
+ };
37
+ toasts: {
38
+ show(config: ToastConfig): void;
39
+ close(id: string): void;
40
+ };
41
+ extensions: {
42
+ getForSlot(slot: string): Observable<ExtensionConfig[]>;
43
+ };
44
+ };
45
+ }
46
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Observable } from './reactive';
2
+
3
+ export interface Command<TParams = any, TResponse = any> {
4
+ params: TParams;
5
+ response: TResponse;
6
+ }
7
+ export interface Query<TParams = any, TResponse = any> {
8
+ params: TParams;
9
+ response: TResponse;
10
+ }
11
+ export interface ServiceRegistry<TCommands extends Record<string, Command> = any, TQueries extends Record<string, Query> = any> {
12
+ execute<K extends keyof TCommands>(name: K, params: TCommands[K]["params"]): Promise<TCommands[K]["response"]>;
13
+ observe<K extends keyof TQueries>(name: K, params: TQueries[K]["params"]): Observable<TQueries[K]["response"]>;
14
+ }
@@ -0,0 +1,42 @@
1
+ export interface ServiceDefinition<TParams = any, TPayload = any, TResponse = any> {
2
+ params?: TParams;
3
+ payload?: TPayload;
4
+ response?: TResponse;
5
+ }
6
+ export type ServiceMap = {
7
+ [key: string]: ServiceDefinition;
8
+ };
9
+ export interface GlobalServices extends ServiceMap {
10
+ 'platform:router:push': {
11
+ params: {
12
+ path: string;
13
+ options?: any;
14
+ };
15
+ response: void;
16
+ };
17
+ 'platform:auth:expired': {
18
+ params: {};
19
+ response: void;
20
+ };
21
+ 'platform:ui:toast': {
22
+ params: {
23
+ message: string;
24
+ type: 'success' | 'error';
25
+ };
26
+ response: void;
27
+ };
28
+ }
29
+ export interface ServiceInvocation<T = any> {
30
+ appId: string;
31
+ data: T;
32
+ timestamp: number;
33
+ }
34
+ export type ServiceHandlerFn<P = any, T = any, R = any> = (options: ServiceCallOptions<P, T>) => Promise<R>;
35
+ export type ServiceHandlerMetadata<P = any, T = any, R = any> = {
36
+ appId: string;
37
+ fn: ServiceHandlerFn<P, T, R>;
38
+ };
39
+ export type ServiceCallOptions<P, T> = {
40
+ params?: P;
41
+ payload?: T;
42
+ };
@@ -0,0 +1,29 @@
1
+ export interface ModalConfig {
2
+ id: string;
3
+ displayName: string;
4
+ resource: string;
5
+ size?: 'sm' | 'md' | 'lg' | 'xl';
6
+ position?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'corner' | 'sidebar';
7
+ }
8
+ export interface ToastConfig {
9
+ id: string;
10
+ title?: string;
11
+ type: 'success' | 'error' | 'warning' | 'info';
12
+ message?: string;
13
+ duration?: number;
14
+ actions?: {
15
+ label: string;
16
+ onClick: () => void;
17
+ }[];
18
+ }
19
+ export interface ExtensionConfig {
20
+ id: string;
21
+ slot: string;
22
+ displayName: string;
23
+ resource: string;
24
+ icon?: string;
25
+ priority?: number;
26
+ conditions?: {
27
+ [key: string]: any;
28
+ };
29
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opencxh/domain",
3
+ "version": "1.1.4",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "vite build",
13
+ "typecheck": "tsc --noEmit"
14
+ },
15
+ "peerDependencies": {
16
+ "rxjs": "^7.8.2"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.2.2",
20
+ "vite": "^6.3.5",
21
+ "vite-plugin-dts": "^3.9.1"
22
+ }
23
+ }