@xapp/chat-widget 1.28.0 → 1.30.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.
@@ -6,6 +6,7 @@ export declare type MessageMiddlewareSendMessage = Omit<ChatMessageRequest, "tim
6
6
  export interface MessageMiddlewareContext {
7
7
  readonly user: UserInfo;
8
8
  send(msg: MessageMiddlewareSendMessage): void;
9
+ write(msg: MessageMiddlewareSendMessage): void;
9
10
  openUrl(url: string): void;
10
11
  }
11
12
  export interface MessageMiddlewareProps {
@@ -1,6 +1,7 @@
1
1
  import { Action } from "redux";
2
2
  import { Attachment } from "../xapp/Attachment";
3
3
  import { ChatServerMessage } from "../xapp/ChatServerMessage";
4
+ import { UserInfo } from "../xapp/UserInfo";
4
5
  export declare type CONNECTION_STATUS_TYPE = "online" | "pending" | "offline";
5
6
  export declare type ACCOUNT_STATUS_TYPE = "offline" | "online";
6
7
  export declare type ACTION_TYPE = "chat" | "account_status" | "connection_update" | "department_update" | "visitor_update" | "agent_update" | "error" | "reset";
@@ -8,8 +9,8 @@ export interface ActionDetail {
8
9
  timestamp: number;
9
10
  }
10
11
  export interface ChatActionDetail<T> extends ActionDetail {
11
- type: T;
12
- nick: string;
12
+ readonly type: T;
13
+ readonly user: UserInfo;
13
14
  }
14
15
  export interface ChatAction extends Action<"chat"> {
15
16
  detail: ChatDetail;
@@ -24,11 +25,8 @@ export interface ConnectionReceiveTokenDetail extends Action<"receiveToken"> {
24
25
  };
25
26
  }
26
27
  export interface ChatMemberJoinDetail extends ChatActionDetail<"chat.memberjoin"> {
27
- displayName: string;
28
- avatarPath?: string;
29
28
  }
30
29
  export interface ChatMemberLeaveDetail extends ChatActionDetail<"chat.memberleave"> {
31
- displayName: string;
32
30
  }
33
31
  export interface ChatMemberPositionDetail extends ChatActionDetail<"chat.queue.position"> {
34
32
  queuePosition: number;
@@ -39,11 +37,9 @@ export interface ChatRatingDetail extends ChatActionDetail<"chat.rating"> {
39
37
  newRating: string;
40
38
  }
41
39
  export interface ChatFileDetail extends ChatActionDetail<"chat.file"> {
42
- displayName: string;
43
- attachment: Attachment;
40
+ readonly attachment: Attachment;
44
41
  }
45
42
  export interface ChatMsgDetail extends ChatActionDetail<"chat.msg"> {
46
- displayName: string;
47
43
  msg: ChatServerMessage;
48
44
  }
49
45
  export interface ChatTypingDetail extends ChatActionDetail<"chat.typing"> {
@@ -93,8 +89,9 @@ export interface SyntheticAction extends Action<"synthetic"> {
93
89
  detail: SyntheticMsgDetail | SyntheticFileDetail | SyntheticOptionDetail;
94
90
  }
95
91
  export interface SyntheticMsgDetail extends ActionDetail {
96
- readonly type: "visitor.send.msg";
92
+ readonly type: "write_msg";
97
93
  readonly msg: ChatServerMessage;
94
+ readonly user: UserInfo;
98
95
  }
99
96
  export interface SyntheticOptionDetail extends ChatActionDetail<"visitor.send.option"> {
100
97
  msg: ChatServerMessage;
@@ -1,24 +1,23 @@
1
1
  import { ChatServerActionLink } from "../xapp/ChatServerMessage";
2
- import { ACCOUNT_STATUS_TYPE, ChatDetail, CONNECTION_STATUS_TYPE, DepartmentUpdateDetail, VisitorUpdateDetail } from "./ChatAction";
2
+ import { UserInfo } from "../xapp/UserInfo";
3
+ import { ACCOUNT_STATUS_TYPE, ChatDetail, CONNECTION_STATUS_TYPE, DepartmentUpdateDetail } from "./ChatAction";
3
4
  interface ChatDepartments {
4
5
  [id: string]: DepartmentUpdateDetail;
5
6
  }
6
- interface ChatAgents {
7
+ export interface ChatAgents {
7
8
  readonly [nick: string]: ChatAgentInfo | undefined;
8
9
  }
9
10
  export interface ChatAgentInfo {
10
- readonly nick: string;
11
- readonly displayName: string;
12
11
  readonly typing: boolean;
13
- readonly avatarPath?: string;
12
+ readonly user: UserInfo;
14
13
  readonly joined: boolean;
15
14
  }
16
15
  export interface ChatState {
17
16
  readonly connection: ConnectionState;
18
17
  accountStatus: ACCOUNT_STATUS_TYPE;
19
18
  departments: ChatDepartments;
20
- visitor: VisitorUpdateDetail;
21
- agents: ChatAgents;
19
+ visitor: UserInfo;
20
+ readonly agents: ChatAgents;
22
21
  chats: ChatDetail[];
23
22
  lastTimestamp: number;
24
23
  lastRatingRequestTimestamp: number;
@@ -0,0 +1,4 @@
1
+ import { ChatServerMessage } from "../../xapp/ChatServerMessage";
2
+ import { UserInfo } from "../../xapp/UserInfo";
3
+ import { ActionType } from "../ChatAction";
4
+ export declare function writeMessage(msg: ChatServerMessage, user: UserInfo): ActionType;
@@ -1,3 +1,3 @@
1
- import { ChatState } from "../ChatState";
2
1
  import { ChatMemberJoinDetail } from "../ChatAction";
2
+ import { ChatState } from "../ChatState";
3
3
  export declare function memberJoin(state: ChatState, detail: ChatMemberJoinDetail): ChatState;
@@ -0,0 +1,2 @@
1
+ import { ChatAgents } from "../store/ChatState";
2
+ export declare const agents: ChatAgents;
@@ -2,4 +2,5 @@ import { ChatDetail } from "../store/ChatAction";
2
2
  import { ChatServerMessage } from "../xapp/ChatServerMessage";
3
3
  export declare const carouselMessage: ChatServerMessage;
4
4
  export declare const listMessage: ChatServerMessage;
5
+ export declare const locationRequestMessage: ChatServerMessage;
5
6
  export declare const messages: readonly ChatDetail[];
@@ -0,0 +1,2 @@
1
+ import { ChatDispatch } from "../store/actions/types";
2
+ export declare function useChatDispatch(): ChatDispatch;
@@ -2,6 +2,7 @@
2
2
  * This mirrors the declaration in Chat-Server
3
3
  */
4
4
  import { Display } from "stentor-models";
5
+ import { UserInfo } from "./UserInfo";
5
6
  /**
6
7
  * It's the same request in both (visitor <-> agent) direction!
7
8
  */
@@ -9,13 +10,18 @@ export interface ChatMessageRequest {
9
10
  type: "rating" | "ratingRequest" | "comment" | "msg" | "custom" | "startTyping" | "stopTyping" | "userJoined" | "userLeft" | "handOff" | "handBack" | "permissionRequest" | "permissionGrant";
10
11
  timestamp: number;
11
12
  msg?: ChatServerMessage;
12
- userName?: string;
13
- avatarPath?: string;
13
+ readonly user: UserInfo;
14
14
  agent?: boolean;
15
15
  endSession?: boolean;
16
16
  handoffMessage?: string;
17
17
  handoffTarget?: string;
18
- permissionRequestType?: "EMAIL" | "PHONE";
18
+ }
19
+ export declare type PermissionRequestType = "EMAIL" | "PHONE_NUMBER" | "LOCATION_PRECISE";
20
+ export interface PermissionRequest {
21
+ readonly time: number;
22
+ readonly type: PermissionRequestType;
23
+ readonly approve?: ChatServerMessage;
24
+ readonly deny?: ChatServerMessage;
19
25
  }
20
26
  export interface ChatMessageRequestCustom extends ChatMessageRequest {
21
27
  readonly type: "custom";
@@ -24,13 +30,19 @@ export interface ChatMessageRequestCustom extends ChatMessageRequest {
24
30
  export interface ChatServerMessage {
25
31
  readonly text?: string;
26
32
  readonly html?: string;
33
+ readonly permissionRequest?: PermissionRequest;
27
34
  options?: (string | ChatServerActionLink)[];
28
35
  card?: ChatServerCard;
29
36
  list?: ChatServerList;
30
37
  token?: string;
38
+ location?: ChatServerLocation;
31
39
  displays?: readonly Display[];
32
40
  context?: readonly string[];
33
41
  }
42
+ export interface ChatServerLocation {
43
+ readonly latitude: number;
44
+ readonly longitude: number;
45
+ }
34
46
  export interface ChatServerCard {
35
47
  title?: string;
36
48
  imageUrl?: string;
@@ -11,9 +11,6 @@ export declare class StentorDirectChat implements ChatServer {
11
11
  private dispatch;
12
12
  private visitorInfo;
13
13
  private isNewSession;
14
- private permissionRequestPending;
15
- private permissionRequestTime;
16
- private permissionRequestType;
17
14
  private readonly avatarPath;
18
15
  getAvatarPath(): string;
19
16
  private readonly config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xapp/chat-widget",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "XAPP Chat Widget",
5
5
  "scripts": {
6
6
  "clean": "rm -rf ./lib/* && rm -rf ./dist/*",
@@ -45,11 +45,11 @@
45
45
  "@storybook/addon-essentials": "6.3.12",
46
46
  "@storybook/addon-links": "6.3.12",
47
47
  "@storybook/react": "6.3.12",
48
- "@testing-library/jest-dom": "5.15.0",
48
+ "@testing-library/jest-dom": "5.15.1",
49
49
  "@types/enzyme": "3.10.10",
50
50
  "@types/enzyme-adapter-react-16": "1.0.6",
51
51
  "@types/jest": "26.0.24",
52
- "@types/react": "17.0.34",
52
+ "@types/react": "17.0.37",
53
53
  "@types/react-redux": "7.1.20",
54
54
  "@types/react-transition-group": "4.4.4",
55
55
  "@types/socket.io-client": "1.4.36",
@@ -63,27 +63,27 @@
63
63
  "eslint": "7.32.0",
64
64
  "eslint-config-prettier": "7.2.0",
65
65
  "eslint-config-react-app": "6.0.0",
66
- "eslint-plugin-flowtype": "5.10.0",
67
- "eslint-plugin-import": "2.25.2",
68
- "eslint-plugin-jsx-a11y": "6.4.1",
69
- "eslint-plugin-react": "7.26.1",
70
- "eslint-plugin-react-hooks": "4.2.0",
66
+ "eslint-plugin-flowtype": "8.0.3",
67
+ "eslint-plugin-import": "2.25.3",
68
+ "eslint-plugin-jsx-a11y": "6.5.1",
69
+ "eslint-plugin-react": "7.27.1",
70
+ "eslint-plugin-react-hooks": "4.3.0",
71
71
  "jest": "26.6.3",
72
72
  "prettier": "2.4.1",
73
73
  "react": "16.14.0",
74
74
  "react-dom": "16.14.0",
75
75
  "react-redux": "7.2.6",
76
76
  "redux": "4.1.1",
77
- "redux-thunk": "2.4.0",
78
- "rollup": "2.59.0",
77
+ "redux-thunk": "2.4.1",
78
+ "rollup": "2.60.0",
79
79
  "rollup-plugin-inject-process-env": "1.3.1",
80
80
  "rollup-plugin-peer-deps-external": "2.2.4",
81
- "rollup-plugin-scss": "2.6.1",
81
+ "rollup-plugin-scss": "3.0.0",
82
82
  "rollup-plugin-terser": "7.0.2",
83
83
  "rollup-plugin-typescript2": "0.30.0",
84
84
  "sass": "1.43.4",
85
85
  "sass-loader": "10.2.0",
86
- "stentor-models": "1.48.7",
86
+ "stentor-models": "1.48.30",
87
87
  "ts-jest": "26.5.6",
88
88
  "typescript": "4.4.4"
89
89
  },
@@ -100,12 +100,12 @@
100
100
  },
101
101
  "dependencies": {
102
102
  "@rollup/plugin-replace": "^3.0.0",
103
- "@xapp/stentor-chat-widget": "1.28.0",
103
+ "@xapp/stentor-chat-widget": "1.30.0",
104
104
  "react-transition-group": "4.4.2",
105
- "socket.io-client": "4.1.2",
106
- "stentor-models": "1.48.7",
105
+ "socket.io-client": "4.3.2",
106
+ "stentor-models": "1.48.30",
107
107
  "store": "2.0.12",
108
108
  "tslib": "^2.3.1"
109
109
  },
110
- "gitHead": "bcedfbccfda9ed5d040b017537f7366a1d5a3c70"
110
+ "gitHead": "27246b776ad32566952a7fa20e8b155a8b3795af"
111
111
  }