12 lines
883 B
JavaScript
12 lines
883 B
JavaScript
export const normalize = text => String(text ?? "").replace(/\s+/g, "").toLowerCase();
|
|
export function checkContent({ purpose, task, template, originalTexts, finalText }) {
|
|
if (purpose !== "final") return [];
|
|
const failures = [];
|
|
if (!task || task.kind !== "pptx" || task.status !== "pending") failures.push("No active PPT delivery task");
|
|
if (task?.template && template !== task.template) failures.push("Requested template not used");
|
|
for (const term of task?.requiredTerms ?? []) if (!normalize(finalText).includes(normalize(term))) failures.push(`Missing requirement: ${term}`);
|
|
for (const text of originalTexts) if (normalize(finalText).includes(normalize(text))) failures.push(`Unreplaced template content: ${text.slice(0,100)}`);
|
|
if (template === "swads" && originalTexts.length === 0) failures.push("Template content could not be audited");
|
|
return failures;
|
|
}
|