@mptransformation/omisdk 0.1.1 → 0.1.2
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/README.md +98 -0
- package/dist/omisdk.es.js +1 -1
- package/dist/omisdk.es.js.map +1 -1
- package/dist/omisdk.iife.js +1 -1
- package/dist/omisdk.iife.js.map +1 -1
- package/dist/omisdk.umd.js +1 -1
- package/dist/omisdk.umd.js.map +1 -1
- package/dist/types/index.d.ts +310 -0
- package/package.json +5 -4
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @mptransformation/omisdk
|
|
3
|
+
* For use with ESLint in ReactJS projects
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare module "@mptransformation/omisdk" {
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for the SDK
|
|
9
|
+
*/
|
|
10
|
+
export interface SDKOptions {
|
|
11
|
+
/** Target element ID where the SDK will be mounted */
|
|
12
|
+
targetElementId?: string;
|
|
13
|
+
/** Display mode for the SDK: 'none' (headless) or 'bubble' (UI visible) */
|
|
14
|
+
mode?: SDKMode;
|
|
15
|
+
/** Custom theme for the SDK */
|
|
16
|
+
theme?: SDKTheme;
|
|
17
|
+
/** Socket URL for real-time communication */
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
/** Debug mode flag */
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* SDK display modes
|
|
25
|
+
*/
|
|
26
|
+
export type SDKMode = "none" | "bubble";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Theme options for customizing the SDK appearance
|
|
30
|
+
*/
|
|
31
|
+
export interface SDKTheme {
|
|
32
|
+
/** Primary color */
|
|
33
|
+
primaryColor?: string;
|
|
34
|
+
/** Secondary color */
|
|
35
|
+
secondaryColor?: string;
|
|
36
|
+
/** Text color */
|
|
37
|
+
textColor?: string;
|
|
38
|
+
/** Background color */
|
|
39
|
+
backgroundColor?: string;
|
|
40
|
+
/** Font family */
|
|
41
|
+
fontFamily?: string;
|
|
42
|
+
/** Border radius for elements */
|
|
43
|
+
borderRadius?: string;
|
|
44
|
+
/** Bubble position (for bubble mode) */
|
|
45
|
+
bubblePosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
46
|
+
/** Custom CSS classes */
|
|
47
|
+
customClasses?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Action event data
|
|
52
|
+
*/
|
|
53
|
+
export interface SDKAction {
|
|
54
|
+
/** Type of action */
|
|
55
|
+
type: string;
|
|
56
|
+
/** Payload data for the action */
|
|
57
|
+
payload?: any;
|
|
58
|
+
/** Timestamp when the action occurred */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Socket event data
|
|
64
|
+
*/
|
|
65
|
+
export interface SocketEvent {
|
|
66
|
+
/** Event name */
|
|
67
|
+
name: string;
|
|
68
|
+
/** Event data */
|
|
69
|
+
data?: any;
|
|
70
|
+
/** Timestamp when the event occurred */
|
|
71
|
+
timestamp: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Socket connection states
|
|
76
|
+
*/
|
|
77
|
+
export enum SocketConnectionState {
|
|
78
|
+
DISCONNECTED = "disconnected",
|
|
79
|
+
CONNECTING = "connecting",
|
|
80
|
+
CONNECTED = "connected",
|
|
81
|
+
RECONNECTING = "reconnecting",
|
|
82
|
+
RECONNECTION_FAILED = "reconnection_failed",
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Socket options for configuration
|
|
87
|
+
*/
|
|
88
|
+
export interface SocketOptions {
|
|
89
|
+
/** Whether to enable reconnection */
|
|
90
|
+
reconnection?: boolean;
|
|
91
|
+
/** Maximum number of reconnection attempts */
|
|
92
|
+
reconnectionAttempts?: number;
|
|
93
|
+
/** Delay between reconnection attempts in milliseconds */
|
|
94
|
+
reconnectionDelay?: number;
|
|
95
|
+
/** Connection timeout in milliseconds */
|
|
96
|
+
timeout?: number;
|
|
97
|
+
/** Whether to connect automatically on initialization */
|
|
98
|
+
autoConnect?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Event emitter interface
|
|
103
|
+
*/
|
|
104
|
+
export interface EventEmitter {
|
|
105
|
+
/** Subscribe to an event */
|
|
106
|
+
on(eventName: string, callback: (data: any) => void): void;
|
|
107
|
+
/** Unsubscribe from an event */
|
|
108
|
+
off(eventName: string, callback: (data: any) => void): void;
|
|
109
|
+
/** Emit an event */
|
|
110
|
+
emit(eventName: string, data: any): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface LoginRequest {
|
|
114
|
+
tenantId: number;
|
|
115
|
+
username: string;
|
|
116
|
+
password: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface LoginSSORequest {
|
|
120
|
+
ssoToken: string;
|
|
121
|
+
organization: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SdkResponse {
|
|
125
|
+
success: boolean;
|
|
126
|
+
message: string;
|
|
127
|
+
data?: any;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface CallOptions {
|
|
131
|
+
did?: string;
|
|
132
|
+
enableVideo?: boolean;
|
|
133
|
+
remoteVideoId?: string;
|
|
134
|
+
localVideoId?: string;
|
|
135
|
+
extraVariables?: Record<string, string>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface SdkEvent {
|
|
139
|
+
name: string;
|
|
140
|
+
type?: any;
|
|
141
|
+
timestamp: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export enum CallEventType {
|
|
145
|
+
CALL_INCOMING = "call_incoming",
|
|
146
|
+
CALL_OUTGOING = "call_outgoing",
|
|
147
|
+
CALL_HANGUP = "call_hangup",
|
|
148
|
+
CALL_ANSWERED = "call_answered",
|
|
149
|
+
CALL_REJECTED = "call_rejected",
|
|
150
|
+
CALL_HOLD = "call_hold",
|
|
151
|
+
CALL_UNHOLD = "call_unhold",
|
|
152
|
+
CALL_MUTE = "call_mute",
|
|
153
|
+
CALL_UNMUTE = "call_unmute",
|
|
154
|
+
CALL_TRANSFER = "call_transfer",
|
|
155
|
+
CALL_STATUS_CHANGE = "call_status_change",
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface CallEvent extends SdkEvent {
|
|
159
|
+
type: CallEventType;
|
|
160
|
+
senderId: string;
|
|
161
|
+
applicationId: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export enum AgentStatusEventType {
|
|
165
|
+
AGENT_STATUS_CHANGE = "agent_status_change",
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface AgentStatusEvent extends SdkEvent {
|
|
169
|
+
type: AgentStatusEventType;
|
|
170
|
+
status: string;
|
|
171
|
+
agentId: string;
|
|
172
|
+
tenantId: string;
|
|
173
|
+
changeTime: number;
|
|
174
|
+
reasonCode: string;
|
|
175
|
+
reasonCodeId: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export enum AppEventType {
|
|
179
|
+
READY = "ready",
|
|
180
|
+
DISPLAY_CHANGED = "display_changed",
|
|
181
|
+
BUBBLE_HIDDEN = "bubble_hidden",
|
|
182
|
+
BUBBLE_SHOWN = "bubble_shown",
|
|
183
|
+
LOGGED_IN = "logged_in",
|
|
184
|
+
LOGGED_OUT = "logged_out",
|
|
185
|
+
TOKEN_EXPIRED = "token_expired",
|
|
186
|
+
ERROR = "error",
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface AppEvent extends SdkEvent {
|
|
190
|
+
type: AppEventType;
|
|
191
|
+
message: string;
|
|
192
|
+
error?: Error;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface InteractionEvent extends SdkEvent {
|
|
196
|
+
type: InteractionEventType;
|
|
197
|
+
message: string;
|
|
198
|
+
senderId: string;
|
|
199
|
+
applicationId: string;
|
|
200
|
+
conversationId: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export enum InteractionEventType {
|
|
204
|
+
NEW_CONVERSATION = "new_conversation",
|
|
205
|
+
NEW_MESSAGE = "new_message",
|
|
206
|
+
CLOSE_CONVERSATION = "close_conversation",
|
|
207
|
+
MESSAGE_RECEIVED = "message_received",
|
|
208
|
+
MESSAGE_SENT = "message_sent",
|
|
209
|
+
MESSAGE_DELIVERED = "message_delivered",
|
|
210
|
+
MESSAGE_READ = "message_read",
|
|
211
|
+
CONVERSATION_ENDED = "conversation_ended",
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* SDK instance interface
|
|
216
|
+
*/
|
|
217
|
+
export interface SDK {
|
|
218
|
+
/** Initialize the SDK with options */
|
|
219
|
+
init(options?: SDKOptions): void;
|
|
220
|
+
/** Login with username and password **/
|
|
221
|
+
login(request: LoginRequest): Promise<SdkResponse>;
|
|
222
|
+
/** Login with SSO token**/
|
|
223
|
+
loginSSO(request: LoginSSORequest): Promise<SdkResponse>;
|
|
224
|
+
/** Logout the current user**/
|
|
225
|
+
logout(): Promise<SdkResponse>;
|
|
226
|
+
/** Make a call to a destination**/
|
|
227
|
+
makeCall(destination: string, options?: CallOptions): Promise<SdkResponse>;
|
|
228
|
+
/** Hangup the current call**/
|
|
229
|
+
hangup(): Promise<SdkResponse>;
|
|
230
|
+
/** Answer an incoming call**/
|
|
231
|
+
answerCall(options?: CallOptions): Promise<SdkResponse>;
|
|
232
|
+
/** Reject an incoming call**/
|
|
233
|
+
rejectCall(): Promise<SdkResponse>;
|
|
234
|
+
/** Hold the current call**/
|
|
235
|
+
hold(): Promise<SdkResponse>;
|
|
236
|
+
/** Resume the current call**/
|
|
237
|
+
unhold(): Promise<SdkResponse>;
|
|
238
|
+
/** Mute the current call**/
|
|
239
|
+
mute(): Promise<SdkResponse>;
|
|
240
|
+
/** Unmute the current call**/
|
|
241
|
+
unmute(): Promise<SdkResponse>;
|
|
242
|
+
/** Turn on the camera**/
|
|
243
|
+
cameraOn(): Promise<SdkResponse>;
|
|
244
|
+
/** Turn off the camera**/
|
|
245
|
+
cameraOff(): Promise<SdkResponse>;
|
|
246
|
+
/** Transfer the current call to a different destination**/
|
|
247
|
+
transfer(destination: string): Promise<SdkResponse>;
|
|
248
|
+
/** Change the agent status**/
|
|
249
|
+
changeAgentStatus(status: string): Promise<SdkResponse>;
|
|
250
|
+
/** Get the agent status**/
|
|
251
|
+
getAgentStatus(): Promise<SdkResponse>;
|
|
252
|
+
/** Hide the bubble**/
|
|
253
|
+
hideBubble(): Promise<SdkResponse>;
|
|
254
|
+
/** Show the bubble**/
|
|
255
|
+
showBubble(): Promise<SdkResponse>;
|
|
256
|
+
/** Destroy the SDK instance and clean up resources */
|
|
257
|
+
destroy(): void;
|
|
258
|
+
/** Update SDK options */
|
|
259
|
+
updateOptions(options: Partial<SDKOptions>): void;
|
|
260
|
+
/** Get the current SDK version */
|
|
261
|
+
getVersion(): string;
|
|
262
|
+
/** Get the current SDK options */
|
|
263
|
+
getOptions(): SDKOptions;
|
|
264
|
+
/** Subscribe to an event */
|
|
265
|
+
on(eventName: string, callback: (data: SdkEvent) => void): void;
|
|
266
|
+
/** Unsubscribe from an event */
|
|
267
|
+
off(eventName: string, callback: (data: SdkEvent) => void): void;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Export the OmiSDK class
|
|
271
|
+
export class OmiSDK implements SDK {
|
|
272
|
+
constructor();
|
|
273
|
+
init(options?: SDKOptions): void;
|
|
274
|
+
login(request: LoginRequest): Promise<SdkResponse>;
|
|
275
|
+
loginSSO(request: LoginSSORequest): Promise<SdkResponse>;
|
|
276
|
+
logout(): Promise<SdkResponse>;
|
|
277
|
+
makeCall(destination: string, options?: CallOptions): Promise<SdkResponse>;
|
|
278
|
+
hangup(): Promise<SdkResponse>;
|
|
279
|
+
answerCall(options?: CallOptions): Promise<SdkResponse>;
|
|
280
|
+
rejectCall(): Promise<SdkResponse>;
|
|
281
|
+
hold(): Promise<SdkResponse>;
|
|
282
|
+
unhold(): Promise<SdkResponse>;
|
|
283
|
+
mute(): Promise<SdkResponse>;
|
|
284
|
+
unmute(): Promise<SdkResponse>;
|
|
285
|
+
cameraOn(): Promise<SdkResponse>;
|
|
286
|
+
cameraOff(): Promise<SdkResponse>;
|
|
287
|
+
transfer(destination: string): Promise<SdkResponse>;
|
|
288
|
+
changeAgentStatus(status: string): Promise<SdkResponse>;
|
|
289
|
+
getAgentStatus(): Promise<SdkResponse>;
|
|
290
|
+
hideBubble(): Promise<SdkResponse>;
|
|
291
|
+
showBubble(): Promise<SdkResponse>;
|
|
292
|
+
destroy(): void;
|
|
293
|
+
updateOptions(options: Partial<SDKOptions>): void;
|
|
294
|
+
getVersion(): string;
|
|
295
|
+
getOptions(): SDKOptions;
|
|
296
|
+
on(eventName: string, callback: (data: SdkEvent) => void): void;
|
|
297
|
+
off(eventName: string, callback: (data: SdkEvent) => void): void;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Export the default instance
|
|
301
|
+
const sdkInstance: SDK;
|
|
302
|
+
export default sdkInstance;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Declare global types
|
|
306
|
+
declare global {
|
|
307
|
+
interface Window {
|
|
308
|
+
omisdk: import("@mptransformation/omisdk").SDK;
|
|
309
|
+
}
|
|
310
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mptransformation/omisdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "An embeddable TypeScript SDK for integrating into websites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/omisdk.umd.js",
|
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/omisdk.es.js",
|
|
11
|
-
"require": "./dist/omisdk.umd.js"
|
|
11
|
+
"require": "./dist/omisdk.umd.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
15
16
|
"files": [
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
20
|
"dev": "vite",
|
|
20
|
-
"build": "
|
|
21
|
+
"build": "vite build && node copy-types.js",
|
|
21
22
|
"preview": "vite preview",
|
|
22
23
|
"test": "vitest run",
|
|
23
24
|
"test:watch": "vitest",
|