using ZB.MOM.WW.OtOpcUa.Commons.Browsing;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Browsing;
///
/// Outcome of . On success
/// is and is the
/// registry handle; on failure carries a human-readable
/// diagnostic for the UI's error chip.
///
/// True iff the browse session was opened and registered.
/// Failure diagnostic, or on success.
/// Registry handle on success; on failure.
public sealed record BrowseOpenResult(bool Ok, string? Message, Guid Token);
///
/// Scoped Razor-page facade over the in-process browse-session machinery. Owns
/// driver-type dispatch on open and per-call timeout enforcement on expand/attributes.
///
public interface IBrowserSessionService
{
/// Opens a session against the named driver type using the given JSON config.
/// Never throws — all errors are surfaced via .
Task OpenAsync(string driverType, string configJson, CancellationToken ct);
/// Returns the root nodes of an open session. Throws
/// if the token is unknown.
Task> RootAsync(Guid token, CancellationToken ct);
/// Returns the direct children of in an open session.
/// Throws if the token is unknown.
Task> ExpandAsync(Guid token, string nodeId, CancellationToken ct);
/// Returns the attributes of in an open session. Throws
/// if the token is unknown.
Task> AttributesAsync(Guid token, string nodeId, CancellationToken ct);
/// Removes the session from the registry and disposes it. No-op for unknown tokens.
Task CloseAsync(Guid token);
}
///
/// Raised by the service layer when a caller references a token that is not
/// (or no longer) in the registry — typically because the reaper evicted it
/// between calls.
///
public sealed class BrowseSessionNotFoundException(Guid token)
: InvalidOperationException($"Browse session {token} not found (may have been reaped).");