import ExcelJS from "exceljs"; import type { TodoSourceRow } from "./repo.js"; const COLUMNS: Array<{ key: keyof TodoSourceRow; header: string; width: number }> = [ { key: "snapshot_ts", header: "snapshot_ts", width: 26 }, { key: "id", header: "id", width: 16 }, { key: "job_number", header: "job_number", width: 12 }, { key: "job_name", header: "job_name", width: 30 }, { key: "name", header: "name", width: 50 }, { key: "description", header: "description", width: 60 }, { key: "start_date", header: "start_date", width: 12 }, { key: "end_date", header: "end_date", width: 12 }, { key: "progress", header: "progress", width: 10 }, { key: "stale_days", header: "stale_days", width: 11 }, { key: "assignees", header: "assignees", width: 40 }, { key: "overdue_or_undated", header: "overdue_or_undated", width: 18 }, ]; /** Excel-выгрузка исходных данных выбранного снимка: все открытые to-do с ответственными и Stale Days. */ export async function buildWorkbook(rows: TodoSourceRow[]): Promise { const wb = new ExcelJS.Workbook(); const sheet = wb.addWorksheet("jobtread_todo"); sheet.columns = COLUMNS.map((c) => ({ header: c.header, key: c.key, width: c.width })); sheet.getRow(1).font = { bold: true }; sheet.views = [{ state: "frozen", ySplit: 1 }]; for (const r of rows) sheet.addRow(r); return Buffer.from(await wb.xlsx.writeBuffer()); }