export type Check = {name?: string | undefined, took?: number | undefined, result?: string | undefined, reason?: string | undefined}; export type CreateHeartbeat = {result?: string | undefined, reason?: string | undefined, application?: string | undefined, version?: string | undefined, took?: number | undefined, checks?: Array | undefined}; export type CreateApiV3HeartbeatsLogIdIdArgs = {id: string, logId: string, body: CreateHeartbeat}; export type CreateApiV3HeartbeatsLogIdIdOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new heartbeat. * * POST /v3/heartbeats/{logId}/{id} */ export const createApiV3HeartbeatsLogIdId = async (args: CreateApiV3HeartbeatsLogIdIdArgs, options: CreateApiV3HeartbeatsLogIdIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) query.set("api_key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v3/heartbeats/${encodeURIComponent(String(args.logId))}/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };