export type CreateApiCronProtocolLogsArgs = {dryRun: string, 'X-CRON-API-KEY': string}; export type CreateApiCronProtocolLogsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Read DRE protocol logs into audit actions (cron) * * POST /cron/protocol-logs */ export const createApiCronProtocolLogs = async (args: CreateApiCronProtocolLogsArgs, options: CreateApiCronProtocolLogsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.dryRun != null) query.append("dryRun", String(args.dryRun)) if (args['X-CRON-API-KEY'] != null) headers.set("X-CRON-API-KEY", String(args['X-CRON-API-KEY'])) const url = `${baseUrl.replace(/\/+$/, '')}/cron/protocol-logs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };