diff --git a/lerna.json b/lerna.json index bf193f9a81..90690dbf98 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.8.16", + "version": "0.8.18", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/builder/package.json b/packages/builder/package.json index 6422d8f686..7d86c79c70 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.8.16", + "version": "0.8.18", "license": "AGPL-3.0", "private": true, "scripts": { @@ -66,9 +66,9 @@ }, "dependencies": { "@budibase/bbui": "^1.58.13", - "@budibase/client": "^0.8.16", + "@budibase/client": "^0.8.18", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.8.16", + "@budibase/string-templates": "^0.8.18", "@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 65513ae33c..0630d0b0c9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "cli", - "version": "0.8.15", + "version": "0.8.18", "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 b96c20a2f2..f5f4632de9 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.8.16", + "version": "0.8.18", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,7 +18,7 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/string-templates": "^0.8.16", + "@budibase/string-templates": "^0.8.18", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" @@ -26,7 +26,7 @@ "devDependencies": { "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", - "@budibase/standard-components": "^0.8.16", + "@budibase/standard-components": "^0.8.18", "fs-extra": "^8.1.0", "jsdom": "^16.0.1", "postcss": "^8.2.9", diff --git a/packages/server/package.json b/packages/server/package.json index cc2f642792..d16368a144 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "0.8.16", + "version": "0.8.18", "description": "Budibase Web Server", "main": "src/electron.js", "repository": { @@ -80,8 +80,8 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@budibase/auth": "^0.18.6", - "@budibase/client": "^0.8.16", - "@budibase/string-templates": "^0.8.16", + "@budibase/client": "^0.8.18", + "@budibase/string-templates": "^0.8.18", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -131,7 +131,7 @@ "zlib": "1.0.5" }, "devDependencies": { - "@budibase/standard-components": "^0.8.16", + "@budibase/standard-components": "^0.8.18", "@jest/test-sequencer": "^24.8.0", "docker-compose": "^0.23.6", "eslint": "^6.8.0", diff --git a/packages/server/src/api/controllers/query.js b/packages/server/src/api/controllers/query.js index d239ac0177..cd3dcbd305 100644 --- a/packages/server/src/api/controllers/query.js +++ b/packages/server/src/api/controllers/query.js @@ -119,9 +119,8 @@ exports.preview = async function (ctx) { const enrichedQuery = await enrichQueryFields(fields, parameters) - const rows = formatResponse( - await new Integration(datasource.config)[queryVerb](enrichedQuery) - ) + const integration = new Integration(datasource.config) + const rows = formatResponse(await integration[queryVerb](enrichedQuery)) // get all the potential fields in the schema const keys = rows.flatMap(Object.keys) @@ -130,6 +129,10 @@ exports.preview = async function (ctx) { rows, schemaFields: [...new Set(keys)], } + // cleanup + if (integration.end) { + integration.end() + } } exports.execute = async function (ctx) { @@ -149,10 +152,13 @@ exports.execute = async function (ctx) { ctx.request.body.parameters ) + const integration = new Integration(datasource.config) // call the relevant CRUD method on the integration class - ctx.body = formatResponse( - await new Integration(datasource.config)[query.queryVerb](enrichedQuery) - ) + ctx.body = formatResponse(await integration[query.queryVerb](enrichedQuery)) + // cleanup + if (integration.end) { + integration.end() + } } exports.destroy = async function (ctx) { diff --git a/packages/server/src/db/dynamoClient.js b/packages/server/src/db/dynamoClient.js index 19924b1a7e..58e469f80d 100644 --- a/packages/server/src/db/dynamoClient.js +++ b/packages/server/src/db/dynamoClient.js @@ -2,6 +2,7 @@ let { merge } = require("lodash") let env = require("../environment") const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1" +exports.AWS_REGION = AWS_REGION const TableInfo = { API_KEYS: { diff --git a/packages/server/src/integrations/dynamodb.js b/packages/server/src/integrations/dynamodb.js index 4897690075..8e74b84c6d 100644 --- a/packages/server/src/integrations/dynamodb.js +++ b/packages/server/src/integrations/dynamodb.js @@ -1,5 +1,6 @@ const AWS = require("aws-sdk") const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") +const { AWS_REGION } = require("../db/dynamoClient") const SCHEMA = { docs: "https://github.com/dabit3/dynamodb-documentclient-cheat-sheet", @@ -16,7 +17,7 @@ const SCHEMA = { type: FIELD_TYPES.PASSWORD, required: true, }, - secretKey: { + secretAccessKey: { type: FIELD_TYPES.PASSWORD, required: true, }, @@ -114,10 +115,22 @@ class DynamoDBIntegration { }) } - async connect() { + end() { + this.disconnect() + } + + connect() { AWS.config.update(this.config) } + disconnect() { + AWS.config.update({ + secretAccessKey: undefined, + accessKeyId: undefined, + region: AWS_REGION, + }) + } + async create(query) { const params = { TableName: query.table, diff --git a/packages/server/src/tests/utilities/TestConfiguration.js b/packages/server/src/tests/utilities/TestConfiguration.js index ac26600681..60e503c128 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.js +++ b/packages/server/src/tests/utilities/TestConfiguration.js @@ -306,11 +306,7 @@ class TestConfiguration { return await this._req(config, null, controllers.layout.save) } - async createUser( - email = EMAIL, - password = PASSWORD, - roleId = BUILTIN_ROLE_IDS.POWER - ) { + async createUser(roleId = BUILTIN_ROLE_IDS.POWER) { const globalId = `us_${Math.random()}` const resp = await this.globalUser( globalId, diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 48c966f558..6d58d25144 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,7 +29,7 @@ "keywords": [ "svelte" ], - "version": "0.8.16", + "version": "0.8.18", "license": "MIT", "gitHead": "4b6efc42ed3273595c7a129411f4d883733d3321", "dependencies": { diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index c5ebe0f995..5e8e06bc33 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.8.16", + "version": "0.8.18", "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 6d68f3ff1b..45d2ea7311 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "0.8.16", + "version": "0.8.18", "description": "Budibase background service", "main": "src/index.js", "repository": {