diff --git a/packages/frontend-core/src/components/grid/stores/datasources/table.ts b/packages/frontend-core/src/components/grid/stores/datasources/table.ts index 27fa638596..740ebb4b9f 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/table.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/table.ts @@ -8,6 +8,7 @@ import { import { get } from "svelte/store" import { Store as StoreContext } from ".." import { DatasourceTableActions } from "." +import { TableFetch } from "@budibase/frontend-core" const SuppressErrors = true @@ -119,7 +120,7 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( allFilters.subscribe($allFilters => { // Ensure we're updating the correct fetch - const $fetch = get(fetch) + const $fetch = get(fetch) as TableFetch | null if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { return } @@ -133,7 +134,7 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( sort.subscribe($sort => { // Ensure we're updating the correct fetch - const $fetch = get(fetch) + const $fetch = get(fetch) as TableFetch | null if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { return } diff --git a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts index 8b928364e1..b48d011d7e 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -4,11 +4,11 @@ import { SaveRowRequest, SortOrder, UIDatasource, - UIView, UpdateViewRequest, } from "@budibase/types" import { Store as StoreContext } from ".." import { DatasourceViewActions } from "." +import { ViewV2Fetch } from "@budibase/frontend-core" const SuppressErrors = true @@ -134,6 +134,9 @@ export const initialise = (context: StoreContext) => { if (!get(config).canSaveSchema) { return } + if (!$definition || !("id" in $definition)) { + return + } if ($definition?.id !== $datasource.id) { return } @@ -184,7 +187,10 @@ export const initialise = (context: StoreContext) => { unsubscribers.push( sort.subscribe(async $sort => { // Ensure we're updating the correct view - const $view = get(definition) as UIView + const $view = get(definition) + if (!$view || !("id" in $view)) { + return + } if ($view?.id !== $datasource.id) { return } @@ -207,7 +213,7 @@ export const initialise = (context: StoreContext) => { // Also update the fetch to ensure the new sort is respected. // Ensure we're updating the correct fetch. - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } @@ -225,6 +231,9 @@ export const initialise = (context: StoreContext) => { return } const $view = get(definition) + if (!$view || !("id" in $view)) { + return + } if ($view?.id !== $datasource.id) { return } @@ -246,7 +255,7 @@ export const initialise = (context: StoreContext) => { if (!get(config).canSaveSchema) { return } - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } @@ -262,7 +271,7 @@ export const initialise = (context: StoreContext) => { if (get(config).canSaveSchema) { return } - const $fetch = get(fetch) + const $fetch = get(fetch) as ViewV2Fetch | null if ($fetch?.options?.datasource?.id !== $datasource.id) { return } diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 93ad79ec32..53a33a5be7 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -16,6 +16,11 @@ import { APIClient } from "../api/types" import { Table, ViewV2Enriched } from "@budibase/types" export type DataFetchType = keyof typeof DataFetchMap + +export type { default as TableFetch } from "./TableFetch" +export type { default as ViewFetch } from "./ViewFetch" +export type { default as ViewV2Fetch } from "./ViewV2Fetch" + export type { DataFetchOptions } from "./DataFetch" export type { UserDatasource } from "./UserFetch" export type { GroupUserDatasource } from "./GroupUserFetch" @@ -86,6 +91,8 @@ export type DataFetchDefinition = | { schema?: Record | null primaryDisplay?: string + rowHeight?: number + type?: string } // Constructs a new fetch model for a certain datasource diff --git a/packages/frontend-core/src/index.ts b/packages/frontend-core/src/index.ts index ba80bb3af6..a2a8287236 100644 --- a/packages/frontend-core/src/index.ts +++ b/packages/frontend-core/src/index.ts @@ -3,6 +3,9 @@ export type { APIClient } from "./api" export { fetchData, DataFetchMap } from "./fetch" export type { DataFetchType, + TableFetch, + ViewFetch, + ViewV2Fetch, DataFetchOptions, DataFetchDatasource, UserDatasource,