add method
Appends a row and returns it; the hash links it to the row before.
at defaults to the world's clock; details defaults to an empty object;
correlationId (from nextCorrelationId) defaults to an ID of this row alone.
Implementation
JsonMap add(
FakeWorld world, {
required String action,
String decision = 'allow',
String? actor,
String? denyReason,
String? resourceKind,
String? resourceId,
JsonMap details = const {},
DateTime? at,
String? correlationId,
}) {
final prev = rows.isEmpty ? auditGenesisHash : rows.last['hash']! as String;
final row = <String, Object?>{
'seq': rows.length + 1,
'id': world.nextId(),
'occurred_at': world.stamp(at),
'actor_principal_id': ?actor,
'action': action,
'decision': decision,
'deny_reason': ?denyReason,
'resource_kind': ?resourceKind,
'resource_id': ?resourceId,
'details': details,
'correlation_id': correlationId ?? _correlationId(rows.length + 1),
'prev_hash': prev,
};
row['hash'] = hashOf(row);
rows.add(row);
return row;
}