feat(KB-086): complete Step 5 — add activity log API client functions

This commit is contained in:
gsxdsm
2026-03-30 18:30:28 -07:00
parent b36244f5a7
commit 1f22a04fc4

View File

@@ -10,6 +10,8 @@ import type {
BatchStatusResult,
BatchStatusResponse,
BatchStatusEntry,
ActivityLogEntry,
ActivityEventType,
} from "@kb/core";
import type { PlanningQuestion, PlanningSummary, PlanningResponse } from "@kb/core";
import type { ScheduledTask, ScheduledTaskCreateInput, ScheduledTaskUpdateInput, AutomationRunResult } from "@kb/core";
@@ -944,3 +946,23 @@ export function toggleAutomation(id: string): Promise<ScheduledTask> {
method: "POST",
});
}
// ── Activity Log API ────────────────────────────────────────────
/** Re-export ActivityLogEntry type from core for convenience */
export type { ActivityLogEntry, ActivityEventType } from "@kb/core";
/** Fetch activity log entries */
export function fetchActivityLog(options?: { limit?: number; since?: string; type?: ActivityEventType }): Promise<ActivityLogEntry[]> {
const search = new URLSearchParams();
if (options?.limit !== undefined) search.set("limit", String(options.limit));
if (options?.since !== undefined) search.set("since", options.since);
if (options?.type !== undefined) search.set("type", options.type);
const suffix = search.size > 0 ? `?${search.toString()}` : "";
return api<ActivityLogEntry[]>(`/activity${suffix}`);
}
/** Clear all activity log entries */
export function clearActivityLog(): Promise<{ success: boolean }> {
return api<{ success: boolean }>("/activity", { method: "DELETE" });
}