This commit is contained in:
Martin McKeaveney 2022-09-07 23:31:24 +01:00
commit 4b82f8f3fd
36 changed files with 249 additions and 132 deletions

View File

@ -78,6 +78,7 @@ services:
image: budibase/proxy
environment:
- PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND=10
- PROXY_RATE_LIMIT_API_PER_SECOND=20
depends_on:
- minio-service
- worker-service

View File

@ -65,10 +65,6 @@ http {
proxy_pass http://{{ address }}:4001;
}
location /preview {
proxy_pass http://{{ address }}:4001;
}
location /builder {
proxy_pass http://{{ address }}:3000;
rewrite ^/builder(.*)$ /builder/$1 break;

View File

@ -11,7 +11,7 @@ events {
http {
# rate limiting
limit_req_status 429;
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=20r/s;
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=${PROXY_RATE_LIMIT_API_PER_SECOND}r/s;
limit_req_zone $binary_remote_addr zone=webhooks:10m rate=${PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND}r/s;
include /etc/nginx/mime.types;
@ -88,10 +88,6 @@ http {
proxy_pass http://$apps:4002;
}
location /preview {
proxy_pass http://$apps:4002;
}
location = / {
proxy_pass http://$apps:4002;
}

View File

@ -11,3 +11,4 @@ COPY error.html /usr/share/nginx/html/error.html
# Default environment
ENV PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND=10
ENV PROXY_RATE_LIMIT_API_PER_SECOND=20

View File

@ -4,9 +4,9 @@ echo ${TARGETBUILD} > /buildtarget.txt
if [[ "${TARGETBUILD}" = "aas" ]]; then
# Azure AppService uses /home for persisent data & SSH on port 2222
DATA_DIR=/home
mkdir -p $DATA_DIR/{search,minio,couchdb}
mkdir -p $DATA_DIR/couchdb/{dbs,views}
chown -R couchdb:couchdb $DATA_DIR/couchdb/
mkdir -p $DATA_DIR/{search,minio,couch}
mkdir -p $DATA_DIR/couch/{dbs,views}
chown -R couchdb:couchdb $DATA_DIR/couch/
apt update
apt-get install -y openssh-server
sed -i "s/#Port 22/Port 2222/" /etc/ssh/sshd_config
@ -16,5 +16,4 @@ if [[ "${TARGETBUILD}" = "aas" ]]; then
else
sed -i "s#DATA_DIR#/data#g" /opt/clouseau/clouseau.ini
sed -i "s#DATA_DIR#/data#g" /opt/couchdb/etc/local.ini
fi

View File

@ -1,5 +1,5 @@
; CouchDB Configuration Settings
[couchdb]
database_dir = DATA_DIR/couchdb/dbs
view_index_dir = DATA_DIR/couchdb/views
database_dir = DATA_DIR/couch/dbs
view_index_dir = DATA_DIR/couch/views

View File

@ -36,10 +36,10 @@ fi
export COUCH_DB_URL=http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984
# make these directories in runner, incase of mount
mkdir -p ${DATA_DIR}/couchdb/{dbs,views}
mkdir -p ${DATA_DIR}/couch/{dbs,views}
mkdir -p ${DATA_DIR}/minio
mkdir -p ${DATA_DIR}/search
chown -R couchdb:couchdb ${DATA_DIR}/couchdb
chown -R couchdb:couchdb ${DATA_DIR}/couch
redis-server --requirepass $REDIS_PASSWORD &
/opt/clouseau/bin/clouseau &
/minio/minio server ${DATA_DIR}/minio &

View File

@ -1,5 +1,5 @@
{
"version": "1.2.59",
"version": "1.3.12",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -20,7 +20,8 @@
"test:watch": "jest --watchAll"
},
"dependencies": {
"@budibase/types": "^1.2.59",
"@budibase/types": "^1.3.12",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",
@ -60,7 +61,6 @@
]
},
"devDependencies": {
"@shopify/jest-koa-mocks": "3.1.5",
"@types/jest": "27.5.1",
"@types/koa": "2.0.52",
"@types/lodash": "4.14.180",

View File

@ -543,13 +543,13 @@
semver "^7.3.5"
tar "^6.1.11"
"@shopify/jest-koa-mocks@3.1.5":
version "3.1.5"
resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-3.1.5.tgz#11f77ccfbcaf35cf5ee2c6108a286e61e6bea084"
integrity sha512-gQ3/7ELerv00TWO37AGFX5mT9CsFCS+3/UbKMuoIlKEU0QH2OX8BV9WBf/EKw7adCDNlxss0lqV6J8kf5pgr4A==
"@shopify/jest-koa-mocks@5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-5.0.1.tgz#fba490b6b7985fbb571eb9974897d396a3642e94"
integrity sha512-4YskS9q8+TEHNoyopmuoy2XyhInyqeOl7CF5ShJs19sm6m0EA/jGGvgf/osv2PeTfuf42/L2G9CzWUSg49yTSg==
dependencies:
koa "^2.13.4"
node-mocks-http "^1.5.8"
node-mocks-http "^1.11.0"
"@sideway/address@^4.1.3":
version "4.1.4"
@ -3914,7 +3914,7 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==
node-mocks-http@^1.5.8:
node-mocks-http@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/node-mocks-http/-/node-mocks-http-1.11.0.tgz#defc0febf6b935f08245397d47534a8de592996e"
integrity sha512-jS/WzSOcKbOeGrcgKbenZeNhxUNnP36Yw11+hL4TTxQXErGfqYZ+MaYNNvhaTiGIJlzNSqgQkk9j8dSu1YWSuw==

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.2.59",
"version": "1.3.12",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.2.59",
"@budibase/string-templates": "^1.3.12",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.2.59",
"version": "1.3.12",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -69,10 +69,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^1.2.59",
"@budibase/client": "^1.2.59",
"@budibase/frontend-core": "^1.2.59",
"@budibase/string-templates": "^1.2.59",
"@budibase/bbui": "^1.3.12",
"@budibase/client": "^1.3.12",
"@budibase/frontend-core": "^1.3.12",
"@budibase/string-templates": "^1.3.12",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -290,7 +290,7 @@
<iframe
title="componentPreview"
bind:this={iframe}
src="/preview"
src="/app/preview"
class:hidden={loading || error}
class:tablet={$store.previewDevice === "tablet"}
class:mobile={$store.previewDevice === "mobile"}

View File

@ -54,7 +54,7 @@
},
}
const handleKeyAction = async (component, key, ctrlKey = false) => {
const handleKeyAction = async (event, component, key, ctrlKey = false) => {
if (!component || !key) {
return false
}
@ -70,6 +70,9 @@
const handler = keyHandlers[key]
if (!handler) {
return false
} else if (event) {
event.preventDefault()
event.stopPropagation()
}
return handler(component)
} catch (error) {
@ -89,14 +92,19 @@
return
}
// Key events are always for the selected component
return handleKeyAction($selectedComponent, e.key, e.ctrlKey || e.metaKey)
return await handleKeyAction(
e,
$selectedComponent,
e.key,
e.ctrlKey || e.metaKey
)
}
const handleComponentMenu = async e => {
// Menu events can be for any component
const { id, key, ctrlKey } = e.detail
const component = findComponent($selectedScreen.props, id)
return await handleKeyAction(component, key, ctrlKey)
return await handleKeyAction(null, component, key, ctrlKey)
}
onMount(() => {

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {
@ -26,7 +26,7 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "1.2.58-alpha.7",
"@budibase/backend-core": "^1.3.12",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.2.59",
"version": "1.3.12",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.2.59",
"@budibase/frontend-core": "^1.2.59",
"@budibase/string-templates": "^1.2.59",
"@budibase/bbui": "^1.3.12",
"@budibase/frontend-core": "^1.3.12",
"@budibase/string-templates": "^1.3.12",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -3,7 +3,7 @@
import Component from "./Component.svelte"
import Provider from "./context/Provider.svelte"
import { onMount, getContext } from "svelte"
import { enrichButtonActions } from "utils/buttonActions.js"
import { enrichButtonActions } from "../utils/buttonActions.js"
export let params = {}
@ -29,8 +29,10 @@
...$context,
url: params,
})
if (actions != null) {
actions()
}
}
})
</script>

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "^1.2.59",
"@budibase/bbui": "^1.3.12",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -77,11 +77,11 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "^1.2.59",
"@budibase/client": "^1.2.59",
"@budibase/pro": "1.2.59",
"@budibase/string-templates": "^1.2.59",
"@budibase/types": "^1.2.59",
"@budibase/backend-core": "^1.3.12",
"@budibase/client": "^1.3.12",
"@budibase/pro": "1.3.12",
"@budibase/string-templates": "^1.3.12",
"@budibase/types": "^1.3.12",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -56,7 +56,7 @@ router
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
controller.deleteObjects
)
.get("/preview", authorized(BUILDER), controller.serveBuilderPreview)
.get("/app/preview", authorized(BUILDER), controller.serveBuilderPreview)
.get("/:appId/:path*", controller.serveApp)
.get("/app/:appUrl/:path*", controller.serveApp)
.post(

View File

@ -150,14 +150,14 @@ describe("/static", () => {
})
})
describe("/preview", () => {
describe("/app/preview", () => {
beforeEach(() => {
jest.clearAllMocks()
})
it("should serve the builder preview", async () => {
const headers = config.defaultHeaders()
const res = await request.get(`/preview`).set(headers).expect(200)
const res = await request.get(`/app/preview`).set(headers).expect(200)
expect(res.body.appId).toBe(config.appId)
expect(res.body.builderPreview).toBe(true)

View File

@ -379,7 +379,8 @@ module GoogleSheetsModule {
const rows = await sheet.getRows()
const row = rows[query.rowIndex]
if (row) {
const updateValues = query.row
const updateValues =
typeof query.row === "string" ? JSON.parse(query.row) : query.row
for (let key in updateValues) {
row[key] = updateValues[key]
}

View File

@ -132,12 +132,22 @@ module RedisModule {
async command(query: { json: string }) {
return this.redisContext(async () => {
const commands = query.json.trim().split(" ")
const pipeline = this.client.pipeline([commands])
const result = await pipeline.exec()
return {
response: result[0][1],
// commands split line by line
const commands = query.json.trim().split("\n")
let pipelineCommands = []
// process each command separately
for (let command of commands) {
const tokenised = command.trim().split(" ")
// Pipeline only accepts lower case commands
tokenised[0] = tokenised[0].toLowerCase()
pipelineCommands.push(tokenised)
}
const pipeline = this.client.pipeline(pipelineCommands)
const result = await pipeline.exec()
return result.map((output: string | string[]) => output[1])
})
}
}

View File

@ -46,7 +46,7 @@ describe("Redis Integration", () => {
expect(await config.redis.get(body.key)).toEqual(null)
})
it("calls the command method with the correct params", async () => {
it("calls the pipeline method with the correct params", async () => {
const body = {
json: "KEYS *"
}
@ -55,6 +55,21 @@ describe("Redis Integration", () => {
config.integration.client.pipeline = jest.fn(() => ({ exec: jest.fn(() => [[]]) }))
await config.integration.command(body)
expect(config.integration.client.pipeline).toHaveBeenCalledWith([["KEYS", "*"]])
expect(config.integration.client.pipeline).toHaveBeenCalledWith([["keys", "*"]])
})
it("calls the pipeline method with several separated commands when there are newlines", async () => {
const body = {
json: 'SET foo "bar"\nGET foo'
}
// ioredis-mock doesn't support pipelines
config.integration.client.pipeline = jest.fn(() => ({ exec: jest.fn(() => [[]]) }))
await config.integration.command(body)
expect(config.integration.client.pipeline).toHaveBeenCalledWith([
["set", 'foo', '"bar"'],
["get", 'foo']
])
})
})

View File

@ -19,6 +19,7 @@
"exclude": [
"node_modules",
"dist",
"src/tests",
"**/*.spec.ts",
"**/*.spec.js"
]

View File

@ -1094,12 +1094,13 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.59.tgz#283b4c8bb24c4deacc28b3fb10dfb59d0e63e6ac"
integrity sha512-QC/ftdhdIQPTFbbGG4c5F7BqwPBQpevzj21GuYNbMda3OQPn6nS5SKK0fP99/DRSf9WIRi+5Pg1fzlHg2DIQLA==
"@budibase/backend-core@1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12.tgz#dd5fbfe791b46343e783b9b23ff6f6e22d77ce1c"
integrity sha512-+fRBrf66peeNXzY5WA3y7Dz6Gl6EUYQI0/zswCddtZhs5+x1cFJZLLRu2V1MFJ41z+cNiw0Pru1XrDRcQX7aMw==
dependencies:
"@budibase/types" "^1.2.59"
"@budibase/types" "^1.3.12"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1178,13 +1179,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.59.tgz#2f266d9ede1f722d879841fdb8da1a98a0628136"
integrity sha512-QwNRb5JT+SZaES3sUFxxQA6Ep2dH/fVqXrnzKPV/CoMa43YWkjOUTX2hjgmOWDsipBK90RK3wRYzcTG0BgEkJw==
"@budibase/pro@1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12.tgz#8a92d98e297375bdd6e311ffb8002f13c3af909f"
integrity sha512-luKQPVyiIxu4Jjq1zw2W2YfkJwC9hDq/lEQfMhbwMDfROZ9opbwokg37SVWbYzqqt8NrQ1uZFt5ieWHF937NoA==
dependencies:
"@budibase/backend-core" "1.2.59"
"@budibase/types" "1.2.59"
"@budibase/backend-core" "1.3.12"
"@budibase/types" "1.3.12"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
@ -1207,10 +1208,10 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@1.2.59", "@budibase/types@^1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.59.tgz#e2a04f7fffcb68bd2cd12043430c0bf0db07ae71"
integrity sha512-2DpKE7NMGh2th/obOjT32uxLpQjyGLVQ925yM164pSvfZUyNA3zkQhOmNoMS9HJVHVavHyHVfSgGDQrF0YfNhA==
"@budibase/types@1.3.12", "@budibase/types@^1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12.tgz#5d6cef221085a8ac1c348afa151684a2cebab4bd"
integrity sha512-c+TXAu7j9PeH7o4lOE57fPXj9uJf7MzwJxYvjD0fT962zzCgtseeK9XhD0zF8HERoBc01V3ooNniUWT9llC/Ew==
"@bull-board/api@3.7.0":
version "3.7.0"
@ -2274,6 +2275,14 @@
"@sentry/types" "6.17.7"
tslib "^1.9.3"
"@shopify/jest-koa-mocks@5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-5.0.1.tgz#fba490b6b7985fbb571eb9974897d396a3642e94"
integrity sha512-4YskS9q8+TEHNoyopmuoy2XyhInyqeOl7CF5ShJs19sm6m0EA/jGGvgf/osv2PeTfuf42/L2G9CzWUSg49yTSg==
dependencies:
koa "^2.13.4"
node-mocks-http "^1.11.0"
"@sideway/address@^4.1.3":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
@ -3283,7 +3292,7 @@ abstract-leveldown@~6.2.1, abstract-leveldown@~6.2.3:
level-supports "~1.0.0"
xtend "~4.0.0"
accepts@^1.3.5:
accepts@^1.3.5, accepts@^1.3.7:
version "1.3.8"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==
@ -4838,7 +4847,7 @@ container-info@^1.0.1:
resolved "https://registry.yarnpkg.com/container-info/-/container-info-1.1.0.tgz#6fcb94e93eacd397c6316ca2834491ede44e55ee"
integrity sha512-eD2zLAmxGS2kmL4f1jY8BdOqnmpL6X70kvzTBW/9FIQnxoxiBJ4htMsTmtPLPWRs7NHYFvqKQ1VtppV08mdsQA==
content-disposition@^0.5.2, content-disposition@~0.5.2:
content-disposition@^0.5.2, content-disposition@^0.5.3, content-disposition@~0.5.2:
version "0.5.4"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"
integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==
@ -5290,7 +5299,7 @@ depd@2.0.0, depd@^2.0.0, depd@~2.0.0:
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
depd@^1.1.2, depd@~1.1.2:
depd@^1.1.0, depd@^1.1.2, depd@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==
@ -6615,7 +6624,7 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"
fresh@~0.5.2:
fresh@^0.5.2, fresh@~0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==
@ -9458,7 +9467,7 @@ koa@2.7.0:
type-is "^1.6.16"
vary "^1.1.2"
koa@^2.13.1:
koa@^2.13.1, koa@^2.13.4:
version "2.13.4"
resolved "https://registry.yarnpkg.com/koa/-/koa-2.13.4.tgz#ee5b0cb39e0b8069c38d115139c774833d32462e"
integrity sha512-43zkIKubNbnrULWlHdN5h1g3SEKXOEzoAlRsHOTFpnlDu8JlAOZSMJBLULusuXRequboiwJcj5vtYXKB3k7+2g==
@ -10037,6 +10046,11 @@ memorystream@0.3.1:
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==
merge-descriptors@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
@ -10440,6 +10454,22 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==
node-mocks-http@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/node-mocks-http/-/node-mocks-http-1.11.0.tgz#defc0febf6b935f08245397d47534a8de592996e"
integrity sha512-jS/WzSOcKbOeGrcgKbenZeNhxUNnP36Yw11+hL4TTxQXErGfqYZ+MaYNNvhaTiGIJlzNSqgQkk9j8dSu1YWSuw==
dependencies:
accepts "^1.3.7"
content-disposition "^0.5.3"
depd "^1.1.0"
fresh "^0.5.2"
merge-descriptors "^1.0.1"
methods "^1.1.2"
mime "^1.3.4"
parseurl "^1.3.3"
range-parser "^1.2.0"
type-is "^1.6.18"
node-releases@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.5.tgz#280ed5bc3eba0d96ce44897d8aee478bfb3d9666"
@ -10986,7 +11016,7 @@ parse5@6.0.1:
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==
parseurl@^1.3.2:
parseurl@^1.3.2, parseurl@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"
integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
@ -11845,6 +11875,11 @@ randombytes@^2.1.0:
dependencies:
safe-buffer "^5.1.0"
range-parser@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
raw-body@^2.2.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857"
@ -13893,7 +13928,7 @@ type-fest@^0.8.1:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
type-is@^1.6.14, type-is@^1.6.16:
type-is@^1.6.14, type-is@^1.6.16, type-is@^1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.2.59",
"version": "1.3.12",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.2.59",
"version": "1.3.12",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -36,10 +36,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.2.59",
"@budibase/pro": "1.2.59",
"@budibase/string-templates": "^1.2.59",
"@budibase/types": "^1.2.59",
"@budibase/backend-core": "^1.3.12",
"@budibase/pro": "1.3.12",
"@budibase/string-templates": "^1.3.12",
"@budibase/types": "^1.3.12",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View File

@ -1,6 +1,7 @@
const { StaticDatabases, doWithDB } = require("@budibase/backend-core/db")
const { getTenantId } = require("@budibase/backend-core/tenancy")
const { deleteTenant } = require("@budibase/backend-core/deprovision")
const { quotas } = require("@budibase/pro")
exports.exists = async ctx => {
const tenantId = ctx.request.params
@ -48,6 +49,7 @@ exports.delete = async ctx => {
try {
await deleteTenant(tenantId)
await quotas.bustCache()
ctx.status = 204
} catch (err) {
ctx.log.error(err)

View File

@ -47,10 +47,7 @@ describe("accounts", () => {
const response = await api.accounts.destroyMetadata(id)
expect(response.status).toBe(404)
expect(response.body.message).toBe(
`id=${accounts.formatAccountMetadataId(id)} does not exist`
)
expect(response.status).toBe(204)
})
})
})

View File

@ -46,8 +46,14 @@ export const destroyMetadata = async (accountId: string) => {
await db.doWithDB(StaticDatabases.PLATFORM_INFO.name, async (db: any) => {
const metadata = await getMetadata(accountId)
if (!metadata) {
throw new HTTPError(`id=${accountId} does not exist`, 404)
return
}
try {
await db.remove(accountId, metadata._rev)
} catch (e: any) {
if (e.status !== 404) {
throw e
}
}
})
}

View File

@ -189,23 +189,34 @@ export const save = async (
const tenantId = tenancy.getTenantId()
const db = tenancy.getGlobalDB()
let { email, _id } = user
if (!email && !_id) {
throw new Error("_id or email is required")
}
let dbUser: User | undefined
if (_id) {
// try to get existing user from db
try {
dbUser = (await db.get(_id)) as User
if (email && dbUser.email !== email) {
throw "Email address cannot be changed"
}
email = dbUser.email
} else if (email) {
} catch (e: any) {
if (e.status === 404) {
// do nothing, save this new user with the id specified - required for SSO auth
} else {
throw e
}
}
}
if (!dbUser && email) {
// no id was specified - load from email instead
dbUser = await usersCore.getGlobalUserByEmail(email)
if (dbUser && dbUser._id !== _id) {
throw `Unavailable`
}
} else {
throw new Error("_id or email is required")
}
await validateUniqueUser(email, tenantId)

View File

@ -19,6 +19,7 @@
"exclude": [
"node_modules",
"dist",
"src/tests",
"**/*.spec.ts",
"**/*.spec.js"
]

View File

@ -291,12 +291,13 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.59.tgz#283b4c8bb24c4deacc28b3fb10dfb59d0e63e6ac"
integrity sha512-QC/ftdhdIQPTFbbGG4c5F7BqwPBQpevzj21GuYNbMda3OQPn6nS5SKK0fP99/DRSf9WIRi+5Pg1fzlHg2DIQLA==
"@budibase/backend-core@1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12.tgz#dd5fbfe791b46343e783b9b23ff6f6e22d77ce1c"
integrity sha512-+fRBrf66peeNXzY5WA3y7Dz6Gl6EUYQI0/zswCddtZhs5+x1cFJZLLRu2V1MFJ41z+cNiw0Pru1XrDRcQX7aMw==
dependencies:
"@budibase/types" "^1.2.59"
"@budibase/types" "^1.3.12"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -325,21 +326,21 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.59.tgz#2f266d9ede1f722d879841fdb8da1a98a0628136"
integrity sha512-QwNRb5JT+SZaES3sUFxxQA6Ep2dH/fVqXrnzKPV/CoMa43YWkjOUTX2hjgmOWDsipBK90RK3wRYzcTG0BgEkJw==
"@budibase/pro@1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12.tgz#8a92d98e297375bdd6e311ffb8002f13c3af909f"
integrity sha512-luKQPVyiIxu4Jjq1zw2W2YfkJwC9hDq/lEQfMhbwMDfROZ9opbwokg37SVWbYzqqt8NrQ1uZFt5ieWHF937NoA==
dependencies:
"@budibase/backend-core" "1.2.59"
"@budibase/types" "1.2.59"
"@budibase/backend-core" "1.3.12"
"@budibase/types" "1.3.12"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
"@budibase/types@1.2.59", "@budibase/types@^1.2.59":
version "1.2.59"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.59.tgz#e2a04f7fffcb68bd2cd12043430c0bf0db07ae71"
integrity sha512-2DpKE7NMGh2th/obOjT32uxLpQjyGLVQ925yM164pSvfZUyNA3zkQhOmNoMS9HJVHVavHyHVfSgGDQrF0YfNhA==
"@budibase/types@1.3.12", "@budibase/types@^1.3.12":
version "1.3.12"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12.tgz#5d6cef221085a8ac1c348afa151684a2cebab4bd"
integrity sha512-c+TXAu7j9PeH7o4lOE57fPXj9uJf7MzwJxYvjD0fT962zzCgtseeK9XhD0zF8HERoBc01V3ooNniUWT9llC/Ew==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"
@ -741,6 +742,14 @@
"@sentry/types" "6.17.7"
tslib "^1.9.3"
"@shopify/jest-koa-mocks@5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-5.0.1.tgz#fba490b6b7985fbb571eb9974897d396a3642e94"
integrity sha512-4YskS9q8+TEHNoyopmuoy2XyhInyqeOl7CF5ShJs19sm6m0EA/jGGvgf/osv2PeTfuf42/L2G9CzWUSg49yTSg==
dependencies:
koa "^2.13.4"
node-mocks-http "^1.11.0"
"@sideway/address@^4.1.3":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0"
@ -1208,7 +1217,7 @@ abstract-leveldown@~6.2.1, abstract-leveldown@~6.2.3:
level-supports "~1.0.0"
xtend "~4.0.0"
accepts@^1.3.5:
accepts@^1.3.5, accepts@^1.3.7:
version "1.3.8"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==
@ -2054,7 +2063,7 @@ container-info@^1.0.1:
resolved "https://registry.yarnpkg.com/container-info/-/container-info-1.1.0.tgz#6fcb94e93eacd397c6316ca2834491ede44e55ee"
integrity sha512-eD2zLAmxGS2kmL4f1jY8BdOqnmpL6X70kvzTBW/9FIQnxoxiBJ4htMsTmtPLPWRs7NHYFvqKQ1VtppV08mdsQA==
content-disposition@~0.5.2:
content-disposition@^0.5.3, content-disposition@~0.5.2:
version "0.5.4"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"
integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==
@ -2308,7 +2317,7 @@ depd@2.0.0, depd@^2.0.0, depd@~2.0.0:
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
depd@^1.1.2, depd@~1.1.2:
depd@^1.1.0, depd@^1.1.2, depd@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==
@ -3045,7 +3054,7 @@ forwarded-parse@^2.1.0:
resolved "https://registry.yarnpkg.com/forwarded-parse/-/forwarded-parse-2.1.2.tgz#08511eddaaa2ddfd56ba11138eee7df117a09325"
integrity sha512-alTFZZQDKMporBH77856pXgzhEzaUVmLCDk+egLgIgHst3Tpndzz8MnKe+GzRJRfvVdn69HhpW7cmXzvtLvJAw==
fresh@~0.5.2:
fresh@^0.5.2, fresh@~0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==
@ -4653,7 +4662,7 @@ koa-static@5.0.0:
debug "^3.1.0"
koa-send "^5.0.0"
koa@2.13.4:
koa@2.13.4, koa@^2.13.4:
version "2.13.4"
resolved "https://registry.yarnpkg.com/koa/-/koa-2.13.4.tgz#ee5b0cb39e0b8069c38d115139c774833d32462e"
integrity sha512-43zkIKubNbnrULWlHdN5h1g3SEKXOEzoAlRsHOTFpnlDu8JlAOZSMJBLULusuXRequboiwJcj5vtYXKB3k7+2g==
@ -5000,6 +5009,11 @@ memdown@1.4.1:
ltgt "~2.2.0"
safe-buffer "~5.1.1"
merge-descriptors@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
@ -5040,7 +5054,7 @@ mime@2.6.0:
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
mime@^1.4.1:
mime@^1.3.4, mime@^1.4.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
@ -5201,6 +5215,22 @@ node-int64@^0.4.0:
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==
node-mocks-http@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/node-mocks-http/-/node-mocks-http-1.11.0.tgz#defc0febf6b935f08245397d47534a8de592996e"
integrity sha512-jS/WzSOcKbOeGrcgKbenZeNhxUNnP36Yw11+hL4TTxQXErGfqYZ+MaYNNvhaTiGIJlzNSqgQkk9j8dSu1YWSuw==
dependencies:
accepts "^1.3.7"
content-disposition "^0.5.3"
depd "^1.1.0"
fresh "^0.5.2"
merge-descriptors "^1.0.1"
methods "^1.1.2"
mime "^1.3.4"
parseurl "^1.3.3"
range-parser "^1.2.0"
type-is "^1.6.18"
node-releases@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.5.tgz#280ed5bc3eba0d96ce44897d8aee478bfb3d9666"
@ -5468,7 +5498,7 @@ parse5@6.0.1:
resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==
parseurl@^1.3.2:
parseurl@^1.3.2, parseurl@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"
integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
@ -6061,6 +6091,11 @@ quick-lru@^5.1.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932"
integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==
range-parser@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
raw-body@^2.2.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857"
@ -7168,7 +7203,7 @@ type-fest@^0.8.1:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
type-is@^1.6.14, type-is@^1.6.16:
type-is@^1.6.14, type-is@^1.6.16, type-is@^1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==