import { BaseRouteGuard, GuardContext } from './route-guard'; /** * Feature flag matching strategy */ export type FeatureFlagMatchStrategy = 'any' | 'all' | 'none'; /** * Feature flag state */ export type FeatureFlagState = boolean | string | number | null | undefined; /** * Feature flag provider function */ export type FeatureFlagProvider = (flagKey: string, context?: GuardContext) => FeatureFlagState | Promise; /** * Feature guard configuration */ export interface FeatureGuardConfig { /** Guard name */ readonly name?: string; /** Required feature flags */ readonly requiredFlags: readonly string[]; /** How to match flags */ readonly matchStrategy?: FeatureFlagMatchStrategy; /** Path to redirect when flags not met */ readonly fallbackPath?: string; /** Custom message for fallback */ readonly fallbackMessage?: string; /** Feature flag provider function */ readonly getFlag?: FeatureFlagProvider; /** Default flag value when not found */ readonly defaultFlagValue?: boolean; /** Custom flag evaluation logic */ readonly evaluateFlag?: (flagKey: string, flagValue: FeatureFlagState, context: GuardContext) => boolean; /** Enable caching of flag values */ readonly cacheFlags?: boolean; /** Cache TTL in milliseconds */ readonly cacheTTL?: number; /** Routes this guard applies to */ readonly routes?: readonly string[]; /** Routes to exclude */ readonly exclude?: readonly string[]; /** Guard priority */ readonly priority?: number; /** Parent feature flag for this guard */ readonly featureFlag?: string; } /** * Feature flag check result */ export interface FeatureFlagCheckResult { /** Whether flags allow access */ readonly hasAccess: boolean; /** Evaluated flag states */ readonly flagStates: Readonly>; /** Enabled flags */ readonly enabledFlags: readonly string[]; /** Disabled flags */ readonly disabledFlags: readonly string[]; /** Strategy used */ readonly strategy: FeatureFlagMatchStrategy; /** Whether result came from cache */ readonly fromCache: boolean; } /** * Default feature guard configuration */ export declare const DEFAULT_FEATURE_CONFIG: Partial; /** * Feature flag route guard * * @example * ```typescript * const guard = new FeatureGuard({ * requiredFlags: ['new-dashboard', 'beta-analytics'], * matchStrategy: 'all', * getFlag: async (key) => featureFlagService.isEnabled(key), * }); * * const result = await guard.execute('canActivate', context); * ``` */ export declare class FeatureGuard extends BaseRouteGuard { private readonly featureConfig; private readonly flagCache; constructor(config: FeatureGuardConfig); /** * Get required flags */ getRequiredFlags(): readonly string[]; /** * Get match strategy */ getMatchStrategy(): FeatureFlagMatchStrategy; /** * Check a single flag without full guard execution */ checkFlag(flagKey: string, context: GuardContext): Promise; /** * Clear flag cache */ clearCache(): void; /** * Invalidate specific flag in cache */ invalidateFlag(flagKey: string): void; /** * Check if required features are enabled */ private checkFeatureAccess; /** * Perform feature flag check */ private performFeatureCheck; /** * Get flag value (with caching) */ private getFlagValue; /** * Determine if a flag is enabled */ private isFlagEnabled; /** * Handle disabled feature */ private handleFeatureDisabled; } /** * Create a feature guard * * @param config - Guard configuration * @returns FeatureGuard instance */ export declare function createFeatureGuard(config: FeatureGuardConfig): FeatureGuard; /** * Create a guard requiring a single feature flag * * @param flag - Required flag * @param options - Additional options * @returns FeatureGuard instance */ export declare function requireFeature(flag: string, options?: Partial>): FeatureGuard; /** * Create a guard requiring any of the specified features * * @param flags - Feature flags (any one required) * @param options - Additional options * @returns FeatureGuard instance */ export declare function requireAnyFeature(flags: readonly string[], options?: Partial>): FeatureGuard; /** * Create a guard requiring all specified features * * @param flags - Feature flags (all required) * @param options - Additional options * @returns FeatureGuard instance */ export declare function requireAllFeatures(flags: readonly string[], options?: Partial>): FeatureGuard; /** * Create a guard for deprecated features (must be disabled) * * @param flags - Deprecated feature flags * @param options - Additional options * @returns FeatureGuard instance */ export declare function deprecatedFeature(flags: readonly string[], options?: Partial>): FeatureGuard; /** * Create a beta feature guard * * @param featureName - Name of the beta feature * @param options - Additional options * @returns FeatureGuard instance */ export declare function betaFeature(featureName: string, options?: Partial>): FeatureGuard; /** * Create a feature flag provider from a static config * * @param flags - Static flag configuration * @returns Feature flag provider function */ export declare function createStaticFlagProvider(flags: Record): FeatureFlagProvider; /** * Create a feature flag provider from localStorage * * @param prefix - Key prefix in localStorage * @returns Feature flag provider function */ export declare function createLocalStorageFlagProvider(prefix?: string): FeatureFlagProvider; /** * Create a feature flag provider from URL parameters * * @param paramPrefix - URL parameter prefix * @returns Feature flag provider function */ export declare function createUrlFlagProvider(paramPrefix?: string): FeatureFlagProvider; /** * Combine multiple flag providers (first defined value wins) * * @param providers - Array of providers * @returns Combined provider function */ export declare function combineFlagProviders(providers: readonly FeatureFlagProvider[]): FeatureFlagProvider; /** * Type guard for FeatureGuard */ export declare function isFeatureGuard(value: unknown): value is FeatureGuard; /** * Type guard for FeatureFlagCheckResult */ export declare function isFeatureFlagCheckResult(value: unknown): value is FeatureFlagCheckResult;