From 09ff8a06624c3c99ac0c5b5dfc046f6538a08a43 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 31 Jan 2024 15:00:32 +0000 Subject: [PATCH 01/33] License Test Changes License.manage.spec.ts/StripeAPI.ts - Test updated and now successfully updates from Free plan to premium - createCheckoutSession updated to support this plan upgrade --- qa-core/src/account-api/api/apis/StripeAPI.ts | 4 ++-- .../tests/licensing/license.manage.spec.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/qa-core/src/account-api/api/apis/StripeAPI.ts b/qa-core/src/account-api/api/apis/StripeAPI.ts index 5a4e810655..aeb027f428 100644 --- a/qa-core/src/account-api/api/apis/StripeAPI.ts +++ b/qa-core/src/account-api/api/apis/StripeAPI.ts @@ -11,12 +11,12 @@ export default class StripeAPI extends BaseAPI { } async createCheckoutSession( - priceId: string, + price: object, opts: APIRequestOpts = { status: 200 } ) { return this.doRequest(() => { return this.client.post(`/api/stripe/checkout-session`, { - body: { priceId }, + body: { prices: [price] }, }) }, opts) } diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index 9a8662ea3b..2d5b9332c6 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -36,11 +36,11 @@ describe("license management", () => { const [plansRes, planBody] = await config.api.licenses.getPlans() // Select priceId from premium plan - let premiumPriceId = null - let businessPriceId = "" + let premiumPrice = null + let businessPriceId: "" for (const plan of planBody) { if (plan.type === PlanType.PREMIUM_PLUS) { - premiumPriceId = plan.prices[0].priceId + premiumPrice = plan.prices[0] } if (plan.type === PlanType.ENTERPRISE_BASIC) { businessPriceId = plan.prices[0].priceId @@ -49,7 +49,7 @@ describe("license management", () => { // Create checkout session for price const checkoutSessionRes = await config.api.stripe.createCheckoutSession( - premiumPriceId + { id: premiumPrice.priceId, type: premiumPrice.type } ) const checkoutSessionUrl = checkoutSessionRes[1].url expect(checkoutSessionUrl).toContain("checkout.stripe.com") @@ -84,7 +84,7 @@ describe("license management", () => { customer: customer.id, items: [ { - price: premiumPriceId, + price: premiumPrice.priceId, quantity: 1, }, ], @@ -105,6 +105,7 @@ describe("license management", () => { expect(portalSessionBody.url).toContain("billing.stripe.com") // Update subscription from premium to business license + //await config.api.licenses.updatePlan(businessPriceId.priceId) await config.api.licenses.updatePlan(businessPriceId) // License updated to Business From d7ae4c04b9e84e48ab3bc3553ed5e39aa6e3e414 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 6 Feb 2024 17:15:11 +0000 Subject: [PATCH 02/33] Removing commented line --- qa-core/src/account-api/tests/licensing/license.manage.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index 2d5b9332c6..baed5734cf 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -105,7 +105,6 @@ describe("license management", () => { expect(portalSessionBody.url).toContain("billing.stripe.com") // Update subscription from premium to business license - //await config.api.licenses.updatePlan(businessPriceId.priceId) await config.api.licenses.updatePlan(businessPriceId) // License updated to Business From 3726e10f3a6bee0f40e9f3f86da6bd6d7c309af5 Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Tue, 6 Feb 2024 17:28:00 +0000 Subject: [PATCH 03/33] lint --- .../src/account-api/tests/licensing/license.manage.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts index baed5734cf..85ee530bb7 100644 --- a/qa-core/src/account-api/tests/licensing/license.manage.spec.ts +++ b/qa-core/src/account-api/tests/licensing/license.manage.spec.ts @@ -48,9 +48,10 @@ describe("license management", () => { } // Create checkout session for price - const checkoutSessionRes = await config.api.stripe.createCheckoutSession( - { id: premiumPrice.priceId, type: premiumPrice.type } - ) + const checkoutSessionRes = await config.api.stripe.createCheckoutSession({ + id: premiumPrice.priceId, + type: premiumPrice.type, + }) const checkoutSessionUrl = checkoutSessionRes[1].url expect(checkoutSessionUrl).toContain("checkout.stripe.com") From 5dfa46037408b1fe7e8026a15e81d90d7234c8af Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 20 Feb 2024 16:23:35 +0000 Subject: [PATCH 04/33] Disabling VM by default in string-templates, backend services *MUST* set their JS runner specifically rather than assuming the VM library by default. --- .../src/helpers/javascript.js | 7 +++- packages/string-templates/src/index.js | 37 +++++++++++-------- packages/string-templates/src/utilities.js | 8 ++++ packages/string-templates/test/vm.spec.js | 27 ++++++++++++++ 4 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 packages/string-templates/test/vm.spec.js diff --git a/packages/string-templates/src/helpers/javascript.js b/packages/string-templates/src/helpers/javascript.js index 4a7f602690..7827736812 100644 --- a/packages/string-templates/src/helpers/javascript.js +++ b/packages/string-templates/src/helpers/javascript.js @@ -1,4 +1,4 @@ -const { atob } = require("../utilities") +const { atob, isBackendService, isJSAllowed } = require("../utilities") const cloneDeep = require("lodash.clonedeep") const { LITERAL_MARKER } = require("../helpers/constants") const { getJsHelperList } = require("./list") @@ -7,6 +7,9 @@ const { getJsHelperList } = require("./list") // This setter is used in the entrypoint (either index.js or index.mjs). let runJS module.exports.setJSRunner = runner => (runJS = runner) +module.exports.removeJSRunner = () => { + runJS = undefined +} let onErrorLog module.exports.setOnErrorLog = delegate => (onErrorLog = delegate) @@ -39,7 +42,7 @@ const getContextValue = (path, context) => { // Evaluates JS code against a certain context module.exports.processJS = (handlebars, context) => { - if (process && process.env.NO_JS) { + if (!isJSAllowed() || (isBackendService() && !runJS)) { throw new Error("JS disabled in environment.") } try { diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index bcd63d2e6f..2dc360bd96 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -2,7 +2,7 @@ const vm = require("vm") const handlebars = require("handlebars") const { registerAll, registerMinimum } = require("./helpers/index") const processors = require("./processors") -const { atob, btoa } = require("./utilities") +const { atob, btoa, isBackendService, isJSAllowed } = require("./utilities") const manifest = require("../manifest.json") const { FIND_HBS_REGEX, @@ -404,18 +404,25 @@ module.exports.JsErrorTimeout = errors.JsErrorTimeout module.exports.helpersToRemoveForJs = helpersToRemoveForJs -if (process && !process.env.NO_JS) { - /** - * Use polyfilled vm to run JS scripts in a browser Env - */ - javascript.setJSRunner((js, context) => { - context = { - ...context, - alert: undefined, - setInterval: undefined, - setTimeout: undefined, - } - vm.createContext(context) - return vm.runInNewContext(js, context, { timeout: 1000 }) - }) +function defaultJSSetup() { + if (!isBackendService()) { + /** + * Use polyfilled vm to run JS scripts in a browser Env + */ + javascript.setJSRunner((js, context) => { + context = { + ...context, + alert: undefined, + setInterval: undefined, + setTimeout: undefined, + } + vm.createContext(context) + return vm.runInNewContext(js, context, { timeout: 1000 }) + }) + } else { + javascript.removeJSRunner() + } } +defaultJSSetup() + +module.exports.defaultJSSetup = defaultJSSetup diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js index 775c150e1b..00b2d7d855 100644 --- a/packages/string-templates/src/utilities.js +++ b/packages/string-templates/src/utilities.js @@ -4,6 +4,14 @@ module.exports.FIND_HBS_REGEX = /{{([^{].*?)}}/g module.exports.FIND_ANY_HBS_REGEX = /{?{{([^{].*?)}}}?/g module.exports.FIND_TRIPLE_HBS_REGEX = /{{{([^{].*?)}}}/g +module.exports.isBackendService = () => { + return typeof window === "undefined" +} + +module.exports.isJSAllowed = () => { + return process && !process.env.NO_JS +} + // originally this could be done with a single regex using look behinds // but safari does not support this feature // original regex: /(? { + const utilities = jest.requireActual("../src/utilities") + return { + ...utilities, + isBackendService: jest.fn().mockReturnValue(true), + } +}) +const { defaultJSSetup, processStringSync, encodeJSBinding } = require("../src") +const { isBackendService } = require("../src/utilities") +const mockedBackendService = jest.mocked(isBackendService) + +const binding = encodeJSBinding("return 1") +describe("confirm VM is available when expected and when not", () => { + it("shouldn't have JS available in a backend service by default", () => { + defaultJSSetup() + const result = processStringSync(binding, {}) + // shouldn't process at all + expect(result).toBe(binding) + }) + + it("should have JS available in frontend environments", () => { + mockedBackendService.mockReturnValue(false) + defaultJSSetup() + const result = processStringSync(binding, {}) + expect(result).toBe(1) + }) +}) From f294497b4a9e82cb1da47d99183e576cf6e03e16 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 20 Feb 2024 17:38:33 +0100 Subject: [PATCH 05/33] Update submodule ref --- packages/account-portal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account-portal b/packages/account-portal index 8c446c4ba3..d643d74c57 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit 8c446c4ba385592127fa31755d3b64467b291882 +Subproject commit d643d74c577a2ddb782489a6907639461cbcc438 From 4e61230c9a30be5f1c024c050fa8c12c4e01bf94 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 20 Feb 2024 17:17:13 +0000 Subject: [PATCH 06/33] Removing unused function. --- packages/string-templates/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js index 2dc360bd96..0125b9e0ab 100644 --- a/packages/string-templates/src/index.js +++ b/packages/string-templates/src/index.js @@ -2,7 +2,7 @@ const vm = require("vm") const handlebars = require("handlebars") const { registerAll, registerMinimum } = require("./helpers/index") const processors = require("./processors") -const { atob, btoa, isBackendService, isJSAllowed } = require("./utilities") +const { atob, btoa, isBackendService } = require("./utilities") const manifest = require("../manifest.json") const { FIND_HBS_REGEX, From 41599540391cf8e5ef788ead457eb47088a4f23b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 20 Feb 2024 14:23:42 -0300 Subject: [PATCH 07/33] acct portal submodule --- packages/account-portal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account-portal b/packages/account-portal index d643d74c57..4384bc742c 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit d643d74c577a2ddb782489a6907639461cbcc438 +Subproject commit 4384bc742ca22fb1e9bf91843e65ae929daf17e2 From 2145480572549d2fb1590e98e3da4521cf5649e4 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 20 Feb 2024 18:09:43 +0000 Subject: [PATCH 08/33] Bump version to 2.20.4 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 1cba488aa3..41b473161a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.20.3", + "version": "2.20.4", "npmClient": "yarn", "packages": [ "packages/*", From dfb1774d2ce1044cd1c65e25e0f5ecd312d7bd0f Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 20 Feb 2024 16:32:55 -0300 Subject: [PATCH 09/33] bump default memory unit --- packages/server/src/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 873c392942..7842a9b3dc 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -27,7 +27,7 @@ const DEFAULTS = { TEMPLATE_REPOSITORY: "app", PLUGINS_DIR: "/plugins", FORKED_PROCESS_NAME: "main", - JS_RUNNER_MEMORY_LIMIT: 64, + JS_RUNNER_MEMORY_LIMIT: 96, } const QUERY_THREAD_TIMEOUT = From 73fe2e0d1d9ff4e8a5fc5a8f2cf3fded3304c16c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 20 Feb 2024 16:35:34 -0300 Subject: [PATCH 10/33] update JS per execution time --- packages/server/src/environment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts index 7842a9b3dc..f304ce4eb2 100644 --- a/packages/server/src/environment.ts +++ b/packages/server/src/environment.ts @@ -23,11 +23,11 @@ const DEFAULTS = { AUTOMATION_THREAD_TIMEOUT: 12000, AUTOMATION_SYNC_TIMEOUT: 120000, AUTOMATION_MAX_ITERATIONS: 200, - JS_PER_EXECUTION_TIME_LIMIT_MS: 1000, + JS_PER_EXECUTION_TIME_LIMIT_MS: 1500, TEMPLATE_REPOSITORY: "app", PLUGINS_DIR: "/plugins", FORKED_PROCESS_NAME: "main", - JS_RUNNER_MEMORY_LIMIT: 96, + JS_RUNNER_MEMORY_LIMIT: 64, } const QUERY_THREAD_TIMEOUT = From 033ab7110906144117990606063823506247c92d Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 20 Feb 2024 19:51:22 +0000 Subject: [PATCH 11/33] Bump version to 2.20.5 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 41b473161a..a62c15997d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.20.4", + "version": "2.20.5", "npmClient": "yarn", "packages": [ "packages/*", From e988890a7ee6ee9458218d913788101e2cf2b523 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 10:12:06 +0100 Subject: [PATCH 12/33] Remove defaultUserValues from test config --- .../src/tests/utilities/TestConfiguration.ts | 81 ++++++++----------- 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index ea3204536a..00550c2c24 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -76,14 +76,6 @@ mocks.licenses.useUnlimited() dbInit() -type DefaultUserValues = { - globalUserId: string - email: string - firstName: string - lastName: string - csrfToken: string -} - export interface TableToBuild extends Omit { sourceId?: string sourceType?: TableSourceType @@ -105,8 +97,8 @@ export default class TestConfiguration { automation: any datasource?: Datasource tenantId?: string - defaultUserValues: DefaultUserValues api: API + csrfToken?: string constructor(openServer = true) { if (openServer) { @@ -121,21 +113,10 @@ export default class TestConfiguration { } this.appId = null this.allApps = [] - this.defaultUserValues = this.populateDefaultUserValues() this.api = new API(this) } - populateDefaultUserValues(): DefaultUserValues { - return { - globalUserId: `us_${newid()}`, - email: generator.email(), - firstName: generator.first(), - lastName: generator.last(), - csrfToken: generator.hash(), - } - } - getRequest() { return this.request } @@ -160,15 +141,6 @@ export default class TestConfiguration { return this.prodAppId } - getUserDetails() { - return { - globalId: this.defaultUserValues.globalUserId, - email: this.defaultUserValues.email, - firstName: this.defaultUserValues.firstName, - lastName: this.defaultUserValues.lastName, - } - } - async doInContext( appId: string | null, task: () => Promise @@ -300,15 +272,27 @@ export default class TestConfiguration { } // USER / AUTH - async globalUser({ - id = this.defaultUserValues.globalUserId, - firstName = this.defaultUserValues.firstName, - lastName = this.defaultUserValues.lastName, - builder = true, - admin = false, - email = this.defaultUserValues.email, - roles, - }: any = {}): Promise { + async globalUser( + config: { + id?: string + firstName?: string + lastName?: string + builder?: boolean + admin?: boolean + email?: string + roles?: any + } = {} + ): Promise { + const { + id = `us_${newid()}`, + firstName = generator.first(), + lastName = generator.last(), + builder = true, + admin = false, + email, + roles, + } = config + const db = tenancy.getTenantDB(this.getTenantId()) let existing try { @@ -327,7 +311,7 @@ export default class TestConfiguration { await sessions.createASession(id, { sessionId: "sessionid", tenantId: this.getTenantId(), - csrfToken: this.defaultUserValues.csrfToken, + csrfToken: this.csrfToken, }) if (builder) { user.builder = { global: true } @@ -358,9 +342,9 @@ export default class TestConfiguration { } = {} ): Promise { let { id, firstName, lastName, email, builder, admin, roles } = user - firstName = firstName || this.defaultUserValues.firstName - lastName = lastName || this.defaultUserValues.lastName - email = email || this.defaultUserValues.email + ;(firstName = firstName || generator.first()), + (lastName = lastName || generator.last()), + (email = email || generator.email()) roles = roles || {} if (builder == null) { builder = true @@ -448,7 +432,7 @@ export default class TestConfiguration { defaultHeaders(extras = {}, prodApp = false) { const tenantId = this.getTenantId() const authObj: AuthToken = { - userId: this.defaultUserValues.globalUserId, + userId: this.user.globalUserId, sessionId: "sessionid", tenantId, } @@ -457,7 +441,7 @@ export default class TestConfiguration { const headers: any = { Accept: "application/json", Cookie: [`${constants.Cookie.Auth}=${authToken}`], - [constants.Header.CSRF_TOKEN]: this.defaultUserValues.csrfToken, + [constants.Header.CSRF_TOKEN]: this.csrfToken, Host: this.tenantHost(), ...extras, } @@ -487,7 +471,7 @@ export default class TestConfiguration { async basicRoleHeaders() { return await this.roleHeaders({ - email: this.defaultUserValues.email, + email: generator.email(), builder: false, prodApp: true, roleId: roles.BUILTIN_ROLE_IDS.BASIC, @@ -495,7 +479,7 @@ export default class TestConfiguration { } async roleHeaders({ - email = this.defaultUserValues.email, + email = generator.email(), roleId = roles.BUILTIN_ROLE_IDS.ADMIN, builder = false, prodApp = true, @@ -519,11 +503,12 @@ export default class TestConfiguration { } async newTenant(appName = newid()): Promise { - this.defaultUserValues = this.populateDefaultUserValues() this.tenantId = structures.tenant.id() this.user = await this.globalUser() this.globalUserId = this.user._id this.userMetadataId = generateUserMetadataID(this.globalUserId) + + this.csrfToken = generator.hash() return this.createApp(appName) } @@ -533,7 +518,7 @@ export default class TestConfiguration { // API - async generateApiKey(userId = this.defaultUserValues.globalUserId) { + async generateApiKey(userId = this.user.globalUserId) { const db = tenancy.getTenantDB(this.getTenantId()) const id = dbCore.generateDevInfoID(userId) let devInfo: any From f6e968efe848b568b8edeb59a17bf764e8a506a1 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 10:18:46 +0100 Subject: [PATCH 13/33] Fix test --- packages/server/src/sdk/users/tests/utils.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/server/src/sdk/users/tests/utils.spec.ts b/packages/server/src/sdk/users/tests/utils.spec.ts index 86dc411caf..efe790d49b 100644 --- a/packages/server/src/sdk/users/tests/utils.spec.ts +++ b/packages/server/src/sdk/users/tests/utils.spec.ts @@ -84,7 +84,8 @@ describe("syncGlobalUsers", () => { await syncGlobalUsers() const metadata = await rawUserMetadata() - expect(metadata).toHaveLength(2) + + expect(metadata).toHaveLength(2 + 1) // ADMIN user created in test bootstrap still in the application expect(metadata).toContainEqual( expect.objectContaining({ _id: db.generateUserMetadataID(user1._id!), @@ -121,7 +122,7 @@ describe("syncGlobalUsers", () => { await syncGlobalUsers() const metadata = await rawUserMetadata() - expect(metadata).toHaveLength(1) //ADMIN user created in test bootstrap still in the application + expect(metadata).toHaveLength(1) // ADMIN user created in test bootstrap still in the application }) }) }) From 0b5226413b7d76353685c1e70eb9eb18c1a7f922 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 10:36:17 +0100 Subject: [PATCH 14/33] Fix ids --- .../src/tests/utilities/TestConfiguration.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 00550c2c24..0204eeb178 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -91,7 +91,6 @@ export default class TestConfiguration { prodApp: any prodAppId: any user: any - globalUserId: any userMetadataId: any table?: Table automation: any @@ -100,6 +99,10 @@ export default class TestConfiguration { api: API csrfToken?: string + private get globalUserId() { + return this.user._id + } + constructor(openServer = true) { if (openServer) { // use a random port because it doesn't matter @@ -141,6 +144,15 @@ export default class TestConfiguration { return this.prodAppId } + getUserDetails() { + return { + globalId: this.globalUserId, + email: this.user.email, + firstName: this.user.firstName, + lastName: this.user.lastName, + } + } + async doInContext( appId: string | null, task: () => Promise @@ -432,7 +444,7 @@ export default class TestConfiguration { defaultHeaders(extras = {}, prodApp = false) { const tenantId = this.getTenantId() const authObj: AuthToken = { - userId: this.user.globalUserId, + userId: this.globalUserId, sessionId: "sessionid", tenantId, } @@ -505,8 +517,7 @@ export default class TestConfiguration { async newTenant(appName = newid()): Promise { this.tenantId = structures.tenant.id() this.user = await this.globalUser() - this.globalUserId = this.user._id - this.userMetadataId = generateUserMetadataID(this.globalUserId) + this.userMetadataId = generateUserMetadataID(this.user._id) this.csrfToken = generator.hash() return this.createApp(appName) @@ -518,7 +529,7 @@ export default class TestConfiguration { // API - async generateApiKey(userId = this.user.globalUserId) { + async generateApiKey(userId = this.user._id) { const db = tenancy.getTenantDB(this.getTenantId()) const id = dbCore.generateDevInfoID(userId) let devInfo: any From f7d5ccee3c95a68f406d3e3ced363dfd53cd50fb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 10:42:36 +0100 Subject: [PATCH 15/33] Fix setting up email --- packages/server/src/tests/utilities/TestConfiguration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 0204eeb178..5b20f83d77 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -301,7 +301,7 @@ export default class TestConfiguration { lastName = generator.last(), builder = true, admin = false, - email, + email = generator.email(), roles, } = config From f68e7359c6379096a55db163bb07bb4b6492853f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 10:57:49 +0100 Subject: [PATCH 16/33] Fix csrf usage --- packages/server/src/tests/utilities/TestConfiguration.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 5b20f83d77..bbe3260d26 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -515,11 +515,12 @@ export default class TestConfiguration { } async newTenant(appName = newid()): Promise { + this.csrfToken = generator.hash() + this.tenantId = structures.tenant.id() this.user = await this.globalUser() this.userMetadataId = generateUserMetadataID(this.user._id) - this.csrfToken = generator.hash() return this.createApp(appName) } From 73bf29ab3c0edab5615f56d65c6410fcaf1cdc4d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 11:22:43 +0100 Subject: [PATCH 17/33] Clean code --- .../src/tests/utilities/TestConfiguration.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index bbe3260d26..8e6ecdfeb1 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -353,14 +353,16 @@ export default class TestConfiguration { roles?: UserRoles } = {} ): Promise { - let { id, firstName, lastName, email, builder, admin, roles } = user - ;(firstName = firstName || generator.first()), - (lastName = lastName || generator.last()), - (email = email || generator.email()) - roles = roles || {} - if (builder == null) { - builder = true - } + const { + id, + firstName = generator.first(), + lastName = generator.last(), + email = generator.email(), + builder = true, + admin, + roles, + } = user + const globalId = !id ? `us_${Math.random()}` : `us_${id}` const resp = await this.globalUser({ id: globalId, @@ -369,7 +371,7 @@ export default class TestConfiguration { email, builder, admin, - roles, + roles: roles || {}, }) await cache.user.invalidateUser(globalId) return resp From f417c2d8a4d96cc958ecb3a35281030cfe6c1f2c Mon Sep 17 00:00:00 2001 From: Joe <49767913+joebudi@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:28:35 +0000 Subject: [PATCH 18/33] Joe's lab day minor updates (#12944) * Change default button type to CTA - change default button type to CTA - change ordering of types/variants * Fix layout shift within portal Within the portal, when navigating from screen to screen, there's a slight layout shift caused by the scrollbar. This is a small fix. * row/column icons change The current row/column icons for positioning components are confusing. I believe these icons are easier to understand. * Fix for horizontal scrollbar showing When adding/removing actions within automations, the horizontal scrollbar flashes. Fix. * Title change for Upload data Upload data is not wrong, but it's best to be explicit. * Increase size of upgrade button * small fix for the styling inconsistency * Dianostics padding fix * lint fix * update account-portal * update icons --------- Co-authored-by: melohagan <101575380+melohagan@users.noreply.github.com> Co-authored-by: Mel O'Hagan --- packages/bbui/src/Layout/Page.svelte | 1 + packages/bbui/src/Typography/Body.svelte | 6 +++++ packages/bbui/src/Typography/Heading.svelte | 4 +++ .../FlowChart/FlowChart.svelte | 1 + .../builder/app/[application]/data/new.svelte | 2 +- .../portal/_components/UpgradeButton.svelte | 4 +-- .../portal/settings/diagnostics.svelte | 9 ++++--- packages/client/manifest.json | 26 +++++++++---------- .../client/src/components/app/Button.svelte | 2 +- 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/packages/bbui/src/Layout/Page.svelte b/packages/bbui/src/Layout/Page.svelte index 57c264231b..2169a12459 100644 --- a/packages/bbui/src/Layout/Page.svelte +++ b/packages/bbui/src/Layout/Page.svelte @@ -43,6 +43,7 @@ flex-direction: row; justify-content: flex-start; align-items: stretch; + overflow-y: scroll !important; flex: 1 1 auto; overflow-x: hidden; } diff --git a/packages/bbui/src/Typography/Body.svelte b/packages/bbui/src/Typography/Body.svelte index 71b4dca248..2123eeee95 100644 --- a/packages/bbui/src/Typography/Body.svelte +++ b/packages/bbui/src/Typography/Body.svelte @@ -20,3 +20,9 @@ >

+ + diff --git a/packages/bbui/src/Typography/Heading.svelte b/packages/bbui/src/Typography/Heading.svelte index c0d0571143..50522fffc3 100644 --- a/packages/bbui/src/Typography/Heading.svelte +++ b/packages/bbui/src/Typography/Heading.svelte @@ -21,4 +21,8 @@ h1 { font-family: var(--font-accent); } + + h1 { + text-wrap: balance; + } diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index 4c458a5627..1ace6c0f00 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -130,6 +130,7 @@ flex-grow: 1; padding: 23px 23px 80px; box-sizing: border-box; + overflow-x: hidden; } .header.scrolling { diff --git a/packages/builder/src/pages/builder/app/[application]/data/new.svelte b/packages/builder/src/pages/builder/app/[application]/data/new.svelte index c07a9f563d..20efd3667b 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/new.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/new.svelte @@ -77,7 +77,7 @@ internalTableModal.show({ promptUpload: true })} - title="Upload data" + title="Upload CSV / JSON" description="Non-relational" {disabled} > diff --git a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte index b12efd6f03..59a791538a 100644 --- a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte +++ b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte @@ -10,7 +10,7 @@ {#if $admin.cloud && $auth?.user?.accountPortalAccess} + +
+ +
(showTooltip = true)} diff --git a/packages/bbui/src/IconPicker/IconPicker.svelte b/packages/bbui/src/IconPicker/IconPicker.svelte index b3cc72daa3..3cd7a16eb0 100644 --- a/packages/bbui/src/IconPicker/IconPicker.svelte +++ b/packages/bbui/src/IconPicker/IconPicker.svelte @@ -58,6 +58,8 @@ } + +
(open = true)}>
+ +
+ +
copyToClipboard(value)}> diff --git a/packages/bbui/src/List/ListItem.svelte b/packages/bbui/src/List/ListItem.svelte index 28015c4c57..76b242cf9c 100644 --- a/packages/bbui/src/List/ListItem.svelte +++ b/packages/bbui/src/List/ListItem.svelte @@ -15,6 +15,8 @@ $: initials = avatar ? title?.[0] : null + +
{#if icon} diff --git a/packages/bbui/src/Menu/Item.svelte b/packages/bbui/src/Menu/Item.svelte index ed759f5b10..05a33adda9 100644 --- a/packages/bbui/src/Menu/Item.svelte +++ b/packages/bbui/src/Menu/Item.svelte @@ -33,6 +33,7 @@ } +
  • + +
    Click me {remaining} diff --git a/packages/bbui/src/Modal/Modal.svelte b/packages/bbui/src/Modal/Modal.svelte index da97bf332e..f891d0584d 100644 --- a/packages/bbui/src/Modal/Modal.svelte +++ b/packages/bbui/src/Modal/Modal.svelte @@ -100,6 +100,7 @@ --> {#if visible} +
    + +
    + +