@epam/ai-dial-chat-visualizer-connector 0.15.0-rc.9 → 0.15.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/index.esm.js +59 -2
- package/package.json +2 -2
- package/src/lib/ChatVisualizerConnector.d.ts +17 -1
package/index.esm.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { VisualizerConnectorRequests, VisualizerConnectorEvents } from '@epam/ai-dial-shared';
|
|
2
2
|
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
|
|
18
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
19
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
29
|
+
var e = new Error(message);
|
|
30
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
|
+
};
|
|
32
|
+
|
|
3
33
|
/**
|
|
4
34
|
* Class which creates connector with DIAL CHAT, allows to interact with it (send/receive data via post messages)
|
|
5
35
|
*/
|
|
@@ -17,6 +47,21 @@ class ChatVisualizerConnector {
|
|
|
17
47
|
this.postMessageListener = this.postMessageListener.bind(this);
|
|
18
48
|
window.addEventListener('message', this.postMessageListener, false);
|
|
19
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Sends the post message to the DIAL Chat
|
|
52
|
+
* @param type Visualizer Event name
|
|
53
|
+
* @param payload Event payload
|
|
54
|
+
* @param dialHost host of the DIAL Chat
|
|
55
|
+
*/
|
|
56
|
+
send({ type, payload, dialHost = this.dialHost, }) {
|
|
57
|
+
if (!(window === null || window === void 0 ? void 0 : window.parent)) {
|
|
58
|
+
throw new Error(`[${this.appName}] There is no parent window to send requests`);
|
|
59
|
+
}
|
|
60
|
+
window.parent.postMessage({
|
|
61
|
+
type: `${this.appName}/${type}`,
|
|
62
|
+
payload,
|
|
63
|
+
}, dialHost);
|
|
64
|
+
}
|
|
20
65
|
/**
|
|
21
66
|
* Sends response via postMessage to the DIAL CHAT to notify it data received
|
|
22
67
|
* @param requestParams {PostMessageRequestParams}
|
|
@@ -52,13 +97,25 @@ class ChatVisualizerConnector {
|
|
|
52
97
|
* Sends 'READY' event via postMessage to the DIAL CHAT to notify that Visualizer loaded
|
|
53
98
|
*/
|
|
54
99
|
sendReady() {
|
|
55
|
-
|
|
100
|
+
this.send({ type: VisualizerConnectorEvents.ready });
|
|
56
101
|
}
|
|
57
102
|
/**
|
|
58
103
|
* Sends 'READY_TO_INTERACT' event via postMessage to the DIAL CHAT to notify that Visualizer ready to get data
|
|
59
104
|
*/
|
|
60
105
|
sendReadyToInteract() {
|
|
61
|
-
|
|
106
|
+
this.send({ type: VisualizerConnectorEvents.readyToInteract });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Send message into the selected conversations
|
|
110
|
+
* @param content {string} text of message that should be sent to the chat
|
|
111
|
+
*/
|
|
112
|
+
sendMessage(content) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
this.send({
|
|
115
|
+
type: VisualizerConnectorEvents.sendMessage,
|
|
116
|
+
payload: { message: content },
|
|
117
|
+
});
|
|
118
|
+
});
|
|
62
119
|
}
|
|
63
120
|
/**
|
|
64
121
|
* Destroys ChatVisualizerConnector
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@epam/ai-dial-chat-visualizer-connector",
|
|
3
3
|
"description": "Package for custom visualizer to connect with Dial Chat",
|
|
4
4
|
"homepage": "https://epam-rail.com",
|
|
5
|
-
"version": "0.15.
|
|
5
|
+
"version": "0.15.1",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@epam/ai-dial-shared": "0.15.
|
|
7
|
+
"@epam/ai-dial-shared": "0.15.1"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"bugs": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttachmentData, VisualizerConnectorRequests } from '@epam/ai-dial-shared';
|
|
1
|
+
import { AttachmentData, VisualizerConnectorEvents, VisualizerConnectorRequests } from '@epam/ai-dial-shared';
|
|
2
2
|
interface RequestParams {
|
|
3
3
|
type: VisualizerConnectorRequests;
|
|
4
4
|
requestId: string;
|
|
@@ -21,6 +21,17 @@ export declare class ChatVisualizerConnector {
|
|
|
21
21
|
* @param dataCallback {(visualizerData: AttachmentData) => void} callback to get data that will be used in the Visualizer
|
|
22
22
|
*/
|
|
23
23
|
constructor(dialHost: string, appName: string, dataCallback: (visualizerData: AttachmentData) => void);
|
|
24
|
+
/**
|
|
25
|
+
* Sends the post message to the DIAL Chat
|
|
26
|
+
* @param type Visualizer Event name
|
|
27
|
+
* @param payload Event payload
|
|
28
|
+
* @param dialHost host of the DIAL Chat
|
|
29
|
+
*/
|
|
30
|
+
send({ type, payload, dialHost, }: {
|
|
31
|
+
type: VisualizerConnectorEvents;
|
|
32
|
+
payload?: unknown;
|
|
33
|
+
dialHost?: string;
|
|
34
|
+
}): void;
|
|
24
35
|
/**
|
|
25
36
|
* Sends response via postMessage to the DIAL CHAT to notify it data received
|
|
26
37
|
* @param requestParams {PostMessageRequestParams}
|
|
@@ -35,6 +46,11 @@ export declare class ChatVisualizerConnector {
|
|
|
35
46
|
* Sends 'READY_TO_INTERACT' event via postMessage to the DIAL CHAT to notify that Visualizer ready to get data
|
|
36
47
|
*/
|
|
37
48
|
sendReadyToInteract(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Send message into the selected conversations
|
|
51
|
+
* @param content {string} text of message that should be sent to the chat
|
|
52
|
+
*/
|
|
53
|
+
sendMessage(content: string): Promise<void>;
|
|
38
54
|
/**
|
|
39
55
|
* Destroys ChatVisualizerConnector
|
|
40
56
|
*/
|