import {
  ChatMessage,
  Conversation,
  CreateMessageDTO,
  CreateEventDTO,
  GetMessagesOptions,
  UpdateMessageDTO,
  ConflictingEvent,
} from "@calchat/shared";

export interface ChatRepository {
  // Conversations
  getConversationsByUser(userId: string): Promise<Conversation[]>;
  getConversationById(conversationId: string): Promise<Conversation | null>;
  createConversation(userId: string): Promise<Conversation>;

  // Messages (cursor-based pagination)
  getMessages(
    conversationId: string,
    options?: GetMessagesOptions,
  ): Promise<ChatMessage[]>;

  createMessage(
    conversationId: string,
    message: CreateMessageDTO,
  ): Promise<ChatMessage>;

  updateMessage(
    messageId: string,
    updates: UpdateMessageDTO,
  ): Promise<ChatMessage | null>;

  updateProposalResponse(
    messageId: string,
    proposalId: string,
    respondedAction: "confirm" | "reject",
  ): Promise<ChatMessage | null>;

  updateProposalEvent(
    messageId: string,
    proposalId: string,
    event: CreateEventDTO,
    conflictingEvents?: ConflictingEvent[],
  ): Promise<ChatMessage | null>;

  getMessageById(messageId: string): Promise<ChatMessage | null>;
}
