@opencxh/domain 1.1.4 → 1.2.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,26 +1,31 @@
1
- import { AIMessage } from '../ai-message/types';
1
+ import { AIMessageInput, AIMessageOutput } from '../ai-message/types';
2
2
  import { Transcript } from '../transcript/types';
3
-
4
3
  export type CallStatus = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
5
4
  export type CallDirection = "inbound" | "outbound";
6
5
  export type CallType = "audio" | "video" | "data" | "screen-share";
7
6
  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";
7
+ export interface Attachment {
8
+ id: string;
9
+ filename: string;
10
+ mimeType: string;
11
+ size?: number;
12
+ url?: string;
13
+ }
8
14
  export interface BaseActivity {
9
15
  id: string;
10
16
  interactionId: string;
11
17
  organizationId: string;
12
- createdAt: number;
13
- provider: {
14
- id?: string;
15
- name?: string;
16
- externalId?: string;
17
- };
18
+ channelId?: string;
19
+ providerId: string;
18
20
  author: {
19
21
  type: "user" | "contact" | "system";
20
22
  id?: string;
21
23
  name: string;
22
24
  };
23
25
  direction: "inbound" | "outbound" | "internal" | "none";
26
+ externalIds?: string[];
27
+ attachments?: Attachment[];
28
+ createdAt?: Date;
24
29
  }
25
30
  export type VoiceCallPayload = {
26
31
  from: string;
@@ -69,8 +74,8 @@ export type EmailPayload = {
69
74
  subject: string;
70
75
  body: string;
71
76
  bodySnippet?: string;
72
- attachmentCount: number;
73
77
  emailId: string;
78
+ threadId?: string;
74
79
  };
75
80
  export type ChatMessagePayload = {
76
81
  text: string;
@@ -114,7 +119,11 @@ export type MeetingParticipantPayload = {
114
119
  id?: string;
115
120
  };
116
121
  export type AIMessageAddedPayload = {
117
- message: AIMessage;
122
+ input: AIMessageInput;
123
+ output?: AIMessageOutput;
124
+ externalId?: string;
125
+ accountId?: string;
126
+ model?: string;
118
127
  };
119
128
  export type Activity = (BaseActivity & {
120
129
  type: "VOICE_CALL_STARTED";
@@ -1,5 +1,4 @@
1
- import { Uri } from '../communication/types';
2
-
1
+ import { Uri } from '../../platform/communication';
3
2
  export interface Channel {
4
3
  id: string;
5
4
  organizationId: string;
@@ -1 +1,2 @@
1
1
  export * from './types';
2
+ export * from './message-template';
@@ -0,0 +1,22 @@
1
+ export interface MessageTemplate {
2
+ id: string;
3
+ name: string;
4
+ body: string;
5
+ subject?: string;
6
+ folderId?: string;
7
+ isPrivate: boolean;
8
+ inboxIds?: string[];
9
+ organizationId: string;
10
+ createdBy: string;
11
+ createdAt?: number;
12
+ updatedAt?: number;
13
+ }
14
+ export interface MessageTemplateFolder {
15
+ id: string;
16
+ name: string;
17
+ parentFolderId?: string;
18
+ organizationId: string;
19
+ createdBy: string;
20
+ createdAt?: number;
21
+ updatedAt?: number;
22
+ }
@@ -1,7 +1,6 @@
1
1
  export type CommunicationProtocol = "sip" | "webrtc" | "custom";
2
2
  export type SessionType = "audio" | "video" | "data" | "screen-share";
3
3
  export type SessionDirection = "inbound" | "outbound";
4
- export type SessionState = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
5
4
  export type AccountStatus = "registering" | "registered" | "unregistered" | "failed";
6
5
  export type AuthType = "password" | "token" | "certificate" | "custom";
7
6
  export interface Participant {
@@ -61,24 +60,3 @@ export interface Transcription {
61
60
  export interface SessionMetadata {
62
61
  [custom: string]: unknown;
63
62
  }
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
- }
@@ -10,6 +10,4 @@ export interface Contact {
10
10
  email?: string;
11
11
  phone?: string;
12
12
  address?: string;
13
- createdAt: Date;
14
- updatedAt: Date;
15
13
  }
@@ -4,6 +4,4 @@ export interface Inbox {
4
4
  displayName: string;
5
5
  description: string;
6
6
  members: string[];
7
- createdAt: string;
8
- updatedAt: string;
9
7
  }
@@ -1,5 +1,4 @@
1
1
  import { Interaction } from './types';
2
-
3
2
  /**
4
3
  * Checks if the interaction is currently assigned to a user or an inbox.
5
4
  */
@@ -1,5 +1,4 @@
1
- import { Uri } from '../communication/types';
2
-
1
+ import { Uri } from '../../platform/communication';
3
2
  export interface InteractionSource {
4
3
  activityId?: string;
5
4
  activityType?: string;
@@ -29,8 +28,9 @@ export interface Interaction {
29
28
  source?: InteractionSource;
30
29
  tags: string[];
31
30
  links: InteractionLink[];
31
+ externalIds?: string[];
32
32
  collaborators: string[];
33
33
  assignedUserId?: string;
34
- createdAt: number;
35
- updatedAt: number;
34
+ createdAt?: number;
35
+ updatedAt?: number;
36
36
  }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './entities/ai-account';
3
3
  export * from './entities/ai-message';
4
4
  export * from './entities/ai-profile';
5
5
  export * from './entities/channel';
6
+ export * from './entities/communication';
6
7
  export * from './entities/contact';
7
8
  export * from './entities/inbox';
8
9
  export * from './entities/interaction';
@@ -26,3 +27,6 @@ export * from './platform/sdk';
26
27
  export * from './platform/service-registry';
27
28
  export * from './platform/services';
28
29
  export * from './platform/ui';
30
+ export * from './platform/media';
31
+ export * from './platform/provider';
32
+ export * from './platform/storage';
@@ -1,5 +1,4 @@
1
1
  import { AppManifest } from './manifest';
2
-
3
2
  export interface InvokeOptions {
4
3
  action: string;
5
4
  params?: Record<string, any>;
@@ -17,3 +16,15 @@ export type SSEMessage<Payload = {
17
16
  app: string;
18
17
  payload: Payload;
19
18
  };
19
+ export interface ApiResponse<T> {
20
+ data: T;
21
+ error?: Error;
22
+ meta?: {
23
+ pagination?: PaginationMetadata;
24
+ };
25
+ }
26
+ export interface PaginationMetadata {
27
+ total: number;
28
+ page: number;
29
+ limit: number;
30
+ }
@@ -1,5 +1,3 @@
1
- import { Uri } from '../entities/communication/types';
2
-
3
1
  export type SessionState = 'idle' | 'ringing' | 'connecting' | 'connected' | 'on_hold' | 'ended' | 'failed';
4
2
  export interface Session {
5
3
  id: string;
@@ -11,6 +9,7 @@ export interface Session {
11
9
  startTime?: number;
12
10
  hasVideo: boolean;
13
11
  isMuted: boolean;
12
+ actions: SessionAction[];
14
13
  ui: {
15
14
  canvas: `${string}:${string}`;
16
15
  actionTray?: `${string}:${string}`;
@@ -39,13 +38,7 @@ export interface ITransportProvider {
39
38
  registerAccount(orgId: string, userId: string, config: any): Promise<CommsAccount>;
40
39
  unregisterAccount(accountId: string): Promise<void>;
41
40
  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;
41
+ handleAction(sessionId: string, actionId: string, ...args: any[]): void;
49
42
  }
50
43
  export interface Capability {
51
44
  scheme: string;
@@ -73,3 +66,22 @@ export interface ProviderDescription {
73
66
  capabilities: Capability[];
74
67
  supportedSchemes: CommunicationScheme[];
75
68
  }
69
+ export interface Uri {
70
+ scheme: CommunicationScheme;
71
+ resource: string;
72
+ }
73
+ export interface SessionAction {
74
+ id: string;
75
+ label: string;
76
+ icon: string;
77
+ isEnabled: boolean;
78
+ isToggle?: boolean;
79
+ isActive?: boolean;
80
+ onClick?: () => void;
81
+ }
82
+ export interface RemoteStreamEvent {
83
+ sessionId: string;
84
+ streamId: string;
85
+ stream: MediaStream | null;
86
+ label?: string;
87
+ }
@@ -1,6 +1,5 @@
1
1
  import { Organization } from '../entities/organization/types';
2
2
  import { User } from '../entities/user/types';
3
-
4
3
  export interface PlatformContext {
5
4
  user: User | null;
6
5
  activeOrg: Organization | null;
@@ -2,7 +2,6 @@ import { IconDefinition } from './common';
2
2
  import { Translations } from './localization';
3
3
  import { MenuItem } from './menu';
4
4
  import { RouteDefinition } from './routing';
5
-
6
5
  export interface ActionDefinition {
7
6
  displayName: string;
8
7
  description: string;
@@ -0,0 +1,6 @@
1
+ export interface AudioChunk {
2
+ sessionId: string;
3
+ buffer: Float32Array;
4
+ sampleRate: number;
5
+ avgRMS?: number;
6
+ }
@@ -1,5 +1,4 @@
1
1
  import { IconDefinition } from './common';
2
-
3
2
  export interface MenuItem {
4
3
  /** The label of the menu item. */
5
4
  label: string;
@@ -0,0 +1,120 @@
1
+ import { Interaction } from '../entities/interaction';
2
+ import { Uri } from './communication';
3
+ export interface ProviderTranscribeRequest {
4
+ file: Float32Array;
5
+ filename: string;
6
+ mimeType: string;
7
+ accountId?: string;
8
+ }
9
+ export interface ProviderTranscribeResponse {
10
+ transcript: string;
11
+ }
12
+ export interface ComposePayload {
13
+ interactionId?: string;
14
+ body: string;
15
+ channelId: string;
16
+ channelUri?: Uri;
17
+ recipientUri: Uri;
18
+ subject?: string;
19
+ }
20
+ export interface ComposeResponse {
21
+ messageId: string;
22
+ type: string;
23
+ payload: any;
24
+ }
25
+ export interface UpsertByExternalProviderIdPayload {
26
+ providerId: string;
27
+ externalIds: string[];
28
+ interaction: Interaction;
29
+ }
30
+ export interface StorageSettings {
31
+ providerId: string;
32
+ providerAccountId?: string;
33
+ path?: string;
34
+ }
35
+ export interface SttSettings {
36
+ providerId: string;
37
+ providerAccountId?: string;
38
+ }
39
+ export interface TtsSettings {
40
+ providerId: string;
41
+ providerAccountId?: string;
42
+ }
43
+ export interface LlmSettings {
44
+ providerId: string;
45
+ providerAccountId?: string;
46
+ }
47
+ export interface FindByAddressPayload {
48
+ addressUri: {
49
+ scheme: string;
50
+ resource: string;
51
+ };
52
+ providerId: string;
53
+ }
54
+ export interface FindActivityByExternalProviderIdPayload {
55
+ providerId: string;
56
+ externalId: string;
57
+ activityType: string;
58
+ interactionId?: string;
59
+ }
60
+ export interface FileUploadPayload {
61
+ file: Uint8Array;
62
+ filename: string;
63
+ mimeType: string;
64
+ accountId?: string;
65
+ path?: string;
66
+ }
67
+ export interface FileUploadResponse {
68
+ id: string;
69
+ url: string;
70
+ }
71
+ export interface FileGetPayload {
72
+ accountId?: string;
73
+ filename: string;
74
+ path?: string;
75
+ }
76
+ export interface FileGetResponse {
77
+ file: Uint8Array;
78
+ }
79
+ export interface FileDeletePayload {
80
+ accountId?: string;
81
+ filename: string;
82
+ path?: string;
83
+ }
84
+ export interface FileDeleteResponse {
85
+ success: boolean;
86
+ }
87
+ export interface FileListPayload {
88
+ accountId?: string;
89
+ path?: string;
90
+ }
91
+ export interface File {
92
+ name: string;
93
+ size: number;
94
+ lastModified: number;
95
+ type: string;
96
+ }
97
+ export interface FileListResponse {
98
+ files: File[];
99
+ }
100
+ export interface FolderCreatePayload {
101
+ accountId?: string;
102
+ name: string;
103
+ path?: string;
104
+ }
105
+ export interface FolderCreateResponse {
106
+ success: boolean;
107
+ url: string;
108
+ }
109
+ export interface ListFilesPayload {
110
+ mimeType?: string;
111
+ name?: string;
112
+ mountId?: string;
113
+ path?: string;
114
+ }
115
+ export interface DownloadAttachmentPayload {
116
+ attachmentId: string;
117
+ accountId?: string;
118
+ path?: string;
119
+ id?: string;
120
+ }
@@ -1,9 +1,10 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { InvokeOptions, SSEMessage } from './api';
3
+ import { CommsAccount, Session } from './communication';
3
4
  import { PlatformConfig, PlatformContext } from './kernel';
5
+ import { AudioChunk } from './media';
4
6
  import { ServiceCallOptions, ServiceMap } from './services';
5
7
  import { ExtensionConfig, ToastConfig } from './ui';
6
-
7
8
  type ServiceKey<S extends ServiceMap> = keyof S;
8
9
  export type ParamsOf<S extends ServiceMap, K extends ServiceKey<S>> = S[K]['params'];
9
10
  export type PayloadOf<S extends ServiceMap, K extends ServiceKey<S>> = S[K]['payload'];
@@ -21,7 +22,8 @@ export interface InternalSDK<LocalServices extends ServiceMap = {}, TranslationK
21
22
  };
22
23
  readonly router: {
23
24
  navigate(path: string, options?: any): void;
24
- currentPath: string;
25
+ currentPath(): string;
26
+ path$: Observable<string>;
25
27
  };
26
28
  readonly resources: {
27
29
  get<T = any>(appName: string, resourceKey: string): Promise<T>;
@@ -42,5 +44,26 @@ export interface InternalSDK<LocalServices extends ServiceMap = {}, TranslationK
42
44
  getForSlot(slot: string): Observable<ExtensionConfig[]>;
43
45
  };
44
46
  };
47
+ readonly communication: {
48
+ sessions$: Observable<Session[]>;
49
+ accounts$: Observable<CommsAccount[]>;
50
+ activeSession$: Observable<Session | null>;
51
+ createSession(target: string, accountId: string): Promise<void>;
52
+ hangupSession(sessionId: string): Promise<void>;
53
+ interceptStream(sessionId: string, callback: (stream: MediaStream) => void): Promise<() => void>;
54
+ setActiveSession(sessionId: string): Promise<void>;
55
+ registerAccount(organizationId: string, userId: string, providerId: string, config: any): Promise<CommsAccount>;
56
+ handleSessionAction(sessionId: string, actionId: string, ...args: any[]): Promise<void>;
57
+ };
58
+ readonly media: {
59
+ localStream$: Observable<MediaStream | null>;
60
+ audioChunks$: Observable<AudioChunk>;
61
+ emitAudioChunk(chunk: AudioChunk): void;
62
+ setInputDevice(deviceId: string): Promise<void>;
63
+ toggleMute(mute?: boolean): void;
64
+ attachProviderStream(sessionId: string, stream: MediaStream): void;
65
+ detachStream(sessionId: string): void;
66
+ setAudioOutput(deviceId: string): Promise<void>;
67
+ };
45
68
  }
46
69
  export {};
@@ -1,5 +1,4 @@
1
1
  import { Observable } from './reactive';
2
-
3
2
  export interface Command<TParams = any, TResponse = any> {
4
3
  params: TParams;
5
4
  response: TResponse;
@@ -0,0 +1,33 @@
1
+ export interface VirtualMount {
2
+ id: string;
3
+ name: string;
4
+ providerId: string;
5
+ basePath: string;
6
+ policyId: string;
7
+ metadata?: Record<string, any>;
8
+ }
9
+ export interface FilePointer {
10
+ id: string;
11
+ mountId: string;
12
+ name: string;
13
+ type: 'file' | 'folder';
14
+ path: string;
15
+ providerKey: string;
16
+ mimeType: string;
17
+ size: number;
18
+ ownerId: string;
19
+ createdAt?: number;
20
+ tags?: string[];
21
+ }
22
+ export type FileAction = 'file:Read' | 'file:Write' | 'file:Delete' | 'file:List' | 'file:Share';
23
+ export interface FilePolicyStatement {
24
+ effect: 'Allow' | 'Deny';
25
+ principal: string[];
26
+ action: FileAction[];
27
+ resource: string[];
28
+ }
29
+ export interface FilePolicy {
30
+ id: string;
31
+ name: string;
32
+ statements: FilePolicyStatement[];
33
+ }
@@ -1,9 +1,13 @@
1
+ import { Activity } from '../entities/activity/types';
2
+ import { Interaction } from '../entities/interaction/types';
1
3
  export interface ModalConfig {
2
4
  id: string;
3
5
  displayName: string;
4
6
  resource: string;
5
7
  size?: 'sm' | 'md' | 'lg' | 'xl';
6
8
  position?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'corner' | 'sidebar';
9
+ props?: Record<string, any>;
10
+ hideHeader?: boolean;
7
11
  }
8
12
  export interface ToastConfig {
9
13
  id: string;
@@ -26,4 +30,13 @@ export interface ExtensionConfig {
26
30
  conditions?: {
27
31
  [key: string]: any;
28
32
  };
33
+ handler?: (...args: any[]) => void;
34
+ }
35
+ export interface ComposerComponentContext {
36
+ interaction?: Interaction;
37
+ activities?: Activity[];
38
+ selectedActivityId?: string;
39
+ setSelectedActivityId: (activityId: string) => void;
40
+ initialComposerText?: string;
41
+ setInitialComposerText: (initialComposerText: string) => void;
29
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "typescript": "^5.2.2",
20
- "vite": "^6.3.5",
21
- "vite-plugin-dts": "^3.9.1"
20
+ "vite": "7.1.7",
21
+ "vite-plugin-dts": "^4.5.4"
22
22
  }
23
23
  }