2019-03-04 13:21:15 +00:00
|
|
|
import { evaluateNode } from 'Engine/evaluation'
|
|
|
|
|
2020-03-26 15:03:19 +00:00
|
|
|
export let evaluateControls = (cache, situationGate, parsedRules) => {
|
|
|
|
return Object.values(parsedRules)
|
|
|
|
.filter(rule => !!rule.contrôles)
|
|
|
|
.map(rule =>
|
|
|
|
rule.contrôles.map(contrôle => ({
|
|
|
|
...contrôle,
|
2019-11-07 11:34:03 +00:00
|
|
|
evaluated: evaluateNode(
|
2019-11-28 11:03:23 +00:00
|
|
|
{ ...cache, contextRule: [rule.dottedName] },
|
2019-11-07 11:34:03 +00:00
|
|
|
situationGate,
|
|
|
|
parsedRules,
|
2020-03-26 15:03:19 +00:00
|
|
|
contrôle.testExpression
|
2019-11-07 11:34:03 +00:00
|
|
|
)
|
|
|
|
}))
|
2020-03-26 15:03:19 +00:00
|
|
|
)
|
|
|
|
.flat()
|
|
|
|
.filter(contrôle => contrôle.evaluated.nodeValue === true)
|
|
|
|
}
|