diff --git a/packages/frontend-core/src/components/grid/stores/datasource.ts b/packages/frontend-core/src/components/grid/stores/datasource.ts index c1757dd59e..4c8933611e 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.ts +++ b/packages/frontend-core/src/components/grid/stores/datasource.ts @@ -30,7 +30,7 @@ interface DerivedDatasourceStore { interface ActionDatasourceStore { datasource: DatasourceStore["definition"] & { - actions: DatasourceActions & { + actions: DatasourceActions & { refreshDefinition: () => Promise changePrimaryDisplay: (column: string) => Promise 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 diff --git a/packages/frontend-core/src/components/grid/stores/datasources/index.ts b/packages/frontend-core/src/components/grid/stores/datasources/index.ts index 8127a9fecf..4f570bd3eb 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/index.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/index.ts @@ -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 {} + extends DatasourceBaseActions {} export interface DatasourceViewActions - extends DatasourceActions {} + extends DatasourceBaseActions {} export interface DatasourceNonPlusActions - extends DatasourceActions {} + extends DatasourceBaseActions {} + +export type DatasourceActions = + | DatasourceTableActions + | DatasourceViewActions + | DatasourceNonPlusActions diff --git a/packages/types/src/ui/stores/grid/datasource.ts b/packages/types/src/ui/stores/grid/datasource.ts index 5d27183806..32ac7d5fe1 100644 --- a/packages/types/src/ui/stores/grid/datasource.ts +++ b/packages/types/src/ui/stores/grid/datasource.ts @@ -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 -} - -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 diff --git a/packages/types/src/ui/stores/grid/index.ts b/packages/types/src/ui/stores/grid/index.ts index a4d8770576..bcd7e3267d 100644 --- a/packages/types/src/ui/stores/grid/index.ts +++ b/packages/types/src/ui/stores/grid/index.ts @@ -1,3 +1,4 @@ export * from "./columns" export * from "./datasource" export * from "./table" +export * from "./view" diff --git a/packages/types/src/ui/stores/grid/table.ts b/packages/types/src/ui/stores/grid/table.ts index 8975ef4cfc..4c19cbf882 100644 --- a/packages/types/src/ui/stores/grid/table.ts +++ b/packages/types/src/ui/stores/grid/table.ts @@ -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 +} + export type UIFieldSchema = FieldSchema & BasicViewFieldMetadata & { related?: { field: string; subField: string } diff --git a/packages/types/src/ui/stores/grid/view.ts b/packages/types/src/ui/stores/grid/view.ts new file mode 100644 index 0000000000..af214e7d82 --- /dev/null +++ b/packages/types/src/ui/stores/grid/view.ts @@ -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 + sort?: { + field: string + order: SortOrder + } + queryUI: UISearchFilter +}