From 582d05651d0cc7d7240d19869ff5f060f59bb872 Mon Sep 17 00:00:00 2001 From: andz-bb Date: Tue, 3 Dec 2024 15:50:51 +0000 Subject: [PATCH 01/11] sort table names alphabetically when selecting data source --- .../DataSourceSelect/DataSourceSelect.svelte | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte b/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte index 410af53648..9eef8c1c06 100644 --- a/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte @@ -52,9 +52,16 @@ let modal $: text = value?.label ?? "Choose an option" - $: tables = $tablesStore.list.map(table => - format.table(table, $datasources.list) - ) + $: tables = $tablesStore.list + .map(table => format.table(table, $datasources.list)) + .sort((a, b) => { + // sort tables alphabetically, grouped by datasource + const dsComparison = a.datasourceName.localeCompare(b.datasourceName) + if (dsComparison !== 0) { + return dsComparison + } + return a.label.localeCompare(b.label) + }) $: viewsV1 = $viewsStore.list.map(view => ({ ...view, label: view.name, From 0b8f2c111d998ce10341742dafd517c93a05d5bd Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 3 Dec 2024 18:07:21 +0000 Subject: [PATCH 02/11] Linting. --- packages/server/src/api/controllers/layout.ts | 1 - packages/server/src/automations/steps/executeQuery.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/server/src/api/controllers/layout.ts b/packages/server/src/api/controllers/layout.ts index 447b437a23..a0eee000aa 100644 --- a/packages/server/src/api/controllers/layout.ts +++ b/packages/server/src/api/controllers/layout.ts @@ -2,7 +2,6 @@ import { EMPTY_LAYOUT } from "../../constants/layouts" import { generateLayoutID, getScreenParams } from "../../db/utils" import { events, context } from "@budibase/backend-core" import { - BBContext, DeleteLayoutResponse, Layout, SaveLayoutRequest, diff --git a/packages/server/src/automations/steps/executeQuery.ts b/packages/server/src/automations/steps/executeQuery.ts index 095c91a44d..7af540093f 100644 --- a/packages/server/src/automations/steps/executeQuery.ts +++ b/packages/server/src/automations/steps/executeQuery.ts @@ -12,7 +12,6 @@ import { ExecuteQueryStepInputs, ExecuteQueryStepOutputs, } from "@budibase/types" -import { executeV2AsAutomation } from "../../api/controllers/query" export const definition: AutomationStepDefinition = { name: "External Data Connector", From 92e5667b8176b935a786c0749955d040a53550cd Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 3 Dec 2024 18:55:06 +0000 Subject: [PATCH 03/11] prevent empty snippets being saved, don't crash for old empty snippets --- .../src/components/common/bindings/SnippetDrawer.svelte | 8 ++------ .../components/common/bindings/SnippetSidePanel.svelte | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/common/bindings/SnippetDrawer.svelte b/packages/builder/src/components/common/bindings/SnippetDrawer.svelte index d6b6f92b17..d8e56b059a 100644 --- a/packages/builder/src/components/common/bindings/SnippetDrawer.svelte +++ b/packages/builder/src/components/common/bindings/SnippetDrawer.svelte @@ -63,7 +63,7 @@ if (!name?.length) { return "Name is required" } - if (snippets.some(snippet => snippet.name === name)) { + if (!snippet?.name && snippets.some(snippet => snippet.name === name)) { return "That name is already in use" } if (firstCharNumberRegex.test(name)) { @@ -106,11 +106,7 @@ Delete {/if} - diff --git a/packages/builder/src/components/common/bindings/SnippetSidePanel.svelte b/packages/builder/src/components/common/bindings/SnippetSidePanel.svelte index c68699fc0f..2cc27b91cd 100644 --- a/packages/builder/src/components/common/bindings/SnippetSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/SnippetSidePanel.svelte @@ -186,7 +186,7 @@
{#key hoveredSnippet} From 82a1165077d259f39847eadbeab6f66b9f6c4cd4 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 3 Dec 2024 19:01:00 +0000 Subject: [PATCH 04/11] Bump version to 3.2.23 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index e67812f37b..13bf382d84 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.2.22", + "version": "3.2.23", "npmClient": "yarn", "concurrency": 20, "command": { From 7fcff8a628bb1bd414e962f46ac504cbd57f785e Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 4 Dec 2024 10:15:22 +0000 Subject: [PATCH 05/11] rely on llm status rather than initialised variable --- packages/pro | 2 +- packages/server/src/utilities/rowProcessor/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/pro b/packages/pro index e60f4b1b36..0d7fa31d4c 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit e60f4b1b364fd49d2bb082f298757f83cb2032f0 +Subproject commit 0d7fa31d4c4019690e2200323421025cdc74b89e diff --git a/packages/server/src/utilities/rowProcessor/utils.ts b/packages/server/src/utilities/rowProcessor/utils.ts index 9dbeb8ebb2..3728401ab8 100644 --- a/packages/server/src/utilities/rowProcessor/utils.ts +++ b/packages/server/src/utilities/rowProcessor/utils.ts @@ -126,8 +126,8 @@ export async function processAIColumns( const numRows = Array.isArray(inputRows) ? inputRows.length : 1 span?.addTags({ table_id: table._id, numRows }) const rows = Array.isArray(inputRows) ? inputRows : [inputRows] - const llm = await pro.ai.LargeLanguageModel.forCurrentTenant("gpt-4o-mini") - if (rows && llm.initialised) { + const llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant("gpt-4o-mini") + if (rows && llmWrapper.llm) { // Ensure we have snippet context await context.ensureSnippetContext() From e119e310efe30fa2fdaf8f5516206578cfe8385b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 4 Dec 2024 10:19:57 +0000 Subject: [PATCH 06/11] pro ref --- packages/pro | 2 +- packages/server/src/automations/steps/openai.ts | 8 ++++---- packages/server/src/utilities/rowProcessor/utils.ts | 8 +++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/pro b/packages/pro index 0d7fa31d4c..7b8789efd9 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 0d7fa31d4c4019690e2200323421025cdc74b89e +Subproject commit 7b8789efd940d9f8e5be9927243b19f07361c445 diff --git a/packages/server/src/automations/steps/openai.ts b/packages/server/src/automations/steps/openai.ts index 6f9adec1dc..8464c49763 100644 --- a/packages/server/src/automations/steps/openai.ts +++ b/packages/server/src/automations/steps/openai.ts @@ -106,13 +106,13 @@ export async function run({ (await features.flags.isEnabled(FeatureFlag.BUDIBASE_AI)) && (await pro.features.isBudibaseAIEnabled()) - let llm + let llmWrapper if (budibaseAIEnabled || customConfigsEnabled) { - llm = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model) + llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model) } - response = llm?.initialised - ? await llm.run(inputs.prompt) + response = llmWrapper?.llm + ? await llmWrapper.run(inputs.prompt) : await legacyOpenAIPrompt(inputs) return { diff --git a/packages/server/src/utilities/rowProcessor/utils.ts b/packages/server/src/utilities/rowProcessor/utils.ts index 3728401ab8..09d3324ded 100644 --- a/packages/server/src/utilities/rowProcessor/utils.ts +++ b/packages/server/src/utilities/rowProcessor/utils.ts @@ -126,7 +126,9 @@ export async function processAIColumns( const numRows = Array.isArray(inputRows) ? inputRows.length : 1 span?.addTags({ table_id: table._id, numRows }) const rows = Array.isArray(inputRows) ? inputRows : [inputRows] - const llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant("gpt-4o-mini") + const llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant( + "gpt-4o-mini" + ) if (rows && llmWrapper.llm) { // Ensure we have snippet context await context.ensureSnippetContext() @@ -151,14 +153,14 @@ export async function processAIColumns( } } - const prompt = llm.buildPromptFromAIOperation({ + const prompt = llmWrapper.buildPromptFromAIOperation({ schema: aiSchema, row, }) return tracer.trace("processAIColumn", {}, async span => { span?.addTags({ table_id: table._id, column }) - const llmResponse = await llm.run(prompt!) + const llmResponse = await llmWrapper.run(prompt!) return { ...row, [column]: llmResponse, From 46bd790b3a2950ff3b1ace16354e4fe3c3ca2008 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 4 Dec 2024 10:35:04 +0000 Subject: [PATCH 07/11] update tests --- packages/server/src/api/routes/tests/row.spec.ts | 2 +- packages/server/src/automations/steps/openai.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 1f4c4bc7cb..fb728a3fea 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -48,7 +48,7 @@ jest.mock("@budibase/pro", () => ({ ai: { LargeLanguageModel: { forCurrentTenant: async () => ({ - initialised: true, + llm: {}, run: jest.fn(() => `Mock LLM Response`), buildPromptFromAIOperation: jest.fn(), }), diff --git a/packages/server/src/automations/steps/openai.ts b/packages/server/src/automations/steps/openai.ts index 8464c49763..48eaa93057 100644 --- a/packages/server/src/automations/steps/openai.ts +++ b/packages/server/src/automations/steps/openai.ts @@ -108,7 +108,9 @@ export async function run({ let llmWrapper if (budibaseAIEnabled || customConfigsEnabled) { - llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant(inputs.model) + llmWrapper = await pro.ai.LargeLanguageModel.forCurrentTenant( + inputs.model + ) } response = llmWrapper?.llm From 48a367c2c2affa98e231132abaeb47716c139b1c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 4 Dec 2024 10:43:44 +0000 Subject: [PATCH 08/11] fix openai automation tests --- packages/server/src/automations/tests/openai.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/automations/tests/openai.spec.ts b/packages/server/src/automations/tests/openai.spec.ts index 9f2bc50599..1985465fc0 100644 --- a/packages/server/src/automations/tests/openai.spec.ts +++ b/packages/server/src/automations/tests/openai.spec.ts @@ -27,7 +27,7 @@ jest.mock("@budibase/pro", () => ({ ai: { LargeLanguageModel: { forCurrentTenant: jest.fn().mockImplementation(() => ({ - initialised: true, + llm: {}, init: jest.fn(), run: jest.fn(), })), From 3d8e15abc3a5840f82816385ba5257a96316e57d Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 4 Dec 2024 10:59:31 +0000 Subject: [PATCH 09/11] more usages of initialised --- packages/server/src/api/routes/tests/search.spec.ts | 2 +- packages/server/src/utilities/rowProcessor/tests/utils.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index c66197334e..dd1221d6fb 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -52,7 +52,7 @@ jest.mock("@budibase/pro", () => ({ ai: { LargeLanguageModel: { forCurrentTenant: async () => ({ - initialised: true, + llm: {}, run: jest.fn(() => `Mock LLM Response`), buildPromptFromAIOperation: jest.fn(), }), diff --git a/packages/server/src/utilities/rowProcessor/tests/utils.spec.ts b/packages/server/src/utilities/rowProcessor/tests/utils.spec.ts index 3638b62892..fa674fcc52 100644 --- a/packages/server/src/utilities/rowProcessor/tests/utils.spec.ts +++ b/packages/server/src/utilities/rowProcessor/tests/utils.spec.ts @@ -18,7 +18,7 @@ jest.mock("@budibase/pro", () => ({ ai: { LargeLanguageModel: { forCurrentTenant: async () => ({ - initialised: true, + llm: {}, run: jest.fn(() => "response from LLM"), buildPromptFromAIOperation: buildPromptMock, }), From 8d897ca434e1e387a5e40ebf194202c2f4fe9305 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 4 Dec 2024 11:09:46 +0000 Subject: [PATCH 10/11] Bump version to 3.2.24 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 13bf382d84..e960647b85 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.2.23", + "version": "3.2.24", "npmClient": "yarn", "concurrency": 20, "command": { From da81381d62e08af19b1635afe1233dd6a3feb864 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 4 Dec 2024 13:48:30 +0000 Subject: [PATCH 11/11] PR review comments. --- packages/server/src/api/controllers/integration.ts | 2 +- packages/server/src/api/controllers/plugin/file.ts | 4 ++-- packages/server/src/sdk/plugins/plugins.ts | 4 ++-- packages/types/src/documents/global/plugin.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/controllers/integration.ts b/packages/server/src/api/controllers/integration.ts index 9f770ad049..f26f8dcc52 100644 --- a/packages/server/src/api/controllers/integration.ts +++ b/packages/server/src/api/controllers/integration.ts @@ -26,7 +26,7 @@ export async function find(ctx: UserCtx) { } const integration = await getDefinition(ctx.params.type) if (!integration) { - ctx.throw(400, "Integration not found") + ctx.throw(404, "Integration not found") } ctx.body = integration } diff --git a/packages/server/src/api/controllers/plugin/file.ts b/packages/server/src/api/controllers/plugin/file.ts index 0f40998617..4b1f098939 100644 --- a/packages/server/src/api/controllers/plugin/file.ts +++ b/packages/server/src/api/controllers/plugin/file.ts @@ -3,9 +3,9 @@ import { getPluginMetadata, extractTarball, } from "../../../utilities/fileSystem" -import { FileType } from "@budibase/types" +import { KoaFile } from "@budibase/types" -export async function fileUpload(file: FileType) { +export async function fileUpload(file: KoaFile) { if (!file.name || !file.path) { throw new Error("File is not valid - cannot upload.") } diff --git a/packages/server/src/sdk/plugins/plugins.ts b/packages/server/src/sdk/plugins/plugins.ts index 650065b40c..63f2f22cd9 100644 --- a/packages/server/src/sdk/plugins/plugins.ts +++ b/packages/server/src/sdk/plugins/plugins.ts @@ -1,4 +1,4 @@ -import { FileType, Plugin, PluginSource, PluginType } from "@budibase/types" +import { KoaFile, Plugin, PluginSource, PluginType } from "@budibase/types" import { db as dbCore, objectStore, @@ -26,7 +26,7 @@ export async function fetch(type?: PluginType): Promise { } } -export async function processUploaded(plugin: FileType, source?: PluginSource) { +export async function processUploaded(plugin: KoaFile, source?: PluginSource) { const { metadata, directory } = await fileUpload(plugin) pluginCore.validate(metadata?.schema) diff --git a/packages/types/src/documents/global/plugin.ts b/packages/types/src/documents/global/plugin.ts index 5a7c701ae5..eeddc04e58 100644 --- a/packages/types/src/documents/global/plugin.ts +++ b/packages/types/src/documents/global/plugin.ts @@ -12,7 +12,7 @@ export enum PluginSource { URL = "URL", FILE = "File Upload", } -export interface FileType { +export interface KoaFile { path: string | null name: string | null }