@wildix/xbees-connect 1.0.6-alpha.9 → 1.1.0-alpha.0
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/dist-es/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.0.6-alpha.
|
|
3
|
+
"version": "1.0.6-alpha.12",
|
|
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": "",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"module": "./dist-es/index.js",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"scripts": {
|
|
14
|
+
"build": "yarn clean && yarn build:es && yarn build:types",
|
|
14
15
|
"build:es": "tsc -p tsconfig.es.json",
|
|
15
16
|
"build:types": "tsc -p tsconfig.types.json",
|
|
16
17
|
"build:docs": "typedoc",
|
package/dist-es/src/Client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import packageJson from '../package.json';
|
|
2
|
-
import { ClientEventType, EventType, UrlParams } from './enums';
|
|
2
|
+
import { ClientEventType, DeprecatedUrlParams, EventType, UrlParams } from './enums';
|
|
3
3
|
import PostMessageControllerNative from './helpers/PostMessageControllerNative';
|
|
4
4
|
import PostMessageControllerWeb from './helpers/PostMessageControllerWeb';
|
|
5
5
|
/**
|
|
@@ -38,12 +38,12 @@ export class Client {
|
|
|
38
38
|
variant = null;
|
|
39
39
|
constructor() {
|
|
40
40
|
const params = new URLSearchParams(window.location.search);
|
|
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);
|
|
41
|
+
this.iframeId = (params.get(UrlParams.ID) ?? params.get(DeprecatedUrlParams.ID));
|
|
42
|
+
this.variant = (params.get(UrlParams.VARIANT) ?? params.get(DeprecatedUrlParams.VARIANT));
|
|
43
|
+
this.userEmail = (params.get(UrlParams.USER) ?? params.get(DeprecatedUrlParams.USER));
|
|
44
|
+
this.userToken = (params.get(UrlParams.TOKEN) ?? params.get(DeprecatedUrlParams.TOKEN));
|
|
45
|
+
this.referrer = (params.get(UrlParams.REFERRER) ?? params.get(DeprecatedUrlParams.REFERRER));
|
|
46
|
+
this.needAuthorize = (params.has(UrlParams.AUTHORIZE) ?? params.has(DeprecatedUrlParams.AUTHORIZE));
|
|
47
47
|
// @ts-expect-error window.ReactNativeWebView will be provided by ReactNative WebView
|
|
48
48
|
this.worker = window.ReactNativeWebView
|
|
49
49
|
? new PostMessageControllerNative()
|
|
@@ -107,7 +107,7 @@ export class Client {
|
|
|
107
107
|
return this.userEmail;
|
|
108
108
|
}
|
|
109
109
|
isDataOnly() {
|
|
110
|
-
return this.variant === '
|
|
110
|
+
return this.variant === 'no-ui' || this.variant === 'daemon';
|
|
111
111
|
}
|
|
112
112
|
showsUi() {
|
|
113
113
|
return !this.isDataOnly();
|
|
@@ -121,6 +121,9 @@ export class Client {
|
|
|
121
121
|
getCurrentContact() {
|
|
122
122
|
return this.sendAsync({ type: ClientEventType.CURRENT_CONTACT });
|
|
123
123
|
}
|
|
124
|
+
contactUpdated(query, contact) {
|
|
125
|
+
return this.sendAsync({ type: ClientEventType.CONTACT_CREATE_OR_UPDATE, payload: { query, contact } });
|
|
126
|
+
}
|
|
124
127
|
getThemeMode() {
|
|
125
128
|
return this.sendAsync({ type: ClientEventType.THEME_MODE });
|
|
126
129
|
}
|
|
@@ -22,7 +22,17 @@ export var ClientEventType;
|
|
|
22
22
|
ClientEventType["AUTHORIZED"] = "xBeesAuthorized";
|
|
23
23
|
ClientEventType["CONTACTS_AUTO_SUGGEST"] = "xBeesContactsAutoSuggest";
|
|
24
24
|
ClientEventType["CONTACT_LOOKUP_AND_MATCH"] = "xBeesContactLookupAndMatch";
|
|
25
|
+
ClientEventType["CONTACT_CREATE_OR_UPDATE"] = "xBeesContactCreateOrUpdate";
|
|
25
26
|
})(ClientEventType || (ClientEventType = {}));
|
|
27
|
+
export var DeprecatedUrlParams;
|
|
28
|
+
(function (DeprecatedUrlParams) {
|
|
29
|
+
DeprecatedUrlParams["TOKEN"] = "token";
|
|
30
|
+
DeprecatedUrlParams["ID"] = "iframeId";
|
|
31
|
+
DeprecatedUrlParams["VARIANT"] = "variant";
|
|
32
|
+
DeprecatedUrlParams["USER"] = "u";
|
|
33
|
+
DeprecatedUrlParams["REFERRER"] = "referrer";
|
|
34
|
+
DeprecatedUrlParams["AUTHORIZE"] = "authorize";
|
|
35
|
+
})(DeprecatedUrlParams || (DeprecatedUrlParams = {}));
|
|
26
36
|
export var UrlParams;
|
|
27
37
|
(function (UrlParams) {
|
|
28
38
|
UrlParams["TOKEN"] = "t";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Callback, ConnectClient, ContactQuery, IPayloadAutoSuggestResult, IPayloadContactMatchResult, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, SuggestContactsResolver } from '../types';
|
|
1
|
+
import { Callback, ConnectClient, Contact, ContactQuery, IPayloadAutoSuggestResult, IPayloadContactMatchResult, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, SuggestContactsResolver } from '../types';
|
|
2
2
|
import { ClientEventType, EventType } from './enums';
|
|
3
3
|
/**
|
|
4
4
|
* Client provides functionality of communication between xBees and integrated web applications via iFrame or ReactNative WebView
|
|
@@ -30,6 +30,7 @@ export declare class Client implements ConnectClient {
|
|
|
30
30
|
isActivationOnly(): boolean;
|
|
31
31
|
getContext(): Promise<Message<ClientEventType.CONTEXT>>;
|
|
32
32
|
getCurrentContact(): Promise<Message<ClientEventType.CURRENT_CONTACT>>;
|
|
33
|
+
contactUpdated(query: ContactQuery, contact: Contact): Promise<Message<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
|
|
33
34
|
getThemeMode(): Promise<Message<ClientEventType.THEME_MODE>>;
|
|
34
35
|
getTheme(): Promise<Message<ClientEventType.THEME>>;
|
|
35
36
|
startCall(phoneNumber: string): Promise<Message<ClientEventType.START_CALL>>;
|
|
@@ -19,7 +19,16 @@ export declare enum ClientEventType {
|
|
|
19
19
|
NOT_AUTHORIZED = "xBeesNotAuthorized",
|
|
20
20
|
AUTHORIZED = "xBeesAuthorized",
|
|
21
21
|
CONTACTS_AUTO_SUGGEST = "xBeesContactsAutoSuggest",
|
|
22
|
-
CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch"
|
|
22
|
+
CONTACT_LOOKUP_AND_MATCH = "xBeesContactLookupAndMatch",
|
|
23
|
+
CONTACT_CREATE_OR_UPDATE = "xBeesContactCreateOrUpdate"
|
|
24
|
+
}
|
|
25
|
+
export declare enum DeprecatedUrlParams {
|
|
26
|
+
TOKEN = "token",
|
|
27
|
+
ID = "iframeId",
|
|
28
|
+
VARIANT = "variant",
|
|
29
|
+
USER = "u",
|
|
30
|
+
REFERRER = "referrer",
|
|
31
|
+
AUTHORIZE = "authorize"
|
|
23
32
|
}
|
|
24
33
|
export declare enum UrlParams {
|
|
25
34
|
TOKEN = "t",
|
|
@@ -19,16 +19,8 @@ export type Contact = (ContactShape & {
|
|
|
19
19
|
phone: string;
|
|
20
20
|
});
|
|
21
21
|
export type ContactQuery = {
|
|
22
|
-
id?: string;
|
|
23
|
-
email: string;
|
|
24
|
-
phone?: string;
|
|
25
|
-
} | {
|
|
26
22
|
id?: string;
|
|
27
23
|
email?: string;
|
|
28
|
-
phone: string;
|
|
29
|
-
} | {
|
|
30
|
-
id: string;
|
|
31
|
-
email?: string;
|
|
32
24
|
phone?: string;
|
|
33
25
|
};
|
|
34
26
|
export interface IPayloadViewPort {
|
|
@@ -65,7 +57,7 @@ export interface IPayloadContactResult {
|
|
|
65
57
|
}
|
|
66
58
|
export interface IPayloadContextResult extends IPayloadContactResult {
|
|
67
59
|
}
|
|
68
|
-
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 ? IPayloadThemeChange : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
|
|
60
|
+
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_CREATE_OR_UPDATE ? 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 ? IPayloadThemeChange : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : never;
|
|
69
61
|
export type Message<T extends MessageType = MessageType> = {
|
|
70
62
|
type: T;
|
|
71
63
|
payload?: EventPayload<T>;
|
|
@@ -98,7 +90,8 @@ export interface Listener<T extends EventType = EventType> {
|
|
|
98
90
|
eventName: T;
|
|
99
91
|
callback: Callback<T>;
|
|
100
92
|
}
|
|
101
|
-
|
|
93
|
+
type DeprecatedWorkVariants = 'info-frame' | 'daemon' | 'dialog';
|
|
94
|
+
export type WorkVariants = 'ui' | 'no-ui' | 'd' | DeprecatedWorkVariants;
|
|
102
95
|
export interface PostMessageController {
|
|
103
96
|
sendAsync<T extends MessageType>(data: MessageIFrameResponse<T>): Promise<ResponseMessage<T>>;
|
|
104
97
|
}
|
|
@@ -137,6 +130,9 @@ export interface ConnectClient {
|
|
|
137
130
|
/**
|
|
138
131
|
* Retrieves current opened in x-bees contact data */
|
|
139
132
|
getCurrentContact: () => Promise<Message<ClientEventType.CURRENT_CONTACT>>;
|
|
133
|
+
/**
|
|
134
|
+
* Sends notification to x-bees about contact data updated */
|
|
135
|
+
contactUpdated(query: ContactQuery, contact: Contact): Promise<Message<ClientEventType.CONTACT_CREATE_OR_UPDATE>>;
|
|
140
136
|
/**
|
|
141
137
|
* Retrieves current theme mode (light or dark) */
|
|
142
138
|
getThemeMode: () => Promise<Message<ClientEventType.THEME_MODE>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-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": "",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"module": "./dist-es/index.js",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"scripts": {
|
|
14
|
+
"build": "yarn clean && yarn build:es && yarn build:types",
|
|
14
15
|
"build:es": "tsc -p tsconfig.es.json",
|
|
15
16
|
"build:types": "tsc -p tsconfig.types.json",
|
|
16
17
|
"build:docs": "typedoc",
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": ">=16"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9d4812edf4f972f695efbda9dfaebed3a5a6af1f"
|
|
45
46
|
}
|