Split types

This commit is contained in:
Adria Navarro 2024-12-24 11:56:39 +01:00
parent a318290518
commit 6c17d3e257
6 changed files with 45 additions and 33 deletions

View File

@ -30,7 +30,7 @@ interface DerivedDatasourceStore {
interface ActionDatasourceStore {
datasource: DatasourceStore["definition"] & {
actions: DatasourceActions<UpdateViewRequest | SaveTableRequest> & {
actions: DatasourceActions & {
refreshDefinition: () => Promise<void>
changePrimaryDisplay: (column: string) => Promise<void>
addSchemaMutation: (field: string, mutation: UIFieldMutation) => void
@ -339,7 +339,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
// Checks if a certain datasource config is valid
const isDatasourceValid = (datasource: UIDatasource) => {
return getAPI()?.actions.isDatasourceValid(datasource)
return getAPI()?.actions.isDatasourceValid(datasource as any)
}
// Checks if this datasource can use a specific column by name

View File

@ -8,7 +8,7 @@ import {
UpdateViewRequest,
} from "@budibase/types"
interface DatasourceActions<
interface DatasourceBaseActions<
TDatasource = UITable | UIView,
TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest
> {
@ -22,10 +22,15 @@ interface DatasourceActions<
}
export interface DatasourceTableActions
extends DatasourceActions<UITable, SaveTableRequest> {}
extends DatasourceBaseActions<UITable, SaveTableRequest> {}
export interface DatasourceViewActions
extends DatasourceActions<UIView, UpdateViewRequest> {}
extends DatasourceBaseActions<UIView, UpdateViewRequest> {}
export interface DatasourceNonPlusActions
extends DatasourceActions<UIDatasource, never> {}
extends DatasourceBaseActions<UIDatasource, never> {}
export type DatasourceActions =
| DatasourceTableActions
| DatasourceViewActions
| DatasourceNonPlusActions

View File

@ -1,33 +1,7 @@
import { SortOrder, UIFieldSchema, UISearchFilter } from "@budibase/types"
import { UITable, UIView } from "@budibase/types"
export type UIDatasource = UITable | UIView
export interface UITable {
type: string
name: string
id: string
tableId: string
primaryDisplay?: string
sort?: {
field: string
order: SortOrder
}
queryUI: UISearchFilter
schema: Record<string, UIFieldSchema>
}
export interface UIView {
type: string
version: 2
id: string
tableId: string
sort?: {
field: string
order: SortOrder
}
queryUI: UISearchFilter
}
export interface UIFieldMutation {
visible: boolean
readonly?: boolean

View File

@ -1,3 +1,4 @@
export * from "./columns"
export * from "./datasource"
export * from "./table"
export * from "./view"

View File

@ -3,8 +3,24 @@ import {
FieldSchema,
FieldType,
RelationSchemaField,
SortOrder,
UISearchFilter,
} from "@budibase/types"
export interface UITable {
type: string
name: string
id: string
tableId: string
primaryDisplay?: string
sort?: {
field: string
order: SortOrder
}
queryUI: UISearchFilter
schema: Record<string, UIFieldSchema>
}
export type UIFieldSchema = FieldSchema &
BasicViewFieldMetadata & {
related?: { field: string; subField: string }

View File

@ -0,0 +1,16 @@
import { SortOrder, UISearchFilter } from "@budibase/types"
import { UIFieldSchema } from "./table"
export interface UIView {
type: string
version: 2
id: string
tableId: string
primaryDisplay?: string
schema: Record<string, UIFieldSchema>
sort?: {
field: string
order: SortOrder
}
queryUI: UISearchFilter
}