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 { Table, TableSourceType } from "@budibase/types"
import { isExternalTableID } from "../../../integrations/utils" import { isExternalTableID } from "../../../integrations/utils"
import { docIds } from "@budibase/backend-core"
export function isExternal(opts: { table?: Table; tableId?: string }): boolean { export function isExternal(opts: { table?: Table; tableId?: string }): boolean {
if (opts.table && opts.table.sourceType === TableSourceType.EXTERNAL) { 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 { 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, ViewV2ColumnEnriched,
ViewV2Enriched, ViewV2Enriched,
} from "@budibase/types" } from "@budibase/types"
import { context, HTTPError } from "@budibase/backend-core" import { context, docIds, HTTPError } from "@budibase/backend-core"
import { import {
helpers, helpers,
PROTECTED_EXTERNAL_COLUMNS, PROTECTED_EXTERNAL_COLUMNS,
@ -53,9 +53,7 @@ export async function getTable(view: string | ViewV2): Promise<Table> {
} }
export function isView(view: any): view is ViewV2 { export function isView(view: any): view is ViewV2 {
return ( return view._id && docIds.isViewId(view._id) && view.version === 2
view.version === 2 && "id" in view && "tableId" in view && "name" in view
)
} }
async function guardCalculationViewSchema( async function guardCalculationViewSchema(