@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 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 `{ id, type }`, where `type` is `'email'` or `'phone'`. Resolves with a `ResponseMessage` whose payload contains the matching channels returned by x-bees.
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({ id: 'user@example.com', type: 'email' });
528
+ const { payload } = await client.getChannelsByEmailOrPhone({ value: 'user@example.com', type: 'email' });
525
529
  ```
526
530
 
527
531
  ---
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.17-alpha.1",
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": "",
@@ -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;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.17-alpha.1",
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": "",
@@ -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,
@@ -72,6 +72,7 @@ export var UrlParams;
72
72
  UrlParams["AUTHORIZE"] = "a";
73
73
  UrlParams["START_PAGE"] = "sp";
74
74
  UrlParams["PRODUCT"] = "p";
75
+ UrlParams["CLOUD_BACKEND_ENABLED"] = "cbi";
75
76
  })(UrlParams || (UrlParams = {}));
76
77
  export var StartPage;
77
78
  (function (StartPage) {
@@ -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>>;
@@ -68,7 +68,8 @@ export declare enum UrlParams {
68
68
  REFERRER = "r",
69
69
  AUTHORIZE = "a",
70
70
  START_PAGE = "sp",
71
- PRODUCT = "p"
71
+ PRODUCT = "p",
72
+ CLOUD_BACKEND_ENABLED = "cbi"
72
73
  }
73
74
  export declare enum StartPage {
74
75
  CREATE_CONTACT = "createContact"
@@ -12,6 +12,7 @@ export default class ClientParams {
12
12
  readonly userExtension: string | null;
13
13
  readonly startPage: StartPage | null;
14
14
  readonly product: Product | null;
15
+ readonly cloudBackendEnabled: boolean;
15
16
  constructor();
16
17
  toString(): string;
17
18
  }
@@ -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: `id` (email or phone value) and `type` (`'email'` or `'phone'`).
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
  /**
@@ -101,7 +101,7 @@ export interface IPayloadSetChatToOpen {
101
101
  chatId: string;
102
102
  }
103
103
  export interface IPayloadGetChannelsByEmailOrPhone {
104
- id: string;
104
+ value: string;
105
105
  type: 'email' | 'phone';
106
106
  }
107
107
  export interface IPayloadContactWeightUpdate {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.17-alpha.1",
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": "",