@wildix/xbees-connect 1.0.4 → 1.0.5-alpha.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.
- package/README.md +108 -19
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# x-bees-connect client
|
|
2
2
|
|
|
3
3
|
This package is the Community plan edition of the client for UI integration applications.
|
|
4
4
|
|
|
@@ -6,41 +6,130 @@ This package is the Community plan edition of the client for UI integration appl
|
|
|
6
6
|
|
|
7
7
|
Install the package in your project directory with:
|
|
8
8
|
|
|
9
|
-
yarn
|
|
10
|
-
|
|
11
9
|
```bash
|
|
12
10
|
yarn add @wildix/xbees-connect
|
|
13
11
|
```
|
|
14
|
-
|
|
15
|
-
npm
|
|
16
|
-
|
|
17
12
|
```bash
|
|
18
13
|
npm install @wildix/xbees-connect
|
|
19
14
|
```
|
|
20
15
|
|
|
21
16
|
## Usage
|
|
22
17
|
|
|
23
|
-
```
|
|
18
|
+
```ts
|
|
24
19
|
import Client from "@wildix/xbees-connect";
|
|
25
20
|
|
|
26
21
|
const xBeesClient = Client.getInstance();
|
|
22
|
+
|
|
27
23
|
console.log(xBeesClient.version());
|
|
28
24
|
|
|
29
25
|
```
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
## API
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
### Initialization
|
|
30
|
+
|
|
31
|
+
#### `ready()`
|
|
32
|
+
|
|
33
|
+
Sends the signal to x-bees that iFrame is ready to be shown. iFrame should send it when the application starts and is ready.
|
|
34
|
+
|
|
35
|
+
#### `isAuthorized: (payload: string) => Promise<ResponseFromChannel>`
|
|
36
|
+
|
|
37
|
+
Sends the message to x-bees that the user is authorized and no more actions are required.
|
|
38
|
+
|
|
39
|
+
#### `isNotAuthorized: (payload: string) => Promise<ResponseFromChannel>`
|
|
40
|
+
|
|
41
|
+
Sends the message to x-bees that user actions are required:
|
|
42
|
+
|
|
43
|
+
### Contacts search
|
|
44
|
+
|
|
45
|
+
#### `onSuggestContacts: ((query: string, resolve: Resolve, reject: Reject) => void) => RemoveEventListener`
|
|
46
|
+
|
|
47
|
+
Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
Client.getInstance().onSuggestContacts(async (query, resolve) => {
|
|
51
|
+
try {
|
|
52
|
+
const contacts = await fetchContacts(query);
|
|
53
|
+
resolve(contacts);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.log('catch', error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
42
58
|
```
|
|
43
59
|
|
|
44
|
-
|
|
60
|
+
### Context
|
|
61
|
+
#### `getContext(): Promise<Response>`
|
|
62
|
+
|
|
63
|
+
Retrieves current x-bees context data. The data may be different depending on context.
|
|
64
|
+
|
|
65
|
+
#### `getCurrentContact(): Promise<Response>`
|
|
66
|
+
|
|
67
|
+
Retrieves contact data currently opened in x-bees.
|
|
68
|
+
|
|
69
|
+
#### `getThemeMode(): Promise<Response>`
|
|
70
|
+
|
|
71
|
+
Retrieves current theme mode (light or dark)
|
|
72
|
+
|
|
73
|
+
#### `getTheme(): Promise<Response>`
|
|
74
|
+
|
|
75
|
+
Retrieves current theme mode and theme options
|
|
76
|
+
|
|
77
|
+
#### `onThemeChange: (callback: ThemeChangeListenerCallback) => void;`
|
|
78
|
+
|
|
79
|
+
Starts to listen for the events of changing theme and returns the provided callback
|
|
80
|
+
|
|
81
|
+
#### `onPbxTokenChange: (callback: ListenerCallback) => void;`
|
|
45
82
|
|
|
46
|
-
|
|
83
|
+
Starts to listen for the events of changing PBX token and returns the provided callback
|
|
84
|
+
|
|
85
|
+
#### `onCallStarted: (callback: ListenerCallback) => void;`
|
|
86
|
+
|
|
87
|
+
Starts to listen for the events of starting the call and returns the provided callback
|
|
88
|
+
|
|
89
|
+
#### `onCallEnded: (callback: ListenerCallback) => void;`
|
|
90
|
+
|
|
91
|
+
Starts to listen for the events of ending the call and returns the provided callback
|
|
92
|
+
|
|
93
|
+
#### `off: (callback: ListenerCallback) => void;`
|
|
94
|
+
|
|
95
|
+
Removes particular callback from handling events
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Other
|
|
99
|
+
#### `version(): string`
|
|
100
|
+
|
|
101
|
+
Retrieves the version of xBeesConnect
|
|
102
|
+
|
|
103
|
+
#### `startCall(phoneNumber: string)`
|
|
104
|
+
|
|
105
|
+
Sends a request to x-bees to start a call with a number
|
|
106
|
+
|
|
107
|
+
#### `reboot()`
|
|
108
|
+
|
|
109
|
+
Sends a request to x-bees to restart the iFrame, reload with actual parameters and token
|
|
110
|
+
|
|
111
|
+
#### `setViewport({height: number; width: number})`
|
|
112
|
+
|
|
113
|
+
Sends a request to x-bees about changes of the current frame size
|
|
114
|
+
|
|
115
|
+
#### `toClipboard(payload: string)`
|
|
116
|
+
|
|
117
|
+
Sends a request to x-bees to put a string to the user's clipboard
|
|
118
|
+
|
|
119
|
+
#### `addEventListener()`
|
|
120
|
+
|
|
121
|
+
Starts listening for one of the x-bees events and returns the provided callback
|
|
122
|
+
|
|
123
|
+
#### `removeEventListener()`
|
|
124
|
+
|
|
125
|
+
Stops listening for one of the x-bees events with the particular callback
|
|
126
|
+
|
|
127
|
+
## Known issues
|
|
128
|
+
|
|
129
|
+
The below function can fix cases when `String.replaceAll()` does not work in the mobile version. Most likely, this is some kind of WebView bug.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
function replaceAll(str: string, search: string, replace: string) {
|
|
133
|
+
return str.split(search).join(replace);
|
|
134
|
+
}
|
|
135
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5-alpha.0",
|
|
4
4
|
"description": "This library provides easy communication between x-bees and integrated web applications",
|
|
5
5
|
"author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"build:es": "tsc -p tsconfig.es.json",
|
|
15
15
|
"build:types": "tsc -p tsconfig.types.json",
|
|
16
16
|
"build:docs": "typedoc",
|
|
17
|
-
"lint": "eslint .",
|
|
17
|
+
"lint": "eslint . && tsc --noEmit",
|
|
18
18
|
"lint:fix": "eslint . --fix",
|
|
19
19
|
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo"
|
|
20
20
|
},
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=16"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "feeea3ba3e36abc8ac978906e83ba8015d57a3ba"
|
|
45
45
|
}
|