@xapp/chat-widget 1.53.1 → 1.54.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/components/AdminBar/AdminBar.d.ts +7 -0
- package/dist/components/ChatFooter/ChatFooter.d.ts +1 -0
- package/dist/components/ChatFooter/ChatFooter.stories.d.ts +2 -0
- package/dist/index.css +2 -2
- package/dist/index.es.js +417 -115
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +417 -115
- package/dist/index.js.map +1 -1
- package/dist/store/ChatAction.d.ts +13 -9
- package/dist/store/actions/index.d.ts +2 -0
- package/dist/store/actions/receiveToken.d.ts +6 -0
- package/dist/store/actions/sendBargeIn.d.ts +2 -0
- package/dist/store/actions/sendBargeOut.d.ts +2 -0
- package/dist/utils/requestFromMessage.d.ts +2 -1
- package/dist/xapp/ChatServer.d.ts +6 -0
- package/dist/xapp/LogChat.d.ts +2 -0
- package/dist/xapp/StentorDirectChat.d.ts +2 -0
- package/dist/xapp/StentorLocalChat.d.ts +2 -0
- package/dist/xapp/StentorRouterChat.d.ts +41 -10
- package/dist/xapp/StentorServerChat.d.ts +2 -0
- package/package.json +20 -20
- package/dist/components/StatusContainer/StatusContainer.d.ts +0 -17
- package/dist/components/StatusContainer/StatusContainer.stories.d.ts +0 -8
- package/dist/components/StatusContainer/StatusContainer.test.d.ts +0 -1
- package/dist/components/StatusContainer/index.d.ts +0 -1
- package/dist/xapp/UserInfo.d.ts +0 -15
|
@@ -4,7 +4,7 @@ import { Attachment } from "../xapp/Attachment";
|
|
|
4
4
|
import { ChatServerMessage } from "../xapp/ChatServerMessage";
|
|
5
5
|
export declare type CONNECTION_STATUS_TYPE = "online" | "pending" | "offline";
|
|
6
6
|
export declare type ACCOUNT_STATUS_TYPE = "offline" | "online";
|
|
7
|
-
export declare type ACTION_TYPE = "chat" | "account_status" | "connection_update" | "department_update" | "visitor_update" | "agent_update" | "error" | "reset";
|
|
7
|
+
export declare type ACTION_TYPE = "chat" | "account_status" | "connection_update" | "department_update" | "visitor_update" | "agent_update" | "error" | "reset" | "sendGreeting";
|
|
8
8
|
export interface ActionDetail {
|
|
9
9
|
timestamp: number;
|
|
10
10
|
}
|
|
@@ -15,14 +15,18 @@ export interface ChatActionDetail<T> extends ActionDetail {
|
|
|
15
15
|
export interface ChatAction extends Action<"chat"> {
|
|
16
16
|
detail: ChatDetail;
|
|
17
17
|
}
|
|
18
|
-
export interface ChatSendGreetingDetail extends
|
|
18
|
+
export interface ChatSendGreetingDetail extends ChatActionDetail<"sendGreeting"> {
|
|
19
19
|
detail: undefined;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
export interface SendGreetingAction extends Action<"sendGreeting"> {
|
|
22
|
+
detail: ChatSendGreetingDetail;
|
|
23
|
+
}
|
|
24
|
+
export interface ConnectionReceiveTokenAction extends Action<"receiveToken"> {
|
|
25
|
+
readonly detail: ChatConnectionReceiveTokenDetail;
|
|
26
|
+
}
|
|
27
|
+
export interface ChatConnectionReceiveTokenDetail extends ChatActionDetail<"receiveToken"> {
|
|
28
|
+
readonly token: string;
|
|
29
|
+
readonly timestamp: number;
|
|
26
30
|
}
|
|
27
31
|
export interface ChatMemberJoinDetail extends ChatActionDetail<"chat.memberjoin"> {
|
|
28
32
|
}
|
|
@@ -113,5 +117,5 @@ export interface SyntheticFileDetail extends ChatActionDetail<"visitor.send.file
|
|
|
113
117
|
}
|
|
114
118
|
export interface ResetAction extends Action<"reset"> {
|
|
115
119
|
}
|
|
116
|
-
export declare type ActionType = ChatAction | ConnectionUpdateAction | AccountStatusAction | DepartmentUpdateAction | VisitorUpdateAction | AgentUpdateAction | SyntheticAction |
|
|
117
|
-
export declare type ChatDetail = ChatMemberJoinDetail | ChatMemberLeaveDetail | ChatMemberPositionDetail | ChatRequestRatingDetail | ChatRatingDetail | ChatFileDetail | ChatMsgDetail | ChatFailureMsgDetail | ChatTypingDetail | ChatOfflineDetail | ChatPrechatDetail;
|
|
120
|
+
export declare type ActionType = ChatAction | ConnectionUpdateAction | AccountStatusAction | DepartmentUpdateAction | VisitorUpdateAction | AgentUpdateAction | SyntheticAction | ConnectionReceiveTokenAction | ResetAction | SendGreetingAction;
|
|
121
|
+
export declare type ChatDetail = ChatMemberJoinDetail | ChatMemberLeaveDetail | ChatMemberPositionDetail | ChatRequestRatingDetail | ChatRatingDetail | ChatFileDetail | ChatMsgDetail | ChatFailureMsgDetail | ChatTypingDetail | ChatOfflineDetail | ChatPrechatDetail | ChatSendGreetingDetail | ChatConnectionReceiveTokenDetail;
|
|
@@ -9,4 +9,6 @@ export { default as sendTyping } from "./sendTyping";
|
|
|
9
9
|
export { default as sendVisitorInfo } from "./sendVisitorInfo";
|
|
10
10
|
export { default as setAccountStatus } from "./setAccountStatus";
|
|
11
11
|
export { default as setConnectionStatus } from "./setConnectionStatus";
|
|
12
|
+
export { default as sendBargeIn } from "./sendBargeIn";
|
|
13
|
+
export { default as sendBargeOut } from "./sendBargeOut";
|
|
12
14
|
export { default as reset } from "./resetAction";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/*! Copyright (c) 2022, XAPPmedia */
|
|
2
2
|
import { ChatMessageRequest } from "../xapp/ChatServerMessage";
|
|
3
3
|
import { StentorRequest } from "./http-utils";
|
|
4
|
-
|
|
4
|
+
import { VisitorInfo } from "../xapp/StentorRouterChat";
|
|
5
|
+
export declare function requestFromMessage(message: ChatMessageRequest, userId: string, isNewSession: boolean, sessionId: string, accessToken: string, attributes: Record<string, unknown>, visitorInfo: VisitorInfo): StentorRequest;
|
|
@@ -27,6 +27,8 @@ export interface ChatServer {
|
|
|
27
27
|
markAsRead(): void;
|
|
28
28
|
flush(): void;
|
|
29
29
|
dispose(): void;
|
|
30
|
+
bargeOut(arg0: (err?: Error) => void): unknown;
|
|
31
|
+
bargeIn(agentName: string, arg1: (err?: Error) => void): unknown;
|
|
30
32
|
}
|
|
31
33
|
export interface ChatServerOptions {
|
|
32
34
|
readonly token?: string;
|
|
@@ -43,6 +45,10 @@ export interface OfflineMessage {
|
|
|
43
45
|
* The visitor is on person on the browser, talking to either the bot or the live agent.
|
|
44
46
|
*/
|
|
45
47
|
export interface VisitorInfoMessage {
|
|
48
|
+
/**
|
|
49
|
+
* Admin i.e. human agent watching type
|
|
50
|
+
*/
|
|
51
|
+
readonly isAdmin?: boolean;
|
|
46
52
|
/**
|
|
47
53
|
* Visitors name
|
|
48
54
|
*/
|
package/dist/xapp/LogChat.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { ChatMessageRequest, ChatServerMessage } from "./ChatServerMessage";
|
|
|
4
4
|
export declare class LogChat implements ChatServer {
|
|
5
5
|
private readonly inner;
|
|
6
6
|
constructor(inner: ChatServer);
|
|
7
|
+
bargeOut(cb: (err?: Error) => void): void;
|
|
8
|
+
bargeIn(agentName: string, cb: (err?: Error) => void): void;
|
|
7
9
|
init(dispatch: (action: ActionType) => void): void;
|
|
8
10
|
sendOfflineMsg(message: OfflineMessage, cb: (error?: Error) => void): void;
|
|
9
11
|
sendChatMsg(message: ChatServerMessage, cb: (err?: Error) => void): void;
|
|
@@ -28,6 +28,8 @@ export declare class StentorDirectChat implements ChatServer {
|
|
|
28
28
|
private sendFailureMessage;
|
|
29
29
|
sendOfflineMsg(_: OfflineMessage, cb: (error?: Error) => void): void;
|
|
30
30
|
sendChatMsg(message: ChatServerMessage, cb: (err?: Error) => void): Promise<void>;
|
|
31
|
+
bargeOut(_cb: (err?: Error) => void): Promise<void>;
|
|
32
|
+
bargeIn(_agentName: string, _cb: (err?: Error) => void): Promise<void>;
|
|
31
33
|
private getBot;
|
|
32
34
|
sendChatMsgRequest(serviceRequest: ChatMessageRequest, cb: (err?: Error) => void): Promise<void>;
|
|
33
35
|
sendTyping(): void;
|
|
@@ -5,11 +5,23 @@ import { ChatMessageRequest, ChatServerMessage } from "./ChatServerMessage";
|
|
|
5
5
|
export interface StentorRouterChatConfig {
|
|
6
6
|
readonly url: string;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export interface FailureData {
|
|
9
|
+
readonly type: "BOT";
|
|
10
|
+
readonly tries: number;
|
|
11
|
+
readonly delay: number;
|
|
12
|
+
readonly error: string;
|
|
13
|
+
}
|
|
14
|
+
export declare type MessageData = Request | Response | ConnectionStatus | FailureData | undefined;
|
|
15
|
+
export interface ConnectionStatus {
|
|
16
|
+
sessionCreated: boolean;
|
|
17
|
+
errorMessage?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare type EventType = "account status" | "connection update" | "new message" | "user joined" | "user left" | "typing" | "stop typing" | "disconnect" | "reconnect" | "reconnect failed" | "reconnect error" | "barge in" | "barge out" | "failure";
|
|
9
20
|
export interface RouterMessage {
|
|
10
|
-
event:
|
|
11
|
-
data:
|
|
21
|
+
event: EventType;
|
|
22
|
+
data: MessageData;
|
|
12
23
|
sender: VisitorInfo;
|
|
24
|
+
sessionId: string;
|
|
13
25
|
}
|
|
14
26
|
export interface VisitorInfo {
|
|
15
27
|
deviceId: "Widget" | "Bot";
|
|
@@ -21,13 +33,13 @@ export interface VisitorInfo {
|
|
|
21
33
|
urlAttributes: {
|
|
22
34
|
path?: string[];
|
|
23
35
|
query?: {
|
|
24
|
-
|
|
36
|
+
[name: string]: string;
|
|
25
37
|
};
|
|
26
38
|
};
|
|
27
39
|
}
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
}
|
|
40
|
+
export declare type HandlerStore = {
|
|
41
|
+
[event in EventType]: (data: MessageData, sender: VisitorInfo) => void;
|
|
42
|
+
};
|
|
31
43
|
export declare class StentorRouterChat implements ChatServer {
|
|
32
44
|
private dispatch;
|
|
33
45
|
private _userId;
|
|
@@ -40,27 +52,46 @@ export declare class StentorRouterChat implements ChatServer {
|
|
|
40
52
|
private urlAttributes;
|
|
41
53
|
private readonly config;
|
|
42
54
|
private readonly options;
|
|
55
|
+
private readonly configurableMessages;
|
|
43
56
|
private serverUrl;
|
|
44
57
|
private ws;
|
|
45
58
|
private handlers;
|
|
59
|
+
private sessionCreated;
|
|
46
60
|
constructor(config: StentorRouterChatConfig, options?: ChatServerOptions);
|
|
47
61
|
init(dispatch: (action: ActionType) => void): void;
|
|
48
62
|
private autoReconnect;
|
|
49
63
|
private wsCreate;
|
|
64
|
+
private checkConnection;
|
|
50
65
|
private emit;
|
|
51
66
|
private setAccountStatus;
|
|
67
|
+
private setConnectionStatus;
|
|
52
68
|
sendOfflineMsg(_: OfflineMessage, cb: (error?: Error) => void): void;
|
|
53
69
|
sendChatMsg(message: ChatServerMessage, cb: (err?: Error) => void): Promise<void>;
|
|
70
|
+
private sendFailureMessage;
|
|
71
|
+
private checkSession;
|
|
54
72
|
sendChatMsgRequest(serviceRequest: ChatMessageRequest, cb: (err?: Error) => void): Promise<void>;
|
|
55
|
-
sendTyping(
|
|
73
|
+
sendTyping(_isTyping: boolean): void;
|
|
56
74
|
setVisitorInfo(visitorInfoMessage: VisitorInfoMessage, cb: (error?: Error) => void): void;
|
|
57
75
|
sendChatRating(): void;
|
|
58
76
|
sendFile(_: File, cb: (err?: Error) => void): void;
|
|
59
77
|
markAsRead(): void;
|
|
60
78
|
flush(): void;
|
|
61
79
|
dispose(): void;
|
|
80
|
+
bargeOut(_cb: (err?: Error) => void): Promise<void>;
|
|
81
|
+
bargeIn(agentName: string, _cb: (err?: Error) => void): Promise<void>;
|
|
82
|
+
private postVisitorInfo;
|
|
62
83
|
private postMessage;
|
|
63
84
|
private startSession;
|
|
64
|
-
get userId(): string;
|
|
65
|
-
get sessionId(): string;
|
|
66
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param check Function that return true/false if the resource is available
|
|
89
|
+
* @param stepMs check period in ms
|
|
90
|
+
* @param timeoutMs max wait in ms
|
|
91
|
+
* @param resource optional resource name. you will see a log message for every check (step)
|
|
92
|
+
*
|
|
93
|
+
* @returns the elapsed time in ms (both resolve/reject)
|
|
94
|
+
*/
|
|
95
|
+
export declare function waitFor(check: {
|
|
96
|
+
(): boolean;
|
|
97
|
+
}, stepMs: number, timeoutMs: number, resource?: string): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xapp/chat-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.0",
|
|
4
4
|
"description": "XAPP Chat Widget",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rm -rf ./lib/* && rm -rf ./dist/*",
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/XappMedia/chat-widget#readme",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "7.
|
|
41
|
+
"@babel/core": "7.20.12",
|
|
42
42
|
"@rollup/plugin-commonjs": "22.0.2",
|
|
43
43
|
"@rollup/plugin-json": "4.1.0",
|
|
44
44
|
"@rollup/plugin-node-resolve": "13.3.0",
|
|
45
|
-
"@storybook/addon-actions": "6.5.
|
|
46
|
-
"@storybook/addon-essentials": "6.5.
|
|
47
|
-
"@storybook/addon-links": "6.5.
|
|
48
|
-
"@storybook/react": "6.5.
|
|
45
|
+
"@storybook/addon-actions": "6.5.16",
|
|
46
|
+
"@storybook/addon-essentials": "6.5.16",
|
|
47
|
+
"@storybook/addon-links": "6.5.16",
|
|
48
|
+
"@storybook/react": "6.5.16",
|
|
49
49
|
"@testing-library/jest-dom": "5.16.5",
|
|
50
50
|
"@types/enzyme": "3.10.12",
|
|
51
51
|
"@types/enzyme-adapter-react-16": "1.0.6",
|
|
52
52
|
"@types/jest": "27.5.2",
|
|
53
|
-
"@types/react": "17.0.
|
|
54
|
-
"@types/react-redux": "7.1.
|
|
53
|
+
"@types/react": "17.0.53",
|
|
54
|
+
"@types/react-redux": "7.1.25",
|
|
55
55
|
"@types/react-transition-group": "4.4.5",
|
|
56
56
|
"@types/socket.io-client": "1.4.36",
|
|
57
57
|
"@types/store": "2.0.2",
|
|
@@ -59,24 +59,24 @@
|
|
|
59
59
|
"@typescript-eslint/parser": "5.30.6",
|
|
60
60
|
"babel-eslint": "10.1.0",
|
|
61
61
|
"babel-jest": "27.5.1",
|
|
62
|
-
"babel-loader": "8.
|
|
62
|
+
"babel-loader": "8.3.0",
|
|
63
63
|
"enzyme": "3.11.0",
|
|
64
|
-
"enzyme-adapter-react-16": "1.15.
|
|
65
|
-
"eslint": "8.
|
|
64
|
+
"enzyme-adapter-react-16": "1.15.7",
|
|
65
|
+
"eslint": "8.34.0",
|
|
66
66
|
"eslint-config-prettier": "7.2.0",
|
|
67
67
|
"eslint-config-react-app": "6.0.0",
|
|
68
68
|
"eslint-plugin-flowtype": "8.0.3",
|
|
69
|
-
"eslint-plugin-import": "2.
|
|
70
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
69
|
+
"eslint-plugin-import": "2.27.5",
|
|
70
|
+
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
71
71
|
"eslint-plugin-react": "7.31.0",
|
|
72
72
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
73
73
|
"jest": "27.5.1",
|
|
74
74
|
"prettier": "2.7.1",
|
|
75
75
|
"react": "17.0.2",
|
|
76
76
|
"react-dom": "17.0.2",
|
|
77
|
-
"react-redux": "7.2.
|
|
78
|
-
"redux": "4.2.
|
|
79
|
-
"redux-thunk": "2.4.
|
|
77
|
+
"react-redux": "7.2.9",
|
|
78
|
+
"redux": "4.2.1",
|
|
79
|
+
"redux-thunk": "2.4.2",
|
|
80
80
|
"rollup": "2.78.1",
|
|
81
81
|
"rollup-plugin-inject-process-env": "1.3.1",
|
|
82
82
|
"rollup-plugin-peer-deps-external": "2.2.4",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"rollup-plugin-typescript2": "0.34.1",
|
|
86
86
|
"sass": "1.53.0",
|
|
87
87
|
"sass-loader": "10.3.1",
|
|
88
|
-
"stentor-models": "1.57.
|
|
88
|
+
"stentor-models": "1.57.73",
|
|
89
89
|
"ts-jest": "27.1.5",
|
|
90
90
|
"typescript": "4.7.4"
|
|
91
91
|
},
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"@rollup/plugin-replace": "^4.0.0",
|
|
105
|
-
"@xapp/chat-widget-core": "1.
|
|
106
|
-
"@xapp/stentor-chat-widget": "1.
|
|
105
|
+
"@xapp/chat-widget-core": "1.54.0",
|
|
106
|
+
"@xapp/stentor-chat-widget": "1.54.0",
|
|
107
107
|
"date-fns": "2.28.0",
|
|
108
108
|
"react-transition-group": "4.4.5",
|
|
109
109
|
"socket.io-client": "4.5.1",
|
|
110
110
|
"store": "2.0.12",
|
|
111
111
|
"tslib": "2.4.0"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "9dfa1e53eb0adead746c8172b818ba980a4dde64"
|
|
114
114
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { WidgetHeaderConfig } from "@xapp/stentor-chat-widget";
|
|
2
|
-
import React, { FC } from "react";
|
|
3
|
-
import { ChatUserInfo } from "../../xapp/UserInfo";
|
|
4
|
-
import "./StatusContainer.scss";
|
|
5
|
-
export interface Props {
|
|
6
|
-
accountStatus: string;
|
|
7
|
-
readonly canRefresh: boolean;
|
|
8
|
-
readonly canMinimize: boolean;
|
|
9
|
-
readonly canCancel: boolean;
|
|
10
|
-
readonly agent: ChatUserInfo;
|
|
11
|
-
readonly config?: WidgetHeaderConfig;
|
|
12
|
-
refreshOnClick: () => void;
|
|
13
|
-
minimizeOnClick: () => void;
|
|
14
|
-
cancelOnClick: () => void;
|
|
15
|
-
}
|
|
16
|
-
declare const StatusContainer: FC<React.PropsWithChildren<Props>>;
|
|
17
|
-
export default StatusContainer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Meta } from "@storybook/react/types-6-0";
|
|
2
|
-
import { VFC } from "react";
|
|
3
|
-
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
4
|
-
export default _default;
|
|
5
|
-
export declare const Online: VFC;
|
|
6
|
-
export declare const Offline: VFC;
|
|
7
|
-
export declare const Away: VFC;
|
|
8
|
-
export declare const WithLongStatus: VFC;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as StatusContainer } from "./StatusContainer";
|
package/dist/xapp/UserInfo.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { UserInfo } from "@xapp/stentor-chat-widget";
|
|
2
|
-
export interface ChatUserInfo extends UserInfo {
|
|
3
|
-
/**
|
|
4
|
-
* Users name
|
|
5
|
-
*/
|
|
6
|
-
readonly display_name?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The token that is received after a login
|
|
9
|
-
*/
|
|
10
|
-
token?: string;
|
|
11
|
-
/**
|
|
12
|
-
* If the user is typing or not
|
|
13
|
-
*/
|
|
14
|
-
typing?: boolean;
|
|
15
|
-
}
|