namespace Tiku.Application.Security;

public enum SystemScopeCallerType
{
    Platform,
    Worker,
    Migrator,
    PublicQuestionBank,
    Anonymous,
    Test
}

public sealed record SystemScopeRequest(
    Guid? TargetTenantId,
    SystemScopeCallerType CallerType,
    string Caller,
    string Reason,
    string CorrelationId,
    bool IsGlobal = false);

public interface ITenantExecutionScope
{
    Task ExecuteAsync(
        SystemScopeRequest request,
        Func<IServiceProvider, CancellationToken, Task> operation,
        CancellationToken cancellationToken = default);

    Task<TResult> ExecuteAsync<TResult>(
        SystemScopeRequest request,
        Func<IServiceProvider, CancellationToken, Task<TResult>> operation,
        CancellationToken cancellationToken = default);
}