diff --git a/LICENSE b/LICENSE index 9a75fba1f..a6bd92602 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,12 @@ -Copyright 2019-2021, Budibase Ltd +Copyright 2019-2021, Budibase Inc. Each Budibase package has its own license: -builder: AGPLv3 +builder: GPLv3 server: GPLv3 client: MPLv2.0 standard-components: MPLv2.0 + +You can consider Budibase to be GPLv3 licensed. + +The apps that you build with Budibase do not fall under GPLv3 - hence why our components and client library are licensed differently. diff --git a/README.md b/README.md index 4d87e531e..d5eba7132 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@

- +

@@ -43,7 +43,7 @@

- Sign-up + Get started · Docs · @@ -70,7 +70,7 @@ - **Automate processes, integrate with other tools, and connect to webhooks.** Save time by automating manual processes and workflows. From connecting to webhooks, to automating emails, simply tell Budibase what to do and let it work for you. You can easily [create new automations for Budibase here](https://github.com/Budibase/automations) or [request new integrations here](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).

- Budibase design ui + Budibase design ui

diff --git a/lerna.json b/lerna.json index 3379d3f3d..fec1d92e0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.12", + "version": "0.9.19", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 4c4b0ed92..5b4d65966 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.12", + "version": "0.9.19", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/auth/src/middleware/passport/google.js b/packages/auth/src/middleware/passport/google.js index 407772ebf..96a090753 100644 --- a/packages/auth/src/middleware/passport/google.js +++ b/packages/auth/src/middleware/passport/google.js @@ -2,20 +2,26 @@ const env = require("../../environment") const jwt = require("jsonwebtoken") const database = require("../../db") const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy -const { StaticDatabases, generateGlobalUserID } = require("../../db/utils") +const { + StaticDatabases, + generateGlobalUserID, + ViewNames, +} = require("../../db/utils") async function authenticate(token, tokenSecret, profile, done) { // Check the user exists in the instance DB by email const db = database.getDB(StaticDatabases.GLOBAL.name) let dbUser + const userId = generateGlobalUserID(profile.id) try { // use the google profile id dbUser = await db.get(userId) } catch (err) { - console.error("Google user not found. Creating..") + console.log("Google user not found. Creating..") + // create the user const user = { _id: userId, @@ -26,6 +32,26 @@ async function authenticate(token, tokenSecret, profile, done) { }, ...profile._json, } + + // check if an account with the google email address exists locally + const users = await db.query(`database/${ViewNames.USER_BY_EMAIL}`, { + key: profile._json.email, + include_docs: true, + }) + + // Google user already exists by email + if (users.rows.length > 0) { + const existing = users.rows[0].doc + + // remove the local account to avoid conflicts + await db.remove(existing._id, existing._rev) + + // merge with existing account + user.roles = existing.roles + user.builder = existing.builder + user.admin = existing.admin + } + const response = await db.post(user) dbUser = user diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 3f65ca296..5dc733ef3 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.12", + "version": "0.9.19", "license": "AGPL-3.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/LICENSE.md b/packages/builder/LICENSE.md index 08979af1b..7c4a69f39 100644 --- a/packages/builder/LICENSE.md +++ b/packages/builder/LICENSE.md @@ -1,21 +1,23 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright 2019-2021, Budibase Ltd + Copyright 2019-2021, Budibase Inc Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to +the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free -software for all its users. +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you @@ -24,34 +26,44 @@ them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. @@ -60,7 +72,7 @@ modification follow. 0. Definitions. - "This License" refers to version 3 of the GNU Affero General Public License. + "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. @@ -537,45 +549,35 @@ to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. + 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single +under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General +Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published +GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's +versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. @@ -633,29 +635,40 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. + GNU General Public License for more details. - You should have received a copy of the GNU Affero General Public License + You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see +For more information on this, and how to apply and follow the GNU GPL, see . + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/packages/builder/assets/bb-emblem.svg b/packages/builder/assets/bb-emblem.svg new file mode 100644 index 000000000..9f4f3690d --- /dev/null +++ b/packages/builder/assets/bb-emblem.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/package.json b/packages/builder/package.json index 72035ea38..122dcff31 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.12", + "version": "0.9.19", "license": "AGPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.12", - "@budibase/client": "^0.9.12", + "@budibase/bbui": "^0.9.19", + "@budibase/client": "^0.9.19", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.12", + "@budibase/string-templates": "^0.9.19", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index 5dd63fdae..078dbf25b 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -25,7 +25,7 @@ {:else if type === "attachment"} {:else if type === "boolean"} - + {:else if type === "link"} {:else if type === "longform"} diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index f5f6da7d8..00e53a8c6 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -291,7 +291,7 @@ /> {#if relationshipOptions && relationshipOptions.length > 0} - import { Label, Input, Layout } from "@budibase/bbui" + import { Label, Input, Layout, Toggle } from "@budibase/bbui" import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte" import { capitalise } from "helpers" @@ -16,6 +16,11 @@ defaults={schema[configKey].default} bind:object={integration[configKey]} /> + {:else if schema[configKey].type === "boolean"} +
+ + +
{:else}
diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/LuceneFilterBuilder.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/LuceneFilterBuilder.svelte index 5017d39d4..53242f5e9 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/LuceneFilterBuilder.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/FilterEditor/LuceneFilterBuilder.svelte @@ -195,10 +195,10 @@ /> {:else if expression.type === "boolean"} diff --git a/packages/builder/src/pages/builder/admin/index.svelte b/packages/builder/src/pages/builder/admin/index.svelte index 96f0b5467..b49152e2e 100644 --- a/packages/builder/src/pages/builder/admin/index.svelte +++ b/packages/builder/src/pages/builder/admin/index.svelte @@ -11,7 +11,7 @@ import api from "builderStore/api" import { admin } from "stores/portal" import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" let adminUser = {} let error diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index ae11cf0c1..8c8bcbf38 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -6,7 +6,7 @@ import RevertModal from "components/deploy/RevertModal.svelte" import { get } from "builderStore/api" import { isActive, goto, layout } from "@roxi/routify" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" import { capitalise } from "helpers" // Get Package and set store diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index 6f8827677..afe3296f2 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -13,13 +13,13 @@ } from "@budibase/bbui" import { onMount } from "svelte" import { apps, organisation, auth } from "stores/portal" - import { goto } from "@roxi/routify" + import { goto, redirect } from "@roxi/routify" import { AppStatus } from "constants" import { gradient } from "actions" import UpdateUserInfoModal from "components/settings/UpdateUserInfoModal.svelte" import ChangePasswordModal from "components/settings/ChangePasswordModal.svelte" import { processStringSync } from "@budibase/string-templates" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" let loaded = false let userInfoModal @@ -28,10 +28,17 @@ onMount(async () => { await organisation.init() await apps.load() - loaded = true + // Skip the portal if you only have one app + if (!$auth.isBuilder && $apps.filter(publishedAppsOnly).length === 1) { + window.location = `/${publishedApps[0].prodId}` + } else { + loaded = true + } }) - $: publishedApps = $apps.filter(app => app.status === AppStatus.DEPLOYED) + const publishedAppsOnly = app => app.status === AppStatus.DEPLOYED + + $: publishedApps = $apps.filter(publishedAppsOnly) {#if $auth.user && loaded} diff --git a/packages/builder/src/pages/builder/auth/_layout.svelte b/packages/builder/src/pages/builder/auth/_layout.svelte index ac224a41d..eb9e229a9 100644 --- a/packages/builder/src/pages/builder/auth/_layout.svelte +++ b/packages/builder/src/pages/builder/auth/_layout.svelte @@ -7,12 +7,12 @@ // Check this onMount rather than a reactive statement to avoid trumping // the login return URL functionality. onMount(() => { - if ($auth.user) { + if ($auth.user && !$auth.user.forceResetPassword) { $redirect("../") } }) -{#if !$auth.user} +{#if !$auth.user || $auth.user.forceResetPassword} {/if} diff --git a/packages/builder/src/pages/builder/auth/forgot.svelte b/packages/builder/src/pages/builder/auth/forgot.svelte index f56293313..4552774ff 100644 --- a/packages/builder/src/pages/builder/auth/forgot.svelte +++ b/packages/builder/src/pages/builder/auth/forgot.svelte @@ -8,7 +8,7 @@ Heading, } from "@budibase/bbui" import { organisation, auth } from "stores/portal" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" let email = "" diff --git a/packages/builder/src/pages/builder/auth/login.svelte b/packages/builder/src/pages/builder/auth/login.svelte index 734a26cbf..14ce47da8 100644 --- a/packages/builder/src/pages/builder/auth/login.svelte +++ b/packages/builder/src/pages/builder/auth/login.svelte @@ -12,7 +12,7 @@ import { goto, params } from "@roxi/routify" import { auth } from "stores/portal" import GoogleButton from "./_components/GoogleButton.svelte" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" let username = "" let password = "" diff --git a/packages/builder/src/pages/builder/auth/reset.svelte b/packages/builder/src/pages/builder/auth/reset.svelte index e3e6ab42d..aed2034af 100644 --- a/packages/builder/src/pages/builder/auth/reset.svelte +++ b/packages/builder/src/pages/builder/auth/reset.svelte @@ -3,7 +3,7 @@ import { goto, params } from "@roxi/routify" import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte" import { auth } from "stores/portal" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" const resetCode = $params["?code"] let password, error diff --git a/packages/builder/src/pages/builder/invite/index.svelte b/packages/builder/src/pages/builder/invite/index.svelte index fb1a5b828..a8eb9e83c 100644 --- a/packages/builder/src/pages/builder/invite/index.svelte +++ b/packages/builder/src/pages/builder/invite/index.svelte @@ -3,7 +3,7 @@ import { goto, params } from "@roxi/routify" import { users } from "stores/portal" import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" const inviteCode = $params["?code"] let password, error diff --git a/packages/builder/src/pages/builder/portal/_layout.svelte b/packages/builder/src/pages/builder/portal/_layout.svelte index ba5da18d9..0f691a33b 100644 --- a/packages/builder/src/pages/builder/portal/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/_layout.svelte @@ -15,7 +15,7 @@ import { onMount } from "svelte" import UpdateUserInfoModal from "components/settings/UpdateUserInfoModal.svelte" import ChangePasswordModal from "components/settings/ChangePasswordModal.svelte" - import Logo from "assets/bb-space-black.svg" + import Logo from "assets/bb-emblem.svg" let loaded = false let userInfoModal diff --git a/packages/cli/package.json b/packages/cli/package.json index 17dc4b7f9..be5956cf1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "0.9.12", + "version": "0.9.19", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/LICENSE b/packages/client/LICENSE index fd445efb1..2f05846f4 100644 --- a/packages/client/LICENSE +++ b/packages/client/LICENSE @@ -1,7 +1,7 @@ Mozilla Public License Version 2.0 ================================== -Copyright 2019-2021, Budibase Ltd +Copyright 2019-2021, Budibase Inc 1. Definitions -------------- diff --git a/packages/client/package.json b/packages/client/package.json index 8b93dd33e..8f6462ada 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "0.9.12", + "version": "0.9.19", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -18,13 +18,13 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/string-templates": "^0.9.12", + "@budibase/string-templates": "^0.9.19", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" }, "devDependencies": { - "@budibase/standard-components": "^0.9.12", + "@budibase/standard-components": "^0.9.19", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", "fs-extra": "^8.1.0", diff --git a/packages/server/LICENSE b/packages/server/LICENSE index 04c95b2fc..7c4a69f39 100644 --- a/packages/server/LICENSE +++ b/packages/server/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright 2019-2021, Budibase Ltd + Copyright 2019-2021, Budibase Inc Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/packages/server/package.json b/packages/server/package.json index e35353174..885f2a0af 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.12", + "version": "0.9.19", "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.12", - "@budibase/client": "^0.9.12", - "@budibase/string-templates": "^0.9.12", + "@budibase/auth": "^0.9.19", + "@budibase/client": "^0.9.19", + "@budibase/string-templates": "^0.9.19", "@elastic/elasticsearch": "7.10.0", "@koa/router": "8.0.0", "@sendgrid/mail": "7.1.1", @@ -107,7 +107,7 @@ "zlib": "1.0.5" }, "devDependencies": { - "@budibase/standard-components": "^0.9.12", + "@budibase/standard-components": "^0.9.19", "@jest/test-sequencer": "^24.8.0", "docker-compose": "^0.23.6", "eslint": "^6.8.0", diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index c018e5b01..090de0890 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -101,6 +101,7 @@ async function createInstance(template) { if (!ok) { throw "Error loading database dump from template." } + var { _rev } = await db.get(DocumentTypes.APP_METADATA) } else { // create the users table await db.put(USERS_TABLE_SCHEMA) @@ -111,7 +112,7 @@ async function createInstance(template) { await createRoutingView(appId) await createAllSearchIndex(appId) - return { _id: appId } + return { _id: appId, _rev } } exports.fetch = async function (ctx) { @@ -197,6 +198,9 @@ exports.create = async function (ctx) { type: "cloud", }, } + if (instance._rev) { + newApplication._rev = instance._rev + } const instanceDb = new CouchDB(appId) await instanceDb.put(newApplication) diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 4f3ebdb60..fa4bdf289 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -4,6 +4,7 @@ const { getDatasourceParams, getQueryParams, } = require("../../db/utils") +const { integrations } = require("../../integrations") exports.fetch = async function (ctx) { const database = new CouchDB(ctx.appId) @@ -28,6 +29,12 @@ exports.save = async function (ctx) { const response = await db.post(datasource) datasource._rev = response.rev + // Drain connection pools when configuration is changed + const pool = integrations[datasource.source].pool + if (pool) { + await pool.end() + } + ctx.status = 200 ctx.message = "Datasource saved successfully." ctx.body = datasource diff --git a/packages/server/src/api/routes/analytics.js b/packages/server/src/api/routes/analytics.js index fc05ecfec..781a959ac 100644 --- a/packages/server/src/api/routes/analytics.js +++ b/packages/server/src/api/routes/analytics.js @@ -1,10 +1,8 @@ const Router = require("@koa/router") -const authorized = require("../../middleware/authorized") const controller = require("../controllers/analytics") -const { BUILDER } = require("@budibase/auth/permissions") const router = Router() -router.get("/api/analytics", authorized(BUILDER), controller.isEnabled) +router.get("/api/analytics", controller.isEnabled) module.exports = router diff --git a/packages/server/src/api/routes/application.js b/packages/server/src/api/routes/application.js index edb695714..a7209df3e 100644 --- a/packages/server/src/api/routes/application.js +++ b/packages/server/src/api/routes/application.js @@ -7,12 +7,8 @@ const router = Router() router .get("/api/applications/:appId/definition", controller.fetchAppDefinition) - .get("/api/applications", authorized(BUILDER), controller.fetch) - .get( - "/api/applications/:appId/appPackage", - authorized(BUILDER), - controller.fetchAppPackage - ) + .get("/api/applications", controller.fetch) + .get("/api/applications/:appId/appPackage", controller.fetchAppPackage) .put("/api/applications/:appId", authorized(BUILDER), controller.update) .post("/api/applications", authorized(BUILDER), controller.create) .delete("/api/applications/:appId", authorized(BUILDER), controller.delete) diff --git a/packages/server/src/api/routes/tests/application.spec.js b/packages/server/src/api/routes/tests/application.spec.js index dc550cd23..ac353ffb0 100644 --- a/packages/server/src/api/routes/tests/application.spec.js +++ b/packages/server/src/api/routes/tests/application.spec.js @@ -61,14 +61,6 @@ describe("/applications", () => { // two created apps + the inited app expect(res.body.length).toBe(3) }) - - it("should apply authorization to endpoint", async () => { - await checkBuilderEndpoint({ - config, - method: "GET", - url: `/api/applications`, - }) - }) }) describe("fetchAppDefinition", () => { diff --git a/packages/server/src/api/routes/tests/user.spec.js b/packages/server/src/api/routes/tests/user.spec.js index 129a5f44f..30aa71152 100644 --- a/packages/server/src/api/routes/tests/user.spec.js +++ b/packages/server/src/api/routes/tests/user.spec.js @@ -1,13 +1,15 @@ const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") const { checkPermissionsEndpoint } = require("./utilities/TestFunctions") const setup = require("./utilities") -const { basicUser } = setup.structures const workerRequests = require("../../../utilities/workerRequests") jest.mock("../../../utilities/workerRequests", () => ({ getGlobalUsers: jest.fn(() => { return {} }), + getGlobalSelf: jest.fn(() => { + return {} + }), addAppRoleToUser: jest.fn(), deleteGlobalUser: jest.fn(), })) diff --git a/packages/server/src/api/routes/tests/utilities/index.js b/packages/server/src/api/routes/tests/utilities/index.js index 6a9f982bc..713a3f799 100644 --- a/packages/server/src/api/routes/tests/utilities/index.js +++ b/packages/server/src/api/routes/tests/utilities/index.js @@ -8,6 +8,11 @@ jest.mock("../../../../utilities/workerRequests", () => ({ _id: "us_uuid1", } }), + getGlobalSelf: jest.fn(() => { + return { + _id: "us_uuid1", + } + }), })) exports.delay = ms => new Promise(resolve => setTimeout(resolve, ms)) diff --git a/packages/server/src/integrations/Integration.js b/packages/server/src/integrations/Integration.js index 07d6d159b..345787a47 100644 --- a/packages/server/src/integrations/Integration.js +++ b/packages/server/src/integrations/Integration.js @@ -6,6 +6,7 @@ exports.QUERY_TYPES = { exports.FIELD_TYPES = { STRING: "string", + BOOLEAN: "boolean", NUMBER: "number", PASSWORD: "password", LIST: "list", diff --git a/packages/server/src/integrations/microsoftSqlServer.js b/packages/server/src/integrations/microsoftSqlServer.js index 6f99d1014..3dc5676e9 100644 --- a/packages/server/src/integrations/microsoftSqlServer.js +++ b/packages/server/src/integrations/microsoftSqlServer.js @@ -1,8 +1,6 @@ const sqlServer = require("mssql") const { FIELD_TYPES } = require("./Integration") -let pool - const SCHEMA = { docs: "https://github.com/tediousjs/node-mssql", description: @@ -31,6 +29,10 @@ const SCHEMA = { type: FIELD_TYPES.STRING, default: "root", }, + encrypt: { + type: FIELD_TYPES.BOOLEAN, + default: true, + }, }, query: { create: { @@ -49,15 +51,21 @@ const SCHEMA = { } class SqlServerIntegration { + static pool + constructor(config) { this.config = config - if (!pool) { - pool = new sqlServer.ConnectionPool(this.config) + this.config.options = { + encrypt: this.config.encrypt, + } + delete this.config.encrypt + if (!this.pool) { + this.pool = new sqlServer.ConnectionPool(this.config) } } async connect() { - const client = await pool.connect() + const client = await this.pool.connect() this.client = client.request() } diff --git a/packages/server/src/integrations/postgres.js b/packages/server/src/integrations/postgres.js index d567db7ba..ebc39a31a 100644 --- a/packages/server/src/integrations/postgres.js +++ b/packages/server/src/integrations/postgres.js @@ -1,6 +1,5 @@ const { Pool } = require("pg") - -let pool +const { FIELD_TYPES } = require("./Integration") const SCHEMA = { docs: "https://node-postgres.com", @@ -9,30 +8,35 @@ const SCHEMA = { "PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.", datasource: { host: { - type: "string", + type: FIELD_TYPES.STRING, default: "localhost", required: true, }, port: { - type: "number", + type: FIELD_TYPES.NUMBER, required: true, default: 5432, }, database: { - type: "string", + type: FIELD_TYPES.STRING, default: "postgres", required: true, }, user: { - type: "string", + type: FIELD_TYPES.STRING, default: "root", required: true, }, password: { - type: "password", + type: FIELD_TYPES.PASSWORD, default: "root", required: true, }, + ssl: { + type: FIELD_TYPES.BOOLEAN, + default: false, + required: false, + }, }, query: { create: { @@ -51,21 +55,28 @@ const SCHEMA = { } class PostgresIntegration { + static pool + constructor(config) { this.config = config - if (!pool) { - pool = new Pool(this.config) + if (this.config.ssl) { + this.config.ssl = { + rejectUnauthorized: true, + } } + + if (!this.pool) { + this.pool = new Pool(this.config) + } + + this.client = this.pool } async query(sql) { try { - this.client = await pool.connect() return await this.client.query(sql) } catch (err) { throw new Error(err) - } finally { - this.client.release() } } diff --git a/packages/server/src/integrations/rest.js b/packages/server/src/integrations/rest.js index 378158d73..84628c2f9 100644 --- a/packages/server/src/integrations/rest.js +++ b/packages/server/src/integrations/rest.js @@ -20,6 +20,7 @@ const SCHEMA = { }, query: { create: { + readable: true, displayName: "POST", type: QUERY_TYPES.FIELDS, urlDisplay: true, @@ -40,6 +41,7 @@ const SCHEMA = { }, read: { displayName: "GET", + readable: true, type: QUERY_TYPES.FIELDS, urlDisplay: true, fields: { @@ -56,6 +58,7 @@ const SCHEMA = { }, update: { displayName: "PUT", + readable: true, type: QUERY_TYPES.FIELDS, urlDisplay: true, fields: { diff --git a/packages/server/src/middleware/currentapp.js b/packages/server/src/middleware/currentapp.js index f808403ba..ae83da8ba 100644 --- a/packages/server/src/middleware/currentapp.js +++ b/packages/server/src/middleware/currentapp.js @@ -1,7 +1,7 @@ const { getAppId, setCookie, getCookie } = require("@budibase/auth").utils const { Cookies } = require("@budibase/auth").constants const { getRole } = require("@budibase/auth/roles") -const { getGlobalUsers } = require("../utilities/workerRequests") +const { getGlobalSelf } = require("../utilities/workerRequests") const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles") const { generateUserMetadataID } = require("../db/utils") @@ -25,10 +25,11 @@ module.exports = async (ctx, next) => { requestAppId != null && (appCookie == null || requestAppId !== appCookie.appId || - appCookie.roleId === BUILTIN_ROLE_IDS.PUBLIC) + appCookie.roleId === BUILTIN_ROLE_IDS.PUBLIC || + !appCookie.roleId) ) { // Different App ID means cookie needs reset, or if the same public user has logged in - const globalUser = await getGlobalUsers(ctx, requestAppId, ctx.user._id) + const globalUser = await getGlobalSelf(ctx, requestAppId) updateCookie = true appId = requestAppId // retrieving global user gets the right role @@ -51,6 +52,7 @@ module.exports = async (ctx, next) => { // override userID with metadata one _id: userId, userId, + roleId, role: await getRole(appId, roleId), } } diff --git a/packages/server/src/middleware/tests/currentapp.spec.js b/packages/server/src/middleware/tests/currentapp.spec.js index fd5a6623a..2b4a81554 100644 --- a/packages/server/src/middleware/tests/currentapp.spec.js +++ b/packages/server/src/middleware/tests/currentapp.spec.js @@ -3,7 +3,7 @@ mockWorker() function mockWorker() { jest.mock("../../utilities/workerRequests", () => ({ - getGlobalUsers: () => { + getGlobalSelf: () => { return { _id: "us_uuid1", roles: { diff --git a/packages/server/src/utilities/workerRequests.js b/packages/server/src/utilities/workerRequests.js index 49e24e5d6..639c178e2 100644 --- a/packages/server/src/utilities/workerRequests.js +++ b/packages/server/src/utilities/workerRequests.js @@ -9,7 +9,8 @@ function getAppRole(appId, user) { if (!user.roles) { return user } - user.roleId = user.roles[appId] + // always use the deployed app + user.roleId = user.roles[getDeployedAppID(appId)] if (!user.roleId) { user.roleId = BUILTIN_ROLE_IDS.PUBLIC } @@ -97,8 +98,6 @@ exports.deleteGlobalUser = async (ctx, globalId) => { } exports.getGlobalUsers = async (ctx, appId = null, globalId = null) => { - // always use the deployed app - appId = getDeployedAppID(appId) const endpoint = globalId ? `/api/admin/users/${globalId}` : `/api/admin/users` @@ -119,21 +118,23 @@ exports.getGlobalUsers = async (ctx, appId = null, globalId = null) => { return users } -exports.getGlobalSelf = async ctx => { +exports.getGlobalSelf = async (ctx, appId = null) => { const endpoint = `/api/admin/users/self` const response = await fetch( checkSlashesInUrl(env.WORKER_URL + endpoint), request(ctx, { method: "GET" }) ) - const json = await response.json() + let json = await response.json() if (json.status !== 200 && response.status !== 200) { ctx.throw(400, "Unable to get self globally.") } + if (appId) { + json = getAppRole(appId, json) + } return json } exports.addAppRoleToUser = async (ctx, appId, roleId, userId = null) => { - appId = getDeployedAppID(appId) let user, endpoint, body = {} diff --git a/packages/standard-components/LICENSE b/packages/standard-components/LICENSE index fd445efb1..2f05846f4 100644 --- a/packages/standard-components/LICENSE +++ b/packages/standard-components/LICENSE @@ -1,7 +1,7 @@ Mozilla Public License Version 2.0 ================================== -Copyright 2019-2021, Budibase Ltd +Copyright 2019-2021, Budibase Inc 1. Definitions -------------- diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index ba05de829..242cb5b0b 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -29,11 +29,11 @@ "keywords": [ "svelte" ], - "version": "0.9.12", + "version": "0.9.19", "license": "MIT", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "dependencies": { - "@budibase/bbui": "^0.9.12", + "@budibase/bbui": "^0.9.19", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", "apexcharts": "^3.22.1", diff --git a/packages/standard-components/src/Navigation.svelte b/packages/standard-components/src/Navigation.svelte index 43d8a0fa2..29ea9eea8 100644 --- a/packages/standard-components/src/Navigation.svelte +++ b/packages/standard-components/src/Navigation.svelte @@ -4,6 +4,9 @@ const { authStore, linkable, styleable, builderStore } = getContext("sdk") const component = getContext("component") + // BB emblem: https://i.imgur.com/Xhdt1YP.png + // Space logo: https://i.imgur.com/Dn7Xt1G.png + export let logoUrl export let hideLogo @@ -15,7 +18,7 @@ diff --git a/packages/standard-components/src/forms/validation.js b/packages/standard-components/src/forms/validation.js index 5b49fa084..ebdb3b3da 100644 --- a/packages/standard-components/src/forms/validation.js +++ b/packages/standard-components/src/forms/validation.js @@ -77,6 +77,9 @@ const lengthConstraint = maxLength => value => { } const numericalConstraint = (constraint, error) => value => { + if (value == null || value === "") { + return null + } if (isNaN(value)) { return "Must be a number" } diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 354af5a96..341b03e0e 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "0.9.12", + "version": "0.9.19", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/string-templates/src/helpers/date.js b/packages/string-templates/src/helpers/date.js index 0d9bd7803..ce845eee3 100644 --- a/packages/string-templates/src/helpers/date.js +++ b/packages/string-templates/src/helpers/date.js @@ -2,6 +2,7 @@ const dayjs = require("dayjs") dayjs.extend(require("dayjs/plugin/duration")) dayjs.extend(require("dayjs/plugin/advancedFormat")) dayjs.extend(require("dayjs/plugin/relativeTime")) +dayjs.extend(require("dayjs/plugin/utc")) /** * This file was largely taken from the helper-date package - we did this for two reasons: @@ -88,7 +89,11 @@ module.exports.date = (str, pattern, options) => { setLocale(config.str, config.pattern, config.options) - return dayjs(new Date(config.str)).format(config.pattern) + const date = dayjs(new Date(config.str)).utc() + if (config.pattern === "") { + return date.toISOString() + } + return date.format(config.pattern) } module.exports.duration = (str, pattern, format) => { diff --git a/packages/string-templates/src/processors/postprocessor.js b/packages/string-templates/src/processors/postprocessor.js index adc8362ab..4d1c84013 100644 --- a/packages/string-templates/src/processors/postprocessor.js +++ b/packages/string-templates/src/processors/postprocessor.js @@ -18,7 +18,7 @@ class Postprocessor { module.exports.processors = [ new Postprocessor(PostProcessorNames.CONVERT_LITERALS, statement => { - if (!statement.includes(LITERAL_MARKER)) { + if (typeof statement !== "string" || !statement.includes(LITERAL_MARKER)) { return statement } const splitMarkerIndex = statement.indexOf("-") diff --git a/packages/string-templates/test/examples/table.json b/packages/string-templates/test/examples/table.json new file mode 100644 index 000000000..4d982e012 --- /dev/null +++ b/packages/string-templates/test/examples/table.json @@ -0,0 +1,305 @@ +{ + "user":{ + "_id":"ro_ta_users_us_b0bc7ba0ce304294accc1ced8165dd23", + "_rev":"1-e9199d92e7286005a9c11c614fdbcc51", + "email":"test2@test.com", + "status":"active", + "roleId":"PUBLIC", + "test-Created By_text":"", + "test-Updated By_text":"" + }, + "closestComponentId":"c670254c9e74e40518ee5becff53aa5be", + "url":{ + + }, + "c670254c9e74e40518ee5becff53aa5be":{ + "rows":[ + { + "_id":"ro_ta_1399af8a08d244a9885c674dd5555c84_8c1940e906254db5ac79c51011255d6c", + "_rev":"1-49ff5a4094a251a7767155eb85f4c9b7", + "sef":"sefesfesf", + "Name":"sefesf", + "tableId":"ta_1399af8a08d244a9885c674dd5555c84", + "Auto ID":1, + "Created At":"2021-05-27T10:30:37.386Z", + "Updated At":"2021-05-27T10:30:37.386Z", + "type":"row", + "Created By":[ + { + "_id":"ro_ta_users_us_de1bd7fe710146db990d92845008c763" + } + ], + "Updated By":[ + { + "_id":"ro_ta_users_us_de1bd7fe710146db990d92845008c763" + } + ], + "testing":"2", + "Created By_text":"", + "Updated By_text":"" + } + ], + "schema":{ + "Auto ID":{ + "name":"Auto ID", + "type":"number", + "subtype":"autoID", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"number", + "presence":false, + "numericality":{ + "greaterThanOrEqualTo":"", + "lessThanOrEqualTo":"" + } + }, + "lastID":1 + }, + "Created By":{ + "name":"Created By", + "type":"link", + "subtype":"createdBy", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"array", + "presence":false + }, + "tableId":"ta_users", + "fieldName":"test-Created By", + "relationshipType":"many-to-many" + }, + "Created At":{ + "name":"Created At", + "type":"datetime", + "subtype":"createdAt", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"string", + "length":{ + + }, + "presence":false, + "datetime":{ + "latest":"", + "earliest":"" + } + } + }, + "Updated By":{ + "name":"Updated By", + "type":"link", + "subtype":"updatedBy", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"array", + "presence":false + }, + "tableId":"ta_users", + "fieldName":"test-Updated By", + "relationshipType":"many-to-many" + }, + "Updated At":{ + "name":"Updated At", + "type":"datetime", + "subtype":"updatedAt", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"string", + "length":{ + + }, + "presence":false, + "datetime":{ + "latest":"", + "earliest":"" + } + } + }, + "Name":{ + "type":"string", + "constraints":{ + "type":"string", + "length":{ + "maximum":null + }, + "presence":false + }, + "fieldName":"test", + "name":"Name" + }, + "sef":{ + "type":"string", + "constraints":{ + "type":"string", + "length":{ + "maximum":null + }, + "presence":false + }, + "fieldName":"test", + "name":"sef" + }, + "testing":{ + "type":"formula", + "constraints":{ + "type":"string", + "presence":false + }, + "fieldName":"test", + "name":"testing", + "formula":"{{ add [Auto ID] 1 }}" + } + }, + "rowsLength":1 + }, + "data":{ + "rows":[ + { + "_id":"ro_ta_1399af8a08d244a9885c674dd5555c84_8c1940e906254db5ac79c51011255d6c", + "_rev":"1-49ff5a4094a251a7767155eb85f4c9b7", + "sef":"sefesfesf", + "Name":"sefesf", + "tableId":"ta_1399af8a08d244a9885c674dd5555c84", + "Auto ID":1, + "Created At":"2021-05-27T10:30:37.386Z", + "Updated At":"2021-05-27T10:30:37.386Z", + "type":"row", + "Created By":[ + { + "_id":"ro_ta_users_us_de1bd7fe710146db990d92845008c763" + } + ], + "Updated By":[ + { + "_id":"ro_ta_users_us_de1bd7fe710146db990d92845008c763" + } + ], + "testing":"2", + "Created By_text":"", + "Updated By_text":"" + } + ], + "schema":{ + "Auto ID":{ + "name":"Auto ID", + "type":"number", + "subtype":"autoID", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"number", + "presence":false, + "numericality":{ + "greaterThanOrEqualTo":"", + "lessThanOrEqualTo":"" + } + }, + "lastID":1 + }, + "Created By":{ + "name":"Created By", + "type":"link", + "subtype":"createdBy", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"array", + "presence":false + }, + "tableId":"ta_users", + "fieldName":"test-Created By", + "relationshipType":"many-to-many" + }, + "Created At":{ + "name":"Created At", + "type":"datetime", + "subtype":"createdAt", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"string", + "length":{ + + }, + "presence":false, + "datetime":{ + "latest":"", + "earliest":"" + } + } + }, + "Updated By":{ + "name":"Updated By", + "type":"link", + "subtype":"updatedBy", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"array", + "presence":false + }, + "tableId":"ta_users", + "fieldName":"test-Updated By", + "relationshipType":"many-to-many" + }, + "Updated At":{ + "name":"Updated At", + "type":"datetime", + "subtype":"updatedAt", + "icon":"ri-magic-line", + "autocolumn":true, + "constraints":{ + "type":"string", + "length":{ + + }, + "presence":false, + "datetime":{ + "latest":"", + "earliest":"" + } + } + }, + "Name":{ + "type":"string", + "constraints":{ + "type":"string", + "length":{ + "maximum":null + }, + "presence":false + }, + "fieldName":"test", + "name":"Name" + }, + "sef":{ + "type":"string", + "constraints":{ + "type":"string", + "length":{ + "maximum":null + }, + "presence":false + }, + "fieldName":"test", + "name":"sef" + }, + "testing":{ + "type":"formula", + "constraints":{ + "type":"string", + "presence":false + }, + "fieldName":"test", + "name":"testing", + "formula":"{{ add [Auto ID] 1 }}" + } + }, + "rowsLength":1 + } +} \ No newline at end of file diff --git a/packages/string-templates/test/helpers.spec.js b/packages/string-templates/test/helpers.spec.js index 0d14133aa..6be8e2ed0 100644 --- a/packages/string-templates/test/helpers.spec.js +++ b/packages/string-templates/test/helpers.spec.js @@ -1,4 +1,5 @@ const { processString, processObject, isValid } = require("../src/index.cjs") +const tableJson = require("./examples/table.json") describe("test the custom helpers we have applied", () => { it("should be able to use the object helper", async () => { @@ -355,6 +356,15 @@ describe("Cover a few complex use cases", () => { expect(validity).toBe(true) }) + it("should test a case of attempting to get a UTC ISO back out after processing", async () => { + const date = new Date() + const input = `{{ date (subtract (date dateThing "x") 300000) "" }}` + const output = await processString(input, { + dateThing: date.toISOString(), + }) + expect(output).toEqual(new Date(date.getTime() - 300000).toISOString()) + }) + it("test a very complex duration output", async () => { const currentTime = new Date(1612432082000).toISOString(), eventTime = new Date(1612432071000).toISOString() @@ -388,4 +398,17 @@ describe("Cover a few complex use cases", () => { const output = await processObject(input, context) expect(output.text).toBe("12-01") }) + + it("should only invalidate a single string in an object", async () => { + const input = { + dataProvider:"{{ literal [c670254c9e74e40518ee5becff53aa5be] }}", + theme:"spectrum--lightest", + showAutoColumns:false, + quiet:true, + size:"spectrum--medium", + rowCount:8, + } + const output = await processObject(input, tableJson) + expect(output.dataProvider).not.toBe("Invalid Binding") + }) }) diff --git a/packages/worker/package.json b/packages/worker/package.json index f298b0b95..3d1509199 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.12", + "version": "0.9.19", "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.12", - "@budibase/string-templates": "^0.9.12", + "@budibase/auth": "^0.9.19", + "@budibase/string-templates": "^0.9.19", "@koa/router": "^8.0.0", "aws-sdk": "^2.811.0", "bcryptjs": "^2.4.3",