1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00
budibase/packages/server/src/tests/utilities/api/legacyView.ts
2024-03-15 15:57:27 +00:00

37 lines
1.1 KiB
TypeScript

import { Expectations, TestAPI } from "./base"
import { Row, View, ViewCalculation } from "@budibase/types"
export class LegacyViewAPI extends TestAPI {
get = async (
id: string,
query?: { calculation: ViewCalculation; group?: string },
expectations?: Expectations
) => {
return await this._get<Row[]>(`/api/views/${id}`, { query, expectations })
}
save = async (body: View, expectations?: Expectations) => {
return await this._post<View>(`/api/views/`, { body, expectations })
}
fetch = async (expectations?: Expectations) => {
return await this._get<View[]>(`/api/views`, { expectations })
}
destroy = async (id: string, expectations?: Expectations) => {
return await this._delete<View>(`/api/views/${id}`, { expectations })
}
export = async (
viewName: string,
format: "json" | "csv" | "jsonWithSchema",
expectations?: Expectations
) => {
const response = await this._requestRaw("get", `/api/views/export`, {
query: { view: viewName, format },
expectations,
})
return this._checkResponse(response, expectations).text
}
}