diff --git a/packages/backend-core/src/db/constants.ts b/packages/backend-core/src/db/constants.ts deleted file mode 100644 index 69c98fe569..0000000000 --- a/packages/backend-core/src/db/constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { - CONSTANT_INTERNAL_ROW_COLS, - CONSTANT_EXTERNAL_ROW_COLS, - isInternalColumnName, -} from "@budibase/shared-core" diff --git a/packages/backend-core/src/db/couch/index.ts b/packages/backend-core/src/db/couch/index.ts index 932efed3f7..c731d20d6c 100644 --- a/packages/backend-core/src/db/couch/index.ts +++ b/packages/backend-core/src/db/couch/index.ts @@ -2,4 +2,3 @@ export * from "./connections" export * from "./DatabaseImpl" export * from "./utils" export { init, getPouch, getPouchDB, closePouchDB } from "./pouchDB" -export * from "../constants" diff --git a/packages/backend-core/tests/core/utilities/jestUtils.ts b/packages/backend-core/tests/core/utilities/jestUtils.ts index 4a3da8db8c..a49c2a795e 100644 --- a/packages/backend-core/tests/core/utilities/jestUtils.ts +++ b/packages/backend-core/tests/core/utilities/jestUtils.ts @@ -1,4 +1,7 @@ -import { db } from "../../../src" +import { + CONSTANT_EXTERNAL_ROW_COLS, + CONSTANT_INTERNAL_ROW_COLS, +} from "@budibase/shared-core" export function expectFunctionWasCalledTimesWith( jestFunction: any, @@ -11,7 +14,7 @@ export function expectFunctionWasCalledTimesWith( } export const expectAnyInternalColsAttributes: { - [K in (typeof db.CONSTANT_INTERNAL_ROW_COLS)[number]]: any + [K in (typeof CONSTANT_INTERNAL_ROW_COLS)[number]]: any } = { tableId: expect.anything(), type: expect.anything(), @@ -22,7 +25,7 @@ export const expectAnyInternalColsAttributes: { } export const expectAnyExternalColsAttributes: { - [K in (typeof db.CONSTANT_EXTERNAL_ROW_COLS)[number]]: any + [K in (typeof CONSTANT_EXTERNAL_ROW_COLS)[number]]: any } = { tableId: expect.anything(), _id: expect.anything(), diff --git a/packages/server/src/sdk/app/rows/search/internal.ts b/packages/server/src/sdk/app/rows/search/internal.ts index 906ca016d1..097b16b104 100644 --- a/packages/server/src/sdk/app/rows/search/internal.ts +++ b/packages/server/src/sdk/app/rows/search/internal.ts @@ -1,4 +1,5 @@ -import { context, db, HTTPError } from "@budibase/backend-core" +import { context, HTTPError } from "@budibase/backend-core" +import { CONSTANT_INTERNAL_ROW_COLS } from "@budibase/shared-core" import env from "../../../../environment" import { fullSearch, paginatedSearch } from "./utils" import { getRowParams, InternalTables } from "../../../../db/utils" @@ -74,7 +75,7 @@ export async function search( } if (options.fields) { - const fields = [...options.fields, ...db.CONSTANT_INTERNAL_ROW_COLS] + const fields = [...options.fields, ...CONSTANT_INTERNAL_ROW_COLS] response.rows = response.rows.map((r: any) => pick(r, fields)) } diff --git a/packages/server/src/sdk/app/tables/migration.ts b/packages/server/src/sdk/app/tables/migration.ts index d0decf01f6..8e084381aa 100644 --- a/packages/server/src/sdk/app/tables/migration.ts +++ b/packages/server/src/sdk/app/tables/migration.ts @@ -18,6 +18,7 @@ import sdk from "../../../sdk" import { isExternalTableID } from "../../../integrations/utils" import { EventType, updateLinks } from "../../../db/linkedRows" import { cloneDeep } from "lodash" +import { isInternalColumnName } from "@budibase/shared-core" export interface MigrationResult { tablesUpdated: Table[] @@ -36,7 +37,7 @@ export async function migrate( throw new BadRequestError(`Column name cannot be empty`) } - if (dbCore.isInternalColumnName(newColumnName)) { + if (isInternalColumnName(newColumnName)) { throw new BadRequestError(`Column name cannot be a reserved column name`) } diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index fce57a390d..3bdfec7448 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -6,9 +6,13 @@ import { ViewV2, ViewV2Enriched, } from "@budibase/types" -import { HTTPError, db as dbCore } from "@budibase/backend-core" +import { HTTPError } from "@budibase/backend-core" import { features } from "@budibase/pro" -import { helpers } from "@budibase/shared-core" +import { + helpers, + CONSTANT_EXTERNAL_ROW_COLS, + CONSTANT_INTERNAL_ROW_COLS, +} from "@budibase/shared-core" import { cloneDeep } from "lodash/fp" import * as utils from "../../../db/utils" @@ -144,8 +148,8 @@ export function allowedFields(view: View | ViewV2) { const fieldSchema = view.schema![key] return fieldSchema.visible && !fieldSchema.readonly }), - ...dbCore.CONSTANT_EXTERNAL_ROW_COLS, - ...dbCore.CONSTANT_INTERNAL_ROW_COLS, + ...CONSTANT_EXTERNAL_ROW_COLS, + ...CONSTANT_INTERNAL_ROW_COLS, ] }