Implement activity log (task 22)

- activity_log table in _core/schema.ts with household+created_at index;
  migration 0008_activity_log.sql applied
- logActivity() in _core/activity.ts reads current session and inserts a row
- ActivityLogEntry type + renderActivity?(entry): string added to
  EntityTypeRegistration so modules declare human-readable labels without
  any if/else branches in the widget
- core.activity widget replaced with a real async server component that
  queries the last 20 rows and renders via the registry
- logActivity wired into every create/update/delete in calendar, lists,
  and notes server actions; getAuthorizedItem also returns text so
  toggle/delete can include item text in the payload
- pnpm typecheck, lint, build, and all 4 E2E specs pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ginnoir
2026-05-06 13:57:03 -05:00
co-authored by Claude Sonnet 4.6
parent 1133fa8aac
commit 28475e483d
13 changed files with 182 additions and 11 deletions
+20
View File
@@ -0,0 +1,20 @@
import { db } from "@/lib/db";
import { getCurrentSession } from "@/lib/session";
import { activityLog } from "./schema";
export async function logActivity(input: {
entityType: string;
entityId: string;
action: string;
payload?: Record<string, unknown>;
}): Promise<void> {
const { user, household } = await getCurrentSession();
await db.insert(activityLog).values({
householdId: household.id,
entityType: input.entityType,
entityId: input.entityId,
actorId: user.id,
action: input.action,
payload: input.payload ?? null,
});
}