/** * List factory reports, newest first. Read-only. * * @param input - optional `source`, `projectId`, `noteworthy`, `limit` (default 20, max 200) * @returns `{ reports: [{ id, source, title, period, noteworthy, cards, findings, createdAt, url }], total }` without full summaries * * @example * import listReports from 'kody:@kody/kody-factory/reports/list' * await listReports({ source: 'ci-review', limit: 5 }) */ import { appBaseUrl } from '../../lib/links.ts' import { listReports } from '../../reports/store.ts' import { reportUrl } from '../../reports/post.ts' export default async function list(input: { source?: string; projectId?: string; noteworthy?: boolean; limit?: number } = {}) { const { reports, total } = await listReports({ ...input, limit: input?.limit ?? 20 }) const base = await appBaseUrl() return { total, reports: reports.map((r) => ({ id: r.id, source: r.source, title: r.title, projectId: r.projectId, period: r.period, noteworthy: r.noteworthy, findings: r.findings.length, flagged: r.findings.filter((f) => f.flagged).length, cards: r.cards.map((c) => ({ cardId: c.cardId, title: c.title, relation: c.relation, needsKent: c.needsKent })), createdAt: r.createdAt, url: reportUrl(r.id, base), })), } }