@wildix/xbees-connect 1.1.21 → 1.2.0-alpha.10

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.
Files changed (48) hide show
  1. package/dist-es/package.json +1 -1
  2. package/dist-es/src/Client.js +9 -1
  3. package/dist-es/src/enums/index.js +2 -3
  4. package/dist-es/src/helpers/ClientParams.js +29 -0
  5. package/dist-es/src/helpers/MessageListener.js +81 -0
  6. package/dist-es/src/helpers/PostMessageController.js +42 -0
  7. package/dist-es/src/helpers/TechnicalSupport.js +25 -0
  8. package/dist-es/types/Callback.js +1 -0
  9. package/dist-es/types/Client.js +1 -0
  10. package/dist-es/types/Contact.js +1 -0
  11. package/dist-es/types/Event.js +1 -0
  12. package/dist-es/types/Json.js +1 -0
  13. package/dist-es/types/Listener.js +1 -0
  14. package/dist-es/types/Message.js +1 -0
  15. package/dist-es/types/MessageSender.js +1 -0
  16. package/dist-es/types/Payload.js +1 -0
  17. package/dist-es/types/Platform.js +1 -0
  18. package/dist-es/types/Resolver.js +1 -0
  19. package/dist-es/types/Storage.js +1 -0
  20. package/dist-es/types/Toast.js +1 -0
  21. package/dist-es/types/WorkVariant.js +1 -0
  22. package/dist-es/types/conversation.js +1 -0
  23. package/dist-es/types/index.js +1 -1
  24. package/dist-types/src/Client.d.ts +3 -0
  25. package/dist-types/src/enums/index.d.ts +3 -3
  26. package/dist-types/src/helpers/ClientParams.d.ts +13 -0
  27. package/dist-types/src/helpers/MessageListener.d.ts +14 -0
  28. package/dist-types/src/helpers/PostMessageController.d.ts +13 -0
  29. package/dist-types/src/helpers/PostMessageControllerNative.d.ts +2 -2
  30. package/dist-types/src/helpers/PostMessageControllerWeb.d.ts +2 -2
  31. package/dist-types/src/helpers/TechnicalSupport.d.ts +9 -0
  32. package/dist-types/types/Callback.d.ts +4 -0
  33. package/dist-types/types/Client.d.ts +154 -0
  34. package/dist-types/types/Contact.d.ts +24 -0
  35. package/dist-types/types/Event.d.ts +22 -0
  36. package/dist-types/types/Json.d.ts +7 -0
  37. package/dist-types/types/Listener.d.ts +7 -0
  38. package/dist-types/types/Message.d.ts +14 -0
  39. package/dist-types/types/MessageSender.d.ts +4 -0
  40. package/dist-types/types/Payload.d.ts +60 -0
  41. package/dist-types/types/Platform.d.ts +1 -0
  42. package/dist-types/types/Resolver.d.ts +4 -0
  43. package/dist-types/types/Storage.d.ts +1 -0
  44. package/dist-types/types/Toast.d.ts +1 -0
  45. package/dist-types/types/WorkVariant.d.ts +3 -0
  46. package/dist-types/types/conversation.d.ts +4 -0
  47. package/dist-types/types/index.d.ts +14 -263
  48. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.1.21",
3
+ "version": "1.2.0-alpha.10",
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": "",
@@ -1,8 +1,10 @@
1
1
  import packageJson from '../package.json';
2
2
  import { ClientEventType, DeprecatedUrlParams, EventType, UrlParams } from './enums';
3
3
  import LocalStorageManager from './helpers/LocalStorageManager';
4
+ import { MessageListener } from './helpers/MessageListener';
4
5
  import PostMessageControllerNative from './helpers/PostMessageControllerNative';
5
6
  import PostMessageControllerWeb from './helpers/PostMessageControllerWeb';
7
+ import TechnicalSupport from './helpers/TechnicalSupport';
6
8
  import { getUrlSearchParamsMap } from './utils/url/getUrlSearchParamsMap';
7
9
  /**
8
10
  * Client provides functionality of communication between xBees and integrated web applications via iFrame or ReactNative WebView
@@ -69,7 +71,7 @@ export class Client {
69
71
  }
70
72
  parseMessage(message) {
71
73
  try {
72
- const data = typeof message.data === 'string' ? JSON.parse(message.data) : message.data;
74
+ const data = typeof message.data === 'string' ? MessageListener.parseJSON(message.data) : message.data;
73
75
  if (!data?.type) {
74
76
  return null;
75
77
  }
@@ -157,6 +159,9 @@ export class Client {
157
159
  contactUpdated(query, contact) {
158
160
  return this.sendAsync({ type: ClientEventType.CONTACT_CREATE_OR_UPDATE, payload: { query, contact } });
159
161
  }
162
+ contactMatchUpdated(query, contact) {
163
+ return this.sendAsync({ type: ClientEventType.CONTACT_MATCH_UPDATE, payload: { query, contact } });
164
+ }
160
165
  getThemeMode() {
161
166
  return this.sendAsync({ type: ClientEventType.THEME_MODE });
162
167
  }
@@ -312,4 +317,7 @@ export class Client {
312
317
  setIntegrationStorageKey(integrationKey) {
313
318
  this.localStorageManager.setIntegrationKey(integrationKey);
314
319
  }
320
+ getTechnicalSupport() {
321
+ return TechnicalSupport.getInstance();
322
+ }
315
323
  }
@@ -1,6 +1,3 @@
1
- export var EventType1;
2
- (function (EventType1) {
3
- })(EventType1 || (EventType1 = {}));
4
1
  export var EventType;
5
2
  (function (EventType) {
6
3
  EventType["GET_CONTACTS_AUTO_SUGGEST"] = "xBeesGetContactsAutoSuggest";
@@ -32,10 +29,12 @@ export var ClientEventType;
32
29
  ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
33
30
  ClientEventType["CONTACT_LOOKUP_AND_MATCH_NOT_FOUND"] = "xBeesContactLookupAndMatchNotFound";
34
31
  ClientEventType["CONTACT_CREATE_OR_UPDATE"] = "xBeesContactCreateOrUpdate";
32
+ ClientEventType["CONTACT_MATCH_UPDATE"] = "xBeesContactMatchUpdate";
35
33
  ClientEventType["CONTACTS_AUTO_SUGGEST_IS_SUPPORTED"] = "xBeesContactsAutoSuggestIsSupported";
36
34
  ClientEventType["CONTACT_LOOK_UP_AND_MATCH_IS_SUPPORTED"] = "xBeesContactLookupAndMatchIsSupported";
37
35
  ClientEventType["LOGOUT_IS_SUPPORTED"] = "xBeesLogoutIsSupported";
38
36
  ClientEventType["SEND_ANALYTICS"] = "xBeesSendAnalytics";
37
+ ClientEventType["SEND_TECHNICAL_SUPPORT_INFORMATION"] = "xBeesSendTechInfo";
39
38
  })(ClientEventType || (ClientEventType = {}));
40
39
  export var DeprecatedUrlParams;
41
40
  (function (DeprecatedUrlParams) {
@@ -0,0 +1,29 @@
1
+ import { DeprecatedUrlParams, UrlParams } from '../enums';
2
+ import { getUrlSearchParamsMap } from '../utils/url/getUrlSearchParamsMap';
3
+ export default class ClientParams {
4
+ static instance = null;
5
+ static getInstance() {
6
+ if (!this.instance) {
7
+ this.instance = new ClientParams();
8
+ }
9
+ return this.instance;
10
+ }
11
+ userToken;
12
+ userEmail;
13
+ referrer;
14
+ needAuthorize;
15
+ iframeId;
16
+ variant = null;
17
+ constructor() {
18
+ const params = getUrlSearchParamsMap();
19
+ this.iframeId = (params.get(UrlParams.ID) ?? params.get(DeprecatedUrlParams.ID));
20
+ this.variant = (params.get(UrlParams.VARIANT) ?? params.get(DeprecatedUrlParams.VARIANT));
21
+ this.userEmail = (params.get(UrlParams.USER) ?? params.get(DeprecatedUrlParams.USER));
22
+ this.userToken = (params.get(UrlParams.TOKEN) ?? params.get(DeprecatedUrlParams.TOKEN));
23
+ this.referrer = (params.get(UrlParams.REFERRER) ?? params.get(DeprecatedUrlParams.REFERRER));
24
+ this.needAuthorize = params.has(UrlParams.AUTHORIZE) ?? params.has(DeprecatedUrlParams.AUTHORIZE);
25
+ }
26
+ toString() {
27
+ return JSON.stringify(this);
28
+ }
29
+ }
@@ -0,0 +1,81 @@
1
+ import { EventType } from '../enums';
2
+ export class MessageListener {
3
+ static instance = null;
4
+ static getInstance() {
5
+ if (!this.instance) {
6
+ this.instance = new MessageListener();
7
+ }
8
+ return this.instance;
9
+ }
10
+ listeners = [];
11
+ useSubscription = false;
12
+ // eslint-disable-next-line
13
+ constructor() { }
14
+ parseMessage(message) {
15
+ try {
16
+ const data = typeof message.data === 'string' ? MessageListener.parseJSON(message.data) : message.data;
17
+ if (!data?.type) {
18
+ return null;
19
+ }
20
+ return data;
21
+ }
22
+ catch (error) {
23
+ console.error('parse message error', error);
24
+ return null;
25
+ }
26
+ }
27
+ static parseJSON(messageData) {
28
+ const trimmedData = messageData.trim();
29
+ if (!trimmedData || !trimmedData.startsWith('{') || !trimmedData.endsWith('}')) {
30
+ return null;
31
+ }
32
+ return JSON.parse(trimmedData);
33
+ }
34
+ onMessage = (message) => {
35
+ if (window.location.host === message.origin || window === message.source) {
36
+ console.debug(`onMessage skipped ${window.location.host} - ${message.origin} - ${window === message.source} - ${message}`);
37
+ // skip events started from integration itself if any
38
+ return;
39
+ }
40
+ const data = this.parseMessage(message);
41
+ if (!data) {
42
+ console.debug('onMessage skipped', message);
43
+ return;
44
+ }
45
+ const { type, payload } = data;
46
+ console.debug(`onMessage call - ${type} - ${payload}`);
47
+ this.listeners.forEach(({ eventName, callback }) => {
48
+ if (eventName === type) {
49
+ if (type === EventType.ADD_CALL) {
50
+ const callbackFn = callback;
51
+ callbackFn(payload);
52
+ }
53
+ else {
54
+ // @ts-expect-error TODO: check the type for Callback<?>
55
+ const callbackFn = callback;
56
+ callbackFn(payload);
57
+ }
58
+ }
59
+ });
60
+ };
61
+ listen(eventName, callback) {
62
+ if (!this.useSubscription) {
63
+ this.useSubscription = true;
64
+ window.addEventListener('message', this.onMessage);
65
+ }
66
+ const foundThisEvent = this.listeners.find(({ eventName: _eventName, callback: _callback }) => eventName === _eventName && Object.is(callback, _callback));
67
+ if (!foundThisEvent) {
68
+ this.listeners.push({ eventName, callback });
69
+ }
70
+ return () => {
71
+ this.off(eventName, callback);
72
+ };
73
+ }
74
+ off(eventName, callback) {
75
+ this.listeners = this.listeners.filter(({ eventName: _eventName, callback: _callback }) => !(Object.is(callback, _callback) && (!eventName ? true : eventName === _eventName)));
76
+ if (this.useSubscription && !this.listeners.length) {
77
+ this.useSubscription = false;
78
+ window.removeEventListener('message', this.onMessage);
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,42 @@
1
+ import ClientParams from './ClientParams';
2
+ import PostMessageControllerNative from './PostMessageControllerNative';
3
+ import PostMessageControllerWeb from './PostMessageControllerWeb';
4
+ export default class PostMessageController {
5
+ static instance = null;
6
+ static getInstance() {
7
+ if (!this.instance) {
8
+ this.instance = new PostMessageController();
9
+ }
10
+ return this.instance;
11
+ }
12
+ worker;
13
+ isParentReactNativeWebView;
14
+ constructor() {
15
+ // @ts-expect-error window.ReactNativeWebView will be provided by ReactNative WebView
16
+ this.isParentReactNativeWebView = !!window.ReactNativeWebView;
17
+ this.worker = this.isParentReactNativeWebView ? new PostMessageControllerNative() : new PostMessageControllerWeb();
18
+ }
19
+ sendAsync(data) {
20
+ return this.worker.sendAsync({
21
+ ...data,
22
+ iframeId: ClientParams.getInstance().iframeId,
23
+ });
24
+ }
25
+ async sendAsyncErrorSafe(data) {
26
+ try {
27
+ return await this.sendAsync(data);
28
+ }
29
+ catch (error) {
30
+ console.debug('send error - type:', error);
31
+ }
32
+ }
33
+ isPlatformNative() {
34
+ return this.isParentReactNativeWebView;
35
+ }
36
+ isPlatformWeb() {
37
+ return !this.isParentReactNativeWebView;
38
+ }
39
+ isOpenedFromXBees() {
40
+ return this.isParentReactNativeWebView || (!!parent && parent !== window);
41
+ }
42
+ }
@@ -0,0 +1,25 @@
1
+ import { ClientEventType } from '../enums';
2
+ import ClientParams from './ClientParams';
3
+ import PostMessageController from './PostMessageController';
4
+ class TechnicalSupport {
5
+ static instance = null;
6
+ static getInstance() {
7
+ if (!this.instance) {
8
+ this.instance = new TechnicalSupport();
9
+ }
10
+ return this.instance;
11
+ }
12
+ // eslint-disable-next-line
13
+ constructor() { }
14
+ sendTechnicalInformation(message, data) {
15
+ return PostMessageController.getInstance().sendAsyncErrorSafe({
16
+ type: ClientEventType.SEND_TECHNICAL_SUPPORT_INFORMATION,
17
+ payload: {
18
+ 'x-iframe-params': ClientParams.getInstance(),
19
+ message,
20
+ data,
21
+ },
22
+ });
23
+ }
24
+ }
25
+ export default TechnicalSupport;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import { EventType } from '../src/enums';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- import { EventType } from '../src/enums';
1
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { Callback, ConnectClient, Contact, ContactQuery, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, StorageEventCallback, SuggestContactsResolver, SupportedPlatformVariant, ToastSeverity } from '../types';
2
2
  import { ClientEventType, EventType } from './enums';
3
+ import TechnicalSupport from './helpers/TechnicalSupport';
3
4
  /**
4
5
  * Client provides functionality of communication between xBees and integrated web applications via iFrame or ReactNative WebView
5
6
  * integration creates na instance with new Client()
@@ -41,6 +42,7 @@ export declare class Client implements ConnectClient {
41
42
  getCurrentContact(): Promise<Message<ClientEventType.CURRENT_CONTACT>>;
42
43
  getCurrentConversation(): Promise<Message<ClientEventType.CURRENT_CONVERSATION>>;
43
44
  contactUpdated(query: ContactQuery, contact: Contact): Promise<Message<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
45
+ contactMatchUpdated(query: ContactQuery, contact: Contact): Promise<ResponseMessage<ClientEventType.CONTACT_MATCH_UPDATE>>;
44
46
  getThemeMode(): Promise<Message<ClientEventType.THEME_MODE>>;
45
47
  getTheme(): Promise<Message<ClientEventType.THEME>>;
46
48
  startCall(phoneNumber: string): Promise<Message<ClientEventType.START_CALL>>;
@@ -68,4 +70,5 @@ export declare class Client implements ConnectClient {
68
70
  onLogout(callback: Callback<EventType.LOGOUT>): RemoveEventListener;
69
71
  sendAnalytics(eventName: string, params?: Record<string, string>): void;
70
72
  setIntegrationStorageKey(integrationKey: string): void;
73
+ getTechnicalSupport(): TechnicalSupport;
71
74
  }
@@ -1,5 +1,3 @@
1
- export declare enum EventType1 {
2
- }
3
1
  export declare enum EventType {
4
2
  GET_CONTACTS_AUTO_SUGGEST = "xBeesGetContactsAutoSuggest",
5
3
  GET_LOOK_UP_AND_MATCH = "xBeesGetLookUpAndMatch",
@@ -29,10 +27,12 @@ export declare enum ClientEventType {
29
27
  CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch",
30
28
  CONTACT_LOOKUP_AND_MATCH_NOT_FOUND = "xBeesContactLookupAndMatchNotFound",
31
29
  CONTACT_CREATE_OR_UPDATE = "xBeesContactCreateOrUpdate",
30
+ CONTACT_MATCH_UPDATE = "xBeesContactMatchUpdate",
32
31
  CONTACTS_AUTO_SUGGEST_IS_SUPPORTED = "xBeesContactsAutoSuggestIsSupported",
33
32
  CONTACT_LOOK_UP_AND_MATCH_IS_SUPPORTED = "xBeesContactLookupAndMatchIsSupported",
34
33
  LOGOUT_IS_SUPPORTED = "xBeesLogoutIsSupported",
35
- SEND_ANALYTICS = "xBeesSendAnalytics"
34
+ SEND_ANALYTICS = "xBeesSendAnalytics",
35
+ SEND_TECHNICAL_SUPPORT_INFORMATION = "xBeesSendTechInfo"
36
36
  }
37
37
  export declare enum DeprecatedUrlParams {
38
38
  TOKEN = "token",
@@ -0,0 +1,13 @@
1
+ import { WorkVariants } from '../../types';
2
+ export default class ClientParams {
3
+ private static instance;
4
+ static getInstance(): ClientParams;
5
+ userToken: string;
6
+ readonly userEmail: string;
7
+ readonly referrer: string;
8
+ readonly needAuthorize: boolean;
9
+ readonly iframeId: string;
10
+ readonly variant: WorkVariants | null;
11
+ constructor();
12
+ toString(): string;
13
+ }
@@ -0,0 +1,14 @@
1
+ import { Callback, RemoveEventListener } from '../../types';
2
+ import { EventType } from '../enums';
3
+ export declare class MessageListener {
4
+ private static instance;
5
+ static getInstance(): MessageListener;
6
+ private listeners;
7
+ private useSubscription;
8
+ private constructor();
9
+ private parseMessage;
10
+ static parseJSON(messageData: string): any;
11
+ private onMessage;
12
+ listen<T extends EventType = EventType>(eventName: T, callback: Callback<T>): RemoveEventListener;
13
+ off<T extends EventType = EventType>(eventName: T | null, callback: Callback<T>): void;
14
+ }
@@ -0,0 +1,13 @@
1
+ import { Message, MessageType } from '../../types';
2
+ export default class PostMessageController {
3
+ private static instance;
4
+ static getInstance(): PostMessageController;
5
+ private worker;
6
+ private readonly isParentReactNativeWebView;
7
+ constructor();
8
+ sendAsync<T extends MessageType>(data: Message<T>): Promise<import("../../types").ResponseMessage<T>>;
9
+ sendAsyncErrorSafe<T extends MessageType>(data: Message<T>): Promise<import("../../types").ResponseMessage<T> | undefined>;
10
+ isPlatformNative(): boolean;
11
+ isPlatformWeb(): boolean;
12
+ isOpenedFromXBees(): boolean;
13
+ }
@@ -1,5 +1,5 @@
1
- import { MessageIFrameResponse, MessageType, PostMessageController, ResponseMessage } from '../../types';
2
- export default class PostMessageControllerNative implements PostMessageController {
1
+ import { MessageIFrameResponse, MessageSender, MessageType, ResponseMessage } from '../../types';
2
+ export default class PostMessageControllerNative implements MessageSender {
3
3
  private readonly target;
4
4
  private timeout;
5
5
  constructor();
@@ -1,5 +1,5 @@
1
- import { MessageIFrameResponse, MessageType, PostMessageController, ResponseMessage } from '../../types';
2
- export default class PostMessageControllerWeb implements PostMessageController {
1
+ import { MessageIFrameResponse, MessageSender, MessageType, ResponseMessage } from '../../types';
2
+ export default class PostMessageControllerWeb implements MessageSender {
3
3
  private readonly target;
4
4
  private timeout;
5
5
  constructor();
@@ -0,0 +1,9 @@
1
+ import { JSONArray, JSONObject } from '../../types';
2
+ import { ClientEventType } from '../enums';
3
+ declare class TechnicalSupport {
4
+ private static instance;
5
+ static getInstance(): TechnicalSupport;
6
+ private constructor();
7
+ sendTechnicalInformation(message: string, data?: JSONObject | JSONArray): Promise<import("../../types").ResponseMessage<ClientEventType.SEND_TECHNICAL_SUPPORT_INFORMATION> | undefined>;
8
+ }
9
+ export default TechnicalSupport;
@@ -0,0 +1,4 @@
1
+ import { EventType } from '../src/enums';
2
+ import { EventCallbackMap } from './Event';
3
+ export type DefaultCallback = (...args: unknown[]) => void;
4
+ export type Callback<T extends EventType = EventType> = T extends keyof EventCallbackMap ? EventCallbackMap[T] : DefaultCallback;
@@ -0,0 +1,154 @@
1
+ import { ClientEventType, EventType } from '../src/enums';
2
+ import TechnicalSupport from '../src/helpers/TechnicalSupport';
3
+ import { Callback } from './Callback';
4
+ import { Contact, ContactQuery } from './Contact';
5
+ import { RemoveEventListener } from './Listener';
6
+ import { ResponseMessage } from './Message';
7
+ import { IPayloadViewPort } from './Payload';
8
+ import { SupportedPlatformVariant } from './Platform';
9
+ import { LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
10
+ import { StorageEventCallback } from './Storage';
11
+ import { ToastSeverity } from './Toast';
12
+ export interface ConnectClient {
13
+ /**
14
+ * Sends to x-bees signal that iFrame is ready to be shown. iFrame should send it when the application starts and ready */
15
+ ready: (platform?: SupportedPlatformVariant) => Promise<ResponseMessage>;
16
+ /**
17
+ * Retrieves current pbx token */
18
+ getUserPbxToken: () => string;
19
+ /**
20
+ * Retrieves current user's email */
21
+ getUserEmail: () => string;
22
+ /**
23
+ * Retrieves url for x-bees app which uses integration */
24
+ getReferrer: () => string;
25
+ /**
26
+ * Retrieves url to get back to x-bees app integration */
27
+ getBackToAppUrl: () => string;
28
+ /**
29
+ * Retrieves the version of xBeesConnect */
30
+ version: () => string;
31
+ /**
32
+ * Determines x-bees is running on mobile native platform */
33
+ isPlatformNative: () => boolean;
34
+ /**
35
+ * Determines x-bees is running on web browser platform */
36
+ isPlatformWeb: () => boolean;
37
+ /**
38
+ * Determines application is opened as x-bees child in Browser iFrame or Native WebView */
39
+ isOpenedFromXBees: () => boolean;
40
+ /**
41
+ * Determines x-bees is using this connect for messages only and this integration will not be shown on UI */
42
+ isDataOnly: () => boolean;
43
+ /**
44
+ * Determines x-bees is using this connect for show dialog of setup flow */
45
+ isSetupDialog: () => boolean;
46
+ /**
47
+ * Determines x-bees is using this connect for representation on UI and this integration will be shown on UI
48
+ * this opposite to {@link isDataOnly} */
49
+ showsUi: () => boolean;
50
+ /**
51
+ * Determines x-bees is using this connect for activation/authorization on UI and this call of integration UI should show
52
+ * dialog which leads to integration be activated
53
+ * */
54
+ isActivationOnly: () => boolean;
55
+ /**
56
+ * Retrieves current x-bees context data */
57
+ getContext: () => Promise<ResponseMessage<ClientEventType.CONTEXT>>;
58
+ /**
59
+ * Retrieves current opened in x-bees contact data */
60
+ getCurrentContact: () => Promise<ResponseMessage<ClientEventType.CURRENT_CONTACT>>;
61
+ /**
62
+ * Retrieves current opened in x-bees conversation data or undefined if the conversation is temporary */
63
+ getCurrentConversation: () => Promise<ResponseMessage<ClientEventType.CURRENT_CONVERSATION>>;
64
+ /**
65
+ * Sends notification to x-bees about contact data updated */
66
+ contactUpdated(query: ContactQuery, contact: Contact): Promise<ResponseMessage<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
67
+ /**
68
+ * Sends notification to x-bees about contact match was updated */
69
+ contactMatchUpdated(query: ContactQuery, contact: Contact): Promise<ResponseMessage<ClientEventType.CONTACT_MATCH_UPDATE>>;
70
+ /**
71
+ * Retrieves current theme mode (light or dark) */
72
+ getThemeMode: () => Promise<ResponseMessage<ClientEventType.THEME_MODE>>;
73
+ /**
74
+ * Retrieves current theme with mode (light or dark) and theme options like typography settings and palette */
75
+ getTheme: () => Promise<ResponseMessage<ClientEventType.THEME>>;
76
+ /**
77
+ * Sends request to x-bees to start a call with the number */
78
+ startCall: (phoneNumber: string) => Promise<ResponseMessage>;
79
+ /**
80
+ * Sends request to x-bees to restart the iFrame, reload with actual params and token */
81
+ reboot: () => Promise<ResponseMessage>;
82
+ /**
83
+ * Sends request to x-bees about current frame size change */
84
+ setViewport: (payload: IPayloadViewPort) => Promise<ResponseMessage>;
85
+ /**
86
+ * Sends request to x-bees to put string to the users clipboard */
87
+ toClipboard: (payload: string) => Promise<ResponseMessage>;
88
+ /**
89
+ * Sends message to x-bees to be shown as a toast with specified severity level */
90
+ showToast: (message: string, severity?: ToastSeverity) => Promise<ResponseMessage>;
91
+ /**
92
+ * pushes to x-bees message that user is authorized and no more actions required */
93
+ isAuthorized: () => Promise<ResponseMessage>;
94
+ /**
95
+ * pushes to x-bees message that user actions required */
96
+ isNotAuthorized: () => Promise<ResponseMessage>;
97
+ /**
98
+ * Starts listen for one of the events of the x-bees and handle with the provided callback */
99
+ addEventListener: <T extends EventType = EventType>(eventName: T, callback: Callback<T>) => RemoveEventListener;
100
+ /**
101
+ * Stops listen for one of the events of the x-bees with this particular callback */
102
+ removeEventListener: <T extends EventType = EventType>(eventName: T, callback: Callback<T>) => void;
103
+ /**
104
+ * Starts listen for the events of changing theme and handle with the provided callback */
105
+ onThemeChange: (callback: Callback<EventType.USE_THEME>) => RemoveEventListener;
106
+ /**
107
+ * Starts listen for the events of changing pbx token and handle with the provided callback */
108
+ onPbxTokenChange: (callback: Callback<EventType.PBX_TOKEN>) => RemoveEventListener;
109
+ /**
110
+ * Retrieves current x-bees token */
111
+ getXBeesToken: () => Promise<ResponseMessage<ClientEventType.TOKEN>>;
112
+ /**
113
+ * Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */
114
+ onSuggestContacts: (callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void) => RemoveEventListener;
115
+ /**
116
+ * Starts listen for the events of searching contact info and handle match with the provided callback */
117
+ onLookupAndMatchContact: (callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void) => RemoveEventListener;
118
+ /**
119
+ * Starts listen for the events of starting the call and handle with the provided callback */
120
+ onCallStarted: (callback: Callback<EventType.ADD_CALL>) => RemoveEventListener;
121
+ /**
122
+ * Starts listen for the events of ending the call and handle with the provided callback */
123
+ onCallEnded: (callback: Callback<EventType.TERMINATE_CALL>) => RemoveEventListener;
124
+ /**
125
+ * Starts listen for redirect query message which fires when user opens app with deeplink to integration */
126
+ onRedirectQuery: (callback: Callback<EventType.REDIRECT_QUERY>) => RemoveEventListener;
127
+ /**
128
+ * Removes particular callback from handling events */
129
+ off: (callback: Callback | StorageEventCallback) => void;
130
+ /**
131
+ * saves data to localStorage */
132
+ saveToStorage: <SavingType>(key: string, value: SavingType) => void;
133
+ /**
134
+ * Retrieves data from localStorage */
135
+ getFromStorage: <Type>(key: string) => Type | null;
136
+ /**
137
+ * Removes data from localStorage */
138
+ deleteFromStorage: (key: string) => void;
139
+ /**
140
+ * Set parent integration key to switch to parent integration localStorage data */
141
+ setIntegrationStorageKey: (integrationKey: string) => void;
142
+ /**
143
+ * listens on localStorage */
144
+ onStorage: (listener: StorageEventCallback) => () => void;
145
+ /**
146
+ * starts listen on logout event and send event to the x-bees about logout able */
147
+ onLogout: (callback: Callback<EventType.LOGOUT>) => RemoveEventListener;
148
+ /**
149
+ * send analytics data to x-bees for track into analytics data */
150
+ sendAnalytics: (eventName: string, params?: Record<string, string>) => void;
151
+ /**
152
+ * special object to provide x-bees technical support */
153
+ getTechnicalSupport: () => TechnicalSupport;
154
+ }
@@ -0,0 +1,24 @@
1
+ interface ContactShape {
2
+ id: string;
3
+ name: string;
4
+ email?: string;
5
+ phone?: string;
6
+ mobileNumber?: string;
7
+ officeNumber?: string;
8
+ faxNumber?: string;
9
+ homeNumber?: string;
10
+ homeMobileNumber?: string;
11
+ extension?: string;
12
+ organization?: string;
13
+ }
14
+ export type Contact = (ContactShape & {
15
+ email: string;
16
+ }) | (ContactShape & {
17
+ phone: string;
18
+ });
19
+ export type ContactQuery = {
20
+ id?: string;
21
+ email?: string;
22
+ phone?: string;
23
+ };
24
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ClientEventType, EventType } from '../src/enums';
2
+ import { ContactQuery } from './Contact';
3
+ import { Message, MessageType } from './Message';
4
+ import { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
5
+ export 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 | ClientEventType.CONTACT_CREATE_OR_UPDATE | ClientEventType.CONTACT_MATCH_UPDATE ? IPayloadContactMatchResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH_NOT_FOUND ? IPayloadContactMatchResultNotFound : T extends ClientEventType.CONTEXT ? IPayloadContextResult : T extends ClientEventType.CURRENT_CONTACT ? IPayloadContactResult : T extends ClientEventType.CURRENT_CONVERSATION ? IPayloadConversationResult : 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 ClientEventType.SEND_ANALYTICS ? IPayloadSendAnalytics : T extends ClientEventType.SEND_TECHNICAL_SUPPORT_INFORMATION ? IPayloadTechSupport : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
6
+ export type EventPayloadMap = {
7
+ [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
8
+ [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
9
+ [EventType.ADD_CALL]: IPayloadCallStartedInfo;
10
+ [EventType.USE_THEME]: IPayloadThemeChange;
11
+ [EventType.PBX_TOKEN]: string;
12
+ [EventType.REDIRECT_QUERY]: string;
13
+ };
14
+ export type EventCallbackMap = {
15
+ [EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
16
+ [EventType.GET_LOOK_UP_AND_MATCH]: (query: EventPayloadMap[EventType.GET_LOOK_UP_AND_MATCH]) => void;
17
+ [EventType.ADD_CALL]: (callStartInfo: EventPayloadMap[EventType.ADD_CALL]) => void;
18
+ [EventType.USE_THEME]: (theme: EventPayloadMap[EventType.USE_THEME]) => void;
19
+ [EventType.PBX_TOKEN]: (token: EventPayloadMap[EventType.PBX_TOKEN]) => void;
20
+ [EventType.REDIRECT_QUERY]: (query: EventPayloadMap[EventType.REDIRECT_QUERY]) => void;
21
+ };
22
+ export type RawMessageEvent = MessageEvent<string | Message>;
@@ -0,0 +1,7 @@
1
+ type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
2
+ export interface JSONObject {
3
+ [key: string]: JSONValue;
4
+ }
5
+ export interface JSONArray extends Array<JSONValue> {
6
+ }
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { EventType } from '../src/enums';
2
+ import { Callback } from './Callback';
3
+ export interface Listener<T extends EventType = EventType> {
4
+ eventName: T;
5
+ callback: Callback<T>;
6
+ }
7
+ export type RemoveEventListener = () => void;
@@ -0,0 +1,14 @@
1
+ import { ClientEventType, EventType } from '../src/enums';
2
+ import { EventPayload } from './Event';
3
+ export type MessageType = ClientEventType | EventType;
4
+ export type Message<T extends MessageType = MessageType> = {
5
+ type: T;
6
+ payload?: EventPayload<T>;
7
+ };
8
+ export type MessageIFrameResponse<T extends MessageType = MessageType> = Message<T> & {
9
+ iframeId: string;
10
+ };
11
+ export type ErrorMessage = {
12
+ errorMessage?: string;
13
+ };
14
+ export type ResponseMessage<T extends MessageType = MessageType> = Message<T> & ErrorMessage;
@@ -0,0 +1,4 @@
1
+ import { MessageIFrameResponse, MessageType, ResponseMessage } from './Message';
2
+ export interface MessageSender {
3
+ sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
4
+ }
@@ -0,0 +1,60 @@
1
+ import ClientParams from '../src/helpers/ClientParams';
2
+ import { Contact, ContactQuery } from './Contact';
3
+ import { Conversation } from './conversation';
4
+ import { JSONArray, JSONObject } from './Json';
5
+ import { SupportedPlatformVariant } from './Platform';
6
+ import { ToastSeverity } from './Toast';
7
+ export interface IPayloadViewPort {
8
+ height: number | string;
9
+ width: number | string;
10
+ }
11
+ export interface IPayloadVersion {
12
+ version: string;
13
+ platform?: SupportedPlatformVariant;
14
+ }
15
+ export interface IPayloadToast {
16
+ severity: ToastSeverity;
17
+ message: string;
18
+ }
19
+ export interface IPayloadThemeChange {
20
+ mode: 'light' | 'dark';
21
+ themeOptions?: {
22
+ typography?: unknown;
23
+ palette?: unknown;
24
+ };
25
+ }
26
+ export interface IPayloadCallStartedInfo {
27
+ destination: string;
28
+ video: boolean;
29
+ }
30
+ export interface IPayloadCallStart {
31
+ phoneNumber: string;
32
+ }
33
+ export interface IPayloadAutoSuggestResult {
34
+ contacts: Contact[];
35
+ query: string;
36
+ }
37
+ export interface IPayloadContactMatchResult {
38
+ contact: Contact;
39
+ query: ContactQuery;
40
+ }
41
+ export interface IPayloadContactMatchResultNotFound {
42
+ query: ContactQuery;
43
+ }
44
+ export interface IPayloadContactResult {
45
+ contact: Contact;
46
+ }
47
+ export interface IPayloadConversationResult {
48
+ conversation?: Conversation;
49
+ }
50
+ export interface IPayloadContextResult extends IPayloadContactResult, IPayloadConversationResult {
51
+ }
52
+ export interface IPayloadSendAnalytics {
53
+ eventName: string;
54
+ params?: Record<string, string>;
55
+ }
56
+ export interface IPayloadTechSupport {
57
+ 'x-iframe-params': ClientParams;
58
+ message: string;
59
+ data?: JSONObject | JSONArray;
60
+ }
@@ -0,0 +1 @@
1
+ export type SupportedPlatformVariant = 'all' | 'web' | 'mobile';
@@ -0,0 +1,4 @@
1
+ import { Contact } from './Contact';
2
+ export type SuggestContactsResolver = (contacts: Contact[]) => void;
3
+ export type LookupAndMatchContactsResolver = (contact: Contact) => void;
4
+ export type Reject = (reason: string) => void;
@@ -0,0 +1 @@
1
+ export type StorageEventCallback = (event: StorageEvent) => void;
@@ -0,0 +1 @@
1
+ export type ToastSeverity = 'INFO' | 'WARNING' | 'ERROR' | 'SUCCESS' | 'NOTICE';
@@ -0,0 +1,3 @@
1
+ type DeprecatedWorkVariants = 'info-frame' | 'daemon' | 'dialog';
2
+ export type WorkVariants = 'ui' | 'no-ui' | 'd' | DeprecatedWorkVariants;
3
+ export {};
@@ -0,0 +1,4 @@
1
+ export type Conversation = {
2
+ id: string;
3
+ type: string;
4
+ };
@@ -1,263 +1,14 @@
1
- import { ClientEventType, EventType } from '../src/enums';
2
- export type MessageType = ClientEventType | EventType;
3
- interface ContactShape {
4
- id: string;
5
- name: string;
6
- email?: string;
7
- phone?: string;
8
- mobileNumber?: string;
9
- officeNumber?: string;
10
- faxNumber?: string;
11
- homeNumber?: string;
12
- homeMobileNumber?: string;
13
- extension?: string;
14
- organization?: string;
15
- }
16
- export type Contact = (ContactShape & {
17
- email: string;
18
- }) | (ContactShape & {
19
- phone: string;
20
- });
21
- export type Conversation = {
22
- id: string;
23
- type: string;
24
- };
25
- export type ContactQuery = {
26
- id?: string;
27
- email?: string;
28
- phone?: string;
29
- };
30
- export interface IPayloadViewPort {
31
- height: number | string;
32
- width: number | string;
33
- }
34
- export interface IPayloadVersion {
35
- version: string;
36
- platform?: SupportedPlatformVariant;
37
- }
38
- export type ToastSeverity = 'INFO' | 'WARNING' | 'ERROR' | 'SUCCESS' | 'NOTICE';
39
- export interface IPayloadToast {
40
- severity: ToastSeverity;
41
- message: string;
42
- }
43
- export interface IPayloadThemeChange {
44
- mode: 'light' | 'dark';
45
- themeOptions?: {
46
- typography?: unknown;
47
- palette?: unknown;
48
- };
49
- }
50
- export interface IPayloadCallStartedInfo {
51
- destination: string;
52
- video: boolean;
53
- }
54
- export interface IPayloadCallStart {
55
- phoneNumber: string;
56
- }
57
- export interface IPayloadAutoSuggestResult {
58
- contacts: Contact[];
59
- query: string;
60
- }
61
- export interface IPayloadContactMatchResult {
62
- contact: Contact;
63
- query: ContactQuery;
64
- }
65
- export interface IPayloadContactMatchResultNotFound {
66
- query: ContactQuery;
67
- }
68
- export interface IPayloadContactResult {
69
- contact: Contact;
70
- }
71
- export interface IPayloadConversationResult {
72
- conversation?: Conversation;
73
- }
74
- export interface IPayloadContextResult extends IPayloadContactResult, IPayloadConversationResult {
75
- }
76
- export interface IPayloadSendAnalytics {
77
- eventName: string;
78
- params?: Record<string, string>;
79
- }
80
- 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 ClientEventType.CURRENT_CONVERSATION ? IPayloadConversationResult : 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 ClientEventType.SEND_ANALYTICS ? IPayloadSendAnalytics : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
81
- export type Message<T extends MessageType = MessageType> = {
82
- type: T;
83
- payload?: EventPayload<T>;
84
- };
85
- export type ErrorMessage = {
86
- errorMessage?: string;
87
- };
88
- export type MessageIFrameResponse<T extends MessageType = MessageType> = Message<T> & {
89
- iframeId: string;
90
- };
91
- export type ResponseMessage<T extends MessageType = MessageType> = Message<T> & ErrorMessage;
92
- export type RawMessageEvent = MessageEvent<'string' | Message>;
93
- export type DefaultCallback = (...args: unknown[]) => void;
94
- export type EventPayloadMap = {
95
- [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
96
- [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
97
- [EventType.ADD_CALL]: IPayloadCallStartedInfo;
98
- [EventType.USE_THEME]: IPayloadThemeChange;
99
- [EventType.PBX_TOKEN]: string;
100
- [EventType.REDIRECT_QUERY]: string;
101
- };
102
- export type EventCallbackMap = {
103
- [EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
104
- [EventType.GET_LOOK_UP_AND_MATCH]: (query: EventPayloadMap[EventType.GET_LOOK_UP_AND_MATCH]) => void;
105
- [EventType.ADD_CALL]: (callStartInfo: EventPayloadMap[EventType.ADD_CALL]) => void;
106
- [EventType.USE_THEME]: (theme: EventPayloadMap[EventType.USE_THEME]) => void;
107
- [EventType.PBX_TOKEN]: (token: EventPayloadMap[EventType.PBX_TOKEN]) => void;
108
- [EventType.REDIRECT_QUERY]: (query: EventPayloadMap[EventType.REDIRECT_QUERY]) => void;
109
- };
110
- export type StorageEventCallback = (event: StorageEvent) => void;
111
- export type Callback<T extends EventType = EventType> = T extends keyof EventCallbackMap ? EventCallbackMap[T] : DefaultCallback;
112
- export interface Listener<T extends EventType = EventType> {
113
- eventName: T;
114
- callback: Callback<T>;
115
- }
116
- type DeprecatedWorkVariants = 'info-frame' | 'daemon' | 'dialog';
117
- export type WorkVariants = 'ui' | 'no-ui' | 'd' | DeprecatedWorkVariants;
118
- export interface PostMessageController {
119
- sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
120
- }
121
- export type SuggestContactsResolver = (contacts: Contact[]) => void;
122
- export type LookupAndMatchContactsResolver = (contact: Contact) => void;
123
- export type Reject = (reason: string) => void;
124
- export type RemoveEventListener = () => void;
125
- export type SupportedPlatformVariant = 'all' | 'web' | 'mobile';
126
- export interface ConnectClient {
127
- /**
128
- * Sends to x-bees signal that iFrame is ready to be shown. iFrame should send it when the application starts and ready */
129
- ready: (platform?: SupportedPlatformVariant) => Promise<ResponseMessage>;
130
- /**
131
- * Retrieves current pbx token */
132
- getUserPbxToken: () => string;
133
- /**
134
- * Retrieves current user's email */
135
- getUserEmail: () => string;
136
- /**
137
- * Retrieves url for x-bees app which uses integration */
138
- getReferrer: () => string;
139
- /**
140
- * Retrieves url to get back to x-bees app integration */
141
- getBackToAppUrl: () => string;
142
- /**
143
- * Retrieves the version of xBeesConnect */
144
- version: () => string;
145
- /**
146
- * Determines x-bees is running on mobile native platform */
147
- isPlatformNative: () => boolean;
148
- /**
149
- * Determines x-bees is running on web browser platform */
150
- isPlatformWeb: () => boolean;
151
- /**
152
- * Determines application is opened as x-bees child in Browser iFrame or Native WebView */
153
- isOpenedFromXBees: () => boolean;
154
- /**
155
- * Determines x-bees is using this connect for messages only and this integration will not be shown on UI */
156
- isDataOnly: () => boolean;
157
- /**
158
- * Determines x-bees is using this connect for show dialog of setup flow */
159
- isSetupDialog: () => boolean;
160
- /**
161
- * Determines x-bees is using this connect for representation on UI and this integration will be shown on UI
162
- * this opposite to {@link isDataOnly} */
163
- showsUi: () => boolean;
164
- /**
165
- * Determines x-bees is using this connect for activation/authorization on UI and this call of integration UI should show
166
- * dialog which leads to integration be activated
167
- * */
168
- isActivationOnly: () => boolean;
169
- /**
170
- * Retrieves current x-bees context data */
171
- getContext: () => Promise<Message<ClientEventType.CONTEXT>>;
172
- /**
173
- * Retrieves current opened in x-bees contact data */
174
- getCurrentContact: () => Promise<Message<ClientEventType.CURRENT_CONTACT>>;
175
- /**
176
- * Retrieves current opened in x-bees conversation data or undefined if the conversation is temporary */
177
- getCurrentConversation: () => Promise<Message<ClientEventType.CURRENT_CONVERSATION>>;
178
- /**
179
- * Sends notification to x-bees about contact data updated */
180
- contactUpdated(query: ContactQuery, contact: Contact): Promise<Message<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
181
- /**
182
- * Retrieves current theme mode (light or dark) */
183
- getThemeMode: () => Promise<Message<ClientEventType.THEME_MODE>>;
184
- /**
185
- * Retrieves current theme with mode (light or dark) and theme options like typography settings and palette */
186
- getTheme: () => Promise<Message<ClientEventType.THEME>>;
187
- /**
188
- * Sends request to x-bees to start a call with the number */
189
- startCall: (phoneNumber: string) => Promise<Message<ClientEventType.START_CALL>>;
190
- /**
191
- * Sends request to x-bees to restart the iFrame, reload with actual params and token */
192
- reboot: () => Promise<ResponseMessage>;
193
- /**
194
- * Sends request to x-bees about current frame size change */
195
- setViewport: (payload: IPayloadViewPort) => Promise<ResponseMessage>;
196
- /**
197
- * Sends request to x-bees to put string to the users clipboard */
198
- toClipboard: (payload: string) => Promise<ResponseMessage>;
199
- /**
200
- * Sends message to x-bees to be shown as a toast with specified severity level */
201
- showToast: (message: string, severity?: ToastSeverity) => Promise<ResponseMessage>;
202
- /**
203
- * pushes to x-bees message that user is authorized and no more actions required */
204
- isAuthorized: () => Promise<ResponseMessage>;
205
- /**
206
- * pushes to x-bees message that user actions required */
207
- isNotAuthorized: () => Promise<ResponseMessage>;
208
- /**
209
- * Starts listen for one of the events of the x-bees and handle with the provided callback */
210
- addEventListener: <T extends EventType = EventType>(eventName: T, callback: Callback<T>) => RemoveEventListener;
211
- /**
212
- * Stops listen for one of the events of the x-bees with this particular callback */
213
- removeEventListener: <T extends EventType = EventType>(eventName: T, callback: Callback<T>) => void;
214
- /**
215
- * Starts listen for the events of changing theme and handle with the provided callback */
216
- onThemeChange: (callback: Callback<EventType.USE_THEME>) => RemoveEventListener;
217
- /**
218
- * Starts listen for the events of changing pbx token and handle with the provided callback */
219
- onPbxTokenChange: (callback: Callback<EventType.PBX_TOKEN>) => RemoveEventListener;
220
- /**
221
- * Retrieves current x-bees token */
222
- getXBeesToken: () => Promise<Message<ClientEventType.TOKEN>>;
223
- /**
224
- * Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */
225
- onSuggestContacts: (callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void) => RemoveEventListener;
226
- /**
227
- * Starts listen for the events of searching contact info and handle match with the provided callback */
228
- onLookupAndMatchContact: (callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void) => RemoveEventListener;
229
- /**
230
- * Starts listen for the events of starting the call and handle with the provided callback */
231
- onCallStarted: (callback: Callback<EventType.ADD_CALL>) => RemoveEventListener;
232
- /**
233
- * Starts listen for the events of ending the call and handle with the provided callback */
234
- onCallEnded: (callback: Callback<EventType.TERMINATE_CALL>) => RemoveEventListener;
235
- /**
236
- * Starts listen for redirect query message which fires when user opens app with deeplink to integration */
237
- onRedirectQuery: (callback: Callback<EventType.REDIRECT_QUERY>) => RemoveEventListener;
238
- /**
239
- * Removes particular callback from handling events */
240
- off: (callback: Callback | StorageEventCallback) => void;
241
- /**
242
- * saves data to localStorage */
243
- saveToStorage: <SavingType>(key: string, value: SavingType) => void;
244
- /**
245
- * Retrieves data from localStorage */
246
- getFromStorage: <Type>(key: string) => Type | null;
247
- /**
248
- * Removes data from localStorage */
249
- deleteFromStorage: (key: string) => void;
250
- /**
251
- * Set parent integration key to switch to parent integration localStorage data */
252
- setIntegrationStorageKey: (integrationKey: string) => void;
253
- /**
254
- * listens on localStorage */
255
- onStorage: (listener: StorageEventCallback) => () => void;
256
- /**
257
- * starts listen on logout event and send event to the xbees about logout able */
258
- onLogout: (callback: Callback<EventType.LOGOUT>) => RemoveEventListener;
259
- /**
260
- * send analytics data to xbees for track into analytics data */
261
- sendAnalytics: (eventName: string, params?: Record<string, string>) => void;
262
- }
263
- export {};
1
+ export type { Callback } from './Callback';
2
+ export type { ConnectClient } from './Client';
3
+ export type { Contact, ContactQuery } from './Contact';
4
+ export type { EventPayloadMap, RawMessageEvent } from './Event';
5
+ export type { JSONArray, JSONObject } from './Json';
6
+ export type { Listener, RemoveEventListener } from './Listener';
7
+ export type { Message, MessageIFrameResponse, MessageType, ResponseMessage } from './Message';
8
+ export type { MessageSender } from './MessageSender';
9
+ export type { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort, } from './Payload';
10
+ export type { SupportedPlatformVariant } from './Platform';
11
+ export type { LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
12
+ export type { StorageEventCallback } from './Storage';
13
+ export type { ToastSeverity } from './Toast';
14
+ export type { WorkVariants } from './WorkVariant';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.1.21",
3
+ "version": "1.2.0-alpha.10",
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": "48e2a82b88e4228028e3d0e0470d06aa3c20a1df"
45
+ "gitHead": "0b96d918e6bee6ddf1a5f7e8c7a86a20f3ae3c72"
46
46
  }