import { AuditLogApi } from "omsorgcore-client-ts";
import { configFor, callApi } from "./apiClientHelpers.js";

// Kapselt GET /api/audit-log (AuditLogController) über den generierten Client
// (omsorgcore-client-ts) - rein lesend, keine weiteren Verben.
export async function listAuditLog(
  accessToken,
  { page = 1, pageSize = 50, entityType, entityId, actorUserId, category, fromUtc, toUtc } = {}
) {
  const api = new AuditLogApi(configFor(accessToken));
  return callApi(
    api.apiAuditLogGetRaw({
      page,
      pageSize,
      entityType: entityType || undefined,
      entityId: entityId || undefined,
      actorUserId: actorUserId || undefined,
      category: category || undefined,
      fromUtc: fromUtc ? new Date(fromUtc) : undefined,
      toUtc: toUtc ? new Date(toUtc) : undefined
    })
  );
}
