/**
 * session-idle-cleanup cron — session-security (wave-13).
 * Scheduled: nightly (02:30 UTC, see wrangler.toml).
 *
 * Revokes sessions that have been idle beyond their tenant's configured
 * idle_timeout_minutes. Only affects tenants with the setting enabled.
 */
import { cleanupIdleSessions } from '@zync/db/queries'
import { createDb } from '@zync/db/queries'
import type { Env } from '@zync/types'

export async function runSessionIdleCleanup(env: Env): Promise<void> {
  const db = createDb(env)
  const revoked = await cleanupIdleSessions(db)
  console.log(`session-idle-cleanup: revoked ${revoked} idle session rows`)
}
