3 months ago
6ba3a58Adds a generated spend-trend chart to the digest embed's thumbnail: the last 14 days of billed (blurple) vs actual (yellow) as overlaid sparklines, so a reader sees at a glance whether today's drift is a blip or a trend. Built without any image dependency and without our spend figures leaving our infra: - sparkline-png.ts (@tripwire/utils): a dependency-free PNG encoder (hand- assembled chunks + CRC32, IDAT via node:zlib) and a pixel-plotted sparkline renderer. Pure, unit-tested by parsing the PNG back (signature, IHDR dims, chunk order). - guardedPostMultipart (@tripwire/utils): posts multipart/form-data through the SAME SSRF guard as guardedPost. Extracted guardedResolve so the guard is single-sourced; the existing guard test suite still passes unchanged. - getRecentDailyCosts (@tripwire/db): the 14-day billed/actual range query. - economicsDigest attaches the PNG as files[0] and points the embed thumbnail at attachment://econ.png; a day with no invoice yet falls back to its billed figure so the actual line stays continuous. Under two points, no chart and the embed posts as plain JSON. dry-run prints the payload and the attachment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Parentd22742f