/** * Feature Flags — Type Definitions * * Types for the enhanced feature flag provider that communicates with * the global-tenant-svc `evaluateFeatureFlags` GraphQL endpoint. * * Compatible with OpenFeature ResolutionDetails. */ /** Supported feature flag value types */ export type FlagValue = boolean | string | number | Record; /** Feature flag type enumeration (mirrors backend FeatureFlagType) */ export type FlagType = 'BOOLEAN' | 'STRING' | 'NUMBER' | 'JSON'; /** Feature flag status (mirrors backend FeatureFlagStatus) */ export type FlagStatus = 'ACTIVE' | 'ARCHIVED'; /** * Single flag evaluation result from the backend. * Compatible with OpenFeature ResolutionDetails. */ export interface FlagEvaluation { /** Flag key */ key: string; /** Resolved value */ value: FlagValue; /** Variant name (optional) */ variant?: string; /** Resolution reason (e.g., "DEFAULT", "WORKSPACE_OVERRIDE", "USER_PREFERENCE") */ reason: string; /** Flag type */ flagType: FlagType; /** Error code if evaluation failed */ errorCode?: string; } /** * Bulk evaluation response from backend. */ export interface BulkEvaluationResponse { evaluateFeatureFlags: { evaluations: FlagEvaluation[]; }; } /** * Configuration for the FeatureFlagProvider. */ export interface FeatureFlagProviderConfig { /** * Workspace ID for flag evaluation context. * Flags are re-fetched when this changes. */ workspaceId: string | null; /** * Gateway to use for fetching flags. * @default 'global' */ gateway?: 'workspace' | 'global'; /** * Specific flag keys to evaluate. * If omitted, evaluates ALL active flags. */ flagKeys?: string[]; /** * Polling interval in milliseconds for auto-refresh. * Set to 0 to disable polling. * @default 300000 (5 minutes) */ refreshInterval?: number; /** * Stale time in milliseconds. Flags are considered fresh for this duration. * @default 300000 (5 minutes) */ staleTime?: number; /** * Enable debug logging. * @default false */ debug?: boolean; /** * Default value returned by isEnabled() when a flag is not found. * Follows the default-allow principle. * @default true */ defaultEnabled?: boolean; } /** * Feature flag context value provided to consumers. */ export interface FeatureFlagContextValue { /** Map of flag key -> evaluation result */ evaluations: Map; /** Whether flags are currently being fetched */ isLoading: boolean; /** Error from the last fetch attempt */ error: Error | null; /** * Check if a feature flag is enabled. * Returns `defaultEnabled` (default: true) if the flag is not found * (default-allow principle). Pass `defaultValue=false` per-call to opt * into default-deny for not-yet-ready surfaces. */ isEnabled: (flagKey: string, defaultValue?: boolean) => boolean; /** * Get the resolved value of a feature flag. * Returns `defaultValue` if the flag is not found. */ getValue: (flagKey: string, defaultValue: T) => T; /** * Get the full evaluation details for a flag. * Returns undefined if the flag is not found. */ getEvaluation: (flagKey: string) => FlagEvaluation | undefined; /** * Get a flat map of all flag keys to their boolean enabled states. * Useful for bulk checks or debugging. */ getAllFlags: () => Record; /** * Manually trigger a re-fetch of all flags. */ refreshFlags: () => Promise; /** Current workspace ID being evaluated against */ workspaceId: string | null; } //# sourceMappingURL=types.d.ts.map