/**
 * Canonical tenant role names — must match `@zync/db` seed (`SYSTEM_ROLE_NAMES`).
 * Session JWT `role`, `roles.name`, and team member rows all use this casing.
 */
import type { SystemRoleName } from '@zync/db/seed/permission-keys'

export const OWNER_ROLE = 'OWNER' satisfies SystemRoleName
export const ADMIN_ROLE = 'ADMIN' satisfies SystemRoleName
export const MEMBER_ROLE = 'MEMBER' satisfies SystemRoleName
export const CONTRACTOR_ROLE = 'CONTRACTOR' satisfies SystemRoleName

export function isOwnerRole(role: string | null | undefined): boolean {
  return role === OWNER_ROLE
}

export function isOwnerOrAdminRole(role: string | null | undefined): boolean {
  return role === OWNER_ROLE || role === ADMIN_ROLE
}

export function isOwnerAdminOrMemberRole(role: string | null | undefined): boolean {
  return role === OWNER_ROLE || role === ADMIN_ROLE || role === MEMBER_ROLE
}

export function isContractorRole(role: string | null | undefined): boolean {
  return role === CONTRACTOR_ROLE
}
