Update table endpoints
This commit is contained in:
parent
a42fd87c08
commit
100efef538
|
@ -4,24 +4,26 @@ import {
|
||||||
CsvToJsonRequest,
|
CsvToJsonRequest,
|
||||||
CsvToJsonResponse,
|
CsvToJsonResponse,
|
||||||
FetchTablesResponse,
|
FetchTablesResponse,
|
||||||
MigrateRequest,
|
|
||||||
MigrateResponse,
|
|
||||||
Row,
|
Row,
|
||||||
SaveTableRequest,
|
SaveTableRequest,
|
||||||
SaveTableResponse,
|
SaveTableResponse,
|
||||||
SearchRowRequest,
|
SearchRowRequest,
|
||||||
PaginatedSearchRowResponse,
|
PaginatedSearchRowResponse,
|
||||||
TableResponse,
|
|
||||||
TableSchema,
|
TableSchema,
|
||||||
ValidateNewTableImportRequest,
|
ValidateNewTableImportRequest,
|
||||||
ValidateTableImportRequest,
|
ValidateTableImportRequest,
|
||||||
ValidateTableImportResponse,
|
ValidateTableImportResponse,
|
||||||
|
FindTableResponse,
|
||||||
|
FetchRowsResponse,
|
||||||
|
MigrateTableResponse,
|
||||||
|
MigrateTableRequest,
|
||||||
|
DeleteTableResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
export interface TableEndpoints {
|
export interface TableEndpoints {
|
||||||
fetchTableDefinition: (tableId: string) => Promise<TableResponse>
|
fetchTableDefinition: (tableId: string) => Promise<FindTableResponse>
|
||||||
fetchTableData: (tableId: string) => Promise<Row[]>
|
fetchTableData: (tableId: string) => Promise<FetchRowsResponse>
|
||||||
searchTable: (
|
searchTable: (
|
||||||
sourceId: string,
|
sourceId: string,
|
||||||
opts: SearchRowRequest
|
opts: SearchRowRequest
|
||||||
|
@ -33,9 +35,9 @@ export interface TableEndpoints {
|
||||||
) => Promise<BulkImportResponse>
|
) => Promise<BulkImportResponse>
|
||||||
csvToJson: (csvString: string) => Promise<CsvToJsonResponse>
|
csvToJson: (csvString: string) => Promise<CsvToJsonResponse>
|
||||||
getTables: () => Promise<FetchTablesResponse>
|
getTables: () => Promise<FetchTablesResponse>
|
||||||
getTable: (tableId: string) => Promise<TableResponse>
|
getTable: (tableId: string) => Promise<FindTableResponse>
|
||||||
saveTable: (table: SaveTableRequest) => Promise<SaveTableResponse>
|
saveTable: (table: SaveTableRequest) => Promise<SaveTableResponse>
|
||||||
deleteTable: (id: string, rev: string) => Promise<{ message: string }>
|
deleteTable: (id: string, rev: string) => Promise<DeleteTableResponse>
|
||||||
validateNewTableImport: (
|
validateNewTableImport: (
|
||||||
rows: Row[],
|
rows: Row[],
|
||||||
schema: TableSchema
|
schema: TableSchema
|
||||||
|
@ -48,7 +50,7 @@ export interface TableEndpoints {
|
||||||
tableId: string,
|
tableId: string,
|
||||||
oldColumn: string,
|
oldColumn: string,
|
||||||
newColumn: string
|
newColumn: string
|
||||||
) => Promise<MigrateResponse>
|
) => Promise<MigrateTableResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildTableEndpoints = (API: BaseAPIClient): TableEndpoints => ({
|
export const buildTableEndpoints = (API: BaseAPIClient): TableEndpoints => ({
|
||||||
|
@ -179,7 +181,7 @@ export const buildTableEndpoints = (API: BaseAPIClient): TableEndpoints => ({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
migrateColumn: async (tableId, oldColumn, newColumn) => {
|
migrateColumn: async (tableId, oldColumn, newColumn) => {
|
||||||
return await API.post<MigrateRequest, MigrateResponse>({
|
return await API.post<MigrateTableRequest, MigrateTableResponse>({
|
||||||
url: `/api/tables/${tableId}/migrate`,
|
url: `/api/tables/${tableId}/migrate`,
|
||||||
body: {
|
body: {
|
||||||
oldColumn,
|
oldColumn,
|
||||||
|
|
Loading…
Reference in New Issue