import { Observable } from "rxjs"; import * as i0 from "@angular/core"; interface IOpalUserPermissions { permission_id: number; permission_name: string; } interface IOpalUserBusinessUnitUser { business_unit_user_id: string; business_unit_id: number; permissions: IOpalUserPermissions[]; } type OpalUserStateStatus = 'active' | 'created' | 'suspended' | 'deactivated'; interface IOpalUserState { user_id: number; username: string; name: string; status: OpalUserStateStatus | null; version: number | null; business_unit_users: IOpalUserBusinessUnitUser[]; } export declare class OpalUserService { private readonly http; private readonly globalStore; private inFlightUserState$?; private userStateRequestGeneration; private userStateCacheExpiresAtMilliseconds; /** * Converts the user-state API status into the service domain status. * * @param status - The status value returned by the user-state API. * @returns The mapped domain status, or null when the API status is null. */ private toOpalUserStatus; /** * Gets the configured user-state domain from the global store. * * @returns The trimmed user-state domain. * @throws When no non-blank user-state domain has been configured. */ private getUserStateDomain; /** * Maps the Redis-backed user state response into the existing domain-specific user state shape. * * @param userState - The raw user-state API response. * @returns The mapped user state for the configured domain. * @throws When the response does not include the configured domain. */ private toOpalUserState; /** * Extracts the body from the observed user-state HTTP response. * * @param response - The full HTTP response from the user-state endpoint. * @returns The response body. * @throws When the response body is empty. */ private getUserStateResponseBody; /** * Checks whether a user state can be used as a cached logged-in user. * * @param userState - The user state currently held in the global store. * @returns True when the user state contains a positive numeric user ID. */ private isValidCachedUserState; /** * Gets the current cached user state when it is populated and unexpired. * * @returns The cached user state, or null when the cache is empty or expired. */ private getCachedUserState; /** * Calculates the local cache TTL from the response header and configured maximum TTL. * * @param response - The full HTTP response from the user-state endpoint. * @returns The TTL in milliseconds. A zero response header expires the local cache immediately. */ private getUserStateCacheTtlMilliseconds; /** * Invalidates local cache controls and marks existing in-flight requests as stale. */ private clearLocalUserStateCache; /** * Retrieves the logged-in user's state as an observable. * * Uses the global store as a local cache until the effective user-state TTL expires, shares concurrent HTTP * requests, and ignores stale responses after the local cache has been invalidated. * * @returns {Observable} An observable that emits the logged-in user's state. */ getLoggedInUserState(): Observable; /** * Clears the global store user state and invalidates local user-state cache controls. * * Useful for logout and identity switches to avoid reusing stale state or accepting stale in-flight responses. */ clearUserStateCache(): void; /** * Fetches the latest user state from the Redis-backed frontend endpoint, bypassing the current local cache. * * @returns An Observable that emits the current {@link IOpalUserState}. */ refreshUserState(): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }