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: diff --git a/lerna.json b/lerna.json index 77ca852955..8e53ea97a9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.0.2", + "version": "3.0.3", "npmClient": "yarn", "packages": [ "packages/*", 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/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/AISettings.spec.js b/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js index 300d5d5369..e797a1c5bd 100644 --- a/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js +++ b/packages/builder/src/pages/builder/portal/settings/ai/AISettings.spec.js @@ -1,7 +1,7 @@ import { it, expect, describe, vi } from "vitest" import AISettings from "./index.svelte" import { render, fireEvent } from "@testing-library/svelte" -import { admin, licensing } from "stores/portal" +import { admin, licensing, featureFlags } from "stores/portal" import { notifications } from "@budibase/bbui" vi.spyOn(notifications, "error").mockImplementation(vi.fn) @@ -12,12 +12,17 @@ const Hosting = { Self: "self", } -function setupEnv(hosting, features = {}) { +function setupEnv(hosting, features = {}, flags = {}) { const defaultFeatures = { budibaseAIEnabled: false, customAIConfigsEnabled: false, ...features, } + const defaultFlags = { + BUDIBASE_AI: false, + AI_CUSTOM_CONFIGS: false, + ...flags, + } admin.subscribe = vi.fn().mockImplementation(callback => { callback({ cloud: hosting === Hosting.Cloud }) return () => {} @@ -26,6 +31,10 @@ function setupEnv(hosting, features = {}) { callback(defaultFeatures) return () => {} }) + featureFlags.subscribe = vi.fn().mockImplementation(callback => { + callback(defaultFlags) + return () => {} + }) } describe("AISettings", () => { @@ -72,7 +81,11 @@ describe("AISettings", () => { let addConfigurationButton let configModal - setupEnv(Hosting.Cloud, { customAIConfigsEnabled: true }) + setupEnv( + Hosting.Cloud, + { customAIConfigsEnabled: true }, + { AI_CUSTOM_CONFIGS: true } + ) instance = render(AISettings) addConfigurationButton = instance.queryByText("Add configuration") expect(addConfigurationButton).toBeInTheDocument() @@ -85,7 +98,11 @@ describe("AISettings", () => { let addConfigurationButton let configModal - setupEnv(Hosting.Self, { customAIConfigsEnabled: true }) + setupEnv( + Hosting.Self, + { customAIConfigsEnabled: true }, + { AI_CUSTOM_CONFIGS: true } + ) instance = render(AISettings) addConfigurationButton = instance.queryByText("Add configuration") expect(addConfigurationButton).toBeInTheDocument() diff --git a/packages/pro b/packages/pro index fd131d3dfa..2ab8536b60 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit fd131d3dfa0489e68ddd8a55979f4866f4fd6044 +Subproject commit 2ab8536b6005576684810d774f1ac22239218546 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 bca31e39d2..6f9adec1dc 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()) let llm if (budibaseAIEnabled || customConfigsEnabled) { diff --git a/packages/server/src/sdk/app/tables/create.ts b/packages/server/src/sdk/app/tables/create.ts index fa858522bf..0b15cdb15a 100644 --- a/packages/server/src/sdk/app/tables/create.ts +++ b/packages/server/src/sdk/app/tables/create.ts @@ -1,10 +1,10 @@ -import { FeatureFlag, Row, Table } from "@budibase/types" +import { Row, Table } from "@budibase/types" 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", }