Fix types
This commit is contained in:
parent
d101a89003
commit
02578e2f0d
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
Row,
|
||||
SaveRowRequest,
|
||||
SaveRowResponse,
|
||||
SaveTableRequest,
|
||||
SortOrder,
|
||||
} from "@budibase/types"
|
||||
|
@ -9,7 +10,23 @@ import { Store as StoreContext } from ".."
|
|||
|
||||
const SuppressErrors = true
|
||||
|
||||
export const createActions = (context: StoreContext) => {
|
||||
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: { type: string; tableId: any }) => boolean
|
||||
canUseColumn: (name: string) => boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type Store = TableActions
|
||||
|
||||
export const createActions = (context: StoreContext): TableActions => {
|
||||
const { API, datasource, columns } = context
|
||||
|
||||
const saveDefinition = async (newDefinition: SaveTableRequest) => {
|
||||
|
@ -29,7 +46,7 @@ export const createActions = (context: StoreContext) => {
|
|||
}
|
||||
|
||||
const isDatasourceValid = (datasource: { type: string; tableId: any }) => {
|
||||
return datasource?.type === "table" && datasource?.tableId
|
||||
return datasource?.type === "table" && !!datasource?.tableId
|
||||
}
|
||||
|
||||
const getRow = async (id: string) => {
|
||||
|
@ -80,7 +97,7 @@ export const initialise = (context: StoreContext) => {
|
|||
|
||||
// Keep a list of subscriptions so that we can clear them when the datasource
|
||||
// config changes
|
||||
let unsubscribers = []
|
||||
let unsubscribers: any[] = []
|
||||
|
||||
// Observe datasource changes and apply logic for table datasources
|
||||
datasource.subscribe($datasource => {
|
||||
|
|
|
@ -45,7 +45,7 @@ const DependencyOrderedStores = [
|
|||
Users,
|
||||
Menu,
|
||||
Pagination,
|
||||
Config,
|
||||
Config as any,
|
||||
Clipboard,
|
||||
Notifications,
|
||||
Cache,
|
||||
|
@ -56,17 +56,17 @@ export interface BaseStore {
|
|||
}
|
||||
|
||||
export type Store = BaseStore &
|
||||
Columns.Store & {
|
||||
Columns.Store &
|
||||
Table.Store & {
|
||||
// TODO while typing the rest of stores
|
||||
datasource: Writable<any>
|
||||
datasource: Writable<any> & { actions: any }
|
||||
definition: Writable<any>
|
||||
enrichedSchema: Writable<any>
|
||||
enrichedSchema: any
|
||||
fetch: Writable<any>
|
||||
filter: Writable<any>
|
||||
inlineFilters: Writable<any>
|
||||
allFilters: Writable<any>
|
||||
sort: Writable<any>
|
||||
table: Writable<any> & { actions: any }
|
||||
initialFilter: Writable<any>
|
||||
initialSortColumn: Writable<any>
|
||||
initialSortOrder: Writable<any>
|
||||
|
|
Loading…
Reference in New Issue