/** * Feature Flag Service Factory * * Factory class for creating feature flag services with configured providers. * * @fileoverview Service factory for feature flag system * @version 1.0.0 */ import type { FeatureFlagConfig, FeatureFlagProvider, FeatureFlagValue, FeatureFlagProviderType } from '@plyaz/types/features'; import { FeatureFlagService } from '../service'; /** * Feature flag service factory for creating service instances with providers. * * @class FeatureFlagServiceFactory * * @example * ```typescript * // Create and initialize service * const service = await FeatureFlagServiceFactory.createAndInitialize({ * provider: 'database', * isCacheEnabled: true, * cacheTtl: 300, * }, FEATURES); * * // Use the service * const isEnabled = await service.isEnabled('MY_FEATURE'); * await service.createFlag({ key: 'NEW', value: true, name: 'New Flag' }); * ``` */ export declare class FeatureFlagServiceFactory { /** * Creates a new feature flag service with the configured provider. * * @param config - Provider configuration * @param features - Record of feature flag keys to their default values * @returns Configured service instance (not yet initialized) */ static createService(config: FeatureFlagConfig, features: Record): FeatureFlagService; /** * Creates and initializes a feature flag service. * * @param config - Provider configuration * @param features - Record of feature flag keys to their default values * @returns Promise resolving to initialized service instance */ static createAndInitialize(config: FeatureFlagConfig, features: Record): Promise>; /** * Creates a default service with memory provider. * * @param features - Record of feature flag keys to their default values * @param overrides - Optional configuration overrides * @returns Service instance */ static createDefaultService(features: Record, overrides?: Partial>): FeatureFlagService; } /** * Feature flag provider factory for creating provider instances directly. * For most use cases, use FeatureFlagServiceFactory instead. * * @class FeatureFlagProviderFactory */ export declare class FeatureFlagProviderFactory { /** * Creates a new feature flag provider instance based on configuration. * * @param config - Provider configuration * @param features - Record of feature flag keys to their default values * @returns Configured provider instance * @throws Error if provider type is unsupported or configuration is invalid */ static create(config: FeatureFlagConfig, features: Record): FeatureFlagProvider; /** * Creates a provider with automatic initialization. * * @param config - Provider configuration * @param features - Record of feature flag keys to their default values * @returns Promise resolving to initialized provider instance */ static createAndInitialize(config: FeatureFlagConfig, features: Record): Promise>; /** * Gets a list of all supported provider types. * * @returns Array of supported provider names */ static getSupportedProviders(): FeatureFlagProviderType[]; /** * Checks if a provider type is supported. * * @param providerType - Provider type to check * @returns True if provider type is supported */ static isProviderSupported(providerType: string): providerType is FeatureFlagProviderType; /** * Gets provider information including implementation status. * * @returns Record of provider information */ static getProvidersInfo(): Record; /** * Creates a default provider. * Uses file provider if features are not provided, memory provider otherwise. * * @param features - Record of feature flag keys to their default values (optional) * @param overrides - Optional configuration overrides * @returns Provider instance */ static createDefault(features?: Record, overrides?: Partial>): FeatureFlagProvider; /** * Type guard to check if a provider supports feature syncing. * * @param provider - The provider instance to check * @returns True if provider has syncFeatures method */ static isSyncableProvider(provider: FeatureFlagProvider): provider is FeatureFlagProvider & Required, 'syncFeatures'>>; /** * Updates features on a provider if it supports the syncFeatures method. * This is useful for providers like MemoryProvider that can update their features at runtime. * * @param provider - The provider instance * @param newFeatures - New features to sync * @returns Promise that resolves when sync is complete * @throws Error if provider doesn't support feature syncing */ static syncFeatures(provider: FeatureFlagProvider, newFeatures: Record): Promise; /** * Checks if a provider supports feature syncing. * * @param provider - The provider instance to check * @returns True if provider supports syncFeatures method */ static supportsFeaturesSync(provider: FeatureFlagProvider): boolean; /** * Validates provider configuration before instantiation. * * @private * @param config - Configuration to validate * @throws Error if configuration is invalid */ static validateConfig(config: FeatureFlagConfig): void; /** * Validates provider-specific configuration requirements. * * @private * @param config - Configuration to validate * @throws Error if provider-specific configuration is invalid */ private static validateProviderSpecificConfig; private static validateFileConfig; private static validateRedisConfig; private static validateApiConfig; private static validateDatabaseConfig; } //# sourceMappingURL=factory.d.ts.map