src/flag-types.tsTypeScript
@@ -0,0 +1,45 @@
1+
export interface FlagRule {2+
attribute: string;3+
equals: string;4+
}5+
6+
export interface FlagConfig {7+
tenantId: string;8+
key: string;9+
version: string;10+
enabled: boolean;11+
killSwitch: boolean;12+
rolloutBasisPoints: number;13+
startsAt?: string;14+
endsAt?: string;15+
overrides: Readonly<Record<string, boolean>>;16+
segmentRules: readonly FlagRule[];17+
prerequisites: readonly string[];18+
}19+
20+
export interface EvaluationInput {21+
tenantId: string;22+
flagKey: string;23+
configVersion: string;24+
accountId: string;25+
userId: string;26+
attributes: Readonly<Record<string, string>>;27+
now: Date;28+
}29+
30+
export interface FlagStore {31+
load(32+
tenantId: string,33+
flagKey: string,34+
version: string,35+
): Promise<FlagConfig | undefined>;36+
}37+
38+
export interface BucketHasher {39+
bucket(identity: string): number;40+
}41+
42+
export interface FlagDependencies {43+
store: FlagStore;44+
hasher: BucketHasher;45+
}