import { EvaluationDetails, ExperimentEvaluation, GateEvaluation, LayerEvaluation } from './EvaluationTypes'; import { ParamStoreConfig } from './ParamStoreTypes'; import { Flatten } from './TypingUtils'; export type TypedGet = (key: string, fallback?: T) => TypedReturn; export type ParamStoreTypedGet = (key: string, fallback: T) => T; export type TypedReturn = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends Array ? Array : T extends object ? object : unknown; export type SpecType = 'gate' | 'dynamic_config' | 'experiment' | 'layer'; export type FeatureGate = Flatten<{ readonly name: string; readonly ruleID: string; readonly details: EvaluationDetails; readonly value: boolean; readonly idType: string | null; readonly __evaluation: GateEvaluation | null; }>; export type Experiment = Flatten<{ readonly name: string; readonly ruleID: string; readonly details: EvaluationDetails; readonly value: Record; readonly groupName: string | null; readonly idType: string | null; readonly __evaluation: ExperimentEvaluation | null; readonly get: TypedGet; }>; export type DynamicConfig = Flatten>; export type Layer = Flatten<{ readonly name: string; readonly ruleID: string; readonly details: EvaluationDetails; readonly groupName: string | null; readonly __value: Record; readonly __evaluation: LayerEvaluation | null; get: TypedGet; }>; export type ParameterStore = Flatten<{ readonly name: string; readonly details: EvaluationDetails; readonly get: TypedGet; readonly __configuration: ParamStoreConfig | null; }>; export type AnyConfigBasedStatsigType = DynamicConfig | Experiment | Layer; export type AnyStatsigType = FeatureGate | AnyConfigBasedStatsigType | ParameterStore;