import { GuardContext, GuardExecutionResult, GuardResultObject, GuardTiming, RouteGuard } from './route-guard'; /** * Guard resolver configuration */ export interface GuardResolverConfig { /** Default timeout for guard execution (ms) */ readonly defaultTimeout?: number; /** Execute guards in parallel when possible */ readonly parallelExecution?: boolean; /** Stop on first denial */ readonly stopOnDenial?: boolean; /** Global guards applied to all routes */ readonly globalGuards?: readonly RouteGuard[]; /** Hook called before guard execution */ readonly onBeforeGuard?: (guard: RouteGuard, context: GuardContext) => void | Promise; /** Hook called after guard execution */ readonly onAfterGuard?: (guard: RouteGuard, result: GuardExecutionResult, context: GuardContext) => void | Promise; /** Hook called when navigation is blocked */ readonly onNavigationBlocked?: (result: GuardResolutionResult, context: GuardContext) => void | Promise; /** Feature flag for resolver */ readonly featureFlag?: string; } /** * Guard registration options */ export interface GuardRegistrationOptions { /** Routes to apply guard to */ readonly routes?: readonly string[]; /** Routes to exclude */ readonly exclude?: readonly string[]; /** Guard timing overrides */ readonly timing?: GuardTiming; /** Priority override */ readonly priority?: number; } /** * Guard resolution result */ export interface GuardResolutionResult { /** Whether navigation can proceed */ readonly canProceed: boolean; /** Final result (allow, deny, or redirect) */ readonly result: GuardResultObject; /** All executed guard results */ readonly guardResults: readonly GuardExecutionResult[]; /** Guards that passed */ readonly passedGuards: readonly string[]; /** Guards that failed */ readonly failedGuards: readonly string[]; /** Guards that were skipped */ readonly skippedGuards: readonly string[]; /** Total resolution time (ms) */ readonly totalTimeMs: number; /** Redirect path (if applicable) */ readonly redirectTo?: string; /** Denial reasons (if applicable) */ readonly denialReasons: readonly string[]; } /** * Registered guard with metadata */ export interface RegisteredGuard { /** Guard instance */ readonly guard: RouteGuard; /** Registration options */ readonly options: GuardRegistrationOptions; /** Registration ID */ readonly id: string; /** Registration timestamp */ readonly registeredAt: number; } /** * Navigation intent for guard resolution */ export interface NavigationIntent { /** Target path */ readonly to: string; /** Source path (if navigating from another route) */ readonly from?: string; /** Route parameters */ readonly params?: Record; /** Query parameters */ readonly query?: Record; /** Navigation state */ readonly state?: unknown; /** Whether this is initial load */ readonly isInitialLoad?: boolean; /** User context */ readonly user?: GuardContext['user']; /** Feature flags */ readonly features?: Record; } /** * Guard resolver state */ export interface GuardResolverState { /** All registered guards */ readonly guards: readonly RegisteredGuard[]; /** Currently resolving */ readonly isResolving: boolean; /** Last resolution result */ readonly lastResult: GuardResolutionResult | null; } /** * Default resolver configuration */ export declare const DEFAULT_RESOLVER_CONFIG: GuardResolverConfig; /** * Resolves route guards before navigation * * @example * ```typescript * const resolver = new GuardResolver(); * * // Register guards * resolver.register(authGuard); * resolver.register(adminGuard, { routes: ['/admin/**'] }); * * // Resolve before navigation * const result = await resolver.resolve({ * to: '/admin/dashboard', * user: currentUser, * }); * * if (result.canProceed) { * router.navigate(result.result.data?.path ?? intent.to); * } else if (result.redirectTo) { * router.navigate(result.redirectTo); * } * ``` */ export declare class GuardResolver { private readonly config; private guards; private globalGuards; private idCounter; private isResolving; private lastResult; constructor(config?: GuardResolverConfig); /** * Register a guard * * @param guard - Guard to register * @param options - Registration options * @returns Registration ID */ register(guard: RouteGuard, options?: GuardRegistrationOptions): string; /** * Unregister a guard * * @param id - Registration ID * @returns True if guard was found and removed */ unregister(id: string): boolean; /** * Unregister a guard by name * * @param name - Guard name * @returns Number of guards removed */ unregisterByName(name: string): number; /** * Resolve guards for a navigation intent * * @param intent - Navigation intent * @returns Resolution result */ resolve(intent: NavigationIntent): Promise; /** * Resolve guards for deactivation (leaving a route) * * @param intent - Navigation intent (from = current route) * @returns Resolution result */ resolveDeactivation(intent: NavigationIntent): Promise; /** * Get resolver state */ getState(): GuardResolverState; /** * Get all registered guards */ getGuards(): readonly RegisteredGuard[]; /** * Get a specific guard by ID */ getGuard(id: string): RegisteredGuard | undefined; /** * Clear all guards */ clearAll(): void; /** * Check if currently resolving */ getIsResolving(): boolean; /** * Get last resolution result */ getLastResult(): GuardResolutionResult | null; /** * Get guards applicable to a path */ private getApplicableGuards; /** * Check if a registered guard applies to a path */ private guardAppliesToPath; /** * Match a glob pattern */ private matchPattern; /** * Execute guards with timing */ private executeGuards; /** * Execute a single guard */ private executeSingleGuard; } /** * Create a guard resolver * * @param config - Resolver configuration * @returns GuardResolver instance */ export declare function createGuardResolver(config?: GuardResolverConfig): GuardResolver; /** * Get the default guard resolver */ export declare function getGuardResolver(): GuardResolver; /** * Initialize the default guard resolver * * @param config - Resolver configuration */ export declare function initGuardResolver(config?: GuardResolverConfig): void; /** * Reset the default guard resolver */ export declare function resetGuardResolver(): void; /** * Type guard for GuardResolutionResult */ export declare function isGuardResolutionResult(value: unknown): value is GuardResolutionResult; /** * Type guard for NavigationIntent */ export declare function isNavigationIntent(value: unknown): value is NavigationIntent;