/**
 * Shared Hono context contract for zync-api.
 *
 * `Bindings` are the Worker bindings (Env). `Variables` are values set by
 * middleware and read by downstream handlers/guards:
 *   - session: the verified SessionPayload | AdminSessionPayload (authMiddleware)
 *   - db:      a per-request Drizzle client (authMiddleware / withDb)
 *   - accessTokenHash: SHA-256 of the presented access token (for logout blocklist)
 *   - sessionId:     user_sessions.id for the current token (sessionGuard)
 */
import type { Db } from '@zync/db/queries'
import type { AdminSessionPayload, Env, SessionPayload } from '@zync/types'

export type AdminAppSession = AdminSessionPayload & {
  permissions: string[]
  role?: string
}

export type AppVariables = {
  session?: SessionPayload | AdminAppSession
  db: Db
  accessTokenHash?: string
  sessionId?: string
}

export type AppEnv = {
  Bindings: Env
  Variables: AppVariables
}
