@satek-team-intern/chatbot-widget 0.10.7 → 0.11.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/README.md +82 -32
- package/dist/assets/background_chatlive_setting.webp +0 -0
- package/dist/chatbot-widget.es.js +5630 -3892
- package/dist/chatbot-widget.umd.js +1 -25
- package/dist/index.d.ts +1 -0
- package/package.json +6 -7
- package/dist/locales/en.json.d.ts +0 -263
- package/dist/locales/vi.json.d.ts +0 -264
- package/dist/src/assets/Icons.d.ts +0 -48
- package/dist/src/assets/createIcon.d.ts +0 -20
- package/dist/src/assets/index.d.ts +0 -2
- package/dist/src/components/ChatWidget.d.ts +0 -3
- package/dist/src/components/ChatWindow.d.ts +0 -32
- package/dist/src/components/FloatingButton.d.ts +0 -17
- package/dist/src/components/index.d.ts +0 -7
- package/dist/src/components/modals/AddChat.d.ts +0 -16
- package/dist/src/components/modals/AddGroup.d.ts +0 -7
- package/dist/src/components/modals/AddMember.d.ts +0 -7
- package/dist/src/components/modals/FileViewer.d.ts +0 -10
- package/dist/src/components/modals/ThemeModal.d.ts +0 -8
- package/dist/src/components/modals/UpdateGroup.d.ts +0 -10
- package/dist/src/components/modals/UserProfileModal.d.ts +0 -10
- package/dist/src/components/modals/index.d.ts +0 -5
- package/dist/src/components/shared/AvatarFallBack.d.ts +0 -5
- package/dist/src/components/shared/ChatAvatar.d.ts +0 -5
- package/dist/src/components/shared/MemberAvatarFallBack.d.ts +0 -5
- package/dist/src/components/shared/ToastContainer.d.ts +0 -2
- package/dist/src/components/shared/index.d.ts +0 -3
- package/dist/src/components/sidebar/AppSideBar.d.ts +0 -4
- package/dist/src/components/sidebar/ChatInfoPanel.d.ts +0 -11
- package/dist/src/components/sidebar/ChatList.d.ts +0 -8
- package/dist/src/components/sidebar/ChatSearchBar.d.ts +0 -10
- package/dist/src/components/sidebar/SideBarInfoChat.d.ts +0 -11
- package/dist/src/components/sidebar/index.d.ts +0 -4
- package/dist/src/components/view/ChatHeader.d.ts +0 -14
- package/dist/src/components/view/ChatInput.d.ts +0 -4
- package/dist/src/components/view/ChatListItem.d.ts +0 -9
- package/dist/src/components/view/ContactList.d.ts +0 -6
- package/dist/src/components/view/GroupList.d.ts +0 -8
- package/dist/src/components/view/ImageFileItem.d.ts +0 -10
- package/dist/src/components/view/MessageFiles.d.ts +0 -20
- package/dist/src/components/view/MessageItem.d.ts +0 -8
- package/dist/src/components/view/MessageList.d.ts +0 -2
- package/dist/src/components/view/ThemeSetting.d.ts +0 -3
- package/dist/src/components/view/index.d.ts +0 -10
- package/dist/src/config/configEnv.d.ts +0 -11
- package/dist/src/constants/common.d.ts +0 -13
- package/dist/src/constants/file.d.ts +0 -3
- package/dist/src/constants/index.d.ts +0 -2
- package/dist/src/contexts/FileViewerContext.d.ts +0 -14
- package/dist/src/contexts/ToastContext.d.ts +0 -4
- package/dist/src/contexts/index.d.ts +0 -3
- package/dist/src/contexts/toast-context.d.ts +0 -16
- package/dist/src/hooks/index.d.ts +0 -7
- package/dist/src/hooks/useChat.d.ts +0 -2
- package/dist/src/hooks/useDragDropFiles.d.ts +0 -12
- package/dist/src/hooks/useFileViewer.d.ts +0 -2
- package/dist/src/hooks/useSetting.d.ts +0 -5
- package/dist/src/hooks/useToast.d.ts +0 -1
- package/dist/src/hooks/useTranslation.d.ts +0 -5
- package/dist/src/hooks/useVoiceRecorder.d.ts +0 -14
- package/dist/src/index.d.ts +0 -5
- package/dist/src/locales/index.d.ts +0 -3
- package/dist/src/services/chat.service.d.ts +0 -43
- package/dist/src/services/index.d.ts +0 -2
- package/dist/src/services/language.service.d.ts +0 -18
- package/dist/src/store/index.d.ts +0 -3
- package/dist/src/store/selectors/index.d.ts +0 -1
- package/dist/src/store/selectors/setting.d.ts +0 -35
- package/dist/src/store/slices/chatSlice.d.ts +0 -25
- package/dist/src/store/slices/index.d.ts +0 -2
- package/dist/src/store/slices/settingSlice.d.ts +0 -13
- package/dist/src/store/store.d.ts +0 -16
- package/dist/src/styles/index.d.ts +0 -1
- package/dist/src/types/chat.type.d.ts +0 -297
- package/dist/src/types/index.d.ts +0 -2
- package/dist/src/types/types.d.ts +0 -61
- package/dist/src/utils/chat.utils.d.ts +0 -35
- package/dist/src/utils/file.utils.d.ts +0 -20
- package/dist/src/utils/format.utils.d.ts +0 -7
- package/dist/src/utils/formatDateLabel.d.ts +0 -1
- package/dist/src/utils/index.d.ts +0 -5
- package/dist/src/utils/validate.utils.d.ts +0 -1
- package/dist/src/utils/voice.utils.d.ts +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ChatUser, ChatConversation, ChatMessage, PaginationInfo } from '../../../types';
|
|
2
|
-
export interface ChatState {
|
|
3
|
-
currentUser: ChatUser | null;
|
|
4
|
-
chats: ChatConversation[];
|
|
5
|
-
currentChat?: ChatConversation | null;
|
|
6
|
-
currentChatMessages: ChatMessage[];
|
|
7
|
-
currentReceiver?: ChatUser | null;
|
|
8
|
-
currentChatMembers: ChatUser[];
|
|
9
|
-
members: ChatUser[];
|
|
10
|
-
totalMessagesUnread: number;
|
|
11
|
-
messagesPagination: PaginationInfo | null;
|
|
12
|
-
replyingMessage: ChatMessage | null;
|
|
13
|
-
memberSocketMap: Record<number, string[]>;
|
|
14
|
-
disconnectedSockets: Record<string, boolean>;
|
|
15
|
-
isChatLoading: boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare const clearAll: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-chatslice/clearAll">, setCurrentUser: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setCurrentUser">, setChats: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setChats">, setCurrentChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setCurrentChat">, setCurrentChatMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setCurrentChatMessages">, setCurrentChatMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setCurrentChatMembers">, setMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setMembers">, setMember: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setMember">, setMemberDisconnect: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setMemberDisconnect">, setMessagesPagination: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setMessagesPagination">, prependMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/prependMessages">, addNewMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/addNewMessage">, removeChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/removeChat">, addChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/addChat">, updateChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/updateChat">, updateChatAvatar: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/updateChatAvatar">, removeMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/removeMessage">, updateMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/updateMessage">, setReplyingMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setReplyingMessage">, setTotalMessagesUnread: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setTotalMessagesUnread">, updateMemberReadStatus: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
18
|
-
chatId: number;
|
|
19
|
-
memberId: number;
|
|
20
|
-
lastReadId: number;
|
|
21
|
-
}, "widget-chatslice/updateMemberReadStatus">, toggleChatSetting: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
22
|
-
chatId: number;
|
|
23
|
-
setting: "is_muted" | "is_pined";
|
|
24
|
-
}, "widget-chatslice/toggleChatSetting">, renewMemberActivity: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/renewMemberActivity">, memberJoinChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/memberJoinChat">, memberLeaveChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/memberLeaveChat">, setIsChatLoading: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-chatslice/setIsChatLoading">;
|
|
25
|
-
export declare const chatReducer: import('redux').Reducer<ChatState>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LanguageOption, WidgetFeature } from '../../../types';
|
|
2
|
-
export interface SettingState {
|
|
3
|
-
theme: 'light' | 'dark';
|
|
4
|
-
primaryColor: string;
|
|
5
|
-
features: WidgetFeature;
|
|
6
|
-
currentLanguage: LanguageOption;
|
|
7
|
-
hasMultipleLanguages: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const setConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
10
|
-
features?: WidgetFeature;
|
|
11
|
-
language?: LanguageOption;
|
|
12
|
-
}, "widget-settingslice/setConfig">, toggleTheme: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-settingslice/toggleTheme">, setFeatures: import('@reduxjs/toolkit').ActionCreatorWithPayload<WidgetFeature, "widget-settingslice/setFeatures">, setPrimaryColor: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-settingslice/setPrimaryColor">, setLanguage: import('@reduxjs/toolkit').ActionCreatorWithPayload<LanguageOption, "widget-settingslice/setLanguage">;
|
|
13
|
-
export declare const settingReducer: import('redux').Reducer<SettingState>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Tuple, AnyAction, ThunkDispatch, UnknownAction, EnhancedStore, StoreEnhancer } from '@reduxjs/toolkit';
|
|
2
|
-
import { ChatState, SettingState } from '../../store/slices';
|
|
3
|
-
export declare const store: EnhancedStore<{
|
|
4
|
-
chat: ChatState;
|
|
5
|
-
setting: SettingState;
|
|
6
|
-
}, AnyAction, Tuple<[
|
|
7
|
-
StoreEnhancer<{
|
|
8
|
-
dispatch: ThunkDispatch<{
|
|
9
|
-
chat: ChatState;
|
|
10
|
-
setting: SettingState;
|
|
11
|
-
}, undefined, UnknownAction>;
|
|
12
|
-
}>,
|
|
13
|
-
StoreEnhancer
|
|
14
|
-
]>>;
|
|
15
|
-
export type RootState = ReturnType<typeof store.getState>;
|
|
16
|
-
export type AppDispatch = typeof store.dispatch;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stylesTagContent: string;
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { AuthInfo } from './types';
|
|
2
|
-
export interface ChatUser {
|
|
3
|
-
id: number;
|
|
4
|
-
code: string;
|
|
5
|
-
name: string;
|
|
6
|
-
avatar?: string;
|
|
7
|
-
phone?: string;
|
|
8
|
-
email: string;
|
|
9
|
-
socket_at?: string;
|
|
10
|
-
socket_id?: string;
|
|
11
|
-
last_read_id?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface ChatResponse<T = unknown> {
|
|
14
|
-
data?: T;
|
|
15
|
-
message?: string;
|
|
16
|
-
statusCode?: number;
|
|
17
|
-
statusText?: string;
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
}
|
|
20
|
-
export interface ChatMessage {
|
|
21
|
-
id: number;
|
|
22
|
-
type: 'text';
|
|
23
|
-
action: Record<string, number>;
|
|
24
|
-
member: ChatUser;
|
|
25
|
-
content: string | null;
|
|
26
|
-
files?: ChatFile[];
|
|
27
|
-
revoked: boolean;
|
|
28
|
-
removed: boolean;
|
|
29
|
-
date: string;
|
|
30
|
-
reply?: ChatMessage | null;
|
|
31
|
-
created_at: string;
|
|
32
|
-
updated_at: string;
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
}
|
|
35
|
-
export interface ChatConversation {
|
|
36
|
-
id: number;
|
|
37
|
-
code: string;
|
|
38
|
-
name?: string;
|
|
39
|
-
type: 'single' | 'group';
|
|
40
|
-
avatar?: string | null;
|
|
41
|
-
message: ChatMessage | null;
|
|
42
|
-
members?: ChatUser[];
|
|
43
|
-
new: Record<number, number>;
|
|
44
|
-
owner_id?: number;
|
|
45
|
-
updated_at: string;
|
|
46
|
-
create_at: string;
|
|
47
|
-
is_muted?: boolean;
|
|
48
|
-
is_pined?: boolean;
|
|
49
|
-
member?: number;
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
}
|
|
52
|
-
export interface ChatEvent {
|
|
53
|
-
chats_created: 'chats.created';
|
|
54
|
-
chats_updated: 'chats.updated';
|
|
55
|
-
chats_deleted: 'chats.deleted';
|
|
56
|
-
chats_member: 'chats.member';
|
|
57
|
-
chats_action: 'chats.action';
|
|
58
|
-
chats_message: 'chats.message';
|
|
59
|
-
members_connect: 'members.connect';
|
|
60
|
-
members_disconnect: 'members.disconnect';
|
|
61
|
-
new_message: 'new_message';
|
|
62
|
-
}
|
|
63
|
-
export interface ChatFile {
|
|
64
|
-
id: number;
|
|
65
|
-
name: string;
|
|
66
|
-
ext: string;
|
|
67
|
-
size: number;
|
|
68
|
-
link: string;
|
|
69
|
-
}
|
|
70
|
-
export interface ChatConfig {
|
|
71
|
-
debugMode?: boolean;
|
|
72
|
-
maxRetries?: number;
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
}
|
|
75
|
-
export interface ChatSetting {
|
|
76
|
-
allow_delete_chat: boolean;
|
|
77
|
-
allow_delete_message: boolean;
|
|
78
|
-
allow_revoke_message: boolean;
|
|
79
|
-
delete_duration: number;
|
|
80
|
-
delete_duration_unit: 'minutes' | 'hours' | 'days';
|
|
81
|
-
revoke_duration: number;
|
|
82
|
-
revoke_duration_unit: 'minutes' | 'hours' | 'days';
|
|
83
|
-
}
|
|
84
|
-
export type MessageAction = 'like' | 'love' | 'revoke' | 'remove';
|
|
85
|
-
export interface PaginationInfo {
|
|
86
|
-
count: number;
|
|
87
|
-
current_page: number;
|
|
88
|
-
per_page: number;
|
|
89
|
-
total: number;
|
|
90
|
-
total_pages: number;
|
|
91
|
-
}
|
|
92
|
-
export interface ChatEventPayloads {
|
|
93
|
-
'chats.created': {
|
|
94
|
-
chat: ChatConversation;
|
|
95
|
-
};
|
|
96
|
-
'chats.updated': {
|
|
97
|
-
chat: ChatConversation;
|
|
98
|
-
};
|
|
99
|
-
'chats.deleted': {
|
|
100
|
-
chat_id: number;
|
|
101
|
-
};
|
|
102
|
-
'chats.member': {
|
|
103
|
-
type: 'join' | 'leave';
|
|
104
|
-
chat?: ChatConversation;
|
|
105
|
-
chat_id?: number;
|
|
106
|
-
member?: ChatUser;
|
|
107
|
-
member_id?: number;
|
|
108
|
-
};
|
|
109
|
-
'chats.action': {
|
|
110
|
-
chat_id?: number;
|
|
111
|
-
message_id?: number;
|
|
112
|
-
action?: MessageAction;
|
|
113
|
-
user_id?: number;
|
|
114
|
-
chat?: ChatConversation;
|
|
115
|
-
member_id?: number;
|
|
116
|
-
type: 'read' | 'unread';
|
|
117
|
-
};
|
|
118
|
-
'chats.message': {
|
|
119
|
-
chat: ChatConversation;
|
|
120
|
-
message: ChatMessage;
|
|
121
|
-
type: 'add' | 'remove' | 'revoke' | 'like' | 'love';
|
|
122
|
-
chat_id: number;
|
|
123
|
-
message_id: number;
|
|
124
|
-
};
|
|
125
|
-
'members.connect': {
|
|
126
|
-
member: ChatUser;
|
|
127
|
-
socketId: string;
|
|
128
|
-
timestamp: number;
|
|
129
|
-
};
|
|
130
|
-
'members.disconnect': {
|
|
131
|
-
socketId: string;
|
|
132
|
-
};
|
|
133
|
-
new_message: {
|
|
134
|
-
new: number;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
export interface ChatInstance {
|
|
138
|
-
/**
|
|
139
|
-
* Thuộc tính setting trả về cấu hình hiện tại của SDK, bao gồm các quyền hạn và giới hạn như allow_delete_chat, delete_duration...
|
|
140
|
-
*/
|
|
141
|
-
setting: ChatSetting;
|
|
142
|
-
/**
|
|
143
|
-
* Thiết lập cấu hình tùy chỉnh cho SDK.
|
|
144
|
-
* @param config (Object): Các tùy chọn cấu hình như debugMode, maxRetries...
|
|
145
|
-
*/
|
|
146
|
-
setConfig(config: ChatConfig): void;
|
|
147
|
-
/**
|
|
148
|
-
* Thiết lập thông tin xác thực cho SDK.
|
|
149
|
-
* @param data Thông tin người dùng hiện tại
|
|
150
|
-
*/
|
|
151
|
-
setAuth(data: AuthInfo): Promise<ChatUser>;
|
|
152
|
-
/**
|
|
153
|
-
* Lấy thông tin xác thực hiện tại.
|
|
154
|
-
*/
|
|
155
|
-
getAuth(): ChatUser | null;
|
|
156
|
-
/**
|
|
157
|
-
* Xóa thông tin xác thực.
|
|
158
|
-
*/
|
|
159
|
-
clearAuth(): void;
|
|
160
|
-
/**
|
|
161
|
-
* Thiết lập thông tin người nhận.
|
|
162
|
-
* @param data Thông tin người nhận
|
|
163
|
-
*/
|
|
164
|
-
setReceiver(data: ChatUser): Promise<ChatResponse<ChatUser>>;
|
|
165
|
-
/**
|
|
166
|
-
* Lấy thông tin người nhận hiện tại.
|
|
167
|
-
*/
|
|
168
|
-
getReceiver(): ChatUser | null;
|
|
169
|
-
/**
|
|
170
|
-
* Xóa thông tin người nhận.
|
|
171
|
-
*/
|
|
172
|
-
clearReceiver(): void;
|
|
173
|
-
/**
|
|
174
|
-
* Lấy danh sách thành viên
|
|
175
|
-
* @param chatId ID cuộc trò chuyện (tùy chọn, mặc định null lấy tất cả)
|
|
176
|
-
* @param limit Số lượng bản ghi (tùy chọn, mặc định 0 lấy tất cả)
|
|
177
|
-
* @param page Số trang (tùy chọn, mặc định 1)
|
|
178
|
-
* @param include Các trường bổ sung (tùy chọn)
|
|
179
|
-
*/
|
|
180
|
-
getMembers(chatId?: number | null, limit?: number, page?: number, include?: string): Promise<ChatResponse<ChatUser[]>>;
|
|
181
|
-
/**
|
|
182
|
-
* Thêm thành viên vào nhóm.
|
|
183
|
-
* @param chatId ID cuộc trò chuyện.
|
|
184
|
-
* @param memberId ID thành viên cần thêm.
|
|
185
|
-
*/
|
|
186
|
-
addMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
187
|
-
/**
|
|
188
|
-
* Xóa thành viên khỏi nhóm hoặc rời nhóm.
|
|
189
|
-
* Lưu ý: Nếu xóa chính mình, nhóm sẽ bị xóa hoàn toàn.
|
|
190
|
-
* @param chatId ID cuộc trò chuyện (Number)
|
|
191
|
-
* @param memberId ID thành viên cần xóa (Number)
|
|
192
|
-
*/
|
|
193
|
-
removeMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
194
|
-
/**
|
|
195
|
-
* Lấy danh sách cuộc trò chuyện của thành viên hiện tại.
|
|
196
|
-
* @param limit Số lượng bản ghi (tùy chọn, mặc định 0 = tất cả)
|
|
197
|
-
* @param page Số trang (tùy chọn, mặc định 1)
|
|
198
|
-
*/
|
|
199
|
-
getChats(limit?: number, page?: number): Promise<ChatResponse<ChatConversation[]> & {
|
|
200
|
-
pagination?: PaginationInfo;
|
|
201
|
-
}>;
|
|
202
|
-
/**
|
|
203
|
-
* Tìm cuộc trò chuyện 1-1 với một người nhất định.
|
|
204
|
-
* @param receiverId ID người nhận (Number)
|
|
205
|
-
* @returns Promise trả về object cuộc trò chuyện (ChatConversation) hoặc null
|
|
206
|
-
*/
|
|
207
|
-
findChatByReceiver(receiverId: number): Promise<ChatResponse<ChatConversation>>;
|
|
208
|
-
/**
|
|
209
|
-
* Tạo cuộc trò chuyện 1-1 hoặc lấy cuộc trò chuyện cũ nếu đã tồn tại.
|
|
210
|
-
* @param receiverId ID người nhận (Number, bắt buộc)
|
|
211
|
-
* @param content Tin nhắn đầu tiên (String, tùy chọn)
|
|
212
|
-
*/
|
|
213
|
-
addChat(receiverId: number, content?: string): Promise<ChatResponse<ChatConversation>>;
|
|
214
|
-
/**
|
|
215
|
-
* Tạo nhóm trò chuyện mới.
|
|
216
|
-
* @param memberIds Danh sách ID thành viên (ít nhất 2 thành viên khác)
|
|
217
|
-
* @param name Tên nhóm
|
|
218
|
-
* @param avatar URL ảnh đại diện nhóm (tùy chọn)
|
|
219
|
-
* @param userId ID người dùng tạo nhóm (tùy chọn)
|
|
220
|
-
* @returns Promise trả về object nhóm (ChatConversation)
|
|
221
|
-
*/
|
|
222
|
-
addGroup(memberIds: number[], name: string, avatar?: string | File, userId?: number): Promise<ChatResponse<ChatConversation>>;
|
|
223
|
-
/**
|
|
224
|
-
* Cập nhật thông tin nhóm (Tên và Ảnh đại diện).
|
|
225
|
-
* @param chatId ID nhóm (Number, bắt buộc)
|
|
226
|
-
* @param name Tên nhóm mới (String, bắt buộc)
|
|
227
|
-
* @param avatar URL ảnh đại diện mới (String, tùy chọn)
|
|
228
|
-
* @returns Promise trả về object nhóm đã được cập nhật
|
|
229
|
-
*/
|
|
230
|
-
updateGroup(chatId: number, name: string, avatar?: string | File): Promise<ChatResponse<ChatConversation>>;
|
|
231
|
-
/**
|
|
232
|
-
* Xóa một cuộc trò chuyện (chat 1-1 hoặc nhóm).
|
|
233
|
-
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
234
|
-
* @returns Promise trả về kết quả thành công/thất bại
|
|
235
|
-
*/
|
|
236
|
-
removeChat(chatId: number): Promise<ChatResponse>;
|
|
237
|
-
/**
|
|
238
|
-
* Đánh dấu cuộc trò chuyện là đã đọc.
|
|
239
|
-
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
240
|
-
* @returns Promise trả về kết quả
|
|
241
|
-
*/
|
|
242
|
-
readChat(chatId: number): Promise<ChatResponse>;
|
|
243
|
-
/**
|
|
244
|
-
* Đánh dấu cuộc trò chuyện là chưa đọc.
|
|
245
|
-
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
246
|
-
* @returns Promise trả về kết quả
|
|
247
|
-
*/
|
|
248
|
-
unreadChat(chatId: number): Promise<ChatResponse>;
|
|
249
|
-
/**
|
|
250
|
-
* Lấy danh sách tin nhắn trong một cuộc trò chuyện.
|
|
251
|
-
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
252
|
-
* @param limit Số lượng tin nhắn (Number, tùy chọn, mặc định 20)
|
|
253
|
-
* @param page Trang (Number, tùy chọn, mặc định 1)
|
|
254
|
-
*/
|
|
255
|
-
getMessages(chatId: number, limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
256
|
-
pagination?: PaginationInfo;
|
|
257
|
-
}>;
|
|
258
|
-
/**
|
|
259
|
-
* Gửi tin nhắn với nội dung, tập tin, hoặc trả lời tin nhắn khác.
|
|
260
|
-
* @param chatId ID cuộc trò chuyện (Bắt buộc)
|
|
261
|
-
* @param content Nội dung văn bản (Bắt buộc nếu không có files)
|
|
262
|
-
* @param files Danh sách tập tin (FileList hoặc File[])
|
|
263
|
-
* @param replyId ID tin nhắn cần trả lời
|
|
264
|
-
*/
|
|
265
|
-
addMessage(chatId: number, content?: string | null, files?: FileList | File[] | null, replyId?: number | null): Promise<ChatResponse<ChatMessage>>;
|
|
266
|
-
/**
|
|
267
|
-
* Tương tác với tin nhắn (like, love, revoke, remove).
|
|
268
|
-
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
269
|
-
* @param messageId ID tin nhắn (Number, bắt buộc)
|
|
270
|
-
* @param action Kiểu tương tác ('like' | 'love' | 'revoke' | 'remove')
|
|
271
|
-
* @returns Promise trả về kết quả từ SDK
|
|
272
|
-
*/
|
|
273
|
-
actionMessage(chatId: number, messageId: number, action: MessageAction): Promise<{
|
|
274
|
-
message_id: number;
|
|
275
|
-
member_id: number;
|
|
276
|
-
}>;
|
|
277
|
-
EVENTS: ChatEvent;
|
|
278
|
-
/**
|
|
279
|
-
* Đăng ký lắng nghe sự kiện realtime
|
|
280
|
-
* @param event Tên sự kiện (lấy từ chatSDK.EVENTS)
|
|
281
|
-
* @param listener Hàm callback xử lý dữ liệu trả về
|
|
282
|
-
*/
|
|
283
|
-
addEventListener<K extends keyof ChatEventPayloads>(event: K, listener: (data: K extends keyof ChatEventPayloads ? ChatEventPayloads[K] : unknown) => void): void;
|
|
284
|
-
/**
|
|
285
|
-
* Hủy lắng nghe một sự kiện.
|
|
286
|
-
* @param event Tên sự kiện (String, bắt buộc)
|
|
287
|
-
* @param listener Hàm callback cần xóa (Tùy chọn). Nếu không truyền hoặc truyền null, xóa tất cả listeners của sự kiện này.
|
|
288
|
-
*/
|
|
289
|
-
removeEventListener<K extends keyof ChatEventPayloads>(event: K, listener?: (data: ChatEventPayloads[K]) => void): void;
|
|
290
|
-
/**
|
|
291
|
-
* Đẩy một sự kiện cho tất cả listeners (thường dùng cho debug hoặc logic tùy chỉnh).
|
|
292
|
-
* @param name (String, bắt buộc): Tên sự kiện (lấy từ chatSDK.EVENTS)
|
|
293
|
-
* @param data (Object): Dữ liệu đi kèm sự kiện
|
|
294
|
-
*/
|
|
295
|
-
runEvent<K extends keyof ChatEventPayloads>(name: K | string, data?: ChatEventPayloads[K]): void;
|
|
296
|
-
}
|
|
297
|
-
export type ChatConstructor = new (workspace?: string) => ChatInstance;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export type WidgetMode = 'closed' | 'popup' | 'fullpage';
|
|
2
|
-
export interface AuthInfo {
|
|
3
|
-
code: string;
|
|
4
|
-
name: string;
|
|
5
|
-
avatar?: string;
|
|
6
|
-
phone?: string;
|
|
7
|
-
email: string;
|
|
8
|
-
}
|
|
9
|
-
/** Vị trí tính theo tọa độ
|
|
10
|
-
* - x: Khoảng cách từ mép phải của cửa sổ trình duyệt đến điểm đặt widget.
|
|
11
|
-
* - y: Khoảng cách từ mép dưới của cửa sổ trình duyệt đến điểm đặt widget.
|
|
12
|
-
*/
|
|
13
|
-
export interface PositionType {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
}
|
|
17
|
-
/** Các loại định dạng tập tin được phép đính kèm từ thiết bị */
|
|
18
|
-
export type AttachmentType = 'image' | 'video' | 'audio' | 'file' | 'multiple';
|
|
19
|
-
/** Các tùy chọn ngôn ngữ hiển thị trên giao diện */
|
|
20
|
-
export type LanguageOption = 'english' | 'vietnamese';
|
|
21
|
-
/**
|
|
22
|
-
* Các phương thức truyền thông và ghi hình.
|
|
23
|
-
* - 'voice': Ghi âm và gửi tin nhắn thoại.
|
|
24
|
-
*/
|
|
25
|
-
export type CommunicationFeature = 'voice';
|
|
26
|
-
/**
|
|
27
|
-
* Chế độ vận hành của cửa sổ chat.
|
|
28
|
-
* - 'single': Chat 1-1.
|
|
29
|
-
* - 'group': Chế độ chat nhóm nhiều người tham gia.
|
|
30
|
-
*/
|
|
31
|
-
export type WidgetChatMode = 'single' | 'group';
|
|
32
|
-
/**
|
|
33
|
-
* Các tùy chọn can thiệp và mở rộng giao diện Widget.
|
|
34
|
-
* - 'change-color': Người dùng cuối có thể tự chọn màu chủ đạo (Primary Color).
|
|
35
|
-
* - 'change-theme': Người dùng cuối có thể chuyển đổi giữa các chủ đề (ví dụ: Sáng/Tối).
|
|
36
|
-
*/
|
|
37
|
-
export type WidgetCustomizationOptions = 'change-color' | 'change-theme';
|
|
38
|
-
export interface WidgetFeature {
|
|
39
|
-
/** Danh sách các loại tập tin cho phép tải lên. Nếu có 'multiple', cho phép chọn nhiều file. */
|
|
40
|
-
attachments?: AttachmentType[];
|
|
41
|
-
/** Các tính năng tương tác trực tiếp bằng âm thanh và hình ảnh. */
|
|
42
|
-
communication?: CommunicationFeature[];
|
|
43
|
-
/**
|
|
44
|
-
* Xác định các hình thức hội thoại mà widget hỗ trợ.
|
|
45
|
-
* Nếu không truyền, mặc định là ['single']
|
|
46
|
-
*/
|
|
47
|
-
chatModes?: WidgetChatMode[];
|
|
48
|
-
/** Các quyền tùy biến giao diện cho phép người dùng thực hiện. */
|
|
49
|
-
customizations?: WidgetCustomizationOptions[];
|
|
50
|
-
}
|
|
51
|
-
export interface ChatWidgetProps {
|
|
52
|
-
title?: string;
|
|
53
|
-
workspace: string;
|
|
54
|
-
logoUrl?: string;
|
|
55
|
-
primaryColor?: string;
|
|
56
|
-
auth: AuthInfo;
|
|
57
|
-
chatKey: string;
|
|
58
|
-
features?: WidgetFeature;
|
|
59
|
-
language?: LanguageOption;
|
|
60
|
-
initPosition?: PositionType;
|
|
61
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AttachmentType, ChatConversation, ChatUser, CommunicationFeature, WidgetChatMode, WidgetCustomizationOptions, WidgetFeature } from '../../types';
|
|
2
|
-
export declare const getChatName: (chat?: ChatConversation | null, currentUserId?: number, fallback?: string) => string;
|
|
3
|
-
export interface FeatureSet {
|
|
4
|
-
attachments: Set<AttachmentType>;
|
|
5
|
-
communication: Set<CommunicationFeature>;
|
|
6
|
-
chatModes: Set<WidgetChatMode>;
|
|
7
|
-
customizations: Set<WidgetCustomizationOptions>;
|
|
8
|
-
}
|
|
9
|
-
export interface FeatureAnalysis {
|
|
10
|
-
featureSet: FeatureSet;
|
|
11
|
-
hasVoice: boolean;
|
|
12
|
-
hasAttachment: boolean;
|
|
13
|
-
hasMultipleAttachments: boolean;
|
|
14
|
-
hasGroupChat: boolean;
|
|
15
|
-
hasSingleChat: boolean;
|
|
16
|
-
hasChangeColor: boolean;
|
|
17
|
-
hasMultipleLanguages: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare const analyzeFeatures: (features: WidgetFeature, hasMultipleLanguages?: boolean) => FeatureAnalysis;
|
|
20
|
-
export declare const getAcceptFilter: (featureSet: FeatureSet) => string;
|
|
21
|
-
export declare const createFileTypeChecker: (featureSet: FeatureSet) => (file: File) => boolean;
|
|
22
|
-
export declare const isConnected: (socketAt: string | undefined) => boolean;
|
|
23
|
-
export declare const addSocketToMap: (memberSocketMap: Record<string, string[]>, memberId: string | number, // Chấp nhận cả string và number cho key
|
|
24
|
-
socketId: string | undefined) => void;
|
|
25
|
-
export declare const transformMember: (member: ChatUser, memberSocketMap: Record<string, string[]>, disconnectedSockets: Record<string, boolean>) => {
|
|
26
|
-
socket_id: string | undefined;
|
|
27
|
-
socket_at: string | undefined;
|
|
28
|
-
id: number;
|
|
29
|
-
code: string;
|
|
30
|
-
name: string;
|
|
31
|
-
avatar?: string;
|
|
32
|
-
phone?: string;
|
|
33
|
-
email: string;
|
|
34
|
-
last_read_id?: number;
|
|
35
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, JSX } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Lấy icon dựa trên tên file hoặc extension
|
|
4
|
-
* @param fileNameOrExt Có thể là "image.png" hoặc chỉ "png"
|
|
5
|
-
*/
|
|
6
|
-
export declare const getFileIcon: (fileNameOrExt: string) => JSX.Element;
|
|
7
|
-
export declare const getFileKey: (file: File) => string | undefined;
|
|
8
|
-
export declare const formatFileSize: (bytes: number) => string;
|
|
9
|
-
export declare const getFileType: (fileName: string) => "image" | "video" | "audio" | "pdf" | "other";
|
|
10
|
-
export declare const getImagePreview: (file: File) => string;
|
|
11
|
-
export declare const isImageFile: (file: File) => boolean;
|
|
12
|
-
export declare const sortFilesByType: (files: File[]) => File[];
|
|
13
|
-
export declare const sanitizeImage: (file: File) => Promise<File>;
|
|
14
|
-
export declare const getFilesValidationError: (files: File[], hasMultipleAttachments: boolean, isFileTypeAllowed: (file: File) => boolean) => Promise<{
|
|
15
|
-
message: string;
|
|
16
|
-
type: "warning" | "error";
|
|
17
|
-
} | null>;
|
|
18
|
-
export declare const validateFileContent: (file: File) => Promise<boolean>;
|
|
19
|
-
export declare const validateFileUrlContent: (url: string, type: string) => Promise<boolean>;
|
|
20
|
-
export declare function getImageRatioStyleFromLink(imgUrl: string): Promise<CSSProperties>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LanguageOption } from '../../types';
|
|
2
|
-
export declare const formatDateLabel: (dateStr: string | Date, currentLanguage: LanguageOption) => string;
|
|
3
|
-
export declare const formatDuration: (ms: number) => string;
|
|
4
|
-
export declare const removeVietnameseTones: (str: string) => string;
|
|
5
|
-
export declare const formatToDateTimeString: (dateInput: string | number | Date) => string;
|
|
6
|
-
export declare const getCleanTitle: (url: string) => string | null;
|
|
7
|
-
export declare const formatMessageTime: (dateInput: Date, language: LanguageOption) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const formatDateLabel: (dateStr: string | Date) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isStandardUrl: (urlString: string) => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const convertToMp3: (blob: Blob) => Promise<Blob>;
|