@wildix/xbees-connect 1.2.15 → 1.2.16-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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.15",
3
+ "version": "1.2.16-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": "",
@@ -43,6 +43,7 @@ class Client {
43
43
  visible = false;
44
44
  user = null;
45
45
  userExtension = null;
46
+ templateId = null;
46
47
  userEmail;
47
48
  referrer;
48
49
  needAuthorize;
@@ -121,7 +122,12 @@ class Client {
121
122
  }
122
123
  }
123
124
  ready(props = types_1.SupportedPlatformVariant.ALL) {
124
- const payload = typeof props === 'string' ? { version: this.version(), platform: props } : { version: this.version(), ...props };
125
+ const payload = typeof props === 'string'
126
+ ? { version: this.version(), platform: props }
127
+ : { version: this.version(), platform: props.platform };
128
+ if (typeof props !== 'string' && props.templateId) {
129
+ this.templateId = props.templateId;
130
+ }
125
131
  this.getXBeesUser();
126
132
  return this.sendAsync({
127
133
  type: enums_1.ClientEventType.READY,
@@ -239,7 +245,12 @@ class Client {
239
245
  }
240
246
  isAuthorized() {
241
247
  this.sendDailyIntegrationUsageAnalytics();
242
- return this.sendAsync({ type: enums_1.ClientEventType.AUTHORIZED });
248
+ return this.sendAsync({
249
+ type: enums_1.ClientEventType.AUTHORIZED,
250
+ payload: {
251
+ templateId: this.templateId,
252
+ },
253
+ });
243
254
  }
244
255
  addEventListener(eventName, callback) {
245
256
  if (!this.useSubscription) {
@@ -31,7 +31,7 @@ class LocalStorageManager {
31
31
  });
32
32
  }
33
33
  calculateIntegrationKey() {
34
- const pattern = /^\/([^/]+)\/index\.html$/;
34
+ const pattern = /^\/(\S+)?\/index\.html$/;
35
35
  const match = window.location.pathname.match(pattern);
36
36
  if (match && match[1]) {
37
37
  const [, key] = match;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.15",
3
+ "version": "1.2.16-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": "",
@@ -37,6 +37,7 @@ export class Client {
37
37
  visible = false;
38
38
  user = null;
39
39
  userExtension = null;
40
+ templateId = null;
40
41
  userEmail;
41
42
  referrer;
42
43
  needAuthorize;
@@ -115,7 +116,12 @@ export class Client {
115
116
  }
116
117
  }
117
118
  ready(props = SupportedPlatformVariant.ALL) {
118
- const payload = typeof props === 'string' ? { version: this.version(), platform: props } : { version: this.version(), ...props };
119
+ const payload = typeof props === 'string'
120
+ ? { version: this.version(), platform: props }
121
+ : { version: this.version(), platform: props.platform };
122
+ if (typeof props !== 'string' && props.templateId) {
123
+ this.templateId = props.templateId;
124
+ }
119
125
  this.getXBeesUser();
120
126
  return this.sendAsync({
121
127
  type: ClientEventType.READY,
@@ -233,7 +239,12 @@ export class Client {
233
239
  }
234
240
  isAuthorized() {
235
241
  this.sendDailyIntegrationUsageAnalytics();
236
- return this.sendAsync({ type: ClientEventType.AUTHORIZED });
242
+ return this.sendAsync({
243
+ type: ClientEventType.AUTHORIZED,
244
+ payload: {
245
+ templateId: this.templateId,
246
+ },
247
+ });
237
248
  }
238
249
  addEventListener(eventName, callback) {
239
250
  if (!this.useSubscription) {
@@ -29,7 +29,7 @@ class LocalStorageManager {
29
29
  });
30
30
  }
31
31
  calculateIntegrationKey() {
32
- const pattern = /^\/([^/]+)\/index\.html$/;
32
+ const pattern = /^\/(\S+)?\/index\.html$/;
33
33
  const match = window.location.pathname.match(pattern);
34
34
  if (match && match[1]) {
35
35
  const [, key] = match;
@@ -18,6 +18,7 @@ export declare class Client implements ConnectClient {
18
18
  private visible;
19
19
  private user;
20
20
  private userExtension;
21
+ private templateId;
21
22
  private readonly userEmail;
22
23
  private readonly referrer;
23
24
  private readonly needAuthorize;
@@ -1,10 +1,10 @@
1
1
  import { ClientEventType, EventType } from '../src/enums';
2
2
  import { ContactQuery } from './Contact';
3
3
  import { Message, MessageType } from './Message';
4
- import { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
4
+ import { IPayloadAuthorizated, IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
5
5
  import { SupportedPlatformVariant } from './Platform';
6
6
  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 : never;
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.AUTHORIZED ? IPayloadAuthorizated : never;
8
8
  export type EventPayloadMap = {
9
9
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
10
10
  [EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
@@ -10,7 +10,6 @@ export interface IPayloadViewPort {
10
10
  }
11
11
  export interface IPayloadVersion {
12
12
  version: string;
13
- templateId?: string;
14
13
  platform?: SupportedPlatformVariant;
15
14
  }
16
15
  export interface IPayloadToast {
@@ -59,3 +58,6 @@ export interface IPayloadTechSupport {
59
58
  message: string;
60
59
  data?: JSONObject | JSONArray;
61
60
  }
61
+ export interface IPayloadAuthorizated {
62
+ templateId: string | null;
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.15",
3
+ "version": "1.2.16-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": "",
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": ">=16"
45
45
  },
46
- "gitHead": "c2fd946559ddb3cb6efce78cd93f605dc6280d38"
46
+ "gitHead": "742f09aaacde89296cdddc04d938228dc994762a"
47
47
  }