From b7ec577efd3ec7f97164ebf1f5ca520075d5ed5d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 12 Dec 2023 16:57:41 +0100 Subject: [PATCH 01/58] Add redirect --- packages/builder/src/api.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/builder/src/api.js b/packages/builder/src/api.js index 37894d9bbc..e93dae65f8 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.js @@ -45,4 +45,9 @@ export const API = createAPIClient({ } } }, + onMigrationDetected: appId => { + window.location = `/builder/updating/${appId}?returnUrl=${encodeURI( + window.location + )}` + }, }) From 9067d38dce059718577f7fee214f7a31495e14c4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 12 Dec 2023 18:38:29 +0100 Subject: [PATCH 02/58] Create updating page --- packages/builder/src/api.js | 10 +++++++--- .../src/pages/builder/updating/[appId].svelte | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 packages/builder/src/pages/builder/updating/[appId].svelte diff --git a/packages/builder/src/api.js b/packages/builder/src/api.js index e93dae65f8..2fa48273f0 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.js @@ -46,8 +46,12 @@ export const API = createAPIClient({ } }, onMigrationDetected: appId => { - window.location = `/builder/updating/${appId}?returnUrl=${encodeURI( - window.location - )}` + const updatingUrl = `/builder/updating/${appId}` + + if (window.location.pathname === updatingUrl) { + return + } + + window.location = `${updatingUrl}?returnUrl=${encodeURI(window.location)}` }, }) diff --git a/packages/builder/src/pages/builder/updating/[appId].svelte b/packages/builder/src/pages/builder/updating/[appId].svelte new file mode 100644 index 0000000000..69a2d58eed --- /dev/null +++ b/packages/builder/src/pages/builder/updating/[appId].svelte @@ -0,0 +1,14 @@ + + +
+ +
+ + From a2cb32225d35a02179ba41d2ab191485b88a0678 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 12 Dec 2023 18:38:44 +0100 Subject: [PATCH 03/58] Checks --- .../src/pages/builder/updating/[appId].svelte | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/builder/src/pages/builder/updating/[appId].svelte b/packages/builder/src/pages/builder/updating/[appId].svelte index 69a2d58eed..25092dd1a0 100644 --- a/packages/builder/src/pages/builder/updating/[appId].svelte +++ b/packages/builder/src/pages/builder/updating/[appId].svelte @@ -1,5 +1,22 @@
From 0b8d7904dfba652c68751f709643b80f399866a1 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 13 Dec 2023 12:44:32 +0100 Subject: [PATCH 04/58] Encode url properly --- packages/builder/src/api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/api.js b/packages/builder/src/api.js index 2fa48273f0..4817ac2716 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.js @@ -52,6 +52,8 @@ export const API = createAPIClient({ return } - window.location = `${updatingUrl}?returnUrl=${encodeURI(window.location)}` + window.location = `${updatingUrl}?returnUrl=${encodeURIComponent( + window.location + )}` }, }) From 342a1b487bc17d4aea7ddfd6d0d53037d523960c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 13 Dec 2023 16:15:11 +0100 Subject: [PATCH 05/58] Update url --- packages/builder/src/api.js | 2 +- .../[appId].svelte => app/[application]/updating.svelte} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/builder/src/pages/builder/{updating/[appId].svelte => app/[application]/updating.svelte} (100%) diff --git a/packages/builder/src/api.js b/packages/builder/src/api.js index 4817ac2716..a854137e2b 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.js @@ -46,7 +46,7 @@ export const API = createAPIClient({ } }, onMigrationDetected: appId => { - const updatingUrl = `/builder/updating/${appId}` + const updatingUrl = `/builder/app/${appId}/updating` if (window.location.pathname === updatingUrl) { return diff --git a/packages/builder/src/pages/builder/updating/[appId].svelte b/packages/builder/src/pages/builder/app/[application]/updating.svelte similarity index 100% rename from packages/builder/src/pages/builder/updating/[appId].svelte rename to packages/builder/src/pages/builder/app/[application]/updating.svelte From 3a2a2a242cb906cf714864b95fdf0101bd808f15 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 14 Dec 2023 12:52:51 +0100 Subject: [PATCH 06/58] Change interval for timeout --- .../builder/app/[application]/updating.svelte | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/updating.svelte b/packages/builder/src/pages/builder/app/[application]/updating.svelte index 25092dd1a0..22d6371c18 100644 --- a/packages/builder/src/pages/builder/app/[application]/updating.svelte +++ b/packages/builder/src/pages/builder/app/[application]/updating.svelte @@ -2,19 +2,27 @@ import Spinner from "components/common/Spinner.svelte" import { API } from "api" - setInterval(async () => { - const response = await API.get({ url: "/api/migrations/status" }) - if (!response.migrated) { - return - } + let timeout + async function checkMigrationsFinished() { + timeout = setTimeout(async () => { + const response = await API.get({ url: "/api/migrations/status" }) + if (!response.migrated) { + checkMigrationsFinished() + return + } - const urlParams = new URLSearchParams(window.location.search) - const returnUrl = urlParams.get("returnUrl") + const urlParams = new URLSearchParams(window.location.search) + const returnUrl = urlParams.get("returnUrl") - window.location = returnUrl - }, 1000) + window.location = returnUrl + }, 1000) + } + + checkMigrationsFinished() setTimeout(() => { + clearTimeout(timeout) + // TODO alert("Something went wrong 💀") }, 60000) From 5f6210e9a06ae5c9b3e94f487314a22228bef841 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 14 Dec 2023 16:01:49 +0100 Subject: [PATCH 07/58] Use routify --- .../src/pages/builder/app/[application]/updating.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/app/[application]/updating.svelte b/packages/builder/src/pages/builder/app/[application]/updating.svelte index 22d6371c18..a89a3a7165 100644 --- a/packages/builder/src/pages/builder/app/[application]/updating.svelte +++ b/packages/builder/src/pages/builder/app/[application]/updating.svelte @@ -1,5 +1,7 @@
diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js index d4b4f3636e..066ab16f6e 100644 --- a/packages/frontend-core/src/api/index.js +++ b/packages/frontend-core/src/api/index.js @@ -33,6 +33,7 @@ import { buildEnvironmentVariableEndpoints } from "./environmentVariables" import { buildEventEndpoints } from "./events" import { buildAuditLogsEndpoints } from "./auditLogs" import { buildLogsEndpoints } from "./logs" +import { buildMigrationEndpoints } from "./migrations" /** * Random identifier to uniquely identify a session in a tab. This is @@ -298,6 +299,7 @@ export const createAPIClient = config => { ...buildEventEndpoints(API), ...buildAuditLogsEndpoints(API), ...buildLogsEndpoints(API), + ...buildMigrationEndpoints(API), viewV2: buildViewV2Endpoints(API), } } diff --git a/packages/frontend-core/src/api/migrations.js b/packages/frontend-core/src/api/migrations.js new file mode 100644 index 0000000000..2da70d6fcb --- /dev/null +++ b/packages/frontend-core/src/api/migrations.js @@ -0,0 +1,10 @@ +export const buildMigrationEndpoints = API => ({ + /** + * Gets the info about the current app migration + */ + getMigrationStatus: async () => { + return await API.get({ + url: "/api/migrations/status", + }) + }, +}) From c80504ca93d9afd54bc91a78d2bb2575aceb7711 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 18 Dec 2023 10:59:33 +0100 Subject: [PATCH 13/58] Use ?params --- packages/builder/src/api.js | 2 +- .../src/pages/builder/app/[application]/updating.svelte | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/api.js b/packages/builder/src/api.js index 9130c60dea..febf6603bb 100644 --- a/packages/builder/src/api.js +++ b/packages/builder/src/api.js @@ -53,7 +53,7 @@ export const API = createAPIClient({ } get(navigation).goto( - `${updatingUrl}?returnUrl=${encodeURIComponent(window.location)}` + `${updatingUrl}?returnUrl=${encodeURIComponent(window.location.pathname)}` ) }, }) diff --git a/packages/builder/src/pages/builder/app/[application]/updating.svelte b/packages/builder/src/pages/builder/app/[application]/updating.svelte index dca01e3495..0ea9de2ee3 100644 --- a/packages/builder/src/pages/builder/app/[application]/updating.svelte +++ b/packages/builder/src/pages/builder/app/[application]/updating.svelte @@ -1,6 +1,6 @@
+

+ 🛠️ We are updating the system.
Please wait, we will be back in a + second! +

+
@@ -40,5 +45,15 @@ .loading { display: flex; justify-content: center; + align-items: center; + justify-content: center; + flex-direction: column; + gap: var(--spacing-xl); + height: 100vh; + margin: 0; + } + .loading-message { + text-align: center; + font-size: 18px; } From ec4324697427d58e3ab5a211813f5dc9baf6c240 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 4 Jan 2024 12:28:36 +0100 Subject: [PATCH 16/58] Error --- .../builder/app/updating/[application].svelte | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/pages/builder/app/updating/[application].svelte b/packages/builder/src/pages/builder/app/updating/[application].svelte index bbcdccf917..ff8a873700 100644 --- a/packages/builder/src/pages/builder/app/updating/[application].svelte +++ b/packages/builder/src/pages/builder/app/updating/[application].svelte @@ -7,6 +7,8 @@ const timeoutMs = 60000 // 1 minute const loadTime = Date.now() + let timedOut = false + async function checkMigrationsFinished() { setTimeout(async () => { const response = await API.getMigrationStatus() @@ -27,18 +29,23 @@ checkMigrationsFinished() function migrationTimeout() { - // TODO - alert("Something went wrong 💀") + timedOut = true }
-

- 🛠️ We are updating the system.
Please wait, we will be back in a - second! -

+ {#if !timedOut} +

+ 🛠️ We are updating the system.
Please wait, we will be back in a + second! +

- + + {:else} +

+ An error occurred. Please try again later. +

+ {/if}
From 261e60d3bc087a8c7614341acfb70be8d8c677bc Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Fri, 5 Jan 2024 15:08:43 +0000 Subject: [PATCH 17/58] Enable dd-trace logging in QA to try and figure out why user info isn't being added to traces. --- packages/server/src/ddApm.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/server/src/ddApm.ts b/packages/server/src/ddApm.ts index 6c9b8aa289..f0f3ec6055 100644 --- a/packages/server/src/ddApm.ts +++ b/packages/server/src/ddApm.ts @@ -3,5 +3,9 @@ import apm from "dd-trace" // enable APM if configured if (process.env.DD_APM_ENABLED) { console.log("Starting dd-trace") - apm.init() + apm.init({ + // @ts-ignore for some reason dd-trace types don't include this options, + // even though it's spoken about in the docs. + debug: process.env.DD_ENV === "qa", + }) } From f73f8f443343bd26118a2d6b62439dcfe750c1e1 Mon Sep 17 00:00:00 2001 From: rg2011 <52279456+rg2011@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:29:29 +0100 Subject: [PATCH 18/58] Add support for full search path to postgres integration --- .../src/integration-test/postgres.spec.ts | 72 +++++++++++++++++++ packages/server/src/integrations/postgres.ts | 11 ++- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 67e4fee81c..600566c813 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -1118,4 +1118,76 @@ describe("postgres integrations", () => { }) }) }) + + describe("Integration compatibility with postgres search_path", () => { + let client: Client, pathDatasource: Datasource + const schema1 = "test1", + schema2 = "test-2" + + beforeAll(async () => { + const dsConfig = await databaseTestProviders.postgres.getDsConfig() + const dbConfig = dsConfig.config! + + client = new Client(dbConfig) + await client.connect() + await client.query(`CREATE SCHEMA "${schema1}";`) + await client.query(`CREATE SCHEMA "${schema2}";`) + + const pathConfig: any = { + ...dsConfig, + config: { + ...dbConfig, + schema: `${schema1}, ${schema2}`, + }, + } + pathDatasource = await config.api.datasource.create(pathConfig) + }) + + afterAll(async () => { + await client.query(`DROP SCHEMA "${schema1}" CASCADE;`) + await client.query(`DROP SCHEMA "${schema2}" CASCADE;`) + await client.end() + }) + + it("discovers tables from any schema in search path", async () => { + await client.query( + `CREATE TABLE "${schema1}".table1 (id1 SERIAL PRIMARY KEY);` + ) + await client.query( + `CREATE TABLE "${schema2}".table2 (id2 SERIAL PRIMARY KEY);` + ) + const response = await makeRequest("post", "/api/datasources/info", { + datasource: pathDatasource, + }) + expect(response.status).toBe(200) + expect(response.body.tableNames).toBeDefined() + expect(response.body.tableNames).toEqual( + expect.arrayContaining(["table1", "table2"]) + ) + }) + + it("does not mix columns from different tables", async () => { + const repeated_table_name = "table_same_name" + await client.query( + `CREATE TABLE "${schema1}".${repeated_table_name} (id SERIAL PRIMARY KEY, val1 TEXT);` + ) + await client.query( + `CREATE TABLE "${schema2}".${repeated_table_name} (id2 SERIAL PRIMARY KEY, val2 TEXT);` + ) + const response = await makeRequest( + "post", + `/api/datasources/${pathDatasource._id}/schema`, + { + tablesFilter: [repeated_table_name], + } + ) + expect(response.status).toBe(200) + expect( + response.body.datasource.entities[repeated_table_name].schema + ).toBeDefined() + const schema = + response.body.datasource.entities[repeated_table_name].schema + expect(Object.keys(schema).sort()).toEqual(["id", "val1"]) + }) + }) }) diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index de3bf0e59e..e1494ece36 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -159,7 +159,8 @@ class PostgresIntegration extends Sql implements DatasourcePlus { JOIN pg_index ON pg_class.oid = pg_index.indrelid AND pg_index.indisprimary JOIN pg_attribute ON pg_attribute.attrelid = pg_class.oid AND pg_attribute.attnum = ANY(pg_index.indkey) JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace - WHERE pg_namespace.nspname = '${this.config.schema}'; + WHERE pg_namespace.nspname = ANY(current_schemas(false)) + AND pg_table_is_visible(pg_class.oid); ` ENUM_VALUES = () => ` @@ -219,8 +220,12 @@ class PostgresIntegration extends Sql implements DatasourcePlus { if (!this.config.schema) { this.config.schema = "public" } - await this.client.query(`SET search_path TO "${this.config.schema}"`) - this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'` + const search_path = this.config.schema + .split(",") + .map(item => `"${item.trim()}"`) + await this.client.query(`SET search_path TO ${search_path.join(",")};`) + this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = ANY(current_schemas(false)) + AND pg_table_is_visible(to_regclass(table_schema || '.' || table_name));` this.open = true } From ccc91dcca502600c4f7057ed5909c801bb820e37 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 5 Jan 2024 17:22:37 +0000 Subject: [PATCH 19/58] Enable layouts in multistep form blocks --- .../app/blocks/MultiStepFormblock.svelte | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte index 0573ba15b5..b90d0d4c7b 100644 --- a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte +++ b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte @@ -14,6 +14,7 @@ const { fetchDatasourceSchema } = getContext("sdk") const component = getContext("component") + const context = getContext("context") // Set current step context to force child form to use it const currentStep = writable(1) @@ -157,18 +158,23 @@ - - {#each step.fields as field, fieldIdx (`${field.field || field.name}_${stepIdx}_${fieldIdx}`)} - {#if getComponentForField(field)} - - {/if} - {/each} + +
+ {#each step.fields as field, fieldIdx (`${field.field || field.name}_${stepIdx}_${fieldIdx}`)} + {#if getComponentForField(field)} + + {/if} + {/each} +
+ + From 7ca748a3be474e3f90e7b4c1eb25017f8897a6eb Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Fri, 5 Jan 2024 18:10:23 +0000 Subject: [PATCH 20/58] Remove objects from setUser call. We can add them later if we need them. --- packages/backend-core/src/middleware/authenticated.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/backend-core/src/middleware/authenticated.ts b/packages/backend-core/src/middleware/authenticated.ts index e8e16589de..d357dbdbdc 100644 --- a/packages/backend-core/src/middleware/authenticated.ts +++ b/packages/backend-core/src/middleware/authenticated.ts @@ -172,11 +172,8 @@ export default function ( tracer.setUser({ id: user?._id, tenantId: user?.tenantId, - admin: user?.admin, - builder: user?.builder, budibaseAccess: user?.budibaseAccess, status: user?.status, - roles: user?.roles, }) } From b115ead329e7da914bfceb035ade56543998a38e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 10:46:14 +0100 Subject: [PATCH 21/58] Format frontend --- .../builder/app/updating/[application].svelte | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/builder/src/pages/builder/app/updating/[application].svelte b/packages/builder/src/pages/builder/app/updating/[application].svelte index ff8a873700..6994331eff 100644 --- a/packages/builder/src/pages/builder/app/updating/[application].svelte +++ b/packages/builder/src/pages/builder/app/updating/[application].svelte @@ -1,10 +1,9 @@ -
- {#if !timedOut} -

- 🛠️ We are updating the system.
Please wait, we will be back in a - second! -

- - - {:else} -

- An error occurred. Please try again later. -

- {/if} +
+ {text} + {subtext}
From 6c20799b92748813c39004c67cfdabd5b51e07fe Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 8 Jan 2024 09:49:32 +0000 Subject: [PATCH 22/58] Extra traces inside of runJS to find out where time is being used. --- packages/server/src/jsRunner.ts | 64 +++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/packages/server/src/jsRunner.ts b/packages/server/src/jsRunner.ts index a9dcd506d7..f041f211fb 100644 --- a/packages/server/src/jsRunner.ts +++ b/packages/server/src/jsRunner.ts @@ -12,36 +12,48 @@ export function init() { const perRequestLimit = env.JS_PER_REQUEST_TIME_LIMIT_MS let track: TrackerFn = f => f() if (perRequestLimit) { - const bbCtx = context.getCurrentContext() - if (bbCtx) { - if (!bbCtx.jsExecutionTracker) { - bbCtx.jsExecutionTracker = - timers.ExecutionTimeTracker.withLimit(perRequestLimit) + tracer.trace("runJS.setupTracker", {}, span => { + const bbCtx = context.getCurrentContext() + if (bbCtx) { + if (!bbCtx.jsExecutionTracker) { + bbCtx.jsExecutionTracker = + timers.ExecutionTimeTracker.withLimit(perRequestLimit) + } + span?.addTags({ + js: { + limitMS: bbCtx.jsExecutionTracker.limitMs, + elapsedMS: bbCtx.jsExecutionTracker.elapsedMS, + }, + }) + // We call checkLimit() here to prevent paying the cost of creating + // a new VM context below when we don't need to. + bbCtx.jsExecutionTracker.checkLimit() + track = bbCtx.jsExecutionTracker.track.bind( + bbCtx.jsExecutionTracker + ) } - span?.addTags({ - js: { - limitMS: bbCtx.jsExecutionTracker.limitMs, - elapsedMS: bbCtx.jsExecutionTracker.elapsedMS, - }, - }) - // We call checkLimit() here to prevent paying the cost of creating - // a new VM context below when we don't need to. - bbCtx.jsExecutionTracker.checkLimit() - track = bbCtx.jsExecutionTracker.track.bind(bbCtx.jsExecutionTracker) - } + }) } - ctx = { - ...ctx, - alert: undefined, - setInterval: undefined, - setTimeout: undefined, - } - vm.createContext(ctx) + ctx = tracer.trace("runJS.ctxClone", {}, span => { + return { + ...ctx, + alert: undefined, + setInterval: undefined, + setTimeout: undefined, + } + }) + + tracer.trace("runJS.vm.createContext", {}, span => { + vm.createContext(ctx) + }) + return track(() => - vm.runInNewContext(js, ctx, { - timeout: env.JS_PER_EXECUTION_TIME_LIMIT_MS, - }) + tracer.trace("runJS.vm.runInNewContext", {}, span => + vm.runInNewContext(js, ctx, { + timeout: env.JS_PER_EXECUTION_TIME_LIMIT_MS, + }) + ) ) }) }) From d5850d59de4224843dd8444571a30a53186ea74a Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 8 Jan 2024 09:52:07 +0000 Subject: [PATCH 23/58] Add bool to show when execution tracker gets created. --- packages/server/src/jsRunner.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/jsRunner.ts b/packages/server/src/jsRunner.ts index f041f211fb..6fde3ab82a 100644 --- a/packages/server/src/jsRunner.ts +++ b/packages/server/src/jsRunner.ts @@ -12,10 +12,13 @@ export function init() { const perRequestLimit = env.JS_PER_REQUEST_TIME_LIMIT_MS let track: TrackerFn = f => f() if (perRequestLimit) { - tracer.trace("runJS.setupTracker", {}, span => { + tracer.trace("runJS.setupTracker", {}, span => { const bbCtx = context.getCurrentContext() if (bbCtx) { if (!bbCtx.jsExecutionTracker) { + span?.addTags({ + createdExecutionTracker: true, + }) bbCtx.jsExecutionTracker = timers.ExecutionTimeTracker.withLimit(perRequestLimit) } From 010ddc2c34b108a1232d29cb9cea15e638f367c0 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 8 Jan 2024 10:07:14 +0000 Subject: [PATCH 24/58] Set the CouchDB credentials in a safer way inside of runner.sh. --- hosting/couchdb/runner.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosting/couchdb/runner.sh b/hosting/couchdb/runner.sh index e56b8e0e7f..9f6a853ca7 100644 --- a/hosting/couchdb/runner.sh +++ b/hosting/couchdb/runner.sh @@ -76,6 +76,6 @@ done # CouchDB needs the `_users` and `_replicator` databases to exist before it will # function correctly, so we create them here. -curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_users -curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_replicator +curl -X PUT -u "${COUCHDB_USER}:${COUCHDB_PASSWORD}" http://localhost:5984/_users +curl -X PUT -u "${COUCHDB_USER}:${COUCHDB_PASSWORD}" http://localhost:5984/_replicator sleep infinity \ No newline at end of file From a427b322beaa5ab63bc9969f83cde54ac1bd7b3e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 11:11:46 +0100 Subject: [PATCH 25/58] Move ui to frontend-core --- .../builder/app/updating/[application].svelte | 64 +++---------------- .../src/components/Updating.svelte | 61 ++++++++++++++++++ .../frontend-core/src/components/index.js | 1 + 3 files changed, 71 insertions(+), 55 deletions(-) create mode 100644 packages/frontend-core/src/components/Updating.svelte diff --git a/packages/builder/src/pages/builder/app/updating/[application].svelte b/packages/builder/src/pages/builder/app/updating/[application].svelte index 6994331eff..ec6196aaca 100644 --- a/packages/builder/src/pages/builder/app/updating/[application].svelte +++ b/packages/builder/src/pages/builder/app/updating/[application].svelte @@ -1,65 +1,19 @@ -
- {text} - {subtext} -
- - + diff --git a/packages/frontend-core/src/components/Updating.svelte b/packages/frontend-core/src/components/Updating.svelte new file mode 100644 index 0000000000..b591c7e61c --- /dev/null +++ b/packages/frontend-core/src/components/Updating.svelte @@ -0,0 +1,61 @@ + + +
+ {text} + {subtext} +
+ + diff --git a/packages/frontend-core/src/components/index.js b/packages/frontend-core/src/components/index.js index 01a7c78cb8..f724e1e4d9 100644 --- a/packages/frontend-core/src/components/index.js +++ b/packages/frontend-core/src/components/index.js @@ -3,4 +3,5 @@ export { default as TestimonialPage } from "./TestimonialPage.svelte" export { default as Testimonial } from "./Testimonial.svelte" export { default as UserAvatar } from "./UserAvatar.svelte" export { default as UserAvatars } from "./UserAvatars.svelte" +export { default as Updating } from "./Updating.svelte" export { Grid } from "./grid" From d46b22e4a6af1dccd8353d176c879b5a48643682 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 11:52:31 +0100 Subject: [PATCH 26/58] Fix initial checks --- packages/server/src/appMigrations/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/appMigrations/index.ts b/packages/server/src/appMigrations/index.ts index b382d8b533..0758b9f324 100644 --- a/packages/server/src/appMigrations/index.ts +++ b/packages/server/src/appMigrations/index.ts @@ -17,7 +17,7 @@ export const getLatestMigrationId = () => .sort() .reverse()[0] -const getTimestamp = (versionId: string) => versionId?.split("_")[0] +const getTimestamp = (versionId: string) => versionId?.split("_")[0] || "" export async function checkMissingMigrations( ctx: UserCtx, From a8019d86cca93376a5e00f1697a09e6d67e8c54a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 12:09:24 +0100 Subject: [PATCH 27/58] Move api checks --- .../src/pages/builder/app/updating/[application].svelte | 9 +-------- packages/frontend-core/src/components/Updating.svelte | 8 +++++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/pages/builder/app/updating/[application].svelte b/packages/builder/src/pages/builder/app/updating/[application].svelte index ec6196aaca..ec851fa08d 100644 --- a/packages/builder/src/pages/builder/app/updating/[application].svelte +++ b/packages/builder/src/pages/builder/app/updating/[application].svelte @@ -2,13 +2,6 @@ import { Updating } from "@budibase/frontend-core" import { redirect, params } from "@roxi/routify" - import { API } from "api" - - async function isMigrationDone() { - const response = await API.getMigrationStatus() - return response.migrated - } - async function onMigrationDone() { // For some reason routify params is not stripping the ? properly, so we need to check both with and without ? const returnUrl = $params.returnUrl || $params["?returnUrl"] @@ -16,4 +9,4 @@ } - + diff --git a/packages/frontend-core/src/components/Updating.svelte b/packages/frontend-core/src/components/Updating.svelte index b591c7e61c..57433c1164 100644 --- a/packages/frontend-core/src/components/Updating.svelte +++ b/packages/frontend-core/src/components/Updating.svelte @@ -1,5 +1,6 @@
- {text} - {subtext} + + {#if !timedOut} + System update + {:else} + Something went wrong! + {/if} + + + {#if !timedOut} + Please wait and we will be back in a second! + {:else} + An error occurred, please try again later. +
+ Contact support if the issue persists. + {/if}
From 43aca917d718d4b75f0280fa5f2087d79958b234 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 13:33:41 +0100 Subject: [PATCH 35/58] Fix import --- packages/frontend-core/src/components/Updating.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-core/src/components/Updating.svelte b/packages/frontend-core/src/components/Updating.svelte index 7a13de3ca5..0b80fd2391 100644 --- a/packages/frontend-core/src/components/Updating.svelte +++ b/packages/frontend-core/src/components/Updating.svelte @@ -1,5 +1,5 @@ - + diff --git a/packages/frontend-core/src/components/Updating.svelte b/packages/frontend-core/src/components/Updating.svelte index 16e4b51de4..7d4a101fee 100644 --- a/packages/frontend-core/src/components/Updating.svelte +++ b/packages/frontend-core/src/components/Updating.svelte @@ -1,18 +1,17 @@ +
Updating the system...
From bfaab228d57429df634263d34c1017d3ecbf008a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 12:07:26 +0100 Subject: [PATCH 48/58] Use updating page from frontend --- .../client/src/components/UpdatingApp.svelte | 60 +++---------------- 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/packages/client/src/components/UpdatingApp.svelte b/packages/client/src/components/UpdatingApp.svelte index 7d8d54df45..d93355394e 100644 --- a/packages/client/src/components/UpdatingApp.svelte +++ b/packages/client/src/components/UpdatingApp.svelte @@ -1,61 +1,15 @@ -
- {#if !timedOut} -

- 🛠️ We are updating the system.
Please wait, we will be back in a - second! -

- {:else} -

- An error occurred. Please try again later. -

- {/if} -
- - + From 9ebe93f71d3eade90062ca955292d6ef8f3368d6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 12:10:35 +0100 Subject: [PATCH 49/58] Clean --- packages/client/src/components/UpdatingApp.svelte | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/client/src/components/UpdatingApp.svelte b/packages/client/src/components/UpdatingApp.svelte index d93355394e..4177ea017f 100644 --- a/packages/client/src/components/UpdatingApp.svelte +++ b/packages/client/src/components/UpdatingApp.svelte @@ -1,15 +1,9 @@ - + From f77b81267933d2f868b4af188be73b2bbb70a879 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 12:15:12 +0100 Subject: [PATCH 50/58] Handle no migrations --- packages/server/src/api/controllers/static/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/static/index.ts b/packages/server/src/api/controllers/static/index.ts index 0166f92478..5f383e837d 100644 --- a/packages/server/src/api/controllers/static/index.ts +++ b/packages/server/src/api/controllers/static/index.ts @@ -135,9 +135,14 @@ const requiresMigration = async (ctx: Ctx) => { ctx.throw("AppId could not be found") } - const latestAppliedMigration = await getAppMigrationVersion(appId) + const latestMigration = getLatestMigrationId() + if (!latestMigration) { + return false + } - const requiresMigrations = latestAppliedMigration !== getLatestMigrationId() + const latestMigrationApplied = await getAppMigrationVersion(appId) + + const requiresMigrations = latestMigrationApplied !== latestMigration return requiresMigrations } From f123a821bd95add40876b331aeae213e9152238d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 12:21:34 +0100 Subject: [PATCH 51/58] Styling --- packages/client/src/components/UpdatingApp.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/UpdatingApp.svelte b/packages/client/src/components/UpdatingApp.svelte index 4177ea017f..b493b7cd67 100644 --- a/packages/client/src/components/UpdatingApp.svelte +++ b/packages/client/src/components/UpdatingApp.svelte @@ -6,4 +6,12 @@ } - +
+ +
+ + From 2a07aa35f4da73e1447c45708eea967d516b33e5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jan 2024 13:48:50 +0100 Subject: [PATCH 52/58] Pass api call --- packages/client/src/components/UpdatingApp.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/UpdatingApp.svelte b/packages/client/src/components/UpdatingApp.svelte index b493b7cd67..74e5500715 100644 --- a/packages/client/src/components/UpdatingApp.svelte +++ b/packages/client/src/components/UpdatingApp.svelte @@ -1,5 +1,11 @@
- +