export type RunId = string; export type CreateApiRunsRunIdStartArgs = {runId: RunId, body: {startDatetime: string, endDatetime: string, timescale?: number | undefined, externalClock?: boolean | undefined, realtime?: boolean | undefined}}; export type CreateApiRunsRunIdStartOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start a Run * * POST /runs/{runId}/start */ export const createApiRunsRunIdStart = async (args: CreateApiRunsRunIdStartArgs, options?: CreateApiRunsRunIdStartOptions) => { const {baseUrl = "https://api.server.test/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/runs/${encodeURIComponent(String(args.runId))}/start${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 };