You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
996 B
29 lines
996 B
const fs = require('fs');
|
|
const ts = require('typescript');
|
|
|
|
// Compile conditional-rules.ts on the fly
|
|
const source = fs.readFileSync('src/lib/conditional-rules.ts', 'utf8');
|
|
const result = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS }});
|
|
fs.writeFileSync('conditional-rules.js', result.outputText);
|
|
|
|
const rules = require('./conditional-rules.js');
|
|
|
|
const answers = {
|
|
"family_background.parents_survival_status": {
|
|
value: "both_parents_are_alive",
|
|
option_id: "family_background.parents_survival_status.both_parents_are_alive"
|
|
}
|
|
};
|
|
|
|
const visibility = {
|
|
operator: "any_of",
|
|
parent_question_id: "family_background.parents_survival_status",
|
|
trigger_option_ids: ["family_background.parents_survival_status.both_parents_are_alive"],
|
|
clear_answer_when_hidden: true
|
|
};
|
|
|
|
const context = { age: 25, gender: 'male' };
|
|
|
|
const isVisible = rules.ruleMatches(visibility, answers, context);
|
|
console.log("Is parents_marital_status visible?", isVisible);
|
|
|