@wildix/xbees-connect 1.1.7 → 1.1.11

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.1.6",
3
+ "version": "1.1.9",
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": "",
@@ -111,6 +111,9 @@ export class Client {
111
111
  isPlatformWeb() {
112
112
  return !this.isParentReactNativeWebView;
113
113
  }
114
+ isOpenedFromXBees() {
115
+ return this.isParentReactNativeWebView || (!!parent && parent !== window);
116
+ }
114
117
  getUserPbxToken() {
115
118
  return this.userToken;
116
119
  }
@@ -260,6 +263,10 @@ export class Client {
260
263
  });
261
264
  const reject = (reason) => {
262
265
  console.debug(reason);
266
+ void this.sendAsync({
267
+ type: ClientEventType.CONTACT_LOOKUP_AND_MATCH_NOT_FOUND,
268
+ payload: { query },
269
+ });
263
270
  };
264
271
  try {
265
272
  callback(query, resolve, reject);
@@ -284,4 +291,11 @@ export class Client {
284
291
  onStorage(listener) {
285
292
  return this.localStorageManager.onStorage(listener);
286
293
  }
294
+ onLogout(callback) {
295
+ // send event to x-bees
296
+ void this.sendAsync({
297
+ type: ClientEventType.LOGOUT_IS_SUPPORTED,
298
+ });
299
+ return this.addEventListener(EventType.LOGOUT, callback);
300
+ }
287
301
  }
@@ -7,6 +7,7 @@ export var EventType;
7
7
  EventType["USE_THEME"] = "xBeesUseTheme";
8
8
  EventType["PBX_TOKEN"] = "xBeesPbxToken";
9
9
  EventType["REDIRECT_QUERY"] = "xBeesRedirectQuery";
10
+ EventType["LOGOUT"] = "xBeesLogout";
10
11
  })(EventType || (EventType = {}));
11
12
  export var ClientEventType;
12
13
  (function (ClientEventType) {
@@ -25,7 +26,9 @@ export var ClientEventType;
25
26
  ClientEventType["TOKEN"] = "xBeesToken";
26
27
  ClientEventType["CONTACTS_AUTO_SUGGEST"] = "xBeesContactsAutoSuggest";
27
28
  ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
29
+ ClientEventType["CONTACT_LOOKUP_AND_MATCH_NOT_FOUND"] = "xBeesContactLookupAndMatchNotFound";
28
30
  ClientEventType["CONTACT_CREATE_OR_UPDATE"] = "xBeesContactCreateOrUpdate";
31
+ ClientEventType["LOGOUT_IS_SUPPORTED"] = "xBeesLogoutIsSupported";
29
32
  })(ClientEventType || (ClientEventType = {}));
30
33
  export var DeprecatedUrlParams;
31
34
  (function (DeprecatedUrlParams) {
@@ -27,6 +27,7 @@ export declare class Client implements ConnectClient {
27
27
  version(): string;
28
28
  isPlatformNative(): boolean;
29
29
  isPlatformWeb(): boolean;
30
+ isOpenedFromXBees(): boolean;
30
31
  getUserPbxToken(): string;
31
32
  getUserEmail(): string;
32
33
  getReferrer(): string;
@@ -64,4 +65,5 @@ export declare class Client implements ConnectClient {
64
65
  saveToStorage<SavingType>(key: string, value: SavingType): void;
65
66
  deleteFromStorage(key: string): void;
66
67
  onStorage(listener: StorageEventCallback): () => void;
68
+ onLogout(callback: Callback<EventType.LOGOUT>): RemoveEventListener;
67
69
  }
@@ -5,7 +5,8 @@ export declare enum EventType {
5
5
  TERMINATE_CALL = "xBeesTerminateCall",
6
6
  USE_THEME = "xBeesUseTheme",
7
7
  PBX_TOKEN = "xBeesPbxToken",
8
- REDIRECT_QUERY = "xBeesRedirectQuery"
8
+ REDIRECT_QUERY = "xBeesRedirectQuery",
9
+ LOGOUT = "xBeesLogout"
9
10
  }
10
11
  export declare enum ClientEventType {
11
12
  READY = "xBeesReady",
@@ -23,7 +24,9 @@ export declare enum ClientEventType {
23
24
  TOKEN = "xBeesToken",
24
25
  CONTACTS_AUTO_SUGGEST = "xBeesContactsAutoSuggest",
25
26
  CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch",
26
- CONTACT_CREATE_OR_UPDATE = "xBeesContactCreateOrUpdate"
27
+ CONTACT_LOOKUP_AND_MATCH_NOT_FOUND = "xBeesContactLookupAndMatchNotFound",
28
+ CONTACT_CREATE_OR_UPDATE = "xBeesContactCreateOrUpdate",
29
+ LOGOUT_IS_SUPPORTED = "xBeesLogoutIsSupported"
27
30
  }
28
31
  export declare enum DeprecatedUrlParams {
29
32
  TOKEN = "token",
@@ -58,12 +58,15 @@ export interface IPayloadContactMatchResult {
58
58
  contact: Contact;
59
59
  query: ContactQuery;
60
60
  }
61
+ export interface IPayloadContactMatchResultNotFound {
62
+ query: ContactQuery;
63
+ }
61
64
  export interface IPayloadContactResult {
62
65
  contact: Contact;
63
66
  }
64
67
  export interface IPayloadContextResult extends IPayloadContactResult {
65
68
  }
66
- type EventPayload<T extends MessageType> = T extends EventType.GET_CONTACTS_AUTO_SUGGEST ? string : T extends ClientEventType.CONTACTS_AUTO_SUGGEST ? IPayloadAutoSuggestResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH ? IPayloadContactMatchResult : T extends ClientEventType.CONTACT_CREATE_OR_UPDATE ? IPayloadContactMatchResult : T extends ClientEventType.CONTEXT ? IPayloadContextResult : T extends ClientEventType.CURRENT_CONTACT ? IPayloadContactResult : T extends EventType.ADD_CALL ? IPayloadCallStartedInfo : T extends ClientEventType.START_CALL ? IPayloadCallStart : T extends ClientEventType.READY ? IPayloadVersion : T extends ClientEventType.VIEW_PORT ? IPayloadViewPort : T extends ClientEventType.THEME ? IPayloadThemeChange : T extends EventType.USE_THEME ? IPayloadThemeChange : T extends ClientEventType.TOAST ? IPayloadToast : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
69
+ type EventPayload<T extends MessageType> = T extends EventType.GET_CONTACTS_AUTO_SUGGEST ? string : T extends ClientEventType.CONTACTS_AUTO_SUGGEST ? IPayloadAutoSuggestResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH ? IPayloadContactMatchResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH_NOT_FOUND ? IPayloadContactMatchResultNotFound : T extends ClientEventType.CONTACT_CREATE_OR_UPDATE ? IPayloadContactMatchResult : T extends ClientEventType.CONTEXT ? IPayloadContextResult : T extends ClientEventType.CURRENT_CONTACT ? IPayloadContactResult : T extends EventType.ADD_CALL ? IPayloadCallStartedInfo : T extends ClientEventType.START_CALL ? IPayloadCallStart : T extends ClientEventType.READY ? IPayloadVersion : T extends ClientEventType.VIEW_PORT ? IPayloadViewPort : T extends ClientEventType.THEME ? IPayloadThemeChange : T extends EventType.USE_THEME ? IPayloadThemeChange : T extends ClientEventType.TOAST ? IPayloadToast : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
67
70
  export type Message<T extends MessageType = MessageType> = {
68
71
  type: T;
69
72
  payload?: EventPayload<T>;
@@ -134,6 +137,9 @@ export interface ConnectClient {
134
137
  /**
135
138
  * Determines x-bees is running on web browser platform */
136
139
  isPlatformWeb: () => boolean;
140
+ /**
141
+ * Determines application is opened as x-bees child in Browser iFrame or Native WebView */
142
+ isOpenedFromXBees: () => boolean;
137
143
  /**
138
144
  * Determines x-bees is using this connect for messages only and this integration will not be shown on UI */
139
145
  isDataOnly: () => boolean;
@@ -236,5 +242,8 @@ export interface ConnectClient {
236
242
  /**
237
243
  * listens on localStorage */
238
244
  onStorage: (listener: StorageEventCallback) => () => void;
245
+ /**
246
+ * starts listen on logout event and send event to the xbees about logout able */
247
+ onLogout: (callback: Callback<EventType.LOGOUT>) => RemoveEventListener;
239
248
  }
240
249
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.1.7",
3
+ "version": "1.1.11",
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": "",
@@ -42,5 +42,5 @@
42
42
  "engines": {
43
43
  "node": ">=16"
44
44
  },
45
- "gitHead": "0f4783eaf917b09c70b65745fc2a264331d4c721"
45
+ "gitHead": "106c5ae830969189ce148276124aca70c8be3325"
46
46
  }