diff --git a/lerna.json b/lerna.json index e67812f37b..e960647b85 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.24", "npmClient": "yarn", "concurrency": 20, "command": { 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} 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, diff --git a/packages/pro b/packages/pro index e60f4b1b36..7b8789efd9 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit e60f4b1b364fd49d2bb082f298757f83cb2032f0 +Subproject commit 7b8789efd940d9f8e5be9927243b19f07361c445 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/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/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/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/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/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", diff --git a/packages/server/src/automations/steps/openai.ts b/packages/server/src/automations/steps/openai.ts index 6f9adec1dc..48eaa93057 100644 --- a/packages/server/src/automations/steps/openai.ts +++ b/packages/server/src/automations/steps/openai.ts @@ -106,13 +106,15 @@ 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/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(), })), 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/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, }), diff --git a/packages/server/src/utilities/rowProcessor/utils.ts b/packages/server/src/utilities/rowProcessor/utils.ts index 9dbeb8ebb2..09d3324ded 100644 --- a/packages/server/src/utilities/rowProcessor/utils.ts +++ b/packages/server/src/utilities/rowProcessor/utils.ts @@ -126,8 +126,10 @@ 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() @@ -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, 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 }