import type { UserRole } from "@folo-services/constants"
import type { users } from "@folo-services/drizzle"
import type { InferSelectModel } from "drizzle-orm"

import type { PlainSuccessResponse, SerializedModel } from "../../types"

// Base user types from better-auth
export type AuthUser = SerializedModel<InferSelectModel<typeof users>>

export interface AuthSession {
  expiresAt: string
  createdAt: string
  updatedAt: string
  userId: string
  id: string
}

// Session and user responses
export type AuthSessionResponse = PlainSuccessResponse<{
  session: AuthSession | null
  user: AuthUser | null
  role: UserRole
  roleEndAt?: string
  feedSubscriptionLimit: number | null
  rsshubSubscriptionLimit: number | null
}>

export { type UserRole } from "@folo-services/constants"
