@mptransformation/omisdk 0.1.1

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 ADDED
@@ -0,0 +1,206 @@
1
+ # Omi SDK
2
+
3
+ A lightweight, customizable TypeScript SDK that can be embedded in any website. This SDK provides a simple API for integrating with your web applications and supports chat/call/video call for interactions.
4
+
5
+ ## Features
6
+
7
+ - Easy embedding via script tag or import
8
+ - Multiple UI modes (bubble and headless)
9
+ - chat/call/video call with event handling
10
+ - Customizable themes
11
+ - Event-driven architecture
12
+ - Small footprint with minimal dependencies
13
+ - Support for modern and legacy browsers
14
+
15
+ ## Installation
16
+
17
+ ### Using npm
18
+
19
+ ```bash
20
+ npm install @mptransformation/omisdk
21
+ ```
22
+
23
+ ### Using a script tag
24
+
25
+ ```html
26
+ <script src="./js/omisdk.iife.js"></script>
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Basic Usage
32
+
33
+ ```html
34
+ <!-- Auto-initialization with data attributes -->
35
+ <script
36
+ src="./js/omisdk.iife.js"
37
+ data-auto-init="true"
38
+ data-target-element-id="sdk-container"
39
+ data-mode="bubble"
40
+ data-debug="true"
41
+ ></script>
42
+
43
+ <div id="sdk-container"></div>
44
+ ```
45
+
46
+ ### Programmatic Initialization
47
+
48
+ ```javascript
49
+ // Import the SDK (ESM)
50
+ import { OmiSDK } from "@mptransformation/omisdk";
51
+
52
+ // Initialize the SDK
53
+ const sdk = new OmiSDK({
54
+ targetElementId: "sdk-container",
55
+ mode: "bubble", // 'bubble' or 'none'
56
+ debug: true,
57
+ theme: {
58
+ primaryColor: "#4CAF50",
59
+ secondaryColor: "#45a049",
60
+ bubblePosition: "bottom-right",
61
+ },
62
+ });
63
+
64
+ // Initialize the SDK
65
+ sdk.init();
66
+
67
+ // Listen for events
68
+ sdk.on("AppEvent", (event: AppEvent) => {
69
+ console.log("appEvent received:", event);
70
+ });
71
+
72
+ sdk.on("CallEvent", (event: CallEvent) => {
73
+ console.log("callEvent received:", event);
74
+ });
75
+
76
+ // Make a call
77
+ sdk.makeCall("1234567890").then((response) => {
78
+ console.log("Call initiated:", response);
79
+ });
80
+
81
+ // Destroy the SDK when done
82
+ sdk.destroy();
83
+ ```
84
+
85
+ ## API Reference
86
+
87
+ ### SDK Options
88
+
89
+ | Option | Type | Default | Description |
90
+ | ----------------- | ------- | ------------------- | ----------------------------------------------- |
91
+ | `targetElementId` | string | "omi-sdk-container" | ID of the element where the SDK will be mounted |
92
+ | `mode` | string | "bubble" | UI mode: "bubble" or "none" |
93
+ | `socketUrl` | string | null | WebSocket server URL |
94
+ | `debug` | boolean | false | Enable debug logging |
95
+ | `theme` | object | {} | Custom theme options |
96
+
97
+ ### Theme Options
98
+
99
+ | Option | Type | Description |
100
+ | ----------------- | ------ | ------------------------------------------------------------------------------ |
101
+ | `primaryColor` | string | Primary color for UI elements |
102
+ | `secondaryColor` | string | Secondary color for UI elements |
103
+ | `textColor` | string | Text color |
104
+ | `backgroundColor` | string | Background color |
105
+ | `fontFamily` | string | Font family for text |
106
+ | `borderRadius` | string | Border radius for UI elements |
107
+ | `bubblePosition` | string | Position of the bubble: "top-left", "top-right", "bottom-left", "bottom-right" |
108
+
109
+ ### Methods
110
+
111
+ | Method | Description |
112
+ | --------------------------------------------- | ---------------------------------------- |
113
+ | `init(options?: SDKOptions)` | Initialize the SDK with options |
114
+ | `destroy()` | Clean up and remove the SDK from the DOM |
115
+ | `updateOptions(options: Partial<SDKOptions>)` | Update SDK options |
116
+ | `getVersion()` | Get the SDK version |
117
+ | `getOptions()` | Get the current SDK options |
118
+ | `on(event: string, callback: Function)` | Register an event listener |
119
+ | `off(event: string, callback: Function)` | Remove an event listener |
120
+ | `connectSocket()` | Connect to the WebSocket server |
121
+ | `disconnectSocket()` | Disconnect from the WebSocket server |
122
+ | `sendSocketEvent(name: string, data: any)` | Send an event to the socket server |
123
+ | `login(request: LoginRequest)` | Login with username and password |
124
+ | `loginSSO(request: LoginSSORequest)` | Login with SSO token |
125
+ | `logout()` | Logout the current user |
126
+ | `makeCall(destination: string, options?)` | Make a call to a destination |
127
+ | `hangup()` | Hangup the current call |
128
+ | `answerCall(options?)` | Answer an incoming call |
129
+ | `rejectCall()` | Reject an incoming call |
130
+ | `hold()` | Hold the current call |
131
+ | `unhold()` | Resume the current call |
132
+ | `mute()` | Mute the current call |
133
+ | `unmute()` | Unmute the current call |
134
+ | `cameraOn()` | Turn on the camera |
135
+ | `cameraOff()` | Turn off the camera |
136
+ | `transfer(destination: string)` | Transfer the current call |
137
+ | `changeAgentStatus(status: string)` | Change the agent status |
138
+ | `getAgentStatus()` | Get the agent status |
139
+ | `hideBubble()` | Hide the bubble |
140
+ | `showBubble()` | Show the bubble |
141
+
142
+ ## UI Modes
143
+
144
+ ### Bubble Mode
145
+
146
+ In bubble mode, the SDK displays a floating bubble in the corner of the screen that users can interact with. The bubble position can be customized using the theme options.
147
+
148
+ ### None Mode (Headless)
149
+
150
+ In none mode, the SDK operates without any visible UI elements, allowing you to build your own UI on top of the SDK's functionality.
151
+
152
+ ## Examples
153
+
154
+ Check out the examples directory for more detailed usage examples:
155
+
156
+ - [Basic Usage](examples/basic-usage.html) - Shows basic SDK initialization and usage
157
+
158
+ To run the examples with the socket server:
159
+
160
+ ```bash
161
+ # Build the SDK first
162
+ npm run build
163
+
164
+ # Run both the examples server and socket server
165
+ npm start
166
+ ```
167
+
168
+ Then open http://localhost:3000/examples/socket-example.html in your browser.
169
+
170
+ ## Development
171
+
172
+ ### Prerequisites
173
+
174
+ - Node.js 16+
175
+ - npm or yarn
176
+
177
+ ### Setup
178
+
179
+ ```bash
180
+ # Clone the repository
181
+ git clone https://github.com/MPG-MPTransformation/mptsdk.git
182
+ cd mptsdk
183
+
184
+ # Install dependencies
185
+ npm install
186
+
187
+ # Build the SDK
188
+ npm run build
189
+
190
+ # Serve examples
191
+ npm run serve-examples
192
+ ```
193
+
194
+ ### Available Scripts
195
+
196
+ - `npm run dev` - Start development server
197
+ - `npm run build` - Build for production
198
+ - `npm run test` - Run tests
199
+ - `npm run test:watch` - Run tests in watch mode
200
+ - `npm run test:coverage` - Run tests with coverage
201
+ - `npm run demo` - Serve the demo page
202
+ - `npm start` - Run both the examples server and socket server
203
+
204
+ ## License
205
+
206
+ MIT