Extract action interface

This commit is contained in:
Adria Navarro 2024-12-23 09:33:55 +01:00
parent 8265fc8ab5
commit 90b6639125
4 changed files with 25 additions and 28 deletions

View File

@ -0,0 +1,19 @@
import {
Row,
SaveRowRequest,
SaveTableRequest,
UIDatasource,
UpdateViewRequest,
} from "@budibase/types"
export interface DatasourceActions<
TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest
> {
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
addRow: (row: SaveRowRequest) => Promise<Row>
updateRow: (row: SaveRowRequest) => Promise<Row>
deleteRows: (rows: (string | Row)[]) => Promise<void>
getRow: (id: string) => Promise<Row>
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}

View File

@ -1,18 +1,11 @@
import { SortOrder, UIDatasource } from "@budibase/types"
import { get } from "svelte/store"
import { Store as StoreContext } from ".."
import { DatasourceActions } from "."
interface NonPlusActions {
nonPlus: {
actions: {
saveDefinition: () => Promise<void>
addRow: () => Promise<void>
updateRow: () => Promise<void>
deleteRows: () => Promise<void>
getRow: () => Promise<void>
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
actions: DatasourceActions<never>
}
}

View File

@ -1,27 +1,19 @@
import {
Row,
SaveRowRequest,
SaveRowResponse,
SaveTableRequest,
SortOrder,
UIDatasource,
} from "@budibase/types"
import { get } from "svelte/store"
import { Store as StoreContext } from ".."
import { DatasourceActions } from "."
const SuppressErrors = true
interface TableActions {
table: {
actions: {
saveDefinition: (newDefinition: SaveTableRequest) => Promise<void>
addRow: (row: SaveRowRequest) => Promise<SaveRowResponse>
updateRow: (row: SaveRowRequest) => Promise<SaveRowResponse>
deleteRows: (rows: (string | Row)[]) => Promise<void>
getRow: (id: string) => Promise<Row>
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
actions: DatasourceActions<SaveTableRequest>
}
}

View File

@ -7,20 +7,13 @@ import {
UpdateViewRequest,
} from "@budibase/types"
import { Store as StoreContext } from ".."
import { DatasourceActions } from "."
const SuppressErrors = true
interface ViewActions {
viewV2: {
actions: {
saveDefinition: (newDefinition: UpdateViewRequest) => Promise<void>
addRow: (row: SaveRowRequest) => Promise<Row>
updateRow: (row: SaveRowRequest) => Promise<Row>
deleteRows: (rows: (string | Row)[]) => Promise<void>
getRow: (id: string) => Promise<Row>
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
actions: DatasourceActions<UpdateViewRequest>
}
}