getDomainAuditLog method
Returns audit log entries for a domain the caller can read (owner, org admin, actor/target user, or platform admin — enforced by RLS). Ordered newest-first. Used for the access-history view and for tests.
Implementation
Future<List<Map<String, dynamic>>> getDomainAuditLog(
String domainId, {
int limit = 100,
}) async {
final response = await _client
.from('audit_log')
.select(
'id, event_type, previous_value, new_value, '
'target_user_id, actor_id, created_at, metadata',
)
.eq('domain_id', domainId)
.order('created_at', ascending: false)
.limit(limit);
return (response as List<dynamic>)
.map((row) => row as Map<String, dynamic>)
.toList();
}