Update isTable and isView to depend on the ID format.

This commit is contained in:
Sam Rose 2024-09-26 17:10:53 +01:00
parent 8dd21e5592
commit d7ffdf02c2
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import { Table, TableSourceType } from "@budibase/types"
import { isExternalTableID } from "../../../integrations/utils"
import { docIds } from "@budibase/backend-core"
export function isExternal(opts: { table?: Table; tableId?: string }): boolean {
if (opts.table && opts.table.sourceType === TableSourceType.EXTERNAL) {
@ -11,5 +12,5 @@ export function isExternal(opts: { table?: Table; tableId?: string }): boolean {
}
export function isTable(table: any): table is Table {
return table.type === "table"
return table._id && docIds.isTableId(table._id)
}

View File

@ -9,7 +9,7 @@ import {
ViewV2ColumnEnriched,
ViewV2Enriched,
} from "@budibase/types"
import { context, HTTPError } from "@budibase/backend-core"
import { context, docIds, HTTPError } from "@budibase/backend-core"
import {
helpers,
PROTECTED_EXTERNAL_COLUMNS,
@ -53,9 +53,7 @@ export async function getTable(view: string | ViewV2): Promise<Table> {
}
export function isView(view: any): view is ViewV2 {
return (
view.version === 2 && "id" in view && "tableId" in view && "name" in view
)
return view._id && docIds.isViewId(view._id) && view.version === 2
}
async function guardCalculationViewSchema(