From f9bfe51c81a878a2dbbd67823dec1e3b36a88fa5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 26 Jul 2024 14:37:47 +0200 Subject: [PATCH] Rename external --- packages/backend-core/tests/core/utilities/jestUtils.ts | 4 ++-- .../backend/DataTable/modals/CreateEditColumn.svelte | 4 ++-- packages/server/src/sdk/app/rows/search/external.ts | 4 ++-- packages/server/src/sdk/app/views/index.ts | 4 ++-- packages/shared-core/src/constants/rows.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/tests/core/utilities/jestUtils.ts b/packages/backend-core/tests/core/utilities/jestUtils.ts index 7d2cfb41fa..683a4e025b 100644 --- a/packages/backend-core/tests/core/utilities/jestUtils.ts +++ b/packages/backend-core/tests/core/utilities/jestUtils.ts @@ -1,5 +1,5 @@ import { - CONSTANT_EXTERNAL_ROW_COLS, + PROTECTED_EXTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS, } from "@budibase/shared-core" @@ -25,7 +25,7 @@ export const expectAnyInternalColsAttributes: { } export const expectAnyExternalColsAttributes: { - [K in (typeof CONSTANT_EXTERNAL_ROW_COLS)[number]]: any + [K in (typeof PROTECTED_EXTERNAL_COLUMNS)[number]]: any } = { tableId: expect.anything(), _id: expect.anything(), diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 6f96e77ca4..a9ea90242a 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -18,7 +18,7 @@ ValidColumnNameRegex, helpers, PROTECTED_INTERNAL_COLUMNS, - CONSTANT_EXTERNAL_ROW_COLS, + PROTECTED_EXTERNAL_COLUMNS, } from "@budibase/shared-core" import { createEventDispatcher, getContext, onMount } from "svelte" import { cloneDeep } from "lodash/fp" @@ -489,7 +489,7 @@ } const newError = {} const prohibited = externalTable - ? CONSTANT_EXTERNAL_ROW_COLS + ? PROTECTED_EXTERNAL_COLUMNS : PROTECTED_INTERNAL_COLUMNS if (!externalTable && fieldInfo.name?.startsWith("_")) { newError.name = `Column name cannot start with an underscore.` diff --git a/packages/server/src/sdk/app/rows/search/external.ts b/packages/server/src/sdk/app/rows/search/external.ts index cd0650e4c4..c7a89bc0dd 100644 --- a/packages/server/src/sdk/app/rows/search/external.ts +++ b/packages/server/src/sdk/app/rows/search/external.ts @@ -16,7 +16,7 @@ import { breakExternalTableId, breakRowIdField, } from "../../../../integrations/utils" -import { utils, CONSTANT_EXTERNAL_ROW_COLS } from "@budibase/shared-core" +import { utils, PROTECTED_EXTERNAL_COLUMNS } from "@budibase/shared-core" import { ExportRowsParams, ExportRowsResult } from "./types" import { HTTPError } from "@budibase/backend-core" import pick from "lodash/pick" @@ -99,7 +99,7 @@ export async function search( } if (options.fields) { - const fields = [...options.fields, ...CONSTANT_EXTERNAL_ROW_COLS] + const fields = [...options.fields, ...PROTECTED_EXTERNAL_COLUMNS] rows = rows.map((r: any) => pick(r, fields)) } diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 2547788c64..1c09f710d7 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -10,7 +10,7 @@ import { HTTPError } from "@budibase/backend-core" import { features } from "@budibase/pro" import { helpers, - CONSTANT_EXTERNAL_ROW_COLS, + PROTECTED_EXTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS, } from "@budibase/shared-core" import { cloneDeep } from "lodash/fp" @@ -148,7 +148,7 @@ export function allowedFields(view: View | ViewV2) { const fieldSchema = view.schema![key] return fieldSchema.visible && !fieldSchema.readonly }), - ...CONSTANT_EXTERNAL_ROW_COLS, + ...PROTECTED_EXTERNAL_COLUMNS, ...PROTECTED_INTERNAL_COLUMNS, ] } diff --git a/packages/shared-core/src/constants/rows.ts b/packages/shared-core/src/constants/rows.ts index 47e05baae7..03663a4014 100644 --- a/packages/shared-core/src/constants/rows.ts +++ b/packages/shared-core/src/constants/rows.ts @@ -7,7 +7,7 @@ export const PROTECTED_INTERNAL_COLUMNS = [ "tableId", ] as const -export const CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"] as const +export const PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"] as const export function isInternalColumnName(name: string): boolean { return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)