From 347b2abf4f5e6cfa65d29b3c24ebcf45c9ce51d8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 18 Jun 2021 18:07:51 +0100 Subject: [PATCH 1/7] Adding a server logging script for testing and updating automation script functionality so that you can use 'return trigger.row.firstName' and it'll function as expected. --- packages/server/src/api/controllers/script.js | 6 ++- packages/server/src/automations/actions.js | 3 ++ .../server/src/automations/steps/serverLog.js | 41 +++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 packages/server/src/automations/steps/serverLog.js diff --git a/packages/server/src/api/controllers/script.js b/packages/server/src/api/controllers/script.js index 3f110a2764..f312472801 100644 --- a/packages/server/src/api/controllers/script.js +++ b/packages/server/src/api/controllers/script.js @@ -3,13 +3,15 @@ const vm = require("vm") class ScriptExecutor { constructor(body) { - this.script = new vm.Script(body.script) + const code = `let fn = () => {\n${body.script}\n}; out = fn();` + this.script = new vm.Script(code) this.context = vm.createContext(body.context) this.context.fetch = fetch } execute() { - return this.script.runInContext(this.context) + this.script.runInContext(this.context) + return this.context.out } } diff --git a/packages/server/src/automations/actions.js b/packages/server/src/automations/actions.js index 762ce677a7..b0b5f9f1ba 100644 --- a/packages/server/src/automations/actions.js +++ b/packages/server/src/automations/actions.js @@ -7,6 +7,7 @@ const executeScript = require("./steps/executeScript") const bash = require("./steps/bash") const executeQuery = require("./steps/executeQuery") const outgoingWebhook = require("./steps/outgoingWebhook") +const serverLog = require("./steps/serverLog") const env = require("../environment") const Sentry = require("@sentry/node") const { @@ -24,6 +25,7 @@ const BUILTIN_ACTIONS = { EXECUTE_SCRIPT: executeScript.run, EXECUTE_BASH: bash.run, EXECUTE_QUERY: executeQuery.run, + SERVER_LOG: serverLog.run, } const BUILTIN_DEFINITIONS = { SEND_EMAIL: sendgridEmail.definition, @@ -35,6 +37,7 @@ const BUILTIN_DEFINITIONS = { EXECUTE_SCRIPT: executeScript.definition, EXECUTE_QUERY: executeQuery.definition, EXECUTE_BASH: bash.definition, + SERVER_LOG: serverLog.definition, } let MANIFEST = null diff --git a/packages/server/src/automations/steps/serverLog.js b/packages/server/src/automations/steps/serverLog.js new file mode 100644 index 0000000000..a98e87235c --- /dev/null +++ b/packages/server/src/automations/steps/serverLog.js @@ -0,0 +1,41 @@ +/** + * Note, there is some functionality in this that is not currently exposed as it + * is complex and maybe better to be opinionated here. + * GET/DELETE requests cannot handle body elements so they will not be sent if configured. + */ + +module.exports.definition = { + name: "Backend log", + tagline: "Console log a value in the backend", + icon: "ri-server-line", + description: "Logs the given text to the server (using console.log)", + type: "ACTION", + stepId: "SERVER_LOG", + inputs: { + text: "", + }, + schema: { + inputs: { + properties: { + text: { + type: "string", + title: "URL", + }, + }, + required: ["text"], + }, + outputs: { + properties: { + success: { + type: "boolean", + description: "Whether the action was successful", + }, + }, + required: ["success"], + }, + }, +} + +module.exports.run = async function ({ inputs, appId }) { + console.log(`App ${appId} - ${inputs.text}`) +} \ No newline at end of file From 9afd7fb57a7abf694a05272154cff8c1dddf72ef Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 18 Jun 2021 18:34:58 +0100 Subject: [PATCH 2/7] Linting. --- packages/server/src/automations/steps/serverLog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/automations/steps/serverLog.js b/packages/server/src/automations/steps/serverLog.js index a98e87235c..c28309c5c8 100644 --- a/packages/server/src/automations/steps/serverLog.js +++ b/packages/server/src/automations/steps/serverLog.js @@ -38,4 +38,4 @@ module.exports.definition = { module.exports.run = async function ({ inputs, appId }) { console.log(`App ${appId} - ${inputs.text}`) -} \ No newline at end of file +} From 052d14ad38335ee0c50fafa6630d29c543026901 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Sun, 20 Jun 2021 10:53:55 +0100 Subject: [PATCH 3/7] Fixing issue with 1:N relationships and multiple fields, issue #1753. --- packages/server/src/db/linkedRows/LinkController.js | 4 ++-- packages/worker/src/api/routes/tests/realEmail.spec.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index 53ce8e45ad..cba4386105 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -211,14 +211,14 @@ class LinkController { // iterate through the link IDs in the row field, see if any don't exist already for (let linkId of rowField) { if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) { - const links = ( + let links = ( await getLinkDocuments({ appId: this._appId, tableId: field.tableId, rowId: linkId, includeDocs: IncludeDocs.EXCLUDE, }) - ).filter(link => link.id !== row._id) + ).filter(link => link.id !== row._id && link.fieldName === linkedSchema.name) // The 1 side of 1:N is already related to something else // You must remove the existing relationship diff --git a/packages/worker/src/api/routes/tests/realEmail.spec.js b/packages/worker/src/api/routes/tests/realEmail.spec.js index 8c23141a53..acc0c7acc9 100644 --- a/packages/worker/src/api/routes/tests/realEmail.spec.js +++ b/packages/worker/src/api/routes/tests/realEmail.spec.js @@ -53,7 +53,6 @@ describe("/api/admin/email", () => { it("should be able to send a welcome email", async () => { await sendRealEmail(EmailTemplatePurpose.WELCOME) - }) it("should be able to send a invitation email", async () => { From 47fb67ebfcee14b7a2a0cb73bc6f24140792c2e7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Sun, 20 Jun 2021 10:55:12 +0100 Subject: [PATCH 4/7] Linting. --- packages/server/src/db/linkedRows/LinkController.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index cba4386105..c8331dec6b 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -218,7 +218,10 @@ class LinkController { rowId: linkId, includeDocs: IncludeDocs.EXCLUDE, }) - ).filter(link => link.id !== row._id && link.fieldName === linkedSchema.name) + ).filter( + link => + link.id !== row._id && link.fieldName === linkedSchema.name + ) // The 1 side of 1:N is already related to something else // You must remove the existing relationship From 744dd2b77707a3c974c74c6c82010a6433e07e21 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Sun, 20 Jun 2021 10:15:48 +0000 Subject: [PATCH 5/7] v0.9.52 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index de9808a223..466e9a4cca 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.51", + "version": "0.9.52", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 0cf7ae32e5..a148960511 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.51", + "version": "0.9.52", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 3325b23087..8853193c6c 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.51", + "version": "0.9.52", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 76a13ef3de..cde4e9dd12 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.51", + "version": "0.9.52", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.51", - "@budibase/client": "^0.9.51", + "@budibase/bbui": "^0.9.52", + "@budibase/client": "^0.9.52", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.51", + "@budibase/string-templates": "^0.9.52", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 829c173036..125bd5fafe 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.51", + "version": "0.9.52", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 15d4e62a63..93654bb01a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.51", + "version": "0.9.52", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.51", - "@budibase/standard-components": "^0.9.51", - "@budibase/string-templates": "^0.9.51", + "@budibase/bbui": "^0.9.52", + "@budibase/standard-components": "^0.9.52", + "@budibase/string-templates": "^0.9.52", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 8564e15e37..54c845f5d7 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.51", + "version": "0.9.52", "description": "Budibase Web Server", "main": "src/electron.js", "repository": { @@ -55,9 +55,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.51", - "@budibase/client": "^0.9.51", - "@budibase/string-templates": "^0.9.51", + "@budibase/auth": "^0.9.52", + "@budibase/client": "^0.9.52", + "@budibase/string-templates": "^0.9.52", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -109,7 +109,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.51", + "@budibase/standard-components": "^0.9.52", "@jest/test-sequencer": "^24.8.0", "babel-jest": "^27.0.2", "docker-compose": "^0.23.6", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 068ef3ea94..b0833da238 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.51", + "version": "0.9.52", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.51", + "@budibase/bbui": "^0.9.52", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", "apexcharts": "^3.22.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 05939e7ef0..418fa3ecb0 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.51", + "version": "0.9.52", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 0789625567..711279bad9 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.51", + "version": "0.9.52", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.51", - "@budibase/string-templates": "^0.9.51", + "@budibase/auth": "^0.9.52", + "@budibase/string-templates": "^0.9.52", "@koa/router": "^8.0.0", "aws-sdk": "^2.811.0", "bcryptjs": "^2.4.3", From 3df9de2a63b5bdacad8ec798b774491805efc7d7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Sun, 20 Jun 2021 17:36:28 +0100 Subject: [PATCH 6/7] use internal port for watchtower to fix updating through budibase UI --- hosting/envoy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosting/envoy.yaml b/hosting/envoy.yaml index 20e912434a..d7b34f4d5e 100644 --- a/hosting/envoy.yaml +++ b/hosting/envoy.yaml @@ -139,5 +139,5 @@ static_resources: address: socket_address: address: watchtower-service - port_value: 6161 + port_value: 8080 From 5dcc469e8c3abd203d28239bb04a844314b0beca Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Sun, 20 Jun 2021 16:45:30 +0000 Subject: [PATCH 7/7] v0.9.53 --- lerna.json | 2 +- packages/auth/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 8 ++++---- packages/server/package.json | 10 +++++----- packages/standard-components/package.json | 4 ++-- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lerna.json b/lerna.json index 466e9a4cca..297aaa41be 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.52", + "version": "0.9.53", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index a148960511..5fbde7f1b8 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.52", + "version": "0.9.53", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 8853193c6c..847a310c96 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.52", + "version": "0.9.53", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index cde4e9dd12..4cebeed1c8 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.52", + "version": "0.9.53", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.52", - "@budibase/client": "^0.9.52", + "@budibase/bbui": "^0.9.53", + "@budibase/client": "^0.9.53", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.52", + "@budibase/string-templates": "^0.9.53", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 125bd5fafe..143fdebd10 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.52", + "version": "0.9.53", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 93654bb01a..6fc386b053 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.52", + "version": "0.9.53", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,9 +18,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^0.9.52", - "@budibase/standard-components": "^0.9.52", - "@budibase/string-templates": "^0.9.52", + "@budibase/bbui": "^0.9.53", + "@budibase/standard-components": "^0.9.53", + "@budibase/string-templates": "^0.9.53", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 54c845f5d7..25cfe508b6 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.9.52", + "version": "0.9.53", "description": "Budibase Web Server", "main": "src/electron.js", "repository": { @@ -55,9 +55,9 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.52", - "@budibase/client": "^0.9.52", - "@budibase/string-templates": "^0.9.52", + "@budibase/auth": "^0.9.53", + "@budibase/client": "^0.9.53", + "@budibase/string-templates": "^0.9.53", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -109,7 +109,7 @@ "devDependencies": { "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", - "@budibase/standard-components": "^0.9.52", + "@budibase/standard-components": "^0.9.53", "@jest/test-sequencer": "^24.8.0", "babel-jest": "^27.0.2", "docker-compose": "^0.23.6", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index b0833da238..19c448799d 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.52", + "version": "0.9.53", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.52", + "@budibase/bbui": "^0.9.53", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", "apexcharts": "^3.22.1", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 418fa3ecb0..fd1d0f44c0 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.52", + "version": "0.9.53", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 711279bad9..6cb480acd2 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.9.52", + "version": "0.9.53", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -21,8 +21,8 @@ "author": "Budibase", "license": "AGPL-3.0-or-later", "dependencies": { - "@budibase/auth": "^0.9.52", - "@budibase/string-templates": "^0.9.52", + "@budibase/auth": "^0.9.53", + "@budibase/string-templates": "^0.9.53", "@koa/router": "^8.0.0", "aws-sdk": "^2.811.0", "bcryptjs": "^2.4.3",