/** * API Feature Flag Provider * * Provider adapter that uses @plyaz/api services with an injected API client * to fetch feature flags from a remote API. This provider extends the base * FeatureFlagProvider and implements fetchData() using the API services. * * @fileoverview API provider adapter for feature flags * @version 2.0.0 */ import type { FeatureFlag, FeatureFlagRule, FeatureFlagValue, CreateFlagRequest } from '@plyaz/types'; import { FeatureFlagProvider } from '../provider'; import type { ServiceOptions } from '@plyaz/types/api'; import type { ApiFeatureFlagConfig as _ApiFeatureFlagConfig } from '@plyaz/types/features'; type ApiClientType = NonNullable; /** * API-based feature flag provider * * Uses @plyaz/api services with an injected API client to communicate with the backend. * Pass your configured API client via the config. * * @class ApiFeatureFlagProvider * @extends {FeatureFlagProvider} * * @example * ```typescript * // Get client from ApiClientService * const apiClient = ApiClientService.getClient(); * * const provider = new ApiFeatureFlagProvider({ * provider: 'api', * apiClient, * isCacheEnabled: true, * cacheTtl: 300, * }, FEATURES); * * await provider.initialize(); * const isEnabled = await provider.isEnabled('new-feature'); * ``` */ export declare class ApiFeatureFlagProvider extends FeatureFlagProvider { protected readonly apiClient: ApiClientType; /** * Creates a new API feature flag provider. * * @param config - Provider configuration with API client * @param features - Record of feature flag keys to default values */ constructor(config: _ApiFeatureFlagConfig, features: Record); /** * Get service options with injected client */ private getServiceOptions; /** Wrap error in CorePackageError if not already a package error */ private wrapError; /** Transform API response to flags/rules */ private transformResponse; /** * Fetches flags and rules from the API endpoint using @plyaz/api services. * * @protected * @returns Promise resolving to flags and rules data */ protected fetchData(): Promise<{ flags: FeatureFlag[]; rules: FeatureFlagRule[]; }>; /** * Validates the API provider configuration. * * @private */ private validateConfig; /** * Gets API provider status and configuration info. */ getApiInfo(): { hasApiClient: boolean; }; /** * Creates a new feature flag via API */ createFlag(data: CreateFlagRequest): Promise>; /** * Updates a feature flag via API */ updateFlag(key: FeatureFlagKey, data: Partial>): Promise>; /** * Deletes a feature flag via API */ deleteFlag(key: FeatureFlagKey): Promise; /** * Gets rules for a specific flag via API */ getRules(key: FeatureFlagKey): Promise[]>; /** * Gets all rules via API * Note: This requires fetching rules for all flags individually or a dedicated endpoint */ getAllRules(): Promise[]>; } export {}; //# sourceMappingURL=api.d.ts.map