MCPcopy
hub / github.com/openclaw/clawsweeper / resolveDailyReportPointer

Function resolveDailyReportPointer

src/repair/notify-maintainer-report.ts:46–73  ·  view source on GitHub ↗
({
  index,
  baseUrl,
  publicBaseUrl,
  date,
}: {
  index: JsonObject;
  baseUrl: string;
  publicBaseUrl?: string;
  date?: string;
})

Source from the content-addressed store, hash-verified

44const MAX_HIGHLIGHT_CHARS = 220;
45
46export 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
75export function renderMaintainerReportMessage({
76 report,

Callers 2

fetchReportPointerFunction · 0.85

Calls 2

asJsonObjectFunction · 0.90
stringOrNullFunction · 0.70

Tested by

no test coverage detected