Back to Google Sheets CRM repair
demo.cjs
'use strict';
const fs=require('node:fs'), path=require('node:path');
const {createHarness}=require('./lib/mock.cjs');
const out=path.join(__dirname,'evidence'); fs.mkdirSync(out,{recursive:true});
const h=createHarness(); const preview=h.run(); const repaired=h.run({dryRun:false}); const replay=h.run({dryRun:false});
function toCsv(rows) { return rows.map(row=>row.map(v=>'"'+String(v).replaceAll('"','""')+'"').join(',')).join('\n')+'\n'; }
fs.writeFileSync(path.join(out,'after-leads.csv'),toCsv(h.sheets.Leads.data));
fs.writeFileSync(path.join(out,'structured-log.jsonl'),h.logs.map(l=>JSON.stringify(l)).join('\n')+'\n');
const comparison={synthetic:true,inputRows:8,initialLeads:1,preview,repaired,replay,finalLeads:h.sheets.Leads.data.length-1,ownerNote:h.sheets.Leads.data[1][6],ownerFormula:h.sheets.Leads.data[1][7],mockMetrics:h.metrics};
fs.writeFileSync(path.join(out,'demo.json'),JSON.stringify(comparison,null,2)+'\n'); console.log(JSON.stringify(comparison,null,2));