Created
December 4, 2018 19:59
-
-
Save jordangarcia/4f7c9991b59b5c399a0f00a0723c6528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ConditionOperator = 'and' | 'or' | 'not' | |
/** | |
* { | |
* operator: 'and', | |
* conditions: [ | |
* { | |
* operator: 'or', | |
* conditions: [ | |
<Condition>, | |
<Condition>, | |
* ] | |
* } | |
* | |
* ] | |
* } | |
* | |
*/ | |
interface ConditionObject extends OperatorCondition {} | |
type OperatorCondition = { | |
operator: ConditionOperator | |
conditions: Condition[] | ConditionObject[] | |
} | |
type Condition = { | |
name: string | |
value: any | |
match_type: string | |
type: string | |
} | |
type ExperimentKey = string | |
type View = { | |
// conditions to see if a view is active | |
condition: OperatorCondition | |
// experiment keys that should try to activate for a view | |
experiments: ExperimentKey[] | |
} | |
type EnvironmentData = { | |
[key: string]: any | |
} | |
type EvaluatorFn = (condition: OperatorCondition, data: EnvironmentData) => boolean | |
type Change = { | |
config: object, | |
type: string, | |
} | |
type ActivationResult = { | |
variation: string, | |
changes: Change[], | |
} | |
interface Activator { | |
views: View[] | |
// list of activatorAttribute type to Evaluator | |
matchers: { | |
[type: string]: EvaluatorFn | |
} | |
activate({ | |
environmentData: EnvironmentData, | |
userId: string, | |
userAttributes: object, | |
}) : ActivationResult[] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment