import { LibraryIntegration } from './library-integration'; /** * API flag keys */ export declare const API_FLAG_KEYS: { /** Enable API retry logic */ readonly API_RETRY_ENABLED: "api-retry-enabled"; /** Enable API response caching */ readonly API_CACHE_ENABLED: "api-cache-enabled"; /** Enable request deduplication */ readonly API_DEDUPE_ENABLED: "api-dedupe-enabled"; /** Enable rate limiting */ readonly API_RATE_LIMIT_ENABLED: "api-rate-limit-enabled"; /** Use mock API responses */ readonly API_MOCK_ENABLED: "api-mock-enabled"; /** Enable API metrics collection */ readonly API_METRICS_ENABLED: "api-metrics-enabled"; /** Enable API request logging */ readonly API_LOGGING_ENABLED: "api-logging-enabled"; /** Enable optimistic updates */ readonly API_OPTIMISTIC_ENABLED: "api-optimistic-enabled"; /** Enable API versioning */ readonly API_VERSIONING_ENABLED: "api-versioning-enabled"; /** Enable streaming responses */ readonly API_STREAMING_ENABLED: "api-streaming-enabled"; /** Use new API gateway */ readonly API_GATEWAY_V2: "api-gateway-v2"; /** Enable batch requests */ readonly API_BATCH_ENABLED: "api-batch-enabled"; /** Enable GraphQL mode */ readonly API_GRAPHQL_ENABLED: "api-graphql-enabled"; /** Enable offline support */ readonly API_OFFLINE_ENABLED: "api-offline-enabled"; }; export type ApiFlagKey = (typeof API_FLAG_KEYS)[keyof typeof API_FLAG_KEYS]; /** * API flag configuration */ export interface ApiFlagConfig { /** Enable retry logic */ readonly retryEnabled: boolean; /** Enable response caching */ readonly cacheEnabled: boolean; /** Enable request deduplication */ readonly dedupeEnabled: boolean; /** Enable rate limiting */ readonly rateLimitEnabled: boolean; /** Use mock responses */ readonly mockEnabled: boolean; /** Enable metrics collection */ readonly metricsEnabled: boolean; /** Enable request logging */ readonly loggingEnabled: boolean; /** Enable optimistic updates */ readonly optimisticEnabled: boolean; /** Enable API versioning */ readonly versioningEnabled: boolean; /** Enable streaming responses */ readonly streamingEnabled: boolean; /** Use new gateway */ readonly gatewayV2: boolean; /** Enable batch requests */ readonly batchEnabled: boolean; /** Enable GraphQL */ readonly graphqlEnabled: boolean; /** Enable offline support */ readonly offlineEnabled: boolean; /** Index signature for Record compatibility */ [key: string]: unknown; } /** * API endpoint flag configuration */ export interface EndpointFlagConfig { /** Endpoint path pattern */ readonly path: string; /** Feature flag key */ readonly flagKey: string; /** Enabled endpoint URL */ readonly enabledUrl: string; /** Fallback endpoint URL */ readonly fallbackUrl: string; /** Mock data when mocking is enabled */ readonly mockData?: unknown; } /** * Flagged request options */ export interface FlaggedRequestOptions { /** Override retry setting */ readonly forceRetry?: boolean; /** Override cache setting */ readonly forceCache?: boolean; /** Override mock setting */ readonly forceMock?: boolean; /** Additional flag context */ readonly flagContext?: Record; } /** * Default API flag configuration */ export declare const DEFAULT_API_FLAG_CONFIG: ApiFlagConfig; /** * Create API flag integration */ export declare function createApiFlagIntegration(): LibraryIntegration; declare const apiIntegration: LibraryIntegration; /** * API flags helper object for direct flag checking */ declare class ApiFlagsHelper { /** * Set the flag getter function */ setFlagGetter(getter: (flagKey: string) => boolean): void; /** * Check if retry is enabled */ isRetryEnabled(): boolean; /** * Check if caching is enabled */ isCacheEnabled(): boolean; /** * Check if deduplication is enabled */ isDedupeEnabled(): boolean; /** * Check if rate limiting is enabled */ isRateLimitEnabled(): boolean; /** * Check if mock mode is enabled */ isMockEnabled(): boolean; /** * Check if metrics are enabled */ isMetricsEnabled(): boolean; /** * Check if logging is enabled */ isLoggingEnabled(): boolean; /** * Check if optimistic updates are enabled */ isOptimisticEnabled(): boolean; /** * Check if versioning is enabled */ isVersioningEnabled(): boolean; /** * Check if streaming is enabled */ isStreamingEnabled(): boolean; /** * Check if gateway v2 is enabled */ isGatewayV2Enabled(): boolean; /** * Check if batch requests are enabled */ isBatchEnabled(): boolean; /** * Check if GraphQL is enabled */ isGraphQLEnabled(): boolean; /** * Check if offline support is enabled */ isOfflineEnabled(): boolean; /** * Get all flag states */ getAllFlags(): Record; private getFlag; } /** * Global API flags helper instance */ export declare const apiFlags: ApiFlagsHelper; /** * Hook to get API flag configuration */ export declare function useApiFlagConfig(): ApiFlagConfig; /** * Hook to check a specific API flag */ export declare function useApiFlag(flagKey: ApiFlagKey): boolean; /** * Hook for flagged API request configuration */ export declare function useFlaggedApiRequest(endpoint: string, options?: FlaggedRequestOptions): { shouldRetry: boolean; shouldCache: boolean; shouldMock: boolean; shouldLog: boolean; makeRequest: () => Promise; }; /** * Register a flagged endpoint */ export declare function registerFlaggedEndpoint(config: EndpointFlagConfig): void; /** * Get endpoint URL based on flag state */ export declare function getFlaggedEndpointUrl(path: string, getFlag: (flagKey: string) => boolean): string; /** * Get mock data for endpoint if mocking is enabled */ export declare function getFlaggedEndpointMockData(path: string, isMockEnabled: boolean): unknown | undefined; /** * Clear all registered endpoint flags */ export declare function clearFlaggedEndpoints(): void; /** * Create a flag-aware fetch wrapper * * Note: This function intentionally returns a raw fetch wrapper because: * 1. It provides a drop-in replacement for the native fetch API * 2. Users may need to use this with existing code that expects fetch * 3. The wrapper applies feature flag logic on top of fetch * * For new API calls, prefer using apiClient from @/lib/api directly, * which provides retry, authentication, and error handling out of the box. * * @see {@link @/lib/api/api-client} for the recommended API client */ export declare function createFlaggedFetch(getFlag: (flagKey: string) => boolean): typeof fetch; export { apiIntegration };