export type CreateApiTestResultsProxyOptions = {baseUrl: string, lambdaAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /test-results/{proxy+} */ export const createApiTestResultsProxy = async (options: CreateApiTestResultsProxyOptions) => { const {baseUrl, fetch: fetchFn = fetch, lambdaAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (lambdaAuth !== undefined) headers.set("Authorization", lambdaAuth) const url = `${baseUrl.replace(/\/+$/, '')}/test-results/${encodeURIComponent(String(args['proxy+']))}${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 (await res.json()) as unknown };