@wildix/xbees-connect 1.3.17-alpha.1 → 1.3.17-beta.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 +6 -2
- package/dist-cjs/package.json +1 -1
- package/dist-cjs/src/Client.js +11 -0
- package/dist-cjs/src/enums/index.js +1 -0
- package/dist-cjs/src/helpers/ClientParams.js +2 -0
- package/dist-es/package.json +1 -1
- package/dist-es/src/Client.js +11 -0
- package/dist-es/src/enums/index.js +1 -0
- package/dist-es/src/helpers/ClientParams.js +2 -0
- package/dist-types/src/Client.d.ts +2 -0
- package/dist-types/src/enums/index.d.ts +2 -1
- package/dist-types/src/helpers/ClientParams.d.ts +1 -0
- package/dist-types/types/Client.d.ts +4 -1
- package/dist-types/types/Payload.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -182,6 +182,10 @@ Returns `true` when the integration is launched in fullsize mode (`f`).
|
|
|
182
182
|
|
|
183
183
|
Returns `true` when the integration is opened for activation/authorization purposes only (URL contains the `authorize` parameter).
|
|
184
184
|
|
|
185
|
+
#### `isCloudBackendEnabled(): boolean`
|
|
186
|
+
|
|
187
|
+
Returns `true` when cloud backend is enabled for this integration. Reads the `cbi` URL parameter at construction time (`cbi=1` → `true`, `cbi=0` or missing → `false`).
|
|
188
|
+
|
|
185
189
|
---
|
|
186
190
|
|
|
187
191
|
### Context
|
|
@@ -518,10 +522,10 @@ client.setChatToOpen('chat_id');
|
|
|
518
522
|
|
|
519
523
|
#### `getChannelsByEmailOrPhone(payload: IPayloadGetChannelsByEmailOrPhone): Promise<ResponseMessage>`
|
|
520
524
|
|
|
521
|
-
Asks x-bees to look up chat channels for an email address or phone number. The integration sends `ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE` (`xBeesGetChannelsByEmailOrPhone`) with payload `{
|
|
525
|
+
Asks x-bees to look up chat channels for an email address or phone number. The integration sends `ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE` (`xBeesGetChannelsByEmailOrPhone`) with payload `{ value, type }`, where `type` is `'email'` or `'phone'`. Resolves with a `ResponseMessage` whose payload contains the matching channels returned by x-bees.
|
|
522
526
|
|
|
523
527
|
```ts
|
|
524
|
-
const { payload } = await client.getChannelsByEmailOrPhone({
|
|
528
|
+
const { payload } = await client.getChannelsByEmailOrPhone({ value: 'user@example.com', type: 'email' });
|
|
525
529
|
```
|
|
526
530
|
|
|
527
531
|
---
|
package/dist-cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.17-
|
|
3
|
+
"version": "1.3.17-beta.2",
|
|
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": "",
|
package/dist-cjs/src/Client.js
CHANGED
|
@@ -52,6 +52,7 @@ class Client {
|
|
|
52
52
|
variant = null;
|
|
53
53
|
startPage = null;
|
|
54
54
|
product = null;
|
|
55
|
+
cloudBackendEnabled;
|
|
55
56
|
localStorageManager = LocalStorageManager_1.default.getInstance();
|
|
56
57
|
constructor() {
|
|
57
58
|
const params = (0, getUrlSearchParamsMap_1.getUrlSearchParamsMap)();
|
|
@@ -62,6 +63,7 @@ class Client {
|
|
|
62
63
|
this.needAuthorize = params.has(enums_1.UrlParams.AUTHORIZE);
|
|
63
64
|
this.startPage = params.get(enums_1.UrlParams.START_PAGE);
|
|
64
65
|
this.product = params.get(enums_1.UrlParams.PRODUCT);
|
|
66
|
+
this.cloudBackendEnabled = params.get(enums_1.UrlParams.CLOUD_BACKEND_ENABLED) === '1';
|
|
65
67
|
this.integrationId = params.get(enums_1.UrlParams.ID)?.split('-')[0] ?? '';
|
|
66
68
|
// @ts-expect-error window.ReactNativeWebView will be provided by ReactNative WebView
|
|
67
69
|
this.isParentReactNativeWebView = !!window.ReactNativeWebView;
|
|
@@ -239,6 +241,9 @@ class Client {
|
|
|
239
241
|
isActivationOnly() {
|
|
240
242
|
return this.needAuthorize;
|
|
241
243
|
}
|
|
244
|
+
isCloudBackendEnabled() {
|
|
245
|
+
return this.cloudBackendEnabled;
|
|
246
|
+
}
|
|
242
247
|
getContext() {
|
|
243
248
|
return this.sendAsync({ type: enums_1.ClientEventType.CONTEXT });
|
|
244
249
|
}
|
|
@@ -547,6 +552,12 @@ class Client {
|
|
|
547
552
|
});
|
|
548
553
|
}
|
|
549
554
|
getChannelsByEmailOrPhone(payload) {
|
|
555
|
+
if (!payload?.value?.trim()) {
|
|
556
|
+
return Promise.reject(new Error('`value` is required'));
|
|
557
|
+
}
|
|
558
|
+
if (payload.type !== 'email' && payload.type !== 'phone') {
|
|
559
|
+
return Promise.reject(new Error('`type` must be "email" or "phone"'));
|
|
560
|
+
}
|
|
550
561
|
return this.sendAsync({
|
|
551
562
|
type: enums_1.ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE,
|
|
552
563
|
payload,
|
|
@@ -75,6 +75,7 @@ var UrlParams;
|
|
|
75
75
|
UrlParams["AUTHORIZE"] = "a";
|
|
76
76
|
UrlParams["START_PAGE"] = "sp";
|
|
77
77
|
UrlParams["PRODUCT"] = "p";
|
|
78
|
+
UrlParams["CLOUD_BACKEND_ENABLED"] = "cbi";
|
|
78
79
|
})(UrlParams || (exports.UrlParams = UrlParams = {}));
|
|
79
80
|
var StartPage;
|
|
80
81
|
(function (StartPage) {
|
|
@@ -19,6 +19,7 @@ class ClientParams {
|
|
|
19
19
|
userExtension = null;
|
|
20
20
|
startPage = null;
|
|
21
21
|
product = null;
|
|
22
|
+
cloudBackendEnabled;
|
|
22
23
|
constructor() {
|
|
23
24
|
const params = (0, getUrlSearchParamsMap_1.getUrlSearchParamsMap)();
|
|
24
25
|
this.iframeId = params.get(enums_1.UrlParams.ID);
|
|
@@ -30,6 +31,7 @@ class ClientParams {
|
|
|
30
31
|
this.needAuthorize = params.has(enums_1.UrlParams.AUTHORIZE);
|
|
31
32
|
this.startPage = params.get(enums_1.UrlParams.START_PAGE);
|
|
32
33
|
this.product = params.get(enums_1.UrlParams.PRODUCT);
|
|
34
|
+
this.cloudBackendEnabled = params.get(enums_1.UrlParams.CLOUD_BACKEND_ENABLED) === '1';
|
|
33
35
|
}
|
|
34
36
|
toString() {
|
|
35
37
|
const { userToken, ...props } = this;
|
package/dist-es/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.17-
|
|
3
|
+
"version": "1.3.17-beta.2",
|
|
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": "",
|
package/dist-es/src/Client.js
CHANGED
|
@@ -46,6 +46,7 @@ export class Client {
|
|
|
46
46
|
variant = null;
|
|
47
47
|
startPage = null;
|
|
48
48
|
product = null;
|
|
49
|
+
cloudBackendEnabled;
|
|
49
50
|
localStorageManager = LocalStorageManager.getInstance();
|
|
50
51
|
constructor() {
|
|
51
52
|
const params = getUrlSearchParamsMap();
|
|
@@ -56,6 +57,7 @@ export class Client {
|
|
|
56
57
|
this.needAuthorize = params.has(UrlParams.AUTHORIZE);
|
|
57
58
|
this.startPage = params.get(UrlParams.START_PAGE);
|
|
58
59
|
this.product = params.get(UrlParams.PRODUCT);
|
|
60
|
+
this.cloudBackendEnabled = params.get(UrlParams.CLOUD_BACKEND_ENABLED) === '1';
|
|
59
61
|
this.integrationId = params.get(UrlParams.ID)?.split('-')[0] ?? '';
|
|
60
62
|
// @ts-expect-error window.ReactNativeWebView will be provided by ReactNative WebView
|
|
61
63
|
this.isParentReactNativeWebView = !!window.ReactNativeWebView;
|
|
@@ -233,6 +235,9 @@ export class Client {
|
|
|
233
235
|
isActivationOnly() {
|
|
234
236
|
return this.needAuthorize;
|
|
235
237
|
}
|
|
238
|
+
isCloudBackendEnabled() {
|
|
239
|
+
return this.cloudBackendEnabled;
|
|
240
|
+
}
|
|
236
241
|
getContext() {
|
|
237
242
|
return this.sendAsync({ type: ClientEventType.CONTEXT });
|
|
238
243
|
}
|
|
@@ -541,6 +546,12 @@ export class Client {
|
|
|
541
546
|
});
|
|
542
547
|
}
|
|
543
548
|
getChannelsByEmailOrPhone(payload) {
|
|
549
|
+
if (!payload?.value?.trim()) {
|
|
550
|
+
return Promise.reject(new Error('`value` is required'));
|
|
551
|
+
}
|
|
552
|
+
if (payload.type !== 'email' && payload.type !== 'phone') {
|
|
553
|
+
return Promise.reject(new Error('`type` must be "email" or "phone"'));
|
|
554
|
+
}
|
|
544
555
|
return this.sendAsync({
|
|
545
556
|
type: ClientEventType.GET_CHANNELS_BY_EMAIL_OR_PHONE,
|
|
546
557
|
payload,
|
|
@@ -17,6 +17,7 @@ export default class ClientParams {
|
|
|
17
17
|
userExtension = null;
|
|
18
18
|
startPage = null;
|
|
19
19
|
product = null;
|
|
20
|
+
cloudBackendEnabled;
|
|
20
21
|
constructor() {
|
|
21
22
|
const params = getUrlSearchParamsMap();
|
|
22
23
|
this.iframeId = params.get(UrlParams.ID);
|
|
@@ -28,6 +29,7 @@ export default class ClientParams {
|
|
|
28
29
|
this.needAuthorize = params.has(UrlParams.AUTHORIZE);
|
|
29
30
|
this.startPage = params.get(UrlParams.START_PAGE);
|
|
30
31
|
this.product = params.get(UrlParams.PRODUCT);
|
|
32
|
+
this.cloudBackendEnabled = params.get(UrlParams.CLOUD_BACKEND_ENABLED) === '1';
|
|
31
33
|
}
|
|
32
34
|
toString() {
|
|
33
35
|
const { userToken, ...props } = this;
|
|
@@ -29,6 +29,7 @@ export declare class Client implements ConnectClient {
|
|
|
29
29
|
private readonly variant;
|
|
30
30
|
private readonly startPage;
|
|
31
31
|
private readonly product;
|
|
32
|
+
private readonly cloudBackendEnabled;
|
|
32
33
|
private readonly localStorageManager;
|
|
33
34
|
constructor();
|
|
34
35
|
private sendAsync;
|
|
@@ -66,6 +67,7 @@ export declare class Client implements ConnectClient {
|
|
|
66
67
|
showsUi(): boolean;
|
|
67
68
|
isFullsize(): boolean;
|
|
68
69
|
isActivationOnly(): boolean;
|
|
70
|
+
isCloudBackendEnabled(): boolean;
|
|
69
71
|
getContext(): Promise<Message<ClientEventType.CONTEXT>>;
|
|
70
72
|
getCurrentContact(): Promise<Message<ClientEventType.CURRENT_CONTACT>>;
|
|
71
73
|
getCurrentConversation(): Promise<Message<ClientEventType.CURRENT_CONVERSATION>>;
|
|
@@ -79,6 +79,9 @@ export interface ConnectClient {
|
|
|
79
79
|
* dialog which leads to integration be activated
|
|
80
80
|
* */
|
|
81
81
|
isActivationOnly: () => boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Determines whether cloud backend is enabled for this integration (URL parameter `cbi=1`). */
|
|
84
|
+
isCloudBackendEnabled: () => boolean;
|
|
82
85
|
/**
|
|
83
86
|
* Retrieves current x-bees context data */
|
|
84
87
|
getContext: () => Promise<ResponseMessage<ClientEventType.CONTEXT>>;
|
|
@@ -236,7 +239,7 @@ export interface ConnectClient {
|
|
|
236
239
|
setChatToOpen: (chatId: string) => void;
|
|
237
240
|
/**
|
|
238
241
|
* Asks x-bees to look up chat channels for an email address or phone number.
|
|
239
|
-
* @param payload - Contact identifier: `
|
|
242
|
+
* @param payload - Contact identifier: `value` (email or phone value) and `type` (`'email'` or `'phone'`).
|
|
240
243
|
*/
|
|
241
244
|
getChannelsByEmailOrPhone: (payload: IPayloadGetChannelsByEmailOrPhone) => Promise<ResponseMessage>;
|
|
242
245
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.17-
|
|
3
|
+
"version": "1.3.17-beta.2",
|
|
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": "",
|