@wildix/xbees-connect 1.2.19-alpha.2 → 1.2.19-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.19-alpha.1",
3
+ "version": "1.2.19-alpha.6",
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": "",
@@ -113,11 +113,11 @@ class Client {
113
113
  });
114
114
  }
115
115
  sendDailyIntegrationUsageAnalytics() {
116
- const sendedUsageAnalyticsDate = this.getFromStorage('sendedUsageAnalyticsDate');
116
+ const sentUsageAnalyticsDate = this.getFromStorage('sentUsageAnalyticsDate');
117
117
  const today = new Date().toDateString();
118
- if (sendedUsageAnalyticsDate !== today) {
118
+ if (sentUsageAnalyticsDate !== today) {
119
119
  this.sendAnalytics('xBeesIntegrationUsage');
120
- this.saveToStorage('sendedUsageAnalyticsDate', today);
120
+ this.saveToStorage('sentUsageAnalyticsDate', today);
121
121
  }
122
122
  }
123
123
  ready(props = types_1.SupportedPlatformVariant.ALL) {
@@ -204,6 +204,9 @@ class Client {
204
204
  getCurrentConversation() {
205
205
  return this.sendAsync({ type: enums_1.ClientEventType.CURRENT_CONVERSATION });
206
206
  }
207
+ getCachedContact() {
208
+ return this.sendAsync({ type: enums_1.ClientEventType.CACHED_CONTACT });
209
+ }
207
210
  contactUpdated(query, contact) {
208
211
  return this.sendAsync({ type: enums_1.ClientEventType.CONTACT_CREATE_OR_UPDATE, payload: { query, contact } });
209
212
  }
@@ -340,8 +343,9 @@ class Client {
340
343
  getFromStorage(key) {
341
344
  return this.localStorageManager.retrieve(key);
342
345
  }
343
- saveToStorage(key, value) {
346
+ saveToStorage(key, value, sendToXbees = false) {
344
347
  this.localStorageManager.save(key, value);
348
+ sendToXbees && this.sendToXbeesStorage(key, value);
345
349
  }
346
350
  deleteFromStorage(key) {
347
351
  this.localStorageManager.delete(key);
@@ -379,7 +383,7 @@ class Client {
379
383
  type: enums_1.ClientEventType.SAVE_TO_STORAGE,
380
384
  payload: {
381
385
  key,
382
- value,
386
+ value: typeof value === 'string' ? value : JSON.stringify(value),
383
387
  },
384
388
  });
385
389
  }
@@ -42,6 +42,7 @@ var ClientEventType;
42
42
  ClientEventType["USER"] = "xBeesUser";
43
43
  ClientEventType["SAVE_TO_STORAGE"] = "xBeesSaveToStorage";
44
44
  ClientEventType["REQUEST_FROM_STORAGE"] = "xBeesRequestFromStorage";
45
+ ClientEventType["CACHED_CONTACT"] = "xBeesCachedContact";
45
46
  })(ClientEventType || (exports.ClientEventType = ClientEventType = {}));
46
47
  var UrlParams;
47
48
  (function (UrlParams) {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.19-alpha.1",
3
+ "version": "1.2.19-alpha.6",
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": "",
@@ -107,11 +107,11 @@ export class Client {
107
107
  });
108
108
  }
109
109
  sendDailyIntegrationUsageAnalytics() {
110
- const sendedUsageAnalyticsDate = this.getFromStorage('sendedUsageAnalyticsDate');
110
+ const sentUsageAnalyticsDate = this.getFromStorage('sentUsageAnalyticsDate');
111
111
  const today = new Date().toDateString();
112
- if (sendedUsageAnalyticsDate !== today) {
112
+ if (sentUsageAnalyticsDate !== today) {
113
113
  this.sendAnalytics('xBeesIntegrationUsage');
114
- this.saveToStorage('sendedUsageAnalyticsDate', today);
114
+ this.saveToStorage('sentUsageAnalyticsDate', today);
115
115
  }
116
116
  }
117
117
  ready(props = SupportedPlatformVariant.ALL) {
@@ -198,6 +198,9 @@ export class Client {
198
198
  getCurrentConversation() {
199
199
  return this.sendAsync({ type: ClientEventType.CURRENT_CONVERSATION });
200
200
  }
201
+ getCachedContact() {
202
+ return this.sendAsync({ type: ClientEventType.CACHED_CONTACT });
203
+ }
201
204
  contactUpdated(query, contact) {
202
205
  return this.sendAsync({ type: ClientEventType.CONTACT_CREATE_OR_UPDATE, payload: { query, contact } });
203
206
  }
@@ -334,8 +337,9 @@ export class Client {
334
337
  getFromStorage(key) {
335
338
  return this.localStorageManager.retrieve(key);
336
339
  }
337
- saveToStorage(key, value) {
340
+ saveToStorage(key, value, sendToXbees = false) {
338
341
  this.localStorageManager.save(key, value);
342
+ sendToXbees && this.sendToXbeesStorage(key, value);
339
343
  }
340
344
  deleteFromStorage(key) {
341
345
  this.localStorageManager.delete(key);
@@ -373,7 +377,7 @@ export class Client {
373
377
  type: ClientEventType.SAVE_TO_STORAGE,
374
378
  payload: {
375
379
  key,
376
- value,
380
+ value: typeof value === 'string' ? value : JSON.stringify(value),
377
381
  },
378
382
  });
379
383
  }
@@ -39,6 +39,7 @@ export var ClientEventType;
39
39
  ClientEventType["USER"] = "xBeesUser";
40
40
  ClientEventType["SAVE_TO_STORAGE"] = "xBeesSaveToStorage";
41
41
  ClientEventType["REQUEST_FROM_STORAGE"] = "xBeesRequestFromStorage";
42
+ ClientEventType["CACHED_CONTACT"] = "xBeesCachedContact";
42
43
  })(ClientEventType || (ClientEventType = {}));
43
44
  export var UrlParams;
44
45
  (function (UrlParams) {
@@ -0,0 +1 @@
1
+ export {};
@@ -52,6 +52,7 @@ export declare class Client implements ConnectClient {
52
52
  getContext(): Promise<Message<ClientEventType.CONTEXT>>;
53
53
  getCurrentContact(): Promise<Message<ClientEventType.CURRENT_CONTACT>>;
54
54
  getCurrentConversation(): Promise<Message<ClientEventType.CURRENT_CONVERSATION>>;
55
+ getCachedContact(): Promise<Message<ClientEventType.CACHED_CONTACT>>;
55
56
  contactUpdated(query: ContactQuery, contact: Contact): Promise<Message<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
56
57
  contactMatchUpdated(query: ContactQuery, contact: Contact): Promise<ResponseMessage<ClientEventType.CONTACT_MATCH_UPDATE>>;
57
58
  getThemeMode(): Promise<Message<ClientEventType.THEME_MODE>>;
@@ -75,7 +76,7 @@ export declare class Client implements ConnectClient {
75
76
  onLookupAndMatchContact(callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void): RemoveEventListener;
76
77
  onThemeChange(callback: Callback<EventType.USE_THEME>): RemoveEventListener;
77
78
  getFromStorage<Type>(key: string): Type | null;
78
- saveToStorage<SavingType>(key: string, value: SavingType): void;
79
+ saveToStorage<SavingType>(key: string, value: SavingType, sendToXbees?: boolean): void;
79
80
  deleteFromStorage(key: string): void;
80
81
  onStorage(listener: StorageEventCallback): () => void;
81
82
  onLogout(callback: Callback<EventType.LOGOUT>): RemoveEventListener;
@@ -83,6 +84,6 @@ export declare class Client implements ConnectClient {
83
84
  setIntegrationStorageKey(integrationKey: string): void;
84
85
  getTechnicalSupport(): TechnicalSupport;
85
86
  onVisibilityChange(callback: Callback<EventType.VISIBILITY>): RemoveEventListener;
86
- sendToXbeesStorage(key: string, value: string): void;
87
- requestFromXbeesStorage<Type>(key: string): Promise<ResponseMessage<ClientEventType.REQUEST_FROM_STORAGE>>;
87
+ sendToXbeesStorage<SavingType>(key: string, value: SavingType): void;
88
+ requestFromXbeesStorage(key: string): Promise<ResponseMessage<ClientEventType.REQUEST_FROM_STORAGE>>;
88
89
  }
@@ -36,7 +36,8 @@ export declare enum ClientEventType {
36
36
  SEND_TECHNICAL_SUPPORT_INFORMATION = "xBeesSendTechInfo",
37
37
  USER = "xBeesUser",
38
38
  SAVE_TO_STORAGE = "xBeesSaveToStorage",
39
- REQUEST_FROM_STORAGE = "xBeesRequestFromStorage"
39
+ REQUEST_FROM_STORAGE = "xBeesRequestFromStorage",
40
+ CACHED_CONTACT = "xBeesCachedContact"
40
41
  }
41
42
  export declare enum UrlParams {
42
43
  TOKEN = "t",
@@ -0,0 +1,4 @@
1
+ import { ContactShape } from './Contact';
2
+ export type CachedContact = ContactShape & {
3
+ name?: string;
4
+ };
@@ -75,6 +75,9 @@ export interface ConnectClient {
75
75
  /**
76
76
  * Retrieves current opened in x-bees conversation data or undefined if the conversation is temporary */
77
77
  getCurrentConversation: () => Promise<ResponseMessage<ClientEventType.CURRENT_CONVERSATION>>;
78
+ /**
79
+ * Retrieves contact cached by x-bees */
80
+ getCachedContact: () => Promise<ResponseMessage<ClientEventType.CACHED_CONTACT>>;
78
81
  /**
79
82
  * Sends notification to x-bees about contact data updated */
80
83
  contactUpdated(query: ContactQuery, contact: Contact): Promise<ResponseMessage<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
@@ -168,4 +171,10 @@ export interface ConnectClient {
168
171
  /**
169
172
  * Starts listen for the events of changing iframe activity and handle with the provided callback */
170
173
  onVisibilityChange: (callback: Callback<EventType.VISIBILITY>) => RemoveEventListener;
174
+ /**
175
+ * Send data to save in x-bees storage */
176
+ sendToXbeesStorage: (key: string, value: string) => void;
177
+ /**
178
+ * Request stored data from x-bees storage */
179
+ requestFromXbeesStorage: (key: string) => Promise<ResponseMessage<ClientEventType.REQUEST_FROM_STORAGE>>;
171
180
  }
@@ -1,8 +1,9 @@
1
- interface ContactShape {
1
+ export interface ContactShape {
2
2
  id: string;
3
3
  name: string;
4
4
  email?: string;
5
5
  phone?: string;
6
+ picture?: string;
6
7
  mobileNumber?: string;
7
8
  officeNumber?: string;
8
9
  faxNumber?: string;
@@ -21,4 +22,3 @@ export type ContactQuery = {
21
22
  email?: string;
22
23
  phone?: string;
23
24
  };
24
- export {};
@@ -1,10 +1,11 @@
1
1
  import { ClientEventType, EventType } from '../src/enums';
2
+ import { CachedContact } from './CachedContact';
2
3
  import { ContactQuery } from './Contact';
3
4
  import { Message, MessageType } from './Message';
4
5
  import { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadRequestFromStorage, IPayloadSendAnalytics, IPayloadSentToStorage, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
5
6
  import { SupportedPlatformVariant } from './Platform';
6
7
  import { XBeesUser } from './XBeesUser';
7
- 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 ? IPayloadSentToStorage : T extends ClientEventType.REQUEST_FROM_STORAGE ? IPayloadRequestFromStorage : 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.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 ? IPayloadSentToStorage : T extends ClientEventType.REQUEST_FROM_STORAGE ? IPayloadRequestFromStorage : T extends ClientEventType.CACHED_CONTACT ? CachedContact | null : never;
8
9
  export type EventPayloadMap = {
9
10
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
10
11
  [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
@@ -1,4 +1,5 @@
1
1
  export interface XBeesUser {
2
+ id: string;
2
3
  email: string;
3
4
  extension: string;
4
5
  domain: string;
@@ -1,3 +1,4 @@
1
+ export type { CachedContact } from './CachedContact';
1
2
  export type { Callback } from './Callback';
2
3
  export type { ConnectClient } from './Client';
3
4
  export type { Contact, ContactQuery } from './Contact';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.19-alpha.2",
3
+ "version": "1.2.19-alpha.7",
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": "",
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": ">=16"
45
45
  },
46
- "gitHead": "abe96e2f59483b3a77c2a91cc1fce1a4ee101beb"
46
+ "gitHead": "b27f6fe6b4a9ec487df32fc601639960b694d606"
47
47
  }