Initial import
This commit is contained in:
83
src/app/main/chatV2/data/chatGateway.ts
Normal file
83
src/app/main/chatV2/data/chatGateway.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {
|
||||
createChatConversationRoom,
|
||||
deleteChatConversationRequest,
|
||||
deleteChatConversationRoom,
|
||||
fetchChatConversationDetail,
|
||||
fetchChatConversations,
|
||||
fetchChatRuntimeJobDetail,
|
||||
fetchChatRuntimeSnapshot,
|
||||
markChatConversationResponsesRead,
|
||||
renameChatConversationRoom,
|
||||
updateChatConversationRoom,
|
||||
uploadChatComposerFile,
|
||||
} from '../../mainChatPanel';
|
||||
import {
|
||||
dismissChatWebPushNotifications,
|
||||
markChatNotificationMessagesAsRead,
|
||||
} from '../../notificationApi';
|
||||
import type {
|
||||
ChatComposerAttachment,
|
||||
ChatConversationDetailResponse,
|
||||
ChatConversationSummary,
|
||||
ChatRuntimeJobDetail,
|
||||
ChatRuntimeSnapshot,
|
||||
} from '../../mainChatPanel/types';
|
||||
|
||||
export type ChatGateway = {
|
||||
listConversations: () => Promise<ChatConversationSummary[]>;
|
||||
getConversationDetail: (
|
||||
sessionId: string,
|
||||
options?: {
|
||||
limit?: number;
|
||||
beforeMessageId?: number | null;
|
||||
},
|
||||
) => Promise<ChatConversationDetailResponse>;
|
||||
createConversation: (args: {
|
||||
sessionId: string;
|
||||
title: string;
|
||||
contextLabel?: string;
|
||||
contextDescription?: string;
|
||||
notifyOffline?: boolean;
|
||||
}) => Promise<ChatConversationSummary>;
|
||||
renameConversation: (sessionId: string, title: string) => Promise<ChatConversationSummary>;
|
||||
updateConversation: (
|
||||
sessionId: string,
|
||||
payload: Partial<
|
||||
Pick<ChatConversationSummary, 'title' | 'notifyOffline' | 'hasUnreadResponse'>
|
||||
>,
|
||||
) => Promise<ChatConversationSummary>;
|
||||
deleteConversation: (sessionId: string) => Promise<void>;
|
||||
deleteConversationRequest: (sessionId: string, requestId: string) => Promise<void>;
|
||||
markConversationRead: (sessionId: string) => Promise<void>;
|
||||
fetchRuntimeSnapshot: () => Promise<ChatRuntimeSnapshot>;
|
||||
fetchRuntimeJobDetail: (requestId: string) => Promise<ChatRuntimeJobDetail>;
|
||||
uploadComposerFile: (sessionId: string, file: File) => Promise<ChatComposerAttachment>;
|
||||
dismissRoomNotifications: (sessionId: string) => Promise<void>;
|
||||
markRoomNotificationMessagesRead: (sessionId: string) => Promise<void>;
|
||||
};
|
||||
|
||||
export const chatGateway: ChatGateway = {
|
||||
listConversations: fetchChatConversations,
|
||||
getConversationDetail: fetchChatConversationDetail,
|
||||
createConversation: createChatConversationRoom,
|
||||
renameConversation: renameChatConversationRoom,
|
||||
updateConversation: updateChatConversationRoom,
|
||||
deleteConversation: async (sessionId) => {
|
||||
await deleteChatConversationRoom(sessionId);
|
||||
},
|
||||
deleteConversationRequest: async (sessionId, requestId) => {
|
||||
await deleteChatConversationRequest(sessionId, requestId);
|
||||
},
|
||||
markConversationRead: async (sessionId) => {
|
||||
await markChatConversationResponsesRead(sessionId);
|
||||
},
|
||||
fetchRuntimeSnapshot: fetchChatRuntimeSnapshot,
|
||||
fetchRuntimeJobDetail: fetchChatRuntimeJobDetail,
|
||||
uploadComposerFile: uploadChatComposerFile,
|
||||
dismissRoomNotifications: async (sessionId) => {
|
||||
await dismissChatWebPushNotifications(sessionId);
|
||||
},
|
||||
markRoomNotificationMessagesRead: async (sessionId) => {
|
||||
await markChatNotificationMessagesAsRead(sessionId);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user