using System.Security.Claims;
namespace SeaHaven.Services.Interfaces
{
///
/// Server-derived work-order account scope (SH-221): claims for authenticated callers,
/// Location.AccountId for board create, unique Accounts.Name ↔ Customer for ingest/webhook.
///
public interface IWorkOrderAccountResolver
{
///
/// Account filter for reads. Null = org-wide (skip ApplyAccountScope).
/// Throws Forbidden when scope is Missing.
///
int? ResolveAccountFilter(ClaimsPrincipal user);
///
/// Authenticated create: claim account_id, or org-wide Customer unique match.
/// Missing scope → Forbidden. Unresolvable org-wide Customer → AccountUnresolved.
/// Used by legacy AddWorkorder — not board create.
///
Task ResolveForAuthenticatedCreateAsync(
ClaimsPrincipal user,
string? customer,
CancellationToken cancellationToken = default);
///
/// Board create: stamp from JWT account_id or Location.AccountId. Never trusts body customer/accountId.
/// Missing locationId → InvalidValue. Missing location → NotFound. Null Location.AccountId → AccountUnresolved.
/// Scoped location mismatch → Forbidden.
///
Task ResolveForBoardCreateAsync(
ClaimsPrincipal user,
int? locationId,
CancellationToken cancellationToken = default);
///
/// Ingest/webhook/sync create: unique Customer → Accounts.Id or AccountUnresolved.
///
Task ResolveForUnauthenticatedCreateAsync(
string? customer,
CancellationToken cancellationToken = default);
///
/// Best-effort Customer lookup (no throw). Null when blank, missing, or ambiguous.
///
Task TryResolveFromCustomerAsync(
string? customer,
CancellationToken cancellationToken = default);
}
}