import { BulkImportRequest, BulkImportResponse, CsvToJsonRequest, CsvToJsonResponse, MigrateRequest, MigrateResponse, SaveTableRequest, SaveTableResponse, Table, ValidateNewTableImportRequest, ValidateTableImportRequest, ValidateTableImportResponse, } from "@budibase/types" import { Expectations, TestAPI } from "./base" export class TableAPI extends TestAPI { save = async ( data: SaveTableRequest, expectations?: Expectations ): Promise => { return await this._post("/api/tables", { body: data, expectations, }) } fetch = async (expectations?: Expectations): Promise => { return await this._get("/api/tables", { expectations }) } get = async ( tableId: string, expectations?: Expectations ): Promise => { return await this._get
(`/api/tables/${tableId}`, { expectations }) } migrate = async ( tableId: string, data: MigrateRequest, expectations?: Expectations ): Promise => { return await this._post(`/api/tables/${tableId}/migrate`, { body: data, expectations, }) } import = async ( tableId: string, data: BulkImportRequest, expectations?: Expectations ): Promise => { return await this._post( `/api/tables/${tableId}/import`, { body: data, expectations, } ) } destroy = async ( tableId: string, revId: string, expectations?: Expectations ): Promise => { return await this._delete(`/api/tables/${tableId}/${revId}`, { expectations, }) } validateNewTableImport = async ( body: ValidateNewTableImportRequest, expectations?: Expectations ): Promise => { return await this._post( `/api/tables/validateNewTableImport`, { body, expectations, } ) } validateExistingTableImport = async ( body: ValidateTableImportRequest, expectations?: Expectations ): Promise => { return await this._post( `/api/tables/validateExistingTableImport`, { body, expectations, } ) } csvToJson = async ( body: CsvToJsonRequest, expectations?: Expectations ): Promise => { return await this._post(`/api/convert/csvToJson`, { body, expectations, }) } }