using ZB.MOM.WW.ScadaBridge.Commons.Entities.Audit; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Deployment; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites; using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates; namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; public interface ICentralUiRepository { /// Returns all configured sites. /// Cancellation token. /// A task that resolves to a read-only list of all sites. Task> GetAllSitesAsync(CancellationToken cancellationToken = default); /// Returns all data connections for the specified site. /// The site database ID to filter by. /// Cancellation token. /// A task that resolves to a read-only list of data connections for the site. Task> GetDataConnectionsBySiteIdAsync(int siteId, CancellationToken cancellationToken = default); /// Returns all data connections across all sites. /// Cancellation token. /// A task that resolves to a read-only list of all data connections. Task> GetAllDataConnectionsAsync(CancellationToken cancellationToken = default); /// Returns the full template tree including folders and templates. /// Cancellation token. /// A task that resolves to a read-only list of templates. Task> GetTemplateTreeAsync(CancellationToken cancellationToken = default); /// Returns instances filtered by optional site, template, or search term. /// Optional site ID to filter by. /// Optional template ID to filter by. /// Optional keyword to filter instance names. /// Cancellation token. /// A task that resolves to a read-only list of matching instances. Task> GetInstancesFilteredAsync(int? siteId = null, int? templateId = null, string? searchTerm = null, CancellationToken cancellationToken = default); /// Returns the most recent deployment records up to the specified count. /// Maximum number of records to return. /// Cancellation token. /// A task that resolves to a read-only list of recent deployment records. Task> GetRecentDeploymentsAsync(int count, CancellationToken cancellationToken = default); /// Returns the area tree for the specified site. /// The site database ID. /// Cancellation token. /// A task that resolves to a read-only list of areas for the site. Task> GetAreaTreeBySiteIdAsync(int siteId, CancellationToken cancellationToken = default); // Audit log queries /// /// Queries audit log entries with optional filters, returning a page of results and the total matching count. /// /// Optional user filter. /// Optional entity type filter. /// Optional action filter. /// Optional start of date range filter. /// Optional end of date range filter. /// Optional entity ID filter. /// Optional entity name filter. /// Optional bundle import correlation ID filter. /// One-based page number. /// Number of entries per page. /// Cancellation token. /// A task that resolves to a tuple of the matching entries and the total count. Task<(IReadOnlyList Entries, int TotalCount)> GetAuditLogEntriesAsync( string? user = null, string? entityType = null, string? action = null, DateTimeOffset? from = null, DateTimeOffset? to = null, string? entityId = null, string? entityName = null, Guid? bundleImportId = null, int page = 1, int pageSize = 50, CancellationToken cancellationToken = default); /// Persists pending changes to the underlying store. /// Cancellation token. /// A task that resolves to the number of entities written. Task SaveChangesAsync(CancellationToken cancellationToken = default); }