Extract action interface
This commit is contained in:
parent
8265fc8ab5
commit
90b6639125
|
@ -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
|
||||||
|
}
|
|
@ -1,18 +1,11 @@
|
||||||
import { SortOrder, UIDatasource } from "@budibase/types"
|
import { SortOrder, UIDatasource } from "@budibase/types"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
import { DatasourceActions } from "."
|
||||||
|
|
||||||
interface NonPlusActions {
|
interface NonPlusActions {
|
||||||
nonPlus: {
|
nonPlus: {
|
||||||
actions: {
|
actions: DatasourceActions<never>
|
||||||
saveDefinition: () => Promise<void>
|
|
||||||
addRow: () => Promise<void>
|
|
||||||
updateRow: () => Promise<void>
|
|
||||||
deleteRows: () => Promise<void>
|
|
||||||
getRow: () => Promise<void>
|
|
||||||
isDatasourceValid: (datasource: UIDatasource) => boolean
|
|
||||||
canUseColumn: (name: string) => boolean
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
import {
|
import {
|
||||||
Row,
|
Row,
|
||||||
SaveRowRequest,
|
SaveRowRequest,
|
||||||
SaveRowResponse,
|
|
||||||
SaveTableRequest,
|
SaveTableRequest,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
UIDatasource,
|
UIDatasource,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
import { DatasourceActions } from "."
|
||||||
|
|
||||||
const SuppressErrors = true
|
const SuppressErrors = true
|
||||||
|
|
||||||
interface TableActions {
|
interface TableActions {
|
||||||
table: {
|
table: {
|
||||||
actions: {
|
actions: DatasourceActions<SaveTableRequest>
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,13 @@ import {
|
||||||
UpdateViewRequest,
|
UpdateViewRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { Store as StoreContext } from ".."
|
import { Store as StoreContext } from ".."
|
||||||
|
import { DatasourceActions } from "."
|
||||||
|
|
||||||
const SuppressErrors = true
|
const SuppressErrors = true
|
||||||
|
|
||||||
interface ViewActions {
|
interface ViewActions {
|
||||||
viewV2: {
|
viewV2: {
|
||||||
actions: {
|
actions: DatasourceActions<UpdateViewRequest>
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue