diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index 14c32b1bba..39a8dc52af 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -24,6 +24,21 @@ http { default "upgrade"; } + upstream app-service { + server {{address}}:4001; + keepalive 32; + } + + upstream worker-service { + server {{address}}:4002; + keepalive 32; + } + + upstream builder { + server {{address}}:3000; + keepalive 32; + } + server { listen 10000 default_server; server_name _; @@ -43,45 +58,78 @@ http { } location ~ ^/api/(system|admin|global)/ { - proxy_pass http://{{ address }}:4002; + proxy_pass http://worker-service; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + proxy_http_version 1.1; + proxy_set_header Connection ""; } location /api/ { proxy_read_timeout 120s; proxy_connect_timeout 120s; proxy_send_timeout 120s; - proxy_pass http://{{ address }}:4001; + proxy_pass http://app-service; + proxy_http_version 1.1; + proxy_set_header Connection ""; } location = / { - proxy_pass http://{{ address }}:4001; + proxy_pass http://app-service; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + proxy_http_version 1.1; + proxy_set_header Connection ""; } location /app_ { - proxy_pass http://{{ address }}:4001; + proxy_pass http://app-service; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + proxy_http_version 1.1; + proxy_set_header Connection ""; } location /app { - proxy_pass http://{{ address }}:4001; + proxy_pass http://app-service; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + proxy_http_version 1.1; + proxy_set_header Connection ""; } location /builder { - proxy_pass http://{{ address }}:3000; + proxy_pass http://builder; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; + proxy_http_version 1.1; + proxy_set_header Connection ""; rewrite ^/builder(.*)$ /builder/$1 break; } location /builder/ { - proxy_pass http://{{ address }}:3000; + proxy_pass http://builder; proxy_http_version 1.1; proxy_set_header Connection $connection_upgrade; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; } location /vite/ { - proxy_pass http://{{ address }}:3000; + proxy_pass http://builder; + proxy_read_timeout 120s; + proxy_connect_timeout 120s; + proxy_send_timeout 120s; rewrite ^/vite(.*)$ /$1 break; } @@ -91,7 +139,7 @@ http { proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; - proxy_pass http://{{ address }}:4001; + proxy_pass http://app-service; } location / { diff --git a/lerna.json b/lerna.json index d31cde4be4..5600db4cf3 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.0.30-alpha.7", + "version": "2.0.30-alpha.12", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 69d4968e81..3ca2281bd2 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "2.0.30-alpha.7", + "version": "2.0.30-alpha.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,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "2.0.30-alpha.7", + "@budibase/types": "2.0.30-alpha.12", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", @@ -64,7 +64,7 @@ }, "devDependencies": { "@types/chance": "1.1.3", - "@types/ioredis": "4.28.10", + "@types/ioredis": "4.28.0", "@types/jest": "27.5.1", "@types/koa": "2.0.52", "@types/lodash": "4.14.180", diff --git a/packages/backend-core/src/events/publishers/backup.ts b/packages/backend-core/src/events/publishers/backup.ts index bd346cad64..0fc81da259 100644 --- a/packages/backend-core/src/events/publishers/backup.ts +++ b/packages/backend-core/src/events/publishers/backup.ts @@ -1,8 +1,8 @@ -import { AppBackup, AppBackupRevertEvent, Event } from "@budibase/types" +import { AppBackup, AppBackupRestoreEvent, Event } from "@budibase/types" import { publishEvent } from "../events" export async function appBackupRestored(backup: AppBackup) { - const properties: AppBackupRevertEvent = { + const properties: AppBackupRestoreEvent = { appId: backup.appId, backupName: backup.name!, backupCreatedAt: backup.timestamp, diff --git a/packages/backend-core/src/queue/listeners.ts b/packages/backend-core/src/queue/listeners.ts index f264c3a84c..e1975b5d06 100644 --- a/packages/backend-core/src/queue/listeners.ts +++ b/packages/backend-core/src/queue/listeners.ts @@ -6,18 +6,18 @@ export type StalledFn = (job: Job) => Promise export function addListeners( queue: Queue, jobQueue: JobQueue, - removeStalled?: StalledFn + removeStalledCb?: StalledFn ) { logging(queue, jobQueue) - if (removeStalled) { - handleStalled(queue, removeStalled) + if (removeStalledCb) { + handleStalled(queue, removeStalledCb) } } -function handleStalled(queue: Queue, removeStalled?: StalledFn) { +function handleStalled(queue: Queue, removeStalledCb?: StalledFn) { queue.on("stalled", async (job: Job) => { - if (removeStalled) { - await removeStalled(job) + if (removeStalledCb) { + await removeStalledCb(job) } else if (job.opts.repeat) { const jobId = job.id const repeatJobs = await queue.getRepeatableJobs() diff --git a/packages/backend-core/src/queue/queue.ts b/packages/backend-core/src/queue/queue.ts index 7eaafe38a8..b4eeeb31aa 100644 --- a/packages/backend-core/src/queue/queue.ts +++ b/packages/backend-core/src/queue/queue.ts @@ -4,7 +4,7 @@ import { JobQueue } from "./constants" import InMemoryQueue from "./inMemoryQueue" import BullQueue from "bull" import { addListeners, StalledFn } from "./listeners" -const { opts, redisProtocolUrl } = getRedisOptions() +const { opts: redisOpts, redisProtocolUrl } = getRedisOptions() const CLEANUP_PERIOD_MS = 60 * 1000 let QUEUES: BullQueue.Queue[] | InMemoryQueue[] = [] @@ -18,16 +18,16 @@ async function cleanup() { export function createQueue( jobQueue: JobQueue, - removeStalled?: StalledFn + opts: { removeStalledCb?: StalledFn } = {} ): BullQueue.Queue { - const queueConfig: any = redisProtocolUrl || { redis: opts } + const queueConfig: any = redisProtocolUrl || { redis: redisOpts } let queue: any if (!env.isTest()) { queue = new BullQueue(jobQueue, queueConfig) } else { queue = new InMemoryQueue(jobQueue, queueConfig) } - addListeners(queue, jobQueue, removeStalled) + addListeners(queue, jobQueue, opts?.removeStalledCb) QUEUES.push(queue) if (!cleanupInterval) { cleanupInterval = setInterval(cleanup, CLEANUP_PERIOD_MS) diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index d2831ca8fe..d301526ba1 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -291,11 +291,6 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/types@2.0.30-alpha.3": - version "2.0.30-alpha.3" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.0.30-alpha.3.tgz#cb55bcced75b711cc8a675284fbacaa8ebf1c0f2" - integrity sha512-rHeFVuNbSSE4fMnX6uyrM2r47m+neqFXlVNOkhHU9i7KoIcIZbEYInU8CjUFR2da3ruST9ajXjJ5UenX2+MnTg== - "@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" @@ -698,14 +693,6 @@ "@types/connect" "*" "@types/node" "*" -"@types/bull@^3.15.9": - version "3.15.9" - resolved "https://registry.yarnpkg.com/@types/bull/-/bull-3.15.9.tgz#e10e0901ec3762bff85716b3c580277960751c93" - integrity sha512-MPUcyPPQauAmynoO3ezHAmCOhbB0pWmYyijr/5ctaCqhbKWsjW0YCod38ZcLzUBprosfZ9dPqfYIcfdKjk7RNQ== - dependencies: - "@types/ioredis" "*" - "@types/redis" "^2.8.0" - "@types/chance@1.1.3": version "1.1.3" resolved "https://registry.yarnpkg.com/@types/chance/-/chance-1.1.3.tgz#d19fe9391288d60fdccd87632bfc9ab2b4523fea" @@ -776,10 +763,10 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.2.tgz#7315b4c4c54f82d13fa61c228ec5c2ea5cc9e0e1" integrity sha512-EqX+YQxINb+MeXaIqYDASb6U6FCHbWjkj4a1CKDBks3d/QiB2+PqBLyO72vLDgAO1wUI4O+9gweRcQK11bTL/w== -"@types/ioredis@*", "@types/ioredis@^4.28.10": - version "4.28.10" - resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff" - integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ== +"@types/ioredis@4.28.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.0.tgz#609b2ea0d91231df2dd7f67dd77436bc72584911" + integrity sha512-HSA/JQivJgV0e+353gvgu6WVoWvGRe0HyHOnAN2AvbVIhUlJBhNnnkP8gEEokrDWrxywrBkwo8NuDZ6TVPL9XA== dependencies: "@types/node" "*" @@ -1547,7 +1534,7 @@ buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" -bull@^4.10.1: +bull@4.10.1: version "4.10.1" resolved "https://registry.yarnpkg.com/bull/-/bull-4.10.1.tgz#f14974b6089358b62b495a2cbf838aadc098e43f" integrity sha512-Fp21tRPb2EaZPVfmM+ONZKVz2RA+to+zGgaTLyCKt3JMSU8OOBqK8143OQrnGuGpsyE5G+9FevFAGhdZZfQP2g== diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 7d1ac8bbf6..65da2c2cea 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": "2.0.30-alpha.7", + "version": "2.0.30-alpha.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": "2.0.30-alpha.7", + "@budibase/string-templates": "2.0.30-alpha.12", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/bbui/src/Actions/click_outside.js b/packages/bbui/src/Actions/click_outside.js index 49a15d36a3..7fd2879071 100644 --- a/packages/bbui/src/Actions/click_outside.js +++ b/packages/bbui/src/Actions/click_outside.js @@ -1,18 +1,18 @@ export default function clickOutside(element, callbackFunction) { function onClick(event) { if (!element.contains(event.target)) { - callbackFunction() + callbackFunction(event) } } - document.body.addEventListener("mousedown", onClick, true) + document.body.addEventListener("click", onClick, true) return { update(newCallbackFunction) { callbackFunction = newCallbackFunction }, destroy() { - document.body.removeEventListener("mousedown", onClick, true) + document.body.removeEventListener("click", onClick, true) }, } } diff --git a/packages/bbui/src/ColorPicker/ColorPicker.svelte b/packages/bbui/src/ColorPicker/ColorPicker.svelte index 52a877415b..331de38371 100644 --- a/packages/bbui/src/ColorPicker/ColorPicker.svelte +++ b/packages/bbui/src/ColorPicker/ColorPicker.svelte @@ -119,6 +119,13 @@ return "var(--spectrum-global-color-static-gray-900)" } + + const handleOutsideClick = event => { + if (open) { + event.stopPropagation() + open = false + } + }
@@ -131,7 +138,7 @@
{#if open}
(open = false)} + use:clickOutside={handleOutsideClick} transition:fly={{ y: -20, duration: 200 }} class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" class:spectrum-Popover--align-right={alignRight} diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte index d80ca98153..16d13ef2cc 100644 --- a/packages/bbui/src/Form/Core/Picker.svelte +++ b/packages/bbui/src/Form/Core/Picker.svelte @@ -85,7 +85,7 @@ class:is-invalid={!!error} class:is-open={open} aria-haspopup="listbox" - on:mousedown={onClick} + on:click={onClick} > {#if fieldIcon} diff --git a/packages/bbui/src/Form/Core/PickerDropdown.svelte b/packages/bbui/src/Form/Core/PickerDropdown.svelte index 1607876b46..604e446099 100644 --- a/packages/bbui/src/Form/Core/PickerDropdown.svelte +++ b/packages/bbui/src/Form/Core/PickerDropdown.svelte @@ -87,6 +87,20 @@ updateValue(event.target.value) } } + + const handlePrimaryOutsideClick = event => { + if (primaryOpen) { + event.stopPropagation() + primaryOpen = false + } + } + + const handleSecondaryOutsideClick = event => { + if (secondaryOpen) { + event.stopPropagation() + secondaryOpen = false + } + }
{#if primaryOpen}
(primaryOpen = false)} + use:clickOutside={handlePrimaryOutsideClick} transition:fly|local={{ y: -20, duration: 200 }} class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" class:auto-width={autoWidth} @@ -256,7 +270,7 @@ {disabled} class:is-open={secondaryOpen} aria-haspopup="listbox" - on:mousedown={onClickSecondary} + on:click={onClickSecondary} > {#if secondaryFieldIcon} @@ -281,7 +295,7 @@ {#if secondaryOpen}
(secondaryOpen = false)} + use:clickOutside={handleSecondaryOutsideClick} transition:fly|local={{ y: -20, duration: 200 }} class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" style="width: 30%" diff --git a/packages/bbui/src/IconPicker/IconPicker.svelte b/packages/bbui/src/IconPicker/IconPicker.svelte index 0e71be2c33..2b42da61b1 100644 --- a/packages/bbui/src/IconPicker/IconPicker.svelte +++ b/packages/bbui/src/IconPicker/IconPicker.svelte @@ -50,6 +50,13 @@ dispatch("change", value) open = false } + + const handleOutsideClick = event => { + if (open) { + event.stopPropagation() + open = false + } + }
@@ -64,7 +71,7 @@
{#if open}
(open = false)} + use:clickOutside={handleOutsideClick} transition:fly={{ y: -20, duration: 200 }} class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" class:spectrum-Popover--align-right={alignRight} diff --git a/packages/bbui/src/Popover/Popover.svelte b/packages/bbui/src/Popover/Popover.svelte index ded0ed6cfd..b81e76dc1f 100644 --- a/packages/bbui/src/Popover/Popover.svelte +++ b/packages/bbui/src/Popover/Popover.svelte @@ -33,6 +33,13 @@ open = false } + const handleOutsideClick = e => { + if (open) { + e.stopPropagation() + hide() + } + } + let open = null function handleEscape(e) { @@ -47,7 +54,7 @@