refine answerMeaning support category normalisation

This commit is contained in:
2026-08-09 08:06:38 +01:00
parent b2329d8608
commit 36faf70a08
3 changed files with 110 additions and 0 deletions
+18
View File
@@ -11,6 +11,10 @@ const TOP_LEVEL_ARRAY_FIELDS = [
const TOP_LEVEL_NULLABLE_FIELDS = ["selectedQuestion"];
const ANSWER_SUPPORT_CATEGORY_ALIASES = {
conditional_qualification: "conditional_tradeoff",
};
function cloneJsonSafe(value) {
if (value == null) return value;
return JSON.parse(JSON.stringify(value));
@@ -62,6 +66,20 @@ function applyKnownEnumAliases(proposal, normalisationsApplied) {
});
}
const supportCategory = proposal.answerMeaning?.supportCategory;
const canonicalSupportCategory =
ANSWER_SUPPORT_CATEGORY_ALIASES[supportCategory];
if (canonicalSupportCategory) {
normalisationsApplied.push({
path: ["answerMeaning", "supportCategory"],
change: `Converted ${supportCategory} to ${canonicalSupportCategory}`,
});
proposal.answerMeaning = {
...proposal.answerMeaning,
supportCategory: canonicalSupportCategory,
};
}
return proposal;
}