import { default as React, ReactNode } from 'react'; /** * Feature category for organization */ export type FeatureCategory = 'api' | 'routing' | 'ui' | 'performance' | 'auth' | 'monitoring' | 'state' | 'realtime' | 'experimental' | 'beta' | 'deprecated' | string; /** * Feature lifecycle stage */ export type FeatureStage = 'development' | 'testing' | 'beta' | 'stable' | 'deprecated' | 'sunset'; /** * Feature visibility level */ export type FeatureVisibility = 'public' | 'internal' | 'admin' | 'superadmin'; /** * Feature rollout configuration */ export interface FeatureRollout { /** Rollout percentage (0-100) */ readonly percentage?: number; /** Specific user IDs to include */ readonly includedUsers?: readonly string[]; /** Specific user IDs to exclude */ readonly excludedUsers?: readonly string[]; /** Regions to target */ readonly regions?: readonly string[]; /** User segments to target */ readonly segments?: readonly string[]; /** Start date for the rollout */ readonly startDate?: Date; /** End date for the rollout */ readonly endDate?: Date; } /** * Feature dependency definition */ export interface FeatureDependency { /** Dependent feature ID */ readonly featureId: string; /** Dependency type */ readonly type: 'requires' | 'conflicts' | 'enhances'; /** Optional condition */ readonly condition?: (isEnabled: boolean) => boolean; } /** * Feature configuration override */ export interface FeatureOverride { /** Override ID */ readonly id: string; /** Target feature ID */ readonly featureId: string; /** Override enabled state */ readonly enabled: boolean; /** Override priority (higher wins) */ readonly priority: number; /** Override reason */ readonly reason?: string; /** Override expiration */ readonly expiresAt?: Date; } /** * Feature definition */ export interface FeatureDefinition { /** Unique feature identifier */ readonly id: string; /** Human-readable name */ readonly name: string; /** Feature description */ readonly description: string; /** Feature category */ readonly category: FeatureCategory; /** Associated flag key */ readonly flagKey: string; /** Default enabled state */ readonly defaultEnabled: boolean; /** Feature lifecycle stage */ readonly stage?: FeatureStage; /** Visibility level */ readonly visibility?: FeatureVisibility; /** Feature tags for filtering */ readonly tags?: readonly string[]; /** Feature dependencies */ readonly dependencies?: readonly FeatureDependency[]; /** Rollout configuration */ readonly rollout?: FeatureRollout; /** Documentation URL */ readonly docsUrl?: string; /** Owner team/person */ readonly owner?: string; /** Created date */ readonly createdAt?: Date; /** Last modified date */ readonly modifiedAt?: Date; /** Metadata for custom data */ readonly metadata?: Readonly>; } /** * Feature state at runtime */ export interface FeatureState { /** Whether the feature is enabled */ readonly isEnabled: boolean; /** Source of the enabled state */ readonly source: 'flag' | 'override' | 'default' | 'dependency'; /** Applied override if any */ readonly override?: FeatureOverride; /** Unmet dependencies */ readonly unmetDependencies?: readonly string[]; /** Last evaluated timestamp */ readonly evaluatedAt: number; } /** * Feature with runtime state */ export interface ConfigurableFeature extends FeatureDefinition { /** Current runtime state */ readonly state: FeatureState; } /** * Feature registry interface */ export interface FeatureRegistryInterface { /** Register a feature definition */ register(feature: FeatureDefinition): void; /** Unregister a feature */ unregister(featureId: string): void; /** Get a feature by ID */ get(featureId: string): ConfigurableFeature | undefined; /** Get all features */ getAll(): ConfigurableFeature[]; /** Get features by category */ getByCategory(category: FeatureCategory): ConfigurableFeature[]; /** Get features by tag */ getByTag(tag: string): ConfigurableFeature[]; /** Get features by stage */ getByStage(stage: FeatureStage): ConfigurableFeature[]; /** Check if feature is enabled */ isEnabled(featureId: string): boolean; /** Add an override */ addOverride(override: FeatureOverride): void; /** Remove an override */ removeOverride(overrideId: string): void; /** Get all overrides */ getOverrides(): FeatureOverride[]; /** Update flags */ updateFlags(flags: Record): void; /** Subscribe to changes */ subscribe(callback: (features: ConfigurableFeature[]) => void): () => void; /** Export feature configuration */ export(): FeatureExport; /** Import feature configuration */ import(data: FeatureExport): void; /** Clear registry */ clear(): void; } /** * Feature export format */ export interface FeatureExport { readonly version: string; readonly exportedAt: string; readonly features: readonly FeatureDefinition[]; readonly overrides: readonly FeatureOverride[]; } /** * Feature registry implementation */ declare class FeatureRegistryImpl implements FeatureRegistryInterface { private features; private overrides; private flags; private subscribers; register(feature: FeatureDefinition): void; unregister(featureId: string): void; get(featureId: string): ConfigurableFeature | undefined; getAll(): ConfigurableFeature[]; getByCategory(category: FeatureCategory): ConfigurableFeature[]; getByTag(tag: string): ConfigurableFeature[]; getByStage(stage: FeatureStage): ConfigurableFeature[]; isEnabled(featureId: string): boolean; addOverride(override: FeatureOverride): void; removeOverride(overrideId: string): void; getOverrides(): FeatureOverride[]; updateFlags(flags: Record): void; subscribe(callback: (features: ConfigurableFeature[]) => void): () => void; export(): FeatureExport; import(data: FeatureExport): void; clear(): void; private evaluateFeature; private toConfigurableFeature; private notifySubscribers; } /** * Global feature registry singleton */ export declare const featureRegistry: FeatureRegistryImpl; /** * Get the global feature registry */ export declare function getFeatureRegistry(): FeatureRegistryInterface; /** * Define a new feature */ export declare function defineFeature(config: Omit & { createdAt?: Date; modifiedAt?: Date; }): FeatureDefinition; /** * Define and register a feature */ export declare function registerFeature(config: Omit): FeatureDefinition; /** * Batch register features */ export declare function registerFeatures(features: Omit[]): FeatureDefinition[]; /** * Create a feature override */ export declare function createOverride(config: Omit & { id?: string; }): FeatureOverride; /** * Configurable features context value */ export interface ConfigurableFeaturesContextValue { /** Get all features */ readonly features: ConfigurableFeature[]; /** Check if feature is enabled */ isEnabled(featureId: string): boolean; /** Get feature by ID */ getFeature(featureId: string): ConfigurableFeature | undefined; /** Get features by category */ getByCategory(category: FeatureCategory): ConfigurableFeature[]; /** Toggle a feature (adds override) */ toggle(featureId: string): void; /** Set feature enabled state (adds override) */ setEnabled(featureId: string, enabled: boolean): void; /** Clear feature override */ clearOverride(featureId: string): void; /** Refresh features */ refresh(): void; } /** * Props for ConfigurableFeaturesProvider */ export interface ConfigurableFeaturesProviderProps { readonly children: ReactNode; /** Initial features to register */ readonly initialFeatures?: readonly FeatureDefinition[]; /** Flag getter function */ readonly getFlag?: (flagKey: string) => boolean; /** Current flags */ readonly flags?: Record; } /** * Provider component for configurable features */ export declare function ConfigurableFeaturesProvider({ children, initialFeatures, getFlag, flags, }: ConfigurableFeaturesProviderProps): React.JSX.Element; /** * Hook to access configurable features context */ export declare function useConfigurableFeatures(): ConfigurableFeaturesContextValue; /** * Hook to use a single configurable feature */ export declare function useConfigurableFeature(featureId: string): { feature: ConfigurableFeature | undefined; isEnabled: boolean; toggle: () => void; setEnabled: (enabled: boolean) => void; clearOverride: () => void; }; /** * Hook to get features by category */ export declare function useFeaturesByCategory(category: FeatureCategory): ConfigurableFeature[]; /** * Hook to get feature counts by stage */ export declare function useFeatureStats(): { total: number; enabled: number; disabled: number; byStage: Record; byCategory: Record; }; /** * Create feature definitions from flag keys */ export declare function featuresFromFlagKeys(flagKeys: Record, options?: Partial>): FeatureDefinition[]; /** * Validate feature definitions */ export declare function validateFeatures(features: FeatureDefinition[]): { valid: boolean; errors: string[]; }; export {};