[recipes] Daily digest — implement the Supabase Edge Function approach - #445
Conversation
Completes the planned Supabase Edge Function path for the daily-digest recipe (issue NateBJones-Projects#14): a self-contained function that queries thoughts from the last N hours (default 24) via PostgREST, filters out personal/restricted sensitivity tiers by default, groups by type with a summary header (counts, top topics), and emails the digest through Resend. Supports dry_run (returns JSON instead of sending), hours (1-168), and include_personal body params. Access is gated by a DIGEST_ACCESS_KEY query secret, matching the editorial-policy auditor pattern. Formatting is pure template code — no LLM key required, unlike the originally sketched OpenRouter approach. Adds schedule.sql (pg_cron + pg_net, daily 07:00 UTC, with verify and manual-test snippets), rewrites the README's Approach B section from "planned" to full setup steps with expected outcome and troubleshooting, and bumps metadata to 1.1.0.
OB1 PR Gate✅ Folder structure — All files are in allowed directories Result: All 15 checks passed! Ready for human review. Post-Merge TasksThese don't block merge — they're reminders for admins after this PR lands.
|
Fixes #14
Contribution Type
/recipes)/schemas)/dashboards)/integrations)/skills)What does this do?
Completes the daily-digest recipe. The stub already had a working Approach A (Claude Code scheduled task → Gmail draft); the Supabase Edge Function path was marked "Planned — contributions welcome." This PR implements it:
edge-function/index.ts— a self-contained Deno Edge Function that queries thoughts from the last N hours (default 24, max 168) via PostgREST, groups them by type with a summary header (total count, per-type breakdown, top topics), and sends the digest through Resend as both text and HTML. Thoughts withsensitivity_tierofpersonal/restricted(enhanced-thoughts schema) are excluded by default; rows without that column are unaffected. Supports{ dry_run: true }(returns the digest as JSON without sending — used for testing),hours, andinclude_personalbody params.schedule.sql— pg_cron + pg_net job firing daily at 07:00 UTC, with verify/run-history/manual-test/unschedule snippets. Modeled on the editorial-policy recipe'sschedule.sql.--no-verify-jwt(pg_cron can't send a user JWT) and gated by aDIGEST_ACCESS_KEYquery secret instead, the same pattern as the editorial-policy auditor.One deliberate simplification: the digest is formatted with plain template code rather than the OpenRouter LLM call the original stub sketched. It keeps the recipe at "beginner" difficulty and zero marginal cost, and matches what the issue asked for (grouped, readable, with summaries). An LLM-synthesized variant already exists in the weekly-digest recipe for those who want prose synthesis.
Tested:
deno checkpasses, and the function was driven end-to-end under Deno against a mock PostgREST endpoint: auth gate rejects a bad key, dry_run returns the digest without sending,personal/restrictedrows are excluded (and included withinclude_personal), grouping/summary/topic counts/truncation come out as described, and the PostgREST query carries the expected window, ordering, and limit. Not yet run against a live Supabase project — the dry_run curl in the README is the first thing to try on a real instance.Requirements
pg_cron+pg_netextensions (schedule)thoughtstableChecklist
README.mdwith prerequisites, step-by-step instructions, and expected outcomemetadata.jsonhas all required fields