From 476ffd3336b54de1e3954ef341e4be430e21b48c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 16:16:20 +0100 Subject: [PATCH 01/15] Fix enrichment when having AI columns --- packages/server/src/api/controllers/row/staticFormula.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index cce349ff58..28853a8faf 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -160,7 +160,7 @@ export async function finaliseRow( dynamic: false, }) if (aiEnabled) { - enrichedRow = await processAIColumns(table, row, { + enrichedRow = await processAIColumns(table, enrichedRow, { contextRows: [enrichedRow], }) } From b84b272293b6dc68d178f19b8e1dd8488efdcdfb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 16:48:57 +0100 Subject: [PATCH 02/15] Remove TABLES_DEFAULT_ADMIN flag --- .../backend-core/src/features/features.ts | 1 - packages/server/src/sdk/app/tables/create.ts | 16 +++++---------- packages/server/src/sdk/app/views/index.ts | 20 +++++++------------ packages/types/src/sdk/featureFlag.ts | 1 - 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/packages/backend-core/src/features/features.ts b/packages/backend-core/src/features/features.ts index e2f8d9b6a1..b9302f9bce 100644 --- a/packages/backend-core/src/features/features.ts +++ b/packages/backend-core/src/features/features.ts @@ -272,7 +272,6 @@ export const flags = new FlagSet({ [FeatureFlag.SQS]: Flag.boolean(true), [FeatureFlag.AI_CUSTOM_CONFIGS]: Flag.boolean(env.isDev()), [FeatureFlag.ENRICHED_RELATIONSHIPS]: Flag.boolean(env.isDev()), - [FeatureFlag.TABLES_DEFAULT_ADMIN]: Flag.boolean(env.isDev()), [FeatureFlag.BUDIBASE_AI]: Flag.boolean(env.isDev()), }) diff --git a/packages/server/src/sdk/app/tables/create.ts b/packages/server/src/sdk/app/tables/create.ts index fa858522bf..1cba26fc46 100644 --- a/packages/server/src/sdk/app/tables/create.ts +++ b/packages/server/src/sdk/app/tables/create.ts @@ -4,7 +4,7 @@ import * as external from "./external" import * as internal from "./internal" import { isExternal } from "./utils" import { setPermissions } from "../permissions" -import { features, roles } from "@budibase/backend-core" +import { roles } from "@budibase/backend-core" export async function create( table: Omit, @@ -18,16 +18,10 @@ export async function create( createdTable = await internal.create(table, rows, userId) } - const setExplicitPermission = await features.flags.isEnabled( - FeatureFlag.TABLES_DEFAULT_ADMIN - ) - - if (setExplicitPermission) { - await setPermissions(createdTable._id!, { - writeRole: roles.BUILTIN_ROLE_IDS.ADMIN, - readRole: roles.BUILTIN_ROLE_IDS.ADMIN, - }) - } + await setPermissions(createdTable._id!, { + writeRole: roles.BUILTIN_ROLE_IDS.ADMIN, + readRole: roles.BUILTIN_ROLE_IDS.ADMIN, + }) return createdTable } diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index a259dd5505..9c111ff079 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -2,7 +2,6 @@ import { BBReferenceFieldSubType, CalculationType, canGroupBy, - FeatureFlag, FieldType, isNumeric, PermissionLevel, @@ -16,7 +15,7 @@ import { ViewV2ColumnEnriched, ViewV2Enriched, } from "@budibase/types" -import { context, docIds, features, HTTPError } from "@budibase/backend-core" +import { context, docIds, HTTPError } from "@budibase/backend-core" import { helpers, PROTECTED_EXTERNAL_COLUMNS, @@ -287,17 +286,12 @@ export async function create( await guardViewSchema(tableId, viewRequest) const view = await pickApi(tableId).create(tableId, viewRequest) - const setExplicitPermission = await features.flags.isEnabled( - FeatureFlag.TABLES_DEFAULT_ADMIN - ) - if (setExplicitPermission) { - // Set permissions to be the same as the table - const tablePerms = await sdk.permissions.getResourcePerms(tableId) - await sdk.permissions.setPermissions(view.id, { - writeRole: tablePerms[PermissionLevel.WRITE].role, - readRole: tablePerms[PermissionLevel.READ].role, - }) - } + // Set permissions to be the same as the table + const tablePerms = await sdk.permissions.getResourcePerms(tableId) + await sdk.permissions.setPermissions(view.id, { + writeRole: tablePerms[PermissionLevel.WRITE].role, + readRole: tablePerms[PermissionLevel.READ].role, + }) return view } diff --git a/packages/types/src/sdk/featureFlag.ts b/packages/types/src/sdk/featureFlag.ts index 99ee0f9996..97d145db6c 100644 --- a/packages/types/src/sdk/featureFlag.ts +++ b/packages/types/src/sdk/featureFlag.ts @@ -6,7 +6,6 @@ export enum FeatureFlag { AI_CUSTOM_CONFIGS = "AI_CUSTOM_CONFIGS", DEFAULT_VALUES = "DEFAULT_VALUES", ENRICHED_RELATIONSHIPS = "ENRICHED_RELATIONSHIPS", - TABLES_DEFAULT_ADMIN = "TABLES_DEFAULT_ADMIN", BUDIBASE_AI = "BUDIBASE_AI", } From c1bc231b410d875c2f51d580d8196cd238c34a1e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 4 Nov 2024 15:52:41 +0000 Subject: [PATCH 03/15] Fix issue counting number of filters when legacy structure is used --- .../controls/FilterEditor/FilterEditor.svelte | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte index 34c317e865..0af48ca38d 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte @@ -12,6 +12,7 @@ import FilterBuilder from "./FilterBuilder.svelte" import { tables, selectedScreen } from "stores/builder" import { search } from "@budibase/frontend-core" + import { utils } from "@budibase/shared-core" const dispatch = createEventDispatcher() @@ -22,7 +23,7 @@ let drawer - $: localFilters = Helpers.cloneDeep(value) + $: localFilters = value $: datasource = getDatasourceForProvider($selectedScreen, componentInstance) $: dsSchema = getSchemaForDatasource($selectedScreen, datasource)?.schema $: schemaFields = search.getFields( @@ -30,8 +31,7 @@ Object.values(schema || dsSchema || {}), { allowLinks: true } ) - - $: text = getText(value?.groups) + $: text = getText(value) async function saveFilter() { dispatch("change", localFilters) @@ -39,11 +39,14 @@ drawer.hide() } - const getText = (filterGroups = []) => { - const allFilters = filterGroups.reduce((acc, group) => { + const getText = filters => { + if (Array.isArray(filters)) { + filters = utils.processSearchFilters(filters) + } + const groups = filters?.groups || [] + const allFilters = groups.reduce((acc, group) => { return (acc += group.filters.filter(filter => filter.field).length) }, 0) - if (allFilters === 0) { return "No filters set" } else { @@ -62,7 +65,7 @@ on:drawerShow on:drawerShow={() => { // Reset to the currently available value. - localFilters = Helpers.cloneDeep(value) + localFilters = value }} > From 4ef07e9c91c37498ef378a50dc130ef0081e2eb7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 16:59:55 +0100 Subject: [PATCH 04/15] Lint --- packages/server/src/sdk/app/tables/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/tables/create.ts b/packages/server/src/sdk/app/tables/create.ts index 1cba26fc46..0b15cdb15a 100644 --- a/packages/server/src/sdk/app/tables/create.ts +++ b/packages/server/src/sdk/app/tables/create.ts @@ -1,4 +1,4 @@ -import { FeatureFlag, Row, Table } from "@budibase/types" +import { Row, Table } from "@budibase/types" import * as external from "./external" import * as internal from "./internal" From dd6847c8b5a1d63902d343c772f62c8be060e1bf Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 4 Nov 2024 16:01:12 +0000 Subject: [PATCH 05/15] Bump version to 3.0.2 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index e4b72979b9..77ca852955 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.0.1", + "version": "3.0.2", "npmClient": "yarn", "packages": [ "packages/*", From 507ca710b2c1b53ee26eeacf6a896d712107d7bd Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 4 Nov 2024 16:02:54 +0000 Subject: [PATCH 06/15] Lint --- .../design/settings/controls/FilterEditor/FilterEditor.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte index 0af48ca38d..c48cc3b8ce 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte @@ -5,7 +5,6 @@ Button, Drawer, DrawerContent, - Helpers, } from "@budibase/bbui" import { createEventDispatcher } from "svelte" import { getDatasourceForProvider, getSchemaForDatasource } from "dataBinding" From fb760f586ae0c3abaf63abb77211d3636a8c1ee5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 17:03:13 +0100 Subject: [PATCH 07/15] Disable major update --- .github/workflows/tag-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 483e895e98..b44395d2fe 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -13,7 +13,6 @@ on: options: - patch - minor - - major required: true jobs: From 6e2008c817d9b450f34712d838612686f2a9212b Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 4 Nov 2024 16:05:51 +0000 Subject: [PATCH 08/15] Add USE_DEFAULT_REDIS_CONFIG environment variable to single image to disable our config customisations. --- hosting/single/runner.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hosting/single/runner.sh b/hosting/single/runner.sh index d9b8719f0f..e06a197ad5 100644 --- a/hosting/single/runner.sh +++ b/hosting/single/runner.sh @@ -81,11 +81,17 @@ mkdir -p ${DATA_DIR}/minio mkdir -p ${DATA_DIR}/redis chown -R couchdb:couchdb ${DATA_DIR}/couch -sed -i "s#DATA_DIR#${DATA_DIR}#g" /etc/redis/redis.conf +REDIS_CONFIG="/etc/redis/redis.conf" +sed -i "s#DATA_DIR#${DATA_DIR}#g" "${REDIS_CONFIG}" + +if [[ -n "${USE_DEFAULT_REDIS_CONFIG}" ]]; then + REDIS_CONFIG="" +fi + if [[ -n "${REDIS_PASSWORD}" ]]; then - redis-server /etc/redis/redis.conf --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 & + redis-server "${REDIS_CONFIG}" --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 & else - redis-server /etc/redis/redis.conf > /dev/stdout 2>&1 & + redis-server "${REDIS_CONFIG}" > /dev/stdout 2>&1 & fi /bbcouch-runner.sh & From 7b867abd19bb17cacae455f4ed8411f9f1b222b7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 4 Nov 2024 22:15:41 +0000 Subject: [PATCH 09/15] flag ai with feature flags correctly --- .../src/api/controllers/row/staticFormula.ts | 17 +++++++++++++---- .../server/src/automations/steps/openai.ts | 18 +++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/controllers/row/staticFormula.ts b/packages/server/src/api/controllers/row/staticFormula.ts index 28853a8faf..31a6678012 100644 --- a/packages/server/src/api/controllers/row/staticFormula.ts +++ b/packages/server/src/api/controllers/row/staticFormula.ts @@ -4,8 +4,15 @@ import { processAIColumns, processFormulas, } from "../../../utilities/rowProcessor" -import { context } from "@budibase/backend-core" -import { Table, Row, FormulaType, FieldType, ViewV2 } from "@budibase/types" +import { context, features } from "@budibase/backend-core" +import { + Table, + Row, + FeatureFlag, + FormulaType, + FieldType, + ViewV2, +} from "@budibase/types" import * as linkRows from "../../../db/linkedRows" import isEqual from "lodash/isEqual" import { cloneDeep } from "lodash/fp" @@ -145,8 +152,10 @@ export async function finaliseRow( contextRows: [enrichedRow], }) const aiEnabled = - (await pro.features.isBudibaseAIEnabled()) || - (await pro.features.isAICustomConfigsEnabled()) + ((await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) && + (await pro.features.isBudibaseAIEnabled())) || + ((await features.flags.isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)) && + (await pro.features.isAICustomConfigsEnabled())) if (aiEnabled) { row = await processAIColumns(table, row, { contextRows: [enrichedRow], diff --git a/packages/server/src/automations/steps/openai.ts b/packages/server/src/automations/steps/openai.ts index b1dfa3df5b..b3db0da9c5 100644 --- a/packages/server/src/automations/steps/openai.ts +++ b/packages/server/src/automations/steps/openai.ts @@ -7,17 +7,17 @@ import { AutomationIOType, OpenAIStepInputs, OpenAIStepOutputs, + FeatureFlag, } from "@budibase/types" -import { env } from "@budibase/backend-core" +import { env, features } from "@budibase/backend-core" import * as automationUtils from "../automationUtils" import * as pro from "@budibase/pro" enum Model { - GPT_35_TURBO = "gpt-3.5-turbo", - // will only work with api keys that have access to the GPT4 API - GPT_4 = "gpt-4", - GPT_4O = "gpt-4o", GPT_4O_MINI = "gpt-4o-mini", + GPT_4O = "gpt-4o", + GPT_4 = "gpt-4", + GPT_35_TURBO = "gpt-3.5-turbo", } export const definition: AutomationStepDefinition = { @@ -99,8 +99,12 @@ export async function run({ try { let response - const customConfigsEnabled = await pro.features.isAICustomConfigsEnabled() - const budibaseAIEnabled = await pro.features.isBudibaseAIEnabled() + const customConfigsEnabled = + (await features.flags.isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)) && + (await pro.features.isAICustomConfigsEnabled()) + const budibaseAIEnabled = + (await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) && + (await pro.features.isBudibaseAIEnabled()) if (budibaseAIEnabled || customConfigsEnabled) { const llm = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model) From 7c918302a90e92f71ba2711c4343dcab389cdfa8 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 4 Nov 2024 22:27:43 +0000 Subject: [PATCH 10/15] update all areas where ai flags come from license to come from feature flag --- .../src/components/automation/SetupPanel/CronBuilder.svelte | 6 ++++-- .../src/pages/builder/portal/settings/ai/index.svelte | 5 +++-- .../builder/src/pages/builder/portal/settings/index.svelte | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte index 51538944f4..fd235a70f2 100644 --- a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte +++ b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte @@ -9,7 +9,7 @@ } from "@budibase/bbui" import { onMount, createEventDispatcher } from "svelte" import { flags } from "stores/builder" - import { featureFlags } from "stores/portal" + import { featureFlags, licensing } from "stores/portal" import { API } from "api" import MagicWand from "../../../../assets/MagicWand.svelte" @@ -26,7 +26,9 @@ let aiCronPrompt = "" let loadingAICronExpression = false - $: aiEnabled = $featureFlags.AI_CUSTOM_CONFIGS || $featureFlags.BUDIBASE_AI + $: aiEnabled = + ($featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled) || + ($featureFlags.BUDIBASE_AI && $licensing.budibaseAIEnabled) $: { if (cronExpression) { try { diff --git a/packages/builder/src/pages/builder/portal/settings/ai/index.svelte b/packages/builder/src/pages/builder/portal/settings/ai/index.svelte index bbdf46a24e..ec0ff31e58 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/ai/index.svelte @@ -12,7 +12,7 @@ Tags, Tag, } from "@budibase/bbui" - import { admin, licensing } from "stores/portal" + import { admin, licensing, featureFlags } from "stores/portal" import { API } from "api" import AIConfigModal from "./ConfigModal.svelte" import AIConfigTile from "./AIConfigTile.svelte" @@ -27,7 +27,8 @@ let editingUuid $: isCloud = $admin.cloud - $: customAIConfigsEnabled = $licensing.customAIConfigsEnabled + $: customAIConfigsEnabled = + $featureFlags.AI_CUSTOM_CONFIGS && $licensing.customAIConfigsEnabled async function fetchAIConfig() { try { diff --git a/packages/builder/src/pages/builder/portal/settings/index.svelte b/packages/builder/src/pages/builder/portal/settings/index.svelte index 1448b43ec4..9ab8436f94 100644 --- a/packages/builder/src/pages/builder/portal/settings/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/index.svelte @@ -1,8 +1,8 @@