Move type to type/ui

This commit is contained in:
Adria Navarro 2024-12-20 16:01:59 +01:00
parent 7b130c7bcd
commit 8fc0930563
5 changed files with 15 additions and 23 deletions

View File

@ -1,4 +1,4 @@
import { SortOrder } from "@budibase/types"
import { SortOrder, UIDatasource } from "@budibase/types"
import { get } from "svelte/store"
import { Store as StoreContext } from ".."
@ -10,11 +10,7 @@ interface NonPlusActions {
updateRow: () => Promise<void>
deleteRows: () => Promise<void>
getRow: () => Promise<void>
isDatasourceValid: (datasource: {
type: string
id: string
tableId: string
}) => boolean
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
}
@ -41,11 +37,7 @@ export const createActions = (context: StoreContext): NonPlusActions => {
throw "This datasource does not support fetching individual rows"
}
const isDatasourceValid = (datasource: {
type: string
id: string
tableId: string
}) => {
const isDatasourceValid = (datasource: UIDatasource) => {
// There are many different types and shapes of datasource, so we only
// check that we aren't null
return (

View File

@ -4,6 +4,7 @@ import {
SaveRowResponse,
SaveTableRequest,
SortOrder,
UIDatasource,
} from "@budibase/types"
import { get } from "svelte/store"
import { Store as StoreContext } from ".."
@ -18,7 +19,7 @@ interface TableActions {
updateRow: (row: SaveRowRequest) => Promise<SaveRowResponse>
deleteRows: (rows: (string | Row)[]) => Promise<void>
getRow: (id: string) => Promise<Row>
isDatasourceValid: (datasource: { type: string; tableId: any }) => boolean
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
}
@ -45,7 +46,7 @@ export const createActions = (context: StoreContext): TableActions => {
await API.deleteRows(get(datasource).tableId, rows)
}
const isDatasourceValid = (datasource: { type: string; tableId: any }) => {
const isDatasourceValid = (datasource: UIDatasource) => {
return datasource?.type === "table" && !!datasource?.tableId
}

View File

@ -3,6 +3,7 @@ import {
Row,
SaveRowRequest,
SortOrder,
UIDatasource,
UpdateViewRequest,
} from "@budibase/types"
import { Store as StoreContext } from ".."
@ -17,11 +18,7 @@ interface ViewActions {
updateRow: (row: SaveRowRequest) => Promise<Row>
deleteRows: (rows: (string | Row)[]) => Promise<void>
getRow: (id: string) => Promise<Row>
isDatasourceValid: (datasource: {
type: string
id: string
tableId: string
}) => boolean
isDatasourceValid: (datasource: UIDatasource) => boolean
canUseColumn: (name: string) => boolean
}
}
@ -66,11 +63,7 @@ export const createActions = (context: StoreContext): ViewActions => {
return res?.rows?.[0]
}
const isDatasourceValid = (datasource: {
type: string
id: string
tableId: string
}) => {
const isDatasourceValid = (datasource: UIDatasource) => {
return (
datasource?.type === "viewV2" && !!datasource?.id && !!datasource?.tableId
)

View File

@ -0,0 +1,5 @@
export interface UIDatasource {
type: string
id: string
tableId: string
}

View File

@ -1 +1,2 @@
export * from "./columns"
export * from "./datasource"