import type { DefaultEventsMap, EventsMap } from "socket.io/dist/typed-events"
import type { VerifyPayloadType } from "@fastify/jwt"

declare module "socket.io" {
  interface SocketData {
    projects?: Set<string>
    ownedSessions?: string[]
    session?: string
  }

  interface Socket<
    ListenEvents extends EventsMap = DefaultEventsMap,
    EmitEvents extends EventsMap = ListenEvents,
    ServerSideEvents extends EventsMap = DefaultEventsMap,
    SocketData = any,
  > {
    decoded_token?: VerifyPayloadType & { _id?: string }
    user?: {
      _id: string
      account: any
      [key: string]: any
    }
    workSession?: {
      _id: string
      userId: string
      accessType: string
      compositionId: string
      expiryDate: Date
      isActive: boolean
      permissions: number
      pluginData: Record<string, any>
      [key: string]: any
    }
    isWorkSession?: boolean
  }
}

export type StreamTypes = {
  ticket?: { all: boolean }
  user?: { all: boolean }
  tag?: { all: boolean }
  content?: { all: boolean }
}

export type StreamConfig = {
  ticket: boolean
  user: boolean
  tag: boolean
  content: boolean
}
