Fix types

This commit is contained in:
Adria Navarro 2025-01-15 12:27:10 +01:00
parent 0f069b77fc
commit 72d7443d72
4 changed files with 27 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import {
import { get } from "svelte/store" import { get } from "svelte/store"
import { Store as StoreContext } from ".." import { Store as StoreContext } from ".."
import { DatasourceTableActions } from "." import { DatasourceTableActions } from "."
import { TableFetch } from "@budibase/frontend-core"
const SuppressErrors = true const SuppressErrors = true
@ -119,7 +120,7 @@ export const initialise = (context: StoreContext) => {
unsubscribers.push( unsubscribers.push(
allFilters.subscribe($allFilters => { allFilters.subscribe($allFilters => {
// Ensure we're updating the correct fetch // 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) { if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) {
return return
} }
@ -133,7 +134,7 @@ export const initialise = (context: StoreContext) => {
unsubscribers.push( unsubscribers.push(
sort.subscribe($sort => { sort.subscribe($sort => {
// Ensure we're updating the correct fetch // 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) { if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) {
return return
} }

View File

@ -4,11 +4,11 @@ import {
SaveRowRequest, SaveRowRequest,
SortOrder, SortOrder,
UIDatasource, UIDatasource,
UIView,
UpdateViewRequest, UpdateViewRequest,
} from "@budibase/types" } from "@budibase/types"
import { Store as StoreContext } from ".." import { Store as StoreContext } from ".."
import { DatasourceViewActions } from "." import { DatasourceViewActions } from "."
import { ViewV2Fetch } from "@budibase/frontend-core"
const SuppressErrors = true const SuppressErrors = true
@ -134,6 +134,9 @@ export const initialise = (context: StoreContext) => {
if (!get(config).canSaveSchema) { if (!get(config).canSaveSchema) {
return return
} }
if (!$definition || !("id" in $definition)) {
return
}
if ($definition?.id !== $datasource.id) { if ($definition?.id !== $datasource.id) {
return return
} }
@ -184,7 +187,10 @@ export const initialise = (context: StoreContext) => {
unsubscribers.push( unsubscribers.push(
sort.subscribe(async $sort => { sort.subscribe(async $sort => {
// Ensure we're updating the correct view // 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) { if ($view?.id !== $datasource.id) {
return return
} }
@ -207,7 +213,7 @@ export const initialise = (context: StoreContext) => {
// Also update the fetch to ensure the new sort is respected. // Also update the fetch to ensure the new sort is respected.
// Ensure we're updating the correct fetch. // 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) { if ($fetch?.options?.datasource?.id !== $datasource.id) {
return return
} }
@ -225,6 +231,9 @@ export const initialise = (context: StoreContext) => {
return return
} }
const $view = get(definition) const $view = get(definition)
if (!$view || !("id" in $view)) {
return
}
if ($view?.id !== $datasource.id) { if ($view?.id !== $datasource.id) {
return return
} }
@ -246,7 +255,7 @@ export const initialise = (context: StoreContext) => {
if (!get(config).canSaveSchema) { if (!get(config).canSaveSchema) {
return return
} }
const $fetch = get(fetch) const $fetch = get(fetch) as ViewV2Fetch | null
if ($fetch?.options?.datasource?.id !== $datasource.id) { if ($fetch?.options?.datasource?.id !== $datasource.id) {
return return
} }
@ -262,7 +271,7 @@ export const initialise = (context: StoreContext) => {
if (get(config).canSaveSchema) { if (get(config).canSaveSchema) {
return return
} }
const $fetch = get(fetch) const $fetch = get(fetch) as ViewV2Fetch | null
if ($fetch?.options?.datasource?.id !== $datasource.id) { if ($fetch?.options?.datasource?.id !== $datasource.id) {
return return
} }

View File

@ -16,6 +16,11 @@ import { APIClient } from "../api/types"
import { Table, ViewV2Enriched } from "@budibase/types" import { Table, ViewV2Enriched } from "@budibase/types"
export type DataFetchType = keyof typeof DataFetchMap 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 { DataFetchOptions } from "./DataFetch"
export type { UserDatasource } from "./UserFetch" export type { UserDatasource } from "./UserFetch"
export type { GroupUserDatasource } from "./GroupUserFetch" export type { GroupUserDatasource } from "./GroupUserFetch"
@ -86,6 +91,8 @@ export type DataFetchDefinition =
| { | {
schema?: Record<string, any> | null schema?: Record<string, any> | null
primaryDisplay?: string primaryDisplay?: string
rowHeight?: number
type?: string
} }
// Constructs a new fetch model for a certain datasource // Constructs a new fetch model for a certain datasource

View File

@ -3,6 +3,9 @@ export type { APIClient } from "./api"
export { fetchData, DataFetchMap } from "./fetch" export { fetchData, DataFetchMap } from "./fetch"
export type { export type {
DataFetchType, DataFetchType,
TableFetch,
ViewFetch,
ViewV2Fetch,
DataFetchOptions, DataFetchOptions,
DataFetchDatasource, DataFetchDatasource,
UserDatasource, UserDatasource,