budibase/packages/frontend-core/src/api/layouts.ts

36 lines
878 B
TypeScript
Raw Normal View History

2024-12-05 16:34:43 +01:00
import {
DeleteLayoutResponse,
SaveLayoutRequest,
SaveLayoutResponse,
} from "@budibase/types"
2024-12-02 17:06:12 +01:00
import { BaseAPIClient } from "./types"
export interface LayoutEndpoints {
2024-12-05 16:34:43 +01:00
saveLayout: (layout: SaveLayoutRequest) => Promise<SaveLayoutResponse>
deleteLayout: (id: string, rev: string) => Promise<DeleteLayoutResponse>
2024-12-02 17:06:12 +01:00
}
export const buildLayoutEndpoints = (API: BaseAPIClient): LayoutEndpoints => ({
/**
* Saves a layout.
* @param layout the layout to save
*/
saveLayout: async layout => {
2024-12-05 16:34:43 +01:00
return await API.post({
2024-12-02 17:06:12 +01:00
url: "/api/layouts",
body: layout,
})
},
/**
* Deletes a layout.
* @param layoutId the ID of the layout to delete
* @param layoutRev the rev of the layout to delete
*/
deleteLayout: async (id: string, rev: string) => {
return await API.delete({
url: `/api/layouts/${id}/${rev}`,
})
},
})