mon-entreprise/source/engine/controls.js

23 lines
588 B
JavaScript
Raw Normal View History

import { evaluateNode } from 'Engine/evaluation'
2019-11-07 11:34:03 +00:00
import { filter, map, path, pipe, unnest, values } from 'ramda'
let getControls = path(['explanation', 'contrôles'])
export let evaluateControls = (cache, situationGate, parsedRules) =>
pipe(
values,
filter(getControls),
map(rule =>
2019-11-07 11:34:03 +00:00
getControls(rule).map(control => ({
...control,
evaluated: evaluateNode(
{ ...cache, contextRule: [rule.dottedName] },
2019-11-07 11:34:03 +00:00
situationGate,
parsedRules,
control.testExpression
)
}))
),
unnest,
filter(control => control.evaluated.nodeValue === true)
)(cache)