export type CreateApiMappingFormArgs = {interactors?: boolean | undefined, importableOnly?: boolean | undefined, body: BodyInit}; export type CreateApiMappingFormOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Maps the identifiers in the file over the different species * * POST /mapping/form */ export const createApiMappingForm = async (args: CreateApiMappingFormArgs, options: CreateApiMappingFormOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.interactors != null) query.append("interactors", String(args.interactors)) if (args.importableOnly != null) query.append("importableOnly", String(args.importableOnly)) const url = `${baseUrl.replace(/\/+$/, '')}/mapping/form${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };