export type DataFrame = {service: string, table: string, data: Array}; export type CreateApiSourceDataframeArgs = {body: {data: DataFrame}}; export type CreateApiSourceDataframeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set a source data frame * * POST /source-dataframe */ export const createApiSourceDataframe = async (args: CreateApiSourceDataframeArgs, options?: CreateApiSourceDataframeOptions) => { const {baseUrl = "https://rvig-engine.bzlg.apps.digilab.network/v0", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/source-dataframe${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 };