@wildix/xbees-connect 1.2.29 → 1.2.30

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.
@@ -339,6 +339,33 @@ class Client {
339
339
  }
340
340
  });
341
341
  }
342
+ onLookupAndMatchBatchContacts(callback) {
343
+ // send event to x-bees
344
+ void this.sendAsyncErrorSafe({
345
+ type: enums_1.ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS_IS_SUPPORTED,
346
+ });
347
+ return this.addEventListener(enums_1.EventType.GET_LOOK_UP_AND_MATCH_BATCH, (queries) => {
348
+ const returnResults = (contactResultsMap) => this.sendAsync({
349
+ type: enums_1.ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS,
350
+ payload: {
351
+ contactResultsMap: Array.from(contactResultsMap),
352
+ },
353
+ });
354
+ const reject = (reason) => {
355
+ console.debug(reason);
356
+ void this.sendAsync({
357
+ type: enums_1.ClientEventType.LOOKUP_AND_MATCH_BATCH_ERROR,
358
+ payload: { reason },
359
+ });
360
+ };
361
+ try {
362
+ callback(queries, returnResults);
363
+ }
364
+ catch (error) {
365
+ reject(`${error}`);
366
+ }
367
+ });
368
+ }
342
369
  onThemeChange(callback) {
343
370
  return this.addEventListener(enums_1.EventType.USE_THEME, callback);
344
371
  }
@@ -5,6 +5,7 @@ var EventType;
5
5
  (function (EventType) {
6
6
  EventType["GET_CONTACTS_AUTO_SUGGEST"] = "xBeesGetContactsAutoSuggest";
7
7
  EventType["GET_LOOK_UP_AND_MATCH"] = "xBeesGetLookUpAndMatch";
8
+ EventType["GET_LOOK_UP_AND_MATCH_BATCH"] = "xBeesGetLookUpAndMatchBatch";
8
9
  EventType["ADD_CALL"] = "xBeesAddCall";
9
10
  EventType["TERMINATE_CALL"] = "xBeesTerminateCall";
10
11
  EventType["USE_THEME"] = "xBeesUseTheme";
@@ -31,11 +32,14 @@ var ClientEventType;
31
32
  ClientEventType["TOKEN"] = "xBeesToken";
32
33
  ClientEventType["CONTACTS_AUTO_SUGGEST"] = "xBeesContactsAutoSuggest";
33
34
  ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
35
+ ClientEventType["LOOK_UP_AND_MATCH_BATCH_CONTACTS"] = "xBeesLookupAndMatchBatchContacts";
36
+ ClientEventType["LOOKUP_AND_MATCH_BATCH_ERROR"] = "xBeesLookupAndMatchBatchError";
34
37
  ClientEventType["CONTACT_LOOKUP_AND_MATCH_NOT_FOUND"] = "xBeesContactLookupAndMatchNotFound";
35
38
  ClientEventType["CONTACT_CREATE_OR_UPDATE"] = "xBeesContactCreateOrUpdate";
36
39
  ClientEventType["CONTACT_MATCH_UPDATE"] = "xBeesContactMatchUpdate";
37
40
  ClientEventType["CONTACTS_AUTO_SUGGEST_IS_SUPPORTED"] = "xBeesContactsAutoSuggestIsSupported";
38
41
  ClientEventType["CONTACT_LOOK_UP_AND_MATCH_IS_SUPPORTED"] = "xBeesContactLookupAndMatchIsSupported";
42
+ ClientEventType["LOOK_UP_AND_MATCH_BATCH_CONTACTS_IS_SUPPORTED"] = "xBeesLookupAndMatchBatchContactsIsSupported";
39
43
  ClientEventType["LOGOUT_IS_SUPPORTED"] = "xBeesLogoutIsSupported";
40
44
  ClientEventType["SEND_ANALYTICS"] = "xBeesSendAnalytics";
41
45
  ClientEventType["SEND_TECHNICAL_SUPPORT_INFORMATION"] = "xBeesSendTechInfo";
@@ -333,6 +333,33 @@ export class Client {
333
333
  }
334
334
  });
335
335
  }
336
+ onLookupAndMatchBatchContacts(callback) {
337
+ // send event to x-bees
338
+ void this.sendAsyncErrorSafe({
339
+ type: ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS_IS_SUPPORTED,
340
+ });
341
+ return this.addEventListener(EventType.GET_LOOK_UP_AND_MATCH_BATCH, (queries) => {
342
+ const returnResults = (contactResultsMap) => this.sendAsync({
343
+ type: ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS,
344
+ payload: {
345
+ contactResultsMap: Array.from(contactResultsMap),
346
+ },
347
+ });
348
+ const reject = (reason) => {
349
+ console.debug(reason);
350
+ void this.sendAsync({
351
+ type: ClientEventType.LOOKUP_AND_MATCH_BATCH_ERROR,
352
+ payload: { reason },
353
+ });
354
+ };
355
+ try {
356
+ callback(queries, returnResults);
357
+ }
358
+ catch (error) {
359
+ reject(`${error}`);
360
+ }
361
+ });
362
+ }
336
363
  onThemeChange(callback) {
337
364
  return this.addEventListener(EventType.USE_THEME, callback);
338
365
  }
@@ -2,6 +2,7 @@ export var EventType;
2
2
  (function (EventType) {
3
3
  EventType["GET_CONTACTS_AUTO_SUGGEST"] = "xBeesGetContactsAutoSuggest";
4
4
  EventType["GET_LOOK_UP_AND_MATCH"] = "xBeesGetLookUpAndMatch";
5
+ EventType["GET_LOOK_UP_AND_MATCH_BATCH"] = "xBeesGetLookUpAndMatchBatch";
5
6
  EventType["ADD_CALL"] = "xBeesAddCall";
6
7
  EventType["TERMINATE_CALL"] = "xBeesTerminateCall";
7
8
  EventType["USE_THEME"] = "xBeesUseTheme";
@@ -28,11 +29,14 @@ export var ClientEventType;
28
29
  ClientEventType["TOKEN"] = "xBeesToken";
29
30
  ClientEventType["CONTACTS_AUTO_SUGGEST"] = "xBeesContactsAutoSuggest";
30
31
  ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
32
+ ClientEventType["LOOK_UP_AND_MATCH_BATCH_CONTACTS"] = "xBeesLookupAndMatchBatchContacts";
33
+ ClientEventType["LOOKUP_AND_MATCH_BATCH_ERROR"] = "xBeesLookupAndMatchBatchError";
31
34
  ClientEventType["CONTACT_LOOKUP_AND_MATCH_NOT_FOUND"] = "xBeesContactLookupAndMatchNotFound";
32
35
  ClientEventType["CONTACT_CREATE_OR_UPDATE"] = "xBeesContactCreateOrUpdate";
33
36
  ClientEventType["CONTACT_MATCH_UPDATE"] = "xBeesContactMatchUpdate";
34
37
  ClientEventType["CONTACTS_AUTO_SUGGEST_IS_SUPPORTED"] = "xBeesContactsAutoSuggestIsSupported";
35
38
  ClientEventType["CONTACT_LOOK_UP_AND_MATCH_IS_SUPPORTED"] = "xBeesContactLookupAndMatchIsSupported";
39
+ ClientEventType["LOOK_UP_AND_MATCH_BATCH_CONTACTS_IS_SUPPORTED"] = "xBeesLookupAndMatchBatchContactsIsSupported";
36
40
  ClientEventType["LOGOUT_IS_SUPPORTED"] = "xBeesLogoutIsSupported";
37
41
  ClientEventType["SEND_ANALYTICS"] = "xBeesSendAnalytics";
38
42
  ClientEventType["SEND_TECHNICAL_SUPPORT_INFORMATION"] = "xBeesSendTechInfo";
@@ -1,5 +1,6 @@
1
1
  import { Callback, ConnectClient, Contact, ContactQuery, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, StorageEventCallback, SuggestContactsResolver, SupportedPlatformVariant, ToastSeverity, XBeesUser } from '../types';
2
2
  import { ReadyExtendedProps } from '../types/Event';
3
+ import { LookupAndMatchBatchContactsResolver } from '../types/Resolver';
3
4
  import { ClientEventType, EventType } from './enums';
4
5
  import TechnicalSupport from './helpers/TechnicalSupport';
5
6
  /**
@@ -74,6 +75,7 @@ export declare class Client implements ConnectClient {
74
75
  getXBeesToken(): Promise<Message<ClientEventType.TOKEN>>;
75
76
  onSuggestContacts(callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void): RemoveEventListener;
76
77
  onLookupAndMatchContact(callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void): RemoveEventListener;
78
+ onLookupAndMatchBatchContacts(callback: (query: ContactQuery[], returnResults: LookupAndMatchBatchContactsResolver) => void): RemoveEventListener;
77
79
  onThemeChange(callback: Callback<EventType.USE_THEME>): RemoveEventListener;
78
80
  getFromStorage<Type>(key: string): Type | null;
79
81
  saveToStorage<SavingType>(key: string, value: SavingType): void;
@@ -1,6 +1,7 @@
1
1
  export declare enum EventType {
2
2
  GET_CONTACTS_AUTO_SUGGEST = "xBeesGetContactsAutoSuggest",
3
3
  GET_LOOK_UP_AND_MATCH = "xBeesGetLookUpAndMatch",
4
+ GET_LOOK_UP_AND_MATCH_BATCH = "xBeesGetLookUpAndMatchBatch",
4
5
  ADD_CALL = "xBeesAddCall",
5
6
  TERMINATE_CALL = "xBeesTerminateCall",
6
7
  USE_THEME = "xBeesUseTheme",
@@ -26,11 +27,14 @@ export declare enum ClientEventType {
26
27
  TOKEN = "xBeesToken",
27
28
  CONTACTS_AUTO_SUGGEST = "xBeesContactsAutoSuggest",
28
29
  CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch",
30
+ LOOK_UP_AND_MATCH_BATCH_CONTACTS = "xBeesLookupAndMatchBatchContacts",
31
+ LOOKUP_AND_MATCH_BATCH_ERROR = "xBeesLookupAndMatchBatchError",
29
32
  CONTACT_LOOKUP_AND_MATCH_NOT_FOUND = "xBeesContactLookupAndMatchNotFound",
30
33
  CONTACT_CREATE_OR_UPDATE = "xBeesContactCreateOrUpdate",
31
34
  CONTACT_MATCH_UPDATE = "xBeesContactMatchUpdate",
32
35
  CONTACTS_AUTO_SUGGEST_IS_SUPPORTED = "xBeesContactsAutoSuggestIsSupported",
33
36
  CONTACT_LOOK_UP_AND_MATCH_IS_SUPPORTED = "xBeesContactLookupAndMatchIsSupported",
37
+ LOOK_UP_AND_MATCH_BATCH_CONTACTS_IS_SUPPORTED = "xBeesLookupAndMatchBatchContactsIsSupported",
34
38
  LOGOUT_IS_SUPPORTED = "xBeesLogoutIsSupported",
35
39
  SEND_ANALYTICS = "xBeesSendAnalytics",
36
40
  SEND_TECHNICAL_SUPPORT_INFORMATION = "xBeesSendTechInfo",
@@ -7,7 +7,7 @@ import { RemoveEventListener } from './Listener';
7
7
  import { ResponseMessage } from './Message';
8
8
  import { IPayloadViewPort } from './Payload';
9
9
  import { SupportedPlatformVariant } from './Platform';
10
- import { LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
10
+ import { LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
11
11
  import { StorageEventCallback } from './Storage';
12
12
  import { ToastSeverity } from './Toast';
13
13
  import { XBeesUser } from './XBeesUser';
@@ -132,6 +132,9 @@ export interface ConnectClient {
132
132
  /**
133
133
  * Starts listen for the events of searching contact info and handle match with the provided callback */
134
134
  onLookupAndMatchContact: (callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void) => RemoveEventListener;
135
+ /**
136
+ * Starts listen for the events of searching batch contacts info and handle match with the provided callback */
137
+ onLookupAndMatchBatchContacts: (callback: (queries: ContactQuery[], returnResults: LookupAndMatchBatchContactsResolver) => void) => RemoveEventListener;
135
138
  /**
136
139
  * Starts listen for the events of starting the call and handle with the provided callback */
137
140
  onCallStarted: (callback: Callback<EventType.ADD_CALL>) => RemoveEventListener;
@@ -2,13 +2,14 @@ import { ClientEventType, EventType } from '../src/enums';
2
2
  import { AvailableContactData } from './AvailableContactData';
3
3
  import { ContactQuery } from './Contact';
4
4
  import { Message, MessageType } from './Message';
5
- import { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadGetFromStorage, IPayloadSaveToStorage, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
5
+ import { IPayloadAutoSuggestResult, IPayloadBatchContactsMatchResult, IPayloadBatchContactsMatchResultError, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadGetFromStorage, IPayloadSaveToStorage, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
6
6
  import { SupportedPlatformVariant } from './Platform';
7
7
  import { XBeesUser } from './XBeesUser';
8
- 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 : T extends EventType.GET_LOOK_UP_AND_MATCH ? ContactQuery : T extends EventType.VISIBILITY ? boolean : T extends ClientEventType.USER ? XBeesUser : T extends ClientEventType.SAVE_TO_STORAGE ? IPayloadSaveToStorage : T extends ClientEventType.GET_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.REMOVE_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.AVAILABLE_CONTACT_DATA ? AvailableContactData | null : never;
8
+ 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.LOOKUP_AND_MATCH_BATCH_ERROR ? IPayloadBatchContactsMatchResultError : 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 : T extends EventType.GET_LOOK_UP_AND_MATCH ? ContactQuery : T extends EventType.GET_LOOK_UP_AND_MATCH_BATCH ? ContactQuery[] : T extends EventType.VISIBILITY ? boolean : T extends ClientEventType.USER ? XBeesUser : T extends ClientEventType.SAVE_TO_STORAGE ? IPayloadSaveToStorage : T extends ClientEventType.GET_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.REMOVE_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.AVAILABLE_CONTACT_DATA ? AvailableContactData | null : T extends ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS ? IPayloadBatchContactsMatchResult : never;
9
9
  export type EventPayloadMap = {
10
10
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
11
11
  [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
12
+ [EventType.GET_LOOK_UP_AND_MATCH_BATCH]: ContactQuery[];
12
13
  [EventType.ADD_CALL]: IPayloadCallStartedInfo;
13
14
  [EventType.USE_THEME]: IPayloadThemeChange;
14
15
  [EventType.PBX_TOKEN]: string;
@@ -18,6 +19,7 @@ export type EventPayloadMap = {
18
19
  export type EventCallbackMap = {
19
20
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
20
21
  [EventType.GET_LOOK_UP_AND_MATCH]: (query: EventPayloadMap[EventType.GET_LOOK_UP_AND_MATCH]) => void;
22
+ [EventType.GET_LOOK_UP_AND_MATCH_BATCH]: (queries: EventPayloadMap[EventType.GET_LOOK_UP_AND_MATCH_BATCH]) => void;
21
23
  [EventType.ADD_CALL]: (callStartInfo: EventPayloadMap[EventType.ADD_CALL]) => void;
22
24
  [EventType.USE_THEME]: (theme: EventPayloadMap[EventType.USE_THEME]) => void;
23
25
  [EventType.PBX_TOKEN]: (token: EventPayloadMap[EventType.PBX_TOKEN]) => void;
@@ -41,9 +41,15 @@ export interface IPayloadContactMatchResult {
41
41
  contact: Contact;
42
42
  query: ContactQuery;
43
43
  }
44
+ export interface IPayloadBatchContactsMatchResult {
45
+ contactResultsMap: [ContactQuery, Contact | null | undefined][];
46
+ }
44
47
  export interface IPayloadContactMatchResultNotFound {
45
48
  query: ContactQuery;
46
49
  }
50
+ export interface IPayloadBatchContactsMatchResultError {
51
+ reason: string;
52
+ }
47
53
  export interface IPayloadContactResult {
48
54
  contact: Contact;
49
55
  }
@@ -1,4 +1,5 @@
1
- import { Contact } from './Contact';
1
+ import { Contact, ContactQuery } from './Contact';
2
2
  export type SuggestContactsResolver = (contacts: Contact[]) => void;
3
3
  export type LookupAndMatchContactsResolver = (contact: Contact) => void;
4
+ export type LookupAndMatchBatchContactsResolver = (contactResultsMap: Map<ContactQuery, Contact | null | undefined>) => void;
4
5
  export type Reject = (reason: string) => void;
@@ -9,7 +9,7 @@ export type { Message, MessageIFrameResponse, MessageType, ResponseMessage } fro
9
9
  export type { MessageSender } from './MessageSender';
10
10
  export type { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort, } from './Payload';
11
11
  export { SupportedPlatformVariant } from './Platform';
12
- export type { LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
12
+ export type { LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver, } from './Resolver';
13
13
  export type { StorageEventCallback } from './Storage';
14
14
  export type { ToastSeverity } from './Toast';
15
15
  export type { WorkVariants } from './WorkVariant';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.29",
3
+ "version": "1.2.30",
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": "",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=16"
47
47
  },
48
- "gitHead": "822f0458ad85b858ff59879d68928064cd0e6323"
48
+ "gitHead": "1703d08bf2881bb71437334fb474a7b0897da54d"
49
49
  }