feat(commons): add IAuditLogRepository + AuditLogQueryFilter + AuditLogPaging (#23)
Append-only data-access surface for the central AuditLog table — three methods: InsertIfNotExistsAsync (first-write-wins on EventId), QueryAsync (filter + keyset paging on (OccurredAtUtc desc, EventId desc)), and SwitchOutPartitionAsync (M1 honest contract — throws NotSupported until M6 lands the non-aligned-index drop/rebuild dance for the partition switch). No Update, no row-delete; bulk purge is partition-only. Bundle D of the Audit Log #23 M1 Foundation plan.
This commit is contained in:
13
src/ScadaLink.Commons/Types/Audit/AuditLogPaging.cs
Normal file
13
src/ScadaLink.Commons/Types/Audit/AuditLogPaging.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ScadaLink.Commons.Types.Audit;
|
||||
|
||||
/// <summary>
|
||||
/// Keyset paging cursor for <see cref="ScadaLink.Commons.Interfaces.Repositories.IAuditLogRepository.QueryAsync"/>.
|
||||
/// The repository orders by <c>(OccurredAtUtc DESC, EventId DESC)</c>; callers pass
|
||||
/// the last row of the previous page back as <see cref="AfterOccurredAtUtc"/> +
|
||||
/// <see cref="AfterEventId"/> to fetch the next page. Both must be non-null together,
|
||||
/// or both null (first page).
|
||||
/// </summary>
|
||||
public sealed record AuditLogPaging(
|
||||
int PageSize,
|
||||
DateTime? AfterOccurredAtUtc = null,
|
||||
Guid? AfterEventId = null);
|
||||
21
src/ScadaLink.Commons/Types/Audit/AuditLogQueryFilter.cs
Normal file
21
src/ScadaLink.Commons/Types/Audit/AuditLogQueryFilter.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ScadaLink.Commons.Types.Enums;
|
||||
|
||||
namespace ScadaLink.Commons.Types.Audit;
|
||||
|
||||
/// <summary>
|
||||
/// Filter predicate for <see cref="ScadaLink.Commons.Interfaces.Repositories.IAuditLogRepository.QueryAsync"/>.
|
||||
/// Any field left <c>null</c> means "do not constrain on that column". Time bounds
|
||||
/// are half-open in the spec sense — <see cref="FromUtc"/> is inclusive and
|
||||
/// <see cref="ToUtc"/> is inclusive of the upper bound; the repository SQL uses
|
||||
/// <c>>=</c> / <c><=</c> respectively. All filter fields are AND-combined.
|
||||
/// </summary>
|
||||
public sealed record AuditLogQueryFilter(
|
||||
AuditChannel? Channel = null,
|
||||
AuditKind? Kind = null,
|
||||
AuditStatus? Status = null,
|
||||
string? SourceSiteId = null,
|
||||
string? Target = null,
|
||||
string? Actor = null,
|
||||
Guid? CorrelationId = null,
|
||||
DateTime? FromUtc = null,
|
||||
DateTime? ToUtc = null);
|
||||
Reference in New Issue
Block a user