@satek-team-intern/chatbot-widget 0.11.0 → 0.11.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/dist/chatbot-widget.umd.js +9 -1
- package/dist/constants/scenario_guest_vi.json.d.ts +103 -0
- package/dist/locales/en.json.d.ts +331 -0
- package/dist/locales/vi.json.d.ts +332 -0
- package/dist/src/assets/Icons.d.ts +67 -0
- package/dist/src/assets/createIcon.d.ts +24 -0
- package/dist/src/assets/index.d.ts +2 -0
- package/dist/src/components/ChatWidget.d.ts +3 -0
- package/dist/src/components/ChatWindow.d.ts +3 -0
- package/dist/src/components/FloatingButton.d.ts +1 -0
- package/dist/src/components/account/MultiChatManager.d.ts +6 -0
- package/dist/src/components/account/index.d.ts +1 -0
- package/dist/src/components/index.d.ts +8 -0
- package/dist/src/components/modals/AddGroup.d.ts +6 -0
- package/dist/src/components/modals/AddMember.d.ts +6 -0
- package/dist/src/components/modals/FileViewer.d.ts +10 -0
- package/dist/src/components/modals/UpdateGroup.d.ts +8 -0
- package/dist/src/components/modals/UserProfileModal.d.ts +1 -0
- package/dist/src/components/modals/index.d.ts +5 -0
- package/dist/src/components/shared/AvatarFallBack.d.ts +5 -0
- package/dist/src/components/shared/OnboardingFormBlock.d.ts +10 -0
- package/dist/src/components/shared/QuickReplyButton.d.ts +13 -0
- package/dist/src/components/shared/ToastContainer.d.ts +2 -0
- package/dist/src/components/shared/index.d.ts +4 -0
- package/dist/src/components/sidebar/AppSideBar.d.ts +1 -0
- package/dist/src/components/sidebar/ChatInfoPanel.d.ts +10 -0
- package/dist/src/components/sidebar/ChatList.d.ts +7 -0
- package/dist/src/components/sidebar/ChatSearchBar.d.ts +9 -0
- package/dist/src/components/sidebar/ChatSidebar.d.ts +9 -0
- package/dist/src/components/sidebar/index.d.ts +5 -0
- package/dist/src/components/view/ChatHeader.d.ts +10 -0
- package/dist/src/components/view/ChatInput.d.ts +4 -0
- package/dist/src/components/view/ChatListItem.d.ts +7 -0
- package/dist/src/components/view/ChatMainArea.d.ts +9 -0
- package/dist/src/components/view/ChatMainHeader.d.ts +6 -0
- package/dist/src/components/view/ChatliveSetting.d.ts +1 -0
- package/dist/src/components/view/ContactList.d.ts +6 -0
- package/dist/src/components/view/EmptyChatState.d.ts +1 -0
- package/dist/src/components/view/FileIconMap.d.ts +8 -0
- package/dist/src/components/view/GroupList.d.ts +9 -0
- package/dist/src/components/view/ImageFileItem.d.ts +10 -0
- package/dist/src/components/view/MessageFiles.d.ts +23 -0
- package/dist/src/components/view/MessageItem.d.ts +7 -0
- package/dist/src/components/view/MessageList.d.ts +2 -0
- package/dist/src/components/view/SettingSection.d.ts +1 -0
- package/dist/src/components/view/ThemeSetting.d.ts +1 -0
- package/dist/src/components/view/WindowResizeHandles.d.ts +6 -0
- package/dist/src/components/view/index.d.ts +16 -0
- package/dist/src/config/configEnv.d.ts +11 -0
- package/dist/src/constants/common.d.ts +15 -0
- package/dist/src/constants/file.d.ts +3 -0
- package/dist/src/constants/index.d.ts +6 -0
- package/dist/src/constants/onboarding.d.ts +4 -0
- package/dist/src/constants/permissionRules.d.ts +25 -0
- package/dist/src/constants/permissions.d.ts +15 -0
- package/dist/src/contexts/FileViewerContext.d.ts +14 -0
- package/dist/src/contexts/ToastContext.d.ts +4 -0
- package/dist/src/contexts/index.d.ts +3 -0
- package/dist/src/contexts/toast-context.d.ts +16 -0
- package/dist/src/hooks/index.d.ts +13 -0
- package/dist/src/hooks/useChat.d.ts +2 -0
- package/dist/src/hooks/useChatActions.d.ts +9 -0
- package/dist/src/hooks/useChatSearch.d.ts +27 -0
- package/dist/src/hooks/useChatWidget.d.ts +4 -0
- package/dist/src/hooks/useDragDropFiles.d.ts +12 -0
- package/dist/src/hooks/useFileViewer.d.ts +2 -0
- package/dist/src/hooks/usePermissions.d.ts +9 -0
- package/dist/src/hooks/useProcessOnboarding.d.ts +3 -0
- package/dist/src/hooks/useSetting.d.ts +8 -0
- package/dist/src/hooks/useToast.d.ts +1 -0
- package/dist/src/hooks/useTranslation.d.ts +5 -0
- package/dist/src/hooks/useVoiceRecorder.d.ts +14 -0
- package/dist/src/hooks/useWindowControls.d.ts +14 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/locales/index.d.ts +3 -0
- package/dist/src/services/chat.service.d.ts +42 -0
- package/dist/src/services/chatManager.service.d.ts +16 -0
- package/dist/src/services/index.d.ts +3 -0
- package/dist/src/services/language.service.d.ts +18 -0
- package/dist/src/store/index.d.ts +3 -0
- package/dist/src/store/selectors/chat.d.ts +5 -0
- package/dist/src/store/selectors/index.d.ts +2 -0
- package/dist/src/store/selectors/setting.d.ts +4 -0
- package/dist/src/store/slices/chatSlice.d.ts +128 -0
- package/dist/src/store/slices/index.d.ts +4 -0
- package/dist/src/store/slices/layoutSlice.d.ts +12 -0
- package/dist/src/store/slices/onboardingSlice.d.ts +15 -0
- package/dist/src/store/slices/settingSlice.d.ts +16 -0
- package/dist/src/store/store.d.ts +20 -0
- package/dist/src/types/chat.type.d.ts +370 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/layout.type.d.ts +13 -0
- package/dist/src/types/onboarding.type.d.ts +45 -0
- package/dist/src/types/types.d.ts +74 -0
- package/dist/src/utils/chat.utils.d.ts +30 -0
- package/dist/src/utils/engine.utils.d.ts +5 -0
- package/dist/src/utils/file.utils.d.ts +18 -0
- package/dist/src/utils/format.utils.d.ts +7 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/text.utils.d.ts +1 -0
- package/dist/src/utils/validate.utils.d.ts +1 -0
- package/dist/src/utils/voice.utils.d.ts +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ChatUser, ChatConversation, ChatMessage, PaginationInfo, UseChatOptions } from '../../../types';
|
|
2
|
+
export interface AccountChatState {
|
|
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
|
+
disabledMembers: Record<string, boolean>;
|
|
14
|
+
memberSocketMap: Record<number, string[]>;
|
|
15
|
+
disconnectedSockets: Record<string, boolean>;
|
|
16
|
+
selectedUserProfile: ChatUser | null;
|
|
17
|
+
}
|
|
18
|
+
export interface ChatState {
|
|
19
|
+
accounts: Record<string, AccountChatState>;
|
|
20
|
+
activeAccountCode?: string;
|
|
21
|
+
defaultAccountCode?: string;
|
|
22
|
+
accountConfigs: UseChatOptions[];
|
|
23
|
+
}
|
|
24
|
+
export declare const defaultAccountState: AccountChatState;
|
|
25
|
+
export declare const setDefaultAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
26
|
+
accountCode: string;
|
|
27
|
+
}, "widget-chatslice/setDefaultAccount">, setActiveAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
28
|
+
accountCode: string;
|
|
29
|
+
}, "widget-chatslice/setActiveAccount">, registerAccountConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<UseChatOptions, "widget-chatslice/registerAccountConfig">, removeAccountConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
30
|
+
accountCode: string;
|
|
31
|
+
}, "widget-chatslice/removeAccountConfig">, initAccountState: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
32
|
+
accountCode: string;
|
|
33
|
+
}, "widget-chatslice/initAccountState">, clearAccount: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
34
|
+
accountCode: string;
|
|
35
|
+
}, "widget-chatslice/clearAccount">, removeAccountState: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
36
|
+
accountCode: string;
|
|
37
|
+
}, "widget-chatslice/removeAccountState">, setCurrentUser: import('@reduxjs/toolkit').ActionCreatorWithPayload<ChatUser | null, "widget-chatslice/setCurrentUser">, setChats: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
38
|
+
accountCode: string;
|
|
39
|
+
chats: ChatConversation[];
|
|
40
|
+
}, "widget-chatslice/setChats">, setCurrentChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
41
|
+
accountCode: string;
|
|
42
|
+
chat: ChatConversation | null;
|
|
43
|
+
}, "widget-chatslice/setCurrentChat">, setCurrentChatMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
44
|
+
accountCode: string;
|
|
45
|
+
messages: ChatMessage[];
|
|
46
|
+
}, "widget-chatslice/setCurrentChatMessages">, setCurrentChatMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
47
|
+
accountCode: string;
|
|
48
|
+
members: ChatUser[];
|
|
49
|
+
}, "widget-chatslice/setCurrentChatMembers">, setMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
50
|
+
accountCode: string;
|
|
51
|
+
members: ChatUser[];
|
|
52
|
+
}, "widget-chatslice/setMembers">, setDisabledMembers: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
53
|
+
accountCode: string;
|
|
54
|
+
disabledMembers: string[];
|
|
55
|
+
}, "widget-chatslice/setDisabledMembers">, setMember: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
56
|
+
accountCode: string;
|
|
57
|
+
member: ChatUser;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
socketId: string;
|
|
60
|
+
}, "widget-chatslice/setMember">, setMemberDisconnect: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
61
|
+
accountCode: string;
|
|
62
|
+
socketId: string;
|
|
63
|
+
}, "widget-chatslice/setMemberDisconnect">, setMessagesPagination: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
64
|
+
accountCode: string;
|
|
65
|
+
pagination?: PaginationInfo;
|
|
66
|
+
}, "widget-chatslice/setMessagesPagination">, prependMessages: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
67
|
+
accountCode: string;
|
|
68
|
+
messages: ChatMessage[];
|
|
69
|
+
}, "widget-chatslice/prependMessages">, addNewMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
70
|
+
accountCode: string;
|
|
71
|
+
chat: ChatConversation;
|
|
72
|
+
message: ChatMessage;
|
|
73
|
+
}, "widget-chatslice/addNewMessage">, addNewSystemMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
74
|
+
accountCode: string;
|
|
75
|
+
message: ChatMessage;
|
|
76
|
+
}, "widget-chatslice/addNewSystemMessage">, removeChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
77
|
+
accountCode: string;
|
|
78
|
+
chatId: number;
|
|
79
|
+
}, "widget-chatslice/removeChat">, addChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
80
|
+
accountCode: string;
|
|
81
|
+
chat: ChatConversation;
|
|
82
|
+
}, "widget-chatslice/addChat">, updateChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
83
|
+
accountCode: string;
|
|
84
|
+
chat: ChatConversation;
|
|
85
|
+
}, "widget-chatslice/updateChat">, updateChatAvatar: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
86
|
+
accountCode: string;
|
|
87
|
+
chatId: number;
|
|
88
|
+
avatar: string;
|
|
89
|
+
}, "widget-chatslice/updateChatAvatar">, removeMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
90
|
+
accountCode: string;
|
|
91
|
+
chat_id: number;
|
|
92
|
+
message_id: number;
|
|
93
|
+
type: "remove" | "revoke";
|
|
94
|
+
}, "widget-chatslice/removeMessage">, updateMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
95
|
+
accountCode: string;
|
|
96
|
+
chat_id: number;
|
|
97
|
+
message: ChatMessage;
|
|
98
|
+
}, "widget-chatslice/updateMessage">, setReplyingMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
99
|
+
accountCode: string;
|
|
100
|
+
message: ChatMessage | null;
|
|
101
|
+
}, "widget-chatslice/setReplyingMessage">, setTotalMessagesUnread: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
102
|
+
accountCode: string;
|
|
103
|
+
total: number;
|
|
104
|
+
}, "widget-chatslice/setTotalMessagesUnread">, updateMemberReadStatus: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
105
|
+
accountCode: string;
|
|
106
|
+
chatId: number;
|
|
107
|
+
memberId: number;
|
|
108
|
+
lastReadId: number;
|
|
109
|
+
}, "widget-chatslice/updateMemberReadStatus">, toggleChatSetting: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
110
|
+
accountCode: string;
|
|
111
|
+
chatId: number;
|
|
112
|
+
setting: "is_muted" | "is_pined";
|
|
113
|
+
}, "widget-chatslice/toggleChatSetting">, renewMemberActivity: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
114
|
+
accountCode: string;
|
|
115
|
+
userId: number;
|
|
116
|
+
}, "widget-chatslice/renewMemberActivity">, memberJoinChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
117
|
+
accountCode: string;
|
|
118
|
+
member: ChatUser;
|
|
119
|
+
chat: ChatConversation;
|
|
120
|
+
}, "widget-chatslice/memberJoinChat">, memberLeaveChat: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
121
|
+
accountCode: string;
|
|
122
|
+
member_id: number;
|
|
123
|
+
chat: ChatConversation;
|
|
124
|
+
}, "widget-chatslice/memberLeaveChat">, setSelectedUserProfile: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
125
|
+
accountCode: string;
|
|
126
|
+
userProfile: ChatUser | null;
|
|
127
|
+
}, "widget-chatslice/setSelectedUserProfile">;
|
|
128
|
+
export declare const chatReducer: import('redux').Reducer<ChatState>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PositionWidget, WidgetChatTab, WidgetMode, WidgetSize, WidgetSubChatTab } from '../../../types';
|
|
2
|
+
export interface LayoutState {
|
|
3
|
+
mode: WidgetMode;
|
|
4
|
+
isChatLoading: boolean;
|
|
5
|
+
activeChatTab: WidgetChatTab;
|
|
6
|
+
activeSubChatTab: WidgetSubChatTab;
|
|
7
|
+
dragPosition: PositionWidget;
|
|
8
|
+
fullpagePosition: PositionWidget;
|
|
9
|
+
fullpageSize: WidgetSize;
|
|
10
|
+
}
|
|
11
|
+
export declare const setIsChatLoading: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setIsChatLoading">, setActiveChatTab: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setActiveChatTab">, setWidgetMode: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setWidgetMode">, setDragPosition: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setDragPosition">, setFullpagePosition: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setFullpagePosition">, setFullpageSize: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-layoutslice/setFullpageSize">, setActiveSubChatTab: import('@reduxjs/toolkit').ActionCreatorWithPayload<WidgetSubChatTab, "widget-layoutslice/setActiveSubChatTab">;
|
|
12
|
+
export declare const layoutReducer: import('redux').Reducer<LayoutState>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatMessage, MetadataOptions, OnboardingConfigJSON, OnboardingData } from '../../../types';
|
|
2
|
+
export interface OnboardingState {
|
|
3
|
+
onboardingState: string;
|
|
4
|
+
data: OnboardingData;
|
|
5
|
+
messages: ChatMessage[];
|
|
6
|
+
currentGuestCode: string;
|
|
7
|
+
config: OnboardingConfigJSON | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const resetOnboarding: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-onboardingSlice/resetOnboarding">, setCurrentGuestCode: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/setCurrentGuestCode">, updateOnboarding: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
10
|
+
botReply: string;
|
|
11
|
+
nextState: string;
|
|
12
|
+
updatedData: OnboardingData;
|
|
13
|
+
metadata?: MetadataOptions;
|
|
14
|
+
}, "widget-onboardingSlice/updateOnboarding">, addOnboardingMessage: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/addOnboardingMessage">, updateOnboardingState: import('@reduxjs/toolkit').ActionCreatorWithPayload<string, "widget-onboardingSlice/updateOnboardingState">, finishOnboarding: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"widget-onboardingSlice/finishOnboarding">, markMessageAsAnswered: import('@reduxjs/toolkit').ActionCreatorWithPayload<number, "widget-onboardingSlice/markMessageAsAnswered">, setOnboardingConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<OnboardingConfigJSON, "widget-onboardingSlice/setOnboardingConfig">;
|
|
15
|
+
export declare const onboardingReducer: import('redux').Reducer<OnboardingState>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LanguageOption, WidgetFeature, WidgetRole } from '../../../types';
|
|
2
|
+
export interface SettingState {
|
|
3
|
+
theme: 'light' | 'dark';
|
|
4
|
+
primaryColor: string;
|
|
5
|
+
features: WidgetFeature;
|
|
6
|
+
currentLanguage: LanguageOption;
|
|
7
|
+
hasMultipleLanguages: boolean;
|
|
8
|
+
draggable: boolean;
|
|
9
|
+
role: WidgetRole;
|
|
10
|
+
}
|
|
11
|
+
export declare const setConfig: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
12
|
+
features?: WidgetFeature;
|
|
13
|
+
language?: LanguageOption;
|
|
14
|
+
role?: WidgetRole;
|
|
15
|
+
}, "widget-settingslice/setConfig">, setTheme: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-settingslice/setTheme">, setFeatures: import('@reduxjs/toolkit').ActionCreatorWithPayload<WidgetFeature, "widget-settingslice/setFeatures">, setPrimaryColor: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "widget-settingslice/setPrimaryColor">, setDraggable: import('@reduxjs/toolkit').ActionCreatorWithPayload<boolean, "widget-settingslice/setDraggable">, setLanguage: import('@reduxjs/toolkit').ActionCreatorWithPayload<LanguageOption, "widget-settingslice/setLanguage">;
|
|
16
|
+
export declare const settingReducer: import('redux').Reducer<SettingState>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tuple, AnyAction, ThunkDispatch, UnknownAction, EnhancedStore, StoreEnhancer } from '@reduxjs/toolkit';
|
|
2
|
+
import { ChatState, SettingState, LayoutState, OnboardingState } from '../../store/slices';
|
|
3
|
+
export declare const store: EnhancedStore<{
|
|
4
|
+
chat: ChatState;
|
|
5
|
+
setting: SettingState;
|
|
6
|
+
layout: LayoutState;
|
|
7
|
+
onboarding: OnboardingState;
|
|
8
|
+
}, AnyAction, Tuple<[
|
|
9
|
+
StoreEnhancer<{
|
|
10
|
+
dispatch: ThunkDispatch<{
|
|
11
|
+
chat: ChatState;
|
|
12
|
+
setting: SettingState;
|
|
13
|
+
layout: LayoutState;
|
|
14
|
+
onboarding: OnboardingState;
|
|
15
|
+
}, undefined, UnknownAction>;
|
|
16
|
+
}>,
|
|
17
|
+
StoreEnhancer
|
|
18
|
+
]>>;
|
|
19
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
20
|
+
export type AppDispatch = typeof store.dispatch;
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { AuthInfo, WidgetScope } from '../../types';
|
|
2
|
+
export interface UseChatOptions {
|
|
3
|
+
chatKey: string;
|
|
4
|
+
authInfo: AuthInfo;
|
|
5
|
+
scope?: WidgetScope;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
disabledMembers?: string[];
|
|
8
|
+
isPrimary?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ChatUser {
|
|
11
|
+
id: number;
|
|
12
|
+
code: string;
|
|
13
|
+
name: string;
|
|
14
|
+
avatar?: string;
|
|
15
|
+
phone?: string;
|
|
16
|
+
email: string;
|
|
17
|
+
socket_at?: string;
|
|
18
|
+
socket_id?: string;
|
|
19
|
+
last_read_id?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ChatResponse<T = unknown> {
|
|
22
|
+
data?: T;
|
|
23
|
+
message?: string;
|
|
24
|
+
statusCode?: number;
|
|
25
|
+
statusText?: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export type FormFieldType = 'text' | 'tel' | 'email' | 'radio' | 'select';
|
|
29
|
+
export interface FormFieldOption {
|
|
30
|
+
label: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export interface FormFieldValidation {
|
|
34
|
+
rule: string;
|
|
35
|
+
value?: number | string;
|
|
36
|
+
error_message: string;
|
|
37
|
+
}
|
|
38
|
+
export interface FormField {
|
|
39
|
+
save_variable: string;
|
|
40
|
+
label: string;
|
|
41
|
+
type: FormFieldType;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
required: boolean;
|
|
44
|
+
options?: FormFieldOption[];
|
|
45
|
+
validation?: FormFieldValidation;
|
|
46
|
+
}
|
|
47
|
+
interface BaseMetadata {
|
|
48
|
+
isAnswered: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface ButtonMetadata extends BaseMetadata {
|
|
51
|
+
type: 'quick_reply' | 'interactive_input';
|
|
52
|
+
actions: MetadataActions[];
|
|
53
|
+
}
|
|
54
|
+
interface FormMetadata extends BaseMetadata {
|
|
55
|
+
type: 'form_input';
|
|
56
|
+
submit_button_label?: string;
|
|
57
|
+
fields: FormField[];
|
|
58
|
+
}
|
|
59
|
+
export type MetadataOptions = ButtonMetadata | FormMetadata;
|
|
60
|
+
export interface MetadataActions {
|
|
61
|
+
id: string;
|
|
62
|
+
label: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
export interface SystemMessageContent {
|
|
66
|
+
data: {
|
|
67
|
+
code: string;
|
|
68
|
+
};
|
|
69
|
+
name: string;
|
|
70
|
+
type: 'live';
|
|
71
|
+
}
|
|
72
|
+
export type MessageContentType = string | SystemMessageContent | null;
|
|
73
|
+
export interface ChatMessage {
|
|
74
|
+
id: number;
|
|
75
|
+
type: 'text' | 'json' | 'html';
|
|
76
|
+
action: Record<string, number>;
|
|
77
|
+
member: ChatUser;
|
|
78
|
+
content: MessageContentType;
|
|
79
|
+
files?: ChatFile[];
|
|
80
|
+
revoked: boolean;
|
|
81
|
+
removed: boolean;
|
|
82
|
+
date: string;
|
|
83
|
+
reply?: ChatMessage | null;
|
|
84
|
+
created_at: string;
|
|
85
|
+
updated_at: string;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
metadata?: MetadataOptions;
|
|
88
|
+
}
|
|
89
|
+
export interface ChatConversation {
|
|
90
|
+
id: number;
|
|
91
|
+
code: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
type: 'single' | 'group';
|
|
94
|
+
avatar?: string | null;
|
|
95
|
+
message: ChatMessage | null;
|
|
96
|
+
members?: ChatUser[];
|
|
97
|
+
new: Record<number, number>;
|
|
98
|
+
owner_id?: number;
|
|
99
|
+
updated_at: string;
|
|
100
|
+
create_at: string;
|
|
101
|
+
is_muted?: boolean;
|
|
102
|
+
is_pined?: boolean;
|
|
103
|
+
member?: number;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
106
|
+
export interface ChatEvent {
|
|
107
|
+
system_message: 'system.messages';
|
|
108
|
+
chats_created: 'chats.created';
|
|
109
|
+
chats_updated: 'chats.updated';
|
|
110
|
+
chats_deleted: 'chats.deleted';
|
|
111
|
+
chats_member: 'chats.member';
|
|
112
|
+
chats_action: 'chats.action';
|
|
113
|
+
chats_message: 'chats.message';
|
|
114
|
+
members_connect: 'members.connect';
|
|
115
|
+
members_disconnect: 'members.disconnect';
|
|
116
|
+
new_message: 'new_message';
|
|
117
|
+
}
|
|
118
|
+
export interface ChatFile {
|
|
119
|
+
id: number;
|
|
120
|
+
name: string;
|
|
121
|
+
ext: string;
|
|
122
|
+
size: number;
|
|
123
|
+
link: string;
|
|
124
|
+
}
|
|
125
|
+
export interface ChatConfig {
|
|
126
|
+
debugMode?: boolean;
|
|
127
|
+
maxRetries?: number;
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
}
|
|
130
|
+
export type ChatDurationUnit = 'minutes' | 'hours' | 'days';
|
|
131
|
+
export interface ChatSetting {
|
|
132
|
+
allow_delete_chat: boolean;
|
|
133
|
+
allow_delete_message: boolean;
|
|
134
|
+
allow_revoke_message: boolean;
|
|
135
|
+
delete_duration: number;
|
|
136
|
+
delete_duration_unit: ChatDurationUnit;
|
|
137
|
+
revoke_duration: number;
|
|
138
|
+
revoke_duration_unit: ChatDurationUnit;
|
|
139
|
+
project_id: number;
|
|
140
|
+
project_code: string;
|
|
141
|
+
project_name: string;
|
|
142
|
+
workspace: string;
|
|
143
|
+
}
|
|
144
|
+
export type MessageAction = 'like' | 'love' | 'revoke' | 'remove';
|
|
145
|
+
export interface PaginationInfo {
|
|
146
|
+
count: number;
|
|
147
|
+
current_page: number;
|
|
148
|
+
per_page: number;
|
|
149
|
+
total: number;
|
|
150
|
+
total_pages: number;
|
|
151
|
+
}
|
|
152
|
+
export interface ChatEventPayloads {
|
|
153
|
+
'system.messages': {
|
|
154
|
+
message: ChatMessage;
|
|
155
|
+
type: 'add';
|
|
156
|
+
};
|
|
157
|
+
'chats.created': {
|
|
158
|
+
chat: ChatConversation;
|
|
159
|
+
};
|
|
160
|
+
'chats.updated': {
|
|
161
|
+
chat: ChatConversation;
|
|
162
|
+
};
|
|
163
|
+
'chats.deleted': {
|
|
164
|
+
chat_id: number;
|
|
165
|
+
};
|
|
166
|
+
'chats.member': {
|
|
167
|
+
type: 'join' | 'leave';
|
|
168
|
+
chat?: ChatConversation;
|
|
169
|
+
chat_id?: number;
|
|
170
|
+
member?: ChatUser;
|
|
171
|
+
member_id?: number;
|
|
172
|
+
};
|
|
173
|
+
'chats.action': {
|
|
174
|
+
chat_id?: number;
|
|
175
|
+
message_id?: number;
|
|
176
|
+
action?: MessageAction;
|
|
177
|
+
user_id?: number;
|
|
178
|
+
chat?: ChatConversation;
|
|
179
|
+
member_id?: number;
|
|
180
|
+
type: 'read' | 'unread';
|
|
181
|
+
};
|
|
182
|
+
'chats.message': {
|
|
183
|
+
chat: ChatConversation;
|
|
184
|
+
message: ChatMessage;
|
|
185
|
+
type: 'add' | 'remove' | 'revoke' | 'like' | 'love';
|
|
186
|
+
chat_id: number;
|
|
187
|
+
message_id: number;
|
|
188
|
+
};
|
|
189
|
+
'members.connect': {
|
|
190
|
+
member: ChatUser;
|
|
191
|
+
socketId: string;
|
|
192
|
+
timestamp: number;
|
|
193
|
+
};
|
|
194
|
+
'members.disconnect': {
|
|
195
|
+
socketId: string;
|
|
196
|
+
};
|
|
197
|
+
new_message: {
|
|
198
|
+
new: number;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
export interface ChatInstance {
|
|
202
|
+
/**
|
|
203
|
+
* 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...
|
|
204
|
+
*/
|
|
205
|
+
setting: ChatSetting;
|
|
206
|
+
/**
|
|
207
|
+
* Thiết lập cấu hình tùy chỉnh cho SDK.
|
|
208
|
+
* @param config (Object): Các tùy chọn cấu hình như debugMode, maxRetries...
|
|
209
|
+
*/
|
|
210
|
+
setConfig(config: ChatConfig): void;
|
|
211
|
+
/**
|
|
212
|
+
* Thiết lập thông tin xác thực cho SDK.
|
|
213
|
+
* @param data Thông tin người dùng hiện tại
|
|
214
|
+
*/
|
|
215
|
+
setAuth(data: AuthInfo): Promise<ChatUser>;
|
|
216
|
+
/**
|
|
217
|
+
* Lấy thông tin xác thực hiện tại.
|
|
218
|
+
*/
|
|
219
|
+
getAuth(): ChatUser | null;
|
|
220
|
+
/**
|
|
221
|
+
* Xóa thông tin xác thực.
|
|
222
|
+
*/
|
|
223
|
+
clearAuth(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Thiết lập thông tin người nhận.
|
|
226
|
+
* @param data Thông tin người nhận
|
|
227
|
+
*/
|
|
228
|
+
setReceiver(data: ChatUser): Promise<ChatResponse<ChatUser>>;
|
|
229
|
+
/**
|
|
230
|
+
* Lấy thông tin người nhận hiện tại.
|
|
231
|
+
*/
|
|
232
|
+
getReceiver(): ChatUser | null;
|
|
233
|
+
/**
|
|
234
|
+
* Xóa thông tin người nhận.
|
|
235
|
+
*/
|
|
236
|
+
clearReceiver(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Lấy danh sách thành viên
|
|
239
|
+
* @param chatId ID cuộc trò chuyện (tùy chọn, mặc định null lấy tất cả)
|
|
240
|
+
* @param limit Số lượng bản ghi (tùy chọn, mặc định 0 lấy tất cả)
|
|
241
|
+
* @param page Số trang (tùy chọn, mặc định 1)
|
|
242
|
+
* @param include Các trường bổ sung (tùy chọn)
|
|
243
|
+
*/
|
|
244
|
+
getMembers(chatId?: number | null, limit?: number, page?: number, include?: string): Promise<ChatResponse<ChatUser[]>>;
|
|
245
|
+
/**
|
|
246
|
+
* Thêm thành viên vào nhóm.
|
|
247
|
+
* @param chatId ID cuộc trò chuyện.
|
|
248
|
+
* @param memberId ID thành viên cần thêm.
|
|
249
|
+
*/
|
|
250
|
+
addMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
251
|
+
/**
|
|
252
|
+
* Xóa thành viên khỏi nhóm hoặc rời nhóm.
|
|
253
|
+
* Lưu ý: Nếu xóa chính mình, nhóm sẽ bị xóa hoàn toàn.
|
|
254
|
+
* @param chatId ID cuộc trò chuyện (Number)
|
|
255
|
+
* @param memberId ID thành viên cần xóa (Number)
|
|
256
|
+
*/
|
|
257
|
+
removeMember(chatId: number, memberId: number): Promise<ChatResponse>;
|
|
258
|
+
/**
|
|
259
|
+
* Lấy danh sách cuộc trò chuyện của thành viên hiện tại.
|
|
260
|
+
* @param limit Số lượng bản ghi (tùy chọn, mặc định 0 = tất cả)
|
|
261
|
+
* @param page Số trang (tùy chọn, mặc định 1)
|
|
262
|
+
*/
|
|
263
|
+
getChats(limit?: number, page?: number): Promise<ChatResponse<ChatConversation[]> & {
|
|
264
|
+
pagination?: PaginationInfo;
|
|
265
|
+
}>;
|
|
266
|
+
/**
|
|
267
|
+
* Tìm cuộc trò chuyện 1-1 với một người nhất định.
|
|
268
|
+
* @param receiverId ID người nhận (Number)
|
|
269
|
+
* @returns Promise trả về object cuộc trò chuyện (ChatConversation) hoặc null
|
|
270
|
+
*/
|
|
271
|
+
findChatByReceiver(receiverId: number | string): Promise<ChatConversation | undefined>;
|
|
272
|
+
/**
|
|
273
|
+
* 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.
|
|
274
|
+
* @param receiverId ID người nhận (Number, bắt buộc)
|
|
275
|
+
* @param content Tin nhắn đầu tiên (String, tùy chọn)
|
|
276
|
+
*/
|
|
277
|
+
addChat(receiverId: number, content?: string): Promise<ChatResponse<ChatConversation>>;
|
|
278
|
+
/**
|
|
279
|
+
* Tạo nhóm trò chuyện mới.
|
|
280
|
+
* @param memberIds Danh sách ID thành viên (ít nhất 2 thành viên khác)
|
|
281
|
+
* @param name Tên nhóm
|
|
282
|
+
* @param avatar URL ảnh đại diện nhóm (tùy chọn)
|
|
283
|
+
* @param userId ID người dùng tạo nhóm (tùy chọn)
|
|
284
|
+
* @returns Promise trả về object nhóm (ChatConversation)
|
|
285
|
+
*/
|
|
286
|
+
addGroup(memberIds: number[], name: string, avatar?: string | File, userId?: number): Promise<ChatResponse<ChatConversation>>;
|
|
287
|
+
/**
|
|
288
|
+
* Cập nhật thông tin nhóm (Tên và Ảnh đại diện).
|
|
289
|
+
* @param chatId ID nhóm (Number, bắt buộc)
|
|
290
|
+
* @param name Tên nhóm mới (String, bắt buộc)
|
|
291
|
+
* @param avatar URL ảnh đại diện mới (String, tùy chọn)
|
|
292
|
+
* @returns Promise trả về object nhóm đã được cập nhật
|
|
293
|
+
*/
|
|
294
|
+
updateGroup(chatId: number, name: string, avatar?: string | File): Promise<ChatResponse<ChatConversation>>;
|
|
295
|
+
/**
|
|
296
|
+
* Xóa một cuộc trò chuyện (chat 1-1 hoặc nhóm).
|
|
297
|
+
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
298
|
+
* @returns Promise trả về kết quả thành công/thất bại
|
|
299
|
+
*/
|
|
300
|
+
removeChat(chatId: number): Promise<ChatResponse>;
|
|
301
|
+
/**
|
|
302
|
+
* Đánh dấu cuộc trò chuyện là đã đọc.
|
|
303
|
+
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
304
|
+
* @returns Promise trả về kết quả
|
|
305
|
+
*/
|
|
306
|
+
readChat(chatId: number): Promise<ChatResponse>;
|
|
307
|
+
/**
|
|
308
|
+
* Đánh dấu cuộc trò chuyện là chưa đọc.
|
|
309
|
+
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
310
|
+
* @returns Promise trả về kết quả
|
|
311
|
+
*/
|
|
312
|
+
unreadChat(chatId: number): Promise<ChatResponse>;
|
|
313
|
+
/**
|
|
314
|
+
* Lấy danh sách tin nhắn trong một cuộc trò chuyện.
|
|
315
|
+
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
316
|
+
* @param limit Số lượng tin nhắn (Number, tùy chọn, mặc định 20)
|
|
317
|
+
* @param page Trang (Number, tùy chọn, mặc định 1)
|
|
318
|
+
*/
|
|
319
|
+
getMessages(chatId: number, limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
320
|
+
pagination?: PaginationInfo;
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* Gửi tin nhắn với nội dung, tập tin, hoặc trả lời tin nhắn khác.
|
|
324
|
+
* @param chatId ID cuộc trò chuyện (Bắt buộc)
|
|
325
|
+
* @param content Nội dung văn bản (Bắt buộc nếu không có files)
|
|
326
|
+
* @param files Danh sách tập tin (FileList hoặc File[])
|
|
327
|
+
* @param replyId ID tin nhắn cần trả lời
|
|
328
|
+
*/
|
|
329
|
+
addMessage(chatId: number, content?: string | null, files?: FileList | File[] | null, replyId?: number | null): Promise<ChatResponse<ChatMessage>>;
|
|
330
|
+
/**
|
|
331
|
+
* Tương tác với tin nhắn (like, love, revoke, remove).
|
|
332
|
+
* @param chatId ID cuộc trò chuyện (Number, bắt buộc)
|
|
333
|
+
* @param messageId ID tin nhắn (Number, bắt buộc)
|
|
334
|
+
* @param action Kiểu tương tác ('like' | 'love' | 'revoke' | 'remove')
|
|
335
|
+
* @returns Promise trả về kết quả từ SDK
|
|
336
|
+
*/
|
|
337
|
+
actionMessage(chatId: number, messageId: number, action: MessageAction): Promise<{
|
|
338
|
+
message_id: number;
|
|
339
|
+
member_id: number;
|
|
340
|
+
}>;
|
|
341
|
+
/**
|
|
342
|
+
* Lấy danh sách tin nhắn hệ thống (system messages)
|
|
343
|
+
* @param limit Số lượng tin nhắn (Number, tùy chọn, mặc định 20)
|
|
344
|
+
* @param page Trang (Number, tùy chọn, mặc định 1)
|
|
345
|
+
*/
|
|
346
|
+
getSystemMessages(limit?: number, page?: number): Promise<ChatResponse<ChatMessage[]> & {
|
|
347
|
+
pagination?: PaginationInfo;
|
|
348
|
+
}>;
|
|
349
|
+
EVENTS: ChatEvent;
|
|
350
|
+
/**
|
|
351
|
+
* Đăng ký lắng nghe sự kiện realtime
|
|
352
|
+
* @param event Tên sự kiện (lấy từ chatSDK.EVENTS)
|
|
353
|
+
* @param listener Hàm callback xử lý dữ liệu trả về
|
|
354
|
+
*/
|
|
355
|
+
addEventListener<K extends keyof ChatEventPayloads>(event: K, listener: (data: K extends keyof ChatEventPayloads ? ChatEventPayloads[K] : unknown) => void): void;
|
|
356
|
+
/**
|
|
357
|
+
* Hủy lắng nghe một sự kiện.
|
|
358
|
+
* @param event Tên sự kiện (String, bắt buộc)
|
|
359
|
+
* @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.
|
|
360
|
+
*/
|
|
361
|
+
removeEventListener<K extends keyof ChatEventPayloads>(event: K, listener?: (data: ChatEventPayloads[K]) => void): void;
|
|
362
|
+
/**
|
|
363
|
+
* Đẩy một sự kiện cho tất cả listeners (thường dùng cho debug hoặc logic tùy chỉnh).
|
|
364
|
+
* @param name (String, bắt buộc): Tên sự kiện (lấy từ chatSDK.EVENTS)
|
|
365
|
+
* @param data (Object): Dữ liệu đi kèm sự kiện
|
|
366
|
+
*/
|
|
367
|
+
runEvent<K extends keyof ChatEventPayloads>(name: K | string, data?: ChatEventPayloads[K]): void;
|
|
368
|
+
}
|
|
369
|
+
export type ChatConstructor = new (workspace?: string) => ChatInstance;
|
|
370
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type WidgetMode = 'closed' | 'popup' | 'fullpage';
|
|
2
|
+
export type WidgetChatTab = 'chats' | 'contacts' | 'supports' | 'settings';
|
|
3
|
+
export type WidgetContactTab = 'members' | 'groups';
|
|
4
|
+
export type WidgetSettingTab = 'theme' | 'account' | 'chatlive';
|
|
5
|
+
export type WidgetSubChatTab = '' | WidgetContactTab | WidgetSettingTab;
|
|
6
|
+
export interface PositionWidget {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WidgetSize {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FormField } from './chat.type';
|
|
2
|
+
export type OnboardingData = {
|
|
3
|
+
name: string;
|
|
4
|
+
} & Record<string, string | undefined>;
|
|
5
|
+
export type Primitive = string | number | boolean | null | undefined;
|
|
6
|
+
export interface DeepData {
|
|
7
|
+
[key: string]: Primitive | DeepData;
|
|
8
|
+
}
|
|
9
|
+
export interface OnboardingEdgeCase {
|
|
10
|
+
match_keywords: string[];
|
|
11
|
+
override_value: string;
|
|
12
|
+
override_message?: string;
|
|
13
|
+
next_step: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OnboardingOption {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
next_step: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OnboardingValidation {
|
|
21
|
+
rule: string;
|
|
22
|
+
value: string | number | string[];
|
|
23
|
+
error_message: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OnboardingStepConfig {
|
|
26
|
+
type: 'text_input' | 'quick_reply' | 'system_action' | 'interactive_input' | 'form_input';
|
|
27
|
+
save_variable?: keyof OnboardingData | null;
|
|
28
|
+
bot_message: string;
|
|
29
|
+
next_step: string;
|
|
30
|
+
validation?: OnboardingValidation;
|
|
31
|
+
edge_cases?: OnboardingEdgeCase[];
|
|
32
|
+
options?: OnboardingOption[];
|
|
33
|
+
action_name?: string;
|
|
34
|
+
fields?: FormField[];
|
|
35
|
+
submit_button_label?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface OnboardingConfigJSON {
|
|
38
|
+
meta: {
|
|
39
|
+
version: string;
|
|
40
|
+
bot_name: string;
|
|
41
|
+
start_step: string;
|
|
42
|
+
end_step: string;
|
|
43
|
+
};
|
|
44
|
+
steps: Record<string, OnboardingStepConfig>;
|
|
45
|
+
}
|