({
index,
baseUrl,
publicBaseUrl,
date,
}: {
index: JsonObject;
baseUrl: string;
publicBaseUrl?: string;
date?: string;
})
| 44 | const MAX_HIGHLIGHT_CHARS = 220; |
| 45 | |
| 46 | export function resolveDailyReportPointer({ |
| 47 | index, |
| 48 | baseUrl, |
| 49 | publicBaseUrl, |
| 50 | date, |
| 51 | }: { |
| 52 | index: JsonObject; |
| 53 | baseUrl: string; |
| 54 | publicBaseUrl?: string; |
| 55 | date?: string; |
| 56 | }): MaintainerReportPointer | null { |
| 57 | const entries = Array.isArray(index.entries) ? index.entries.map(asJsonObject) : []; |
| 58 | const entry = |
| 59 | (date |
| 60 | ? entries.find((item) => item.period === "day" && item.key === date) |
| 61 | : asJsonObject(asJsonObject(index.latest).day)) ?? |
| 62 | entries.find((item) => item.period === "day"); |
| 63 | if (!entry) return null; |
| 64 | const key = stringOrNull(entry.key); |
| 65 | const href = stringOrNull(entry.href); |
| 66 | const data = stringOrNull(entry.data); |
| 67 | if (!key || !href || !data) return null; |
| 68 | return { |
| 69 | date: key, |
| 70 | reportUrl: new URL(href, publicBaseUrl ?? baseUrl).toString(), |
| 71 | dataUrl: new URL(data, baseUrl).toString(), |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | export function renderMaintainerReportMessage({ |
| 76 | report, |
no test coverage detected