import { defineModule, defineRoute } from "../../shared/define-module"
import type {
  DeleteSessionRequest,
  GetMessagesQuery,
  GetMessagesResponse,
  GetSessionRequest,
  GetUnreadQuery,
  GetUnreadResponse,
  ListSessionsQuery,
  ListSessionsResponse,
  MarkSeenRequest,
  SessionResponse,
  UpdateSessionRequest,
} from "./types"

/**
 * AI Chat Sessions module - comprehensive chat session management
 * Base path: /ai/chat-sessions
 */
export const aiChatSessionsModule = defineModule({
  name: "aiChatSessions",
  prefix: "/ai/chat-sessions",
  routes: {
    // List chat sessions
    list: defineRoute<ListSessionsQuery, ListSessionsResponse>("GET", "/"),

    // Get specific session
    get: defineRoute<GetSessionRequest, SessionResponse>("GET", "/{chatId}"),

    // Create new session
    // create: defineRoute<CreateSessionRequest, SessionResponse>("POST", "/"),

    // Update session
    update: defineRoute<UpdateSessionRequest, SessionResponse>("PATCH", "/{chatId}"),

    // Delete session
    delete: defineRoute<DeleteSessionRequest, { success: boolean }>(
      "DELETE",
      "/{chatId}",
    ),

    // Nested routes
    messages: {
      get: defineRoute<GetMessagesQuery, GetMessagesResponse>("GET", "/{chatId}/messages"),
    },

    markSeen: defineRoute<MarkSeenRequest, SessionResponse>("POST", "/{chatId}/mark-seen"),

    unread: defineRoute<GetUnreadQuery, GetUnreadResponse>("GET", "/unread"),
  },
})

// Export the API type
export type AIChatSessionsAPI = typeof aiChatSessionsModule.api

export type * from "./types"
