@wildix/xbees-connect 1.0.6-alpha.0 → 1.0.6-alpha.1

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
@@ -57,6 +57,21 @@ Client.getInstance().onSuggestContacts(async (query, resolve) => {
57
57
  });
58
58
  ```
59
59
 
60
+ #### `onLookupAndMatchContact: ((query: ContactQuery, resolve: Resolve, reject: Reject) => void) => RemoveEventListener`
61
+
62
+ Starts listen for the events of searching contact info and handle match with the provided callback
63
+
64
+ ```jsx
65
+ Client.getInstance().onLookupAndMatchContact(async (query, resolve) => {
66
+ try {
67
+ const contact = await fetchContactAndMatch(query);
68
+ resolve(contact);
69
+ } catch (error) {
70
+ console.log('catch', error);
71
+ }
72
+ });
73
+ ```
74
+
60
75
  ### Context
61
76
  #### `getContext(): Promise<Response>`
62
77
 
package/dist-es/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import { Client } from './src/Client';
2
+ export * from './src/types';
2
3
  export default Client;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.0.5",
3
+ "version": "1.0.6-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": "",
@@ -1,7 +1,7 @@
1
1
  import packageJson from '../package.json';
2
2
  import PostMessageControllerNative from './helpers/PostMessageControllerNative';
3
3
  import PostMessageControllerWeb from './helpers/PostMessageControllerWeb';
4
- import { ClientEventType, EventType, } from './types';
4
+ import { ClientEventType, EventType, UrlParams, } from './types';
5
5
  /**
6
6
  * Client provides functionality of communication between xBees and integrated web applications via iFrame or ReactNative WebView
7
7
  * integration creates na instance with new Client()
@@ -30,16 +30,25 @@ export class Client {
30
30
  worker;
31
31
  listeners = [];
32
32
  useSubscription = false;
33
+ userToken;
34
+ userEmail;
35
+ referrer;
36
+ needAuthorize;
33
37
  iframeId;
34
38
  variant = null;
35
39
  constructor() {
36
40
  const params = new URLSearchParams(window.location.search);
37
- this.iframeId = params.get('iframeId');
38
- this.variant = params.get('variant');
41
+ this.iframeId = params.get(UrlParams.ID);
42
+ this.variant = params.get(UrlParams.VARIANT);
43
+ this.userEmail = params.get(UrlParams.USER);
44
+ this.userToken = params.get(UrlParams.TOKEN);
45
+ this.referrer = params.get(UrlParams.REFERRER);
46
+ this.needAuthorize = params.has(UrlParams.AUTHORIZE);
39
47
  // @ts-expect-error window.ReactNativeWebView will be provided by ReactNative WebView
40
48
  this.worker = window.ReactNativeWebView
41
49
  ? new PostMessageControllerNative()
42
50
  : new PostMessageControllerWeb();
51
+ this.addEventListener(EventType.PBX_TOKEN, (token) => this.userToken = token);
43
52
  }
44
53
  sendAsync(data) {
45
54
  return this.worker.sendAsync({
@@ -49,7 +58,9 @@ export class Client {
49
58
  }
50
59
  parseMessage(message) {
51
60
  try {
52
- const data = typeof message.data === 'string' ? JSON.parse(message.data) : message.data;
61
+ const data = typeof message.data === 'string'
62
+ ? JSON.parse(message.data)
63
+ : message.data;
53
64
  if (!data?.type) {
54
65
  return null;
55
66
  }
@@ -89,11 +100,20 @@ export class Client {
89
100
  version() {
90
101
  return packageJson.version;
91
102
  }
92
- isDaemon() {
93
- return this.variant === 'daemon';
103
+ getUserPbxToken() {
104
+ return this.userToken;
105
+ }
106
+ getUserEmail() {
107
+ return this.userEmail;
108
+ }
109
+ isDataOnly() {
110
+ return this.variant === 'd';
94
111
  }
95
112
  showsUi() {
96
- return !this.isDaemon();
113
+ return !this.isDataOnly();
114
+ }
115
+ isActivationOnly() {
116
+ return this.needAuthorize;
97
117
  }
98
118
  getContext() {
99
119
  return this.sendAsync({ type: ClientEventType.CONTEXT });
@@ -128,12 +148,18 @@ export class Client {
128
148
  isAuthorized() {
129
149
  return this.sendAsync({ type: ClientEventType.AUTHORIZED });
130
150
  }
131
- getContactsAutoSuggest(payload) {
151
+ sendContactsAutoSuggest(payload) {
132
152
  return this.sendAsync({
133
153
  type: ClientEventType.CONTACTS_AUTO_SUGGEST,
134
154
  payload,
135
155
  });
136
156
  }
157
+ sendContactMatch(payload) {
158
+ return this.sendAsync({
159
+ type: ClientEventType.CONTACT_LOOKUP_AND_MATCH,
160
+ payload,
161
+ });
162
+ }
137
163
  addEventListener(eventName, callback) {
138
164
  if (!this.useSubscription) {
139
165
  this.useSubscription = true;
@@ -187,6 +213,26 @@ export class Client {
187
213
  }
188
214
  });
189
215
  }
216
+ onLookupAndMatchContact(callback) {
217
+ return this.addEventListener(EventType.GET_LOOK_UP_AND_MATCH, (query) => {
218
+ const resolve = (contact) => this.sendAsync({
219
+ type: ClientEventType.CONTACT_LOOKUP_AND_MATCH,
220
+ payload: {
221
+ contact,
222
+ query,
223
+ },
224
+ });
225
+ const reject = (reason) => {
226
+ console.debug(reason);
227
+ };
228
+ try {
229
+ callback(query, resolve, reject);
230
+ }
231
+ catch (error) {
232
+ reject(`${error}`);
233
+ }
234
+ });
235
+ }
190
236
  onThemeChange(callback) {
191
237
  this.addEventListener(EventType.USE_THEME, callback);
192
238
  }
@@ -1,6 +1,7 @@
1
1
  export var EventType;
2
2
  (function (EventType) {
3
3
  EventType["GET_CONTACTS_AUTO_SUGGEST"] = "xBeesGetContactsAutoSuggest";
4
+ EventType["GET_LOOK_UP_AND_MATCH"] = "xBeesGetLookUpAndMatch";
4
5
  EventType["ADD_CALL"] = "xBeesAddCall";
5
6
  EventType["TERMINATE_CALL"] = "xBeesTerminateCall";
6
7
  EventType["USE_THEME"] = "xBeesUseTheme";
@@ -20,4 +21,14 @@ export var ClientEventType;
20
21
  ClientEventType["NOT_AUTHORIZED"] = "xBeesNotAuthorized";
21
22
  ClientEventType["AUTHORIZED"] = "xBeesAuthorized";
22
23
  ClientEventType["CONTACTS_AUTO_SUGGEST"] = "xBeesContactsAutoSuggest";
24
+ ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
23
25
  })(ClientEventType || (ClientEventType = {}));
26
+ export var UrlParams;
27
+ (function (UrlParams) {
28
+ UrlParams["TOKEN"] = "t";
29
+ UrlParams["ID"] = "i";
30
+ UrlParams["VARIANT"] = "v";
31
+ UrlParams["USER"] = "u";
32
+ UrlParams["REFERRER"] = "r";
33
+ UrlParams["AUTHORIZE"] = "a";
34
+ })(UrlParams || (UrlParams = {}));
@@ -1,2 +1,3 @@
1
1
  import { Client } from './src/Client';
2
+ export * from './src/types';
2
3
  export default Client;
@@ -1,42 +1,51 @@
1
- import { AutoSuggestResult, Callback, ConnectClient, EventType, Reject, RemoveEventListener, Resolve, Response, ViewPortSize } from './types';
1
+ import { Callback, ClientEventType, ConnectClient, ContactQuery, EventType, IPayloadAutoSuggestResult, IPayloadContactMatchResult, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, SuggestContactsResolver } from './types';
2
2
  /**
3
3
  * Client provides functionality of communication between xBees and integrated web applications via iFrame or ReactNative WebView
4
4
  * integration creates na instance with new Client()
5
5
  * */
6
6
  export declare class Client implements ConnectClient {
7
7
  private static instance;
8
- static getInstance(): Client;
8
+ static getInstance(): ConnectClient;
9
9
  static initialize(renderer: () => Promise<void>): void;
10
10
  private worker;
11
11
  private listeners;
12
12
  private useSubscription;
13
+ private userToken;
14
+ private readonly userEmail;
15
+ private readonly referrer;
16
+ private readonly needAuthorize;
13
17
  private readonly iframeId;
14
18
  private readonly variant;
15
19
  constructor();
16
20
  private sendAsync;
17
21
  private parseMessage;
18
22
  private onMessage;
19
- ready(): Promise<Response>;
23
+ ready(): Promise<ResponseMessage<ClientEventType.READY>>;
20
24
  version(): string;
21
- isDaemon(): boolean;
25
+ getUserPbxToken(): string;
26
+ getUserEmail(): string;
27
+ isDataOnly(): boolean;
22
28
  showsUi(): boolean;
23
- getContext(): Promise<Response>;
24
- getCurrentContact(): Promise<Response>;
25
- getThemeMode(): Promise<Response>;
26
- getTheme(): Promise<Response>;
27
- startCall(phoneNumber: string): Promise<Response>;
28
- reboot(): Promise<Response>;
29
- setViewport(payload: ViewPortSize): Promise<Response>;
30
- toClipboard(payload: string): Promise<Response>;
31
- isNotAuthorized(): Promise<Response>;
32
- isAuthorized(): Promise<Response>;
33
- getContactsAutoSuggest(payload: AutoSuggestResult): Promise<Response>;
29
+ isActivationOnly(): boolean;
30
+ getContext(): Promise<Message<ClientEventType.CONTEXT>>;
31
+ getCurrentContact(): Promise<Message<ClientEventType.CURRENT_CONTACT>>;
32
+ getThemeMode(): Promise<Message<ClientEventType.THEME_MODE>>;
33
+ getTheme(): Promise<Message<ClientEventType.THEME>>;
34
+ startCall(phoneNumber: string): Promise<Message<ClientEventType.START_CALL>>;
35
+ reboot(): Promise<ResponseMessage>;
36
+ setViewport(payload: IPayloadViewPort): Promise<ResponseMessage>;
37
+ toClipboard(payload: string): Promise<ResponseMessage>;
38
+ isNotAuthorized(): Promise<ResponseMessage>;
39
+ isAuthorized(): Promise<ResponseMessage>;
40
+ sendContactsAutoSuggest(payload: IPayloadAutoSuggestResult): Promise<Message<ClientEventType.CONTACTS_AUTO_SUGGEST>>;
41
+ sendContactMatch(payload: IPayloadContactMatchResult): Promise<Message<ClientEventType.CONTACT_LOOKUP_AND_MATCH>>;
34
42
  addEventListener<T extends EventType = EventType>(eventName: T, callback: Callback<T>): RemoveEventListener;
35
43
  removeEventListener<T extends EventType = EventType>(eventName: T | null, callback: Callback<T>): void;
36
44
  off(callback: Callback): void;
37
45
  onCallEnded(callback: Callback<EventType.TERMINATE_CALL>): void;
38
46
  onCallStarted(callback: Callback<EventType.ADD_CALL>): void;
39
47
  onPbxTokenChange(callback: Callback<EventType.PBX_TOKEN>): void;
40
- onSuggestContacts(callback: (query: string, resolve: Resolve, reject: Reject) => void): RemoveEventListener;
48
+ onSuggestContacts(callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void): RemoveEventListener;
49
+ onLookupAndMatchContact(callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void): RemoveEventListener;
41
50
  onThemeChange(callback: Callback<EventType.USE_THEME>): void;
42
51
  }
@@ -1,8 +1,8 @@
1
- import { MessageResponse, PostMessageController, Response } from '../types';
1
+ import { MessageIFrameResponse, MessageType, PostMessageController, ResponseMessage } from '../types';
2
2
  export default class PostMessageControllerNative implements PostMessageController {
3
3
  private readonly target;
4
4
  private timeout;
5
5
  constructor();
6
- sendAsync(data: MessageResponse): Promise<Response>;
6
+ sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
7
7
  private send;
8
8
  }
@@ -1,8 +1,8 @@
1
- import { MessageResponse, PostMessageController, Response } from '../types';
1
+ import { MessageIFrameResponse, MessageType, PostMessageController, ResponseMessage } from '../types';
2
2
  export default class PostMessageControllerWeb implements PostMessageController {
3
3
  private readonly target;
4
4
  private timeout;
5
5
  constructor();
6
- sendAsync(data: MessageResponse): Promise<Response>;
6
+ sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
7
7
  private send;
8
8
  }
@@ -1,5 +1,6 @@
1
1
  export declare enum EventType {
2
2
  GET_CONTACTS_AUTO_SUGGEST = "xBeesGetContactsAutoSuggest",
3
+ GET_LOOK_UP_AND_MATCH = "xBeesGetLookUpAndMatch",
3
4
  ADD_CALL = "xBeesAddCall",
4
5
  TERMINATE_CALL = "xBeesTerminateCall",
5
6
  USE_THEME = "xBeesUseTheme",
@@ -17,7 +18,8 @@ export declare enum ClientEventType {
17
18
  TO_CLIPBOARD = "xBeesToClipboard",
18
19
  NOT_AUTHORIZED = "xBeesNotAuthorized",
19
20
  AUTHORIZED = "xBeesAuthorized",
20
- CONTACTS_AUTO_SUGGEST = "xBeesContactsAutoSuggest"
21
+ CONTACTS_AUTO_SUGGEST = "xBeesContactsAutoSuggest",
22
+ CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch"
21
23
  }
22
24
  export type MessageType = ClientEventType | EventType;
23
25
  interface ContactShape {
@@ -38,56 +40,73 @@ export type Contact = (ContactShape & {
38
40
  }) | (ContactShape & {
39
41
  phone: string;
40
42
  });
41
- export type ViewPortSize = {
42
- height: number;
43
- width: number;
43
+ export type ContactQuery = {
44
+ email: string;
45
+ phone?: string;
46
+ } | {
47
+ email?: string;
48
+ phone: string;
49
+ } | {
50
+ id: string;
44
51
  };
45
- type EventPayload<T extends MessageType> = T extends EventType.GET_CONTACTS_AUTO_SUGGEST ? string : T extends ClientEventType.CONTACTS_AUTO_SUGGEST ? AutoSuggestResult : T extends EventType.ADD_CALL ? CallStartInfo : T extends ClientEventType.START_CALL ? StartCallPayload : T extends ClientEventType.READY ? {
52
+ export interface IPayloadViewPort {
53
+ height: number | string;
54
+ width: number | string;
55
+ }
56
+ export interface IPayloadVersion {
46
57
  version: string;
47
- } : T extends ClientEventType.VIEW_PORT ? ViewPortSize : T extends EventType.USE_THEME ? string : T extends EventType.PBX_TOKEN ? string : never;
48
- export type Message<T extends MessageType = MessageType> = {
49
- type: T;
50
- payload?: EventPayload<T>;
51
- };
52
- export type MessageResponse<T extends MessageType = MessageType> = Message<T> & {
53
- iframeId: string;
54
- };
55
- export type Payload = string | Record<string, string> | ThemeChangePayload;
56
- export type Response<T extends Payload = Payload> = {
57
- type?: string;
58
- message?: string;
59
- errorMessage?: string;
60
- payload?: T;
61
- };
62
- export type RawMessageEvent = MessageEvent<'string' | Message>;
63
- export type SendPayload = {
64
- type: ClientEventType;
65
- payload?: any;
66
- };
67
- export type ThemeChangePayload = {
58
+ }
59
+ export interface IPayloadThemeChange {
68
60
  mode: 'light' | 'dark';
69
61
  themeOptions?: {
70
62
  typography?: unknown;
71
63
  palette?: unknown;
72
64
  };
73
- };
74
- export type ListenerCallback = (payload: unknown) => void;
75
- export type DefaultCallback = (...args: unknown[]) => void;
76
- type CallStartInfo = {
65
+ }
66
+ export interface IPayloadCallStartedInfo {
77
67
  destination: string;
78
68
  video: boolean;
79
- };
80
- type StartCallPayload = {
69
+ }
70
+ export interface IPayloadCallStart {
81
71
  phoneNumber: string;
72
+ }
73
+ export interface IPayloadAutoSuggestResult {
74
+ contacts: Contact[];
75
+ query: string;
76
+ }
77
+ export interface IPayloadContactMatchResult {
78
+ contact: Contact;
79
+ query: ContactQuery;
80
+ }
81
+ export interface IPayloadContactResult {
82
+ contact: Contact;
83
+ }
84
+ export interface IPayloadContextResult extends IPayloadContactResult {
85
+ }
86
+ 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.CONTEXT ? IPayloadContextResult : 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 ? string : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
87
+ export type Message<T extends MessageType = MessageType> = {
88
+ type: T;
89
+ payload?: EventPayload<T>;
90
+ };
91
+ export type ErrorMessage = {
92
+ errorMessage: string;
93
+ };
94
+ export type MessageIFrameResponse<T extends MessageType = MessageType> = Message<T> & {
95
+ iframeId: string;
82
96
  };
97
+ export type ResponseMessage<T extends MessageType = MessageType> = Message<T> & ErrorMessage;
98
+ export type RawMessageEvent = MessageEvent<'string' | Message>;
99
+ export type DefaultCallback = (...args: unknown[]) => void;
83
100
  export type EventPayloadMap = {
84
101
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
85
- [EventType.ADD_CALL]: CallStartInfo;
86
- [EventType.USE_THEME]: string | ThemeChangePayload;
102
+ [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
103
+ [EventType.ADD_CALL]: IPayloadCallStartedInfo;
104
+ [EventType.USE_THEME]: string | IPayloadThemeChange;
87
105
  [EventType.PBX_TOKEN]: string;
88
106
  };
89
107
  export type EventCallbackMap = {
90
108
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
109
+ [EventType.GET_LOOK_UP_AND_MATCH]: (query: EventPayloadMap[EventType.GET_LOOK_UP_AND_MATCH]) => void;
91
110
  [EventType.ADD_CALL]: (callStartInfo: EventPayloadMap[EventType.ADD_CALL]) => void;
92
111
  [EventType.USE_THEME]: (themeName: EventPayloadMap[EventType.USE_THEME]) => void;
93
112
  [EventType.PBX_TOKEN]: (token: EventPayloadMap[EventType.PBX_TOKEN]) => void;
@@ -103,72 +122,88 @@ export type ClientEventCallbackMap = {
103
122
  [ClientEventType.AUTHORIZED]: () => void;
104
123
  [ClientEventType.CONTACTS_AUTO_SUGGEST]: (suggestions: string[]) => void;
105
124
  };
106
- export interface ReactNativeWebView {
107
- postMessage: (payload: unknown, origin?: string, d?: unknown[]) => void;
108
- }
109
125
  export type Callback<T extends EventType = EventType> = T extends keyof EventCallbackMap ? EventCallbackMap[T] : DefaultCallback;
110
126
  export interface Listener<T extends EventType = EventType> {
111
127
  eventName: T;
112
128
  callback: Callback<T>;
113
129
  }
114
- export type WorkVariants = 'info-frame' | 'daemon' | 'dialog';
115
- export interface AutoSuggestResult {
116
- contacts: Contact[];
117
- query: string;
130
+ export declare enum UrlParams {
131
+ TOKEN = "t",
132
+ ID = "i",
133
+ VARIANT = "v",
134
+ USER = "u",
135
+ REFERRER = "r",
136
+ AUTHORIZE = "a"
118
137
  }
138
+ export type WorkVariants = 'ui' | 'no-ui' | 'd';
119
139
  export interface PostMessageController {
120
- sendAsync(data: MessageResponse): Promise<Response>;
140
+ sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
121
141
  }
122
- export type Resolve = (contacts: Contact[]) => void;
142
+ export type SuggestContactsResolver = (contacts: Contact[]) => void;
143
+ export type LookupAndMatchContactsResolver = (contact: Contact) => void;
123
144
  export type Reject = (reason: string) => void;
124
145
  export type RemoveEventListener = () => void;
125
146
  export interface ConnectClient {
126
147
  /**
127
148
  * Sends to x-bees signal that iFrame is ready to be shown. iFrame should send it when the application starts and ready */
128
- ready: () => Promise<Response>;
149
+ ready: () => Promise<ResponseMessage>;
150
+ /**
151
+ * Retrieves current pbx token */
152
+ getUserPbxToken: () => string;
153
+ /**
154
+ * Retrieves current user's email */
155
+ getUserEmail: () => string;
129
156
  /**
130
157
  * Retrieves the version of xBeesConnect */
131
158
  version: () => string;
132
159
  /**
133
160
  * Determines x-bees is using this connect for messages only and this integration will not be shown on UI */
134
- isDaemon: () => boolean;
161
+ isDataOnly: () => boolean;
135
162
  /**
136
163
  * Determines x-bees is using this connect for representation on UI and this integration will be shown on UI
137
- * this opposite to {@link isDaemon} */
164
+ * this opposite to {@link isDataOnly} */
138
165
  showsUi: () => boolean;
166
+ /**
167
+ * Determines x-bees is using this connect for activation/authorization on UI and this call of integration UI should show
168
+ * dialog which leads to integration be activated
169
+ * */
170
+ isActivationOnly: () => boolean;
139
171
  /**
140
172
  * Retrieves current x-bees context data */
141
- getContext: () => Promise<Response>;
173
+ getContext: () => Promise<Message<ClientEventType.CONTEXT>>;
142
174
  /**
143
175
  * Retrieves current opened in x-bees contact data */
144
- getCurrentContact: () => Promise<Response>;
176
+ getCurrentContact: () => Promise<Message<ClientEventType.CURRENT_CONTACT>>;
145
177
  /**
146
178
  * Retrieves current theme mode (light or dark) */
147
- getThemeMode: () => Promise<Response>;
179
+ getThemeMode: () => Promise<Message<ClientEventType.THEME_MODE>>;
148
180
  /**
149
181
  * Retrieves current theme with mode (light or dark) and theme options like typography settings and palette */
150
- getTheme: () => Promise<Response>;
182
+ getTheme: () => Promise<Message<ClientEventType.THEME>>;
151
183
  /**
152
184
  * Sends request to x-bees to start a call with the number */
153
- startCall: (phoneNumber: string) => Promise<Response>;
185
+ startCall: (phoneNumber: string) => Promise<Message<ClientEventType.START_CALL>>;
154
186
  /**
155
187
  * Sends request to x-bees to restart the iFrame, reload with actual params and token */
156
- reboot: () => Promise<Response>;
188
+ reboot: () => Promise<ResponseMessage>;
157
189
  /**
158
190
  * Sends request to x-bees about current frame size change */
159
- setViewport: (payload: ViewPortSize) => Promise<Response>;
191
+ setViewport: (payload: IPayloadViewPort) => Promise<ResponseMessage>;
160
192
  /**
161
193
  * Sends request to x-bees to put string to the users clipboard */
162
- toClipboard: (payload: string) => Promise<Response>;
194
+ toClipboard: (payload: string) => Promise<ResponseMessage>;
163
195
  /**
164
196
  * Sends a response to x-bees for contacts autoSuggest */
165
- getContactsAutoSuggest: (payload: AutoSuggestResult) => Promise<Response>;
197
+ sendContactsAutoSuggest: (payload: IPayloadAutoSuggestResult) => Promise<Message<ClientEventType.CONTACTS_AUTO_SUGGEST>>;
198
+ /**
199
+ * Sends a response to x-bees for contact match */
200
+ sendContactMatch: (payload: IPayloadContactMatchResult) => Promise<Message<ClientEventType.CONTACT_LOOKUP_AND_MATCH>>;
166
201
  /**
167
202
  * pushes to x-bees message that user is authorized and no more actions required */
168
- isAuthorized: () => Promise<Response>;
203
+ isAuthorized: () => Promise<ResponseMessage>;
169
204
  /**
170
205
  * pushes to x-bees message that user actions required */
171
- isNotAuthorized: () => Promise<Response>;
206
+ isNotAuthorized: () => Promise<ResponseMessage>;
172
207
  /**
173
208
  * Starts listen for one of the events of the x-bees and handle with the provided callback */
174
209
  addEventListener: <T extends EventType = EventType>(eventName: T, callback: Callback<T>) => RemoveEventListener;
@@ -183,7 +218,10 @@ export interface ConnectClient {
183
218
  onPbxTokenChange: (callback: Callback<EventType.PBX_TOKEN>) => void;
184
219
  /**
185
220
  * Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */
186
- onSuggestContacts: (callback: (query: string, resolve: Resolve, reject: Reject) => void) => RemoveEventListener;
221
+ onSuggestContacts: (callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void) => RemoveEventListener;
222
+ /**
223
+ * Starts listen for the events of searching contact info and handle match with the provided callback */
224
+ onLookupAndMatchContact: (callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void) => RemoveEventListener;
187
225
  /**
188
226
  * Starts listen for the events of starting the call and handle with the provided callback */
189
227
  onCallStarted: (callback: Callback<EventType.ADD_CALL>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.0.6-alpha.0",
3
+ "version": "1.0.6-alpha.1",
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": "",
@@ -41,5 +41,5 @@
41
41
  "engines": {
42
42
  "node": ">=16"
43
43
  },
44
- "gitHead": "e0b53be49487f418b06dd171a3068b9ffefe6197"
44
+ "gitHead": "49f97f25e700f11a7f2a04f3a386d474c9f01395"
45
45
  }