Merge branch 'master' of https://github.com/Budibase/budibase into lab-day-2705

This commit is contained in:
Martin McKeaveney 2021-06-01 19:24:24 +01:00
commit 7a0bbfdb84
55 changed files with 3298 additions and 213 deletions

View File

@ -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.

View File

@ -20,7 +20,7 @@
<p align="center">
<img src="https://i.imgur.com/tPQHruf.png">
<img src="https://i.imgur.com/k9ANC3b.png">
</p>
<p align="center">
@ -43,7 +43,7 @@
</p>
<h3 align="center">
<a href="https://portal.budi.live/signup">Sign-up</a>
<a href="https://docs.budibase.com/getting-started">Get started</a>
<span> · </span>
<a href="https://docs.budibase.com">Docs</a>
<span> · </span>
@ -61,16 +61,18 @@
- **Build and ship real software.** Unlike other platforms, with Budibase you build and ship single page applications. Budibase applications have performance baked in and can be designed responsively, providing your users with a great experience.
- **Open source and extensable.** Budibase is open-source. The builder is licensed AGPL v3, the server is GPL v3, and the client is MPL. This should fill you with confidence that Budibase will always be around. You can also code against Budibase or fork it and make changes as you please, providing a developer-friendly experience.
- **Open source and extensable.** Budibase is open-source - licensed as GPL v3. This should fill you with confidence that Budibase will always be around. You can also code against Budibase or fork it and make changes as you please, providing a developer-friendly experience.
- **Load data or start from scratch.** Budibase pulls in data from multiple sources, including MongoDB, CouchDB, PostgreSQL, mySQL, Airtable, Google Sheets, S3, DyanmoDB, or a REST API. And unlike other platforms, with Budibase you can start from scratch and create business apps with no data sources. [Request new data sources](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).
- **Load data or start from scratch.** Budibase pulls in data from multiple sources, including MongoDB, CouchDB, PostgreSQL, mySQL, Airtable, S3, DyanmoDB, or a REST API. And unlike other platforms, with Budibase you can start from scratch and create business apps with no data sources. [Request new data sources](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).
- **Design and build apps with powerful pre-made components.** Budibase comes out of the box with beautifully designed, powerful components which you can use like building blocks to build your UI. We also expose a lot of your favourite CSS styling options so you can go that extra creative mile. [Request new components](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).
- **Design and build apps with powerful pre-made components.** Budibase comes out of the box with beautifully designed, powerful components which you can use like building blocks to build your UI. We also expose a lot of your favourite CSS styling options so you can go that extra creative mile. [Request new component](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).
- **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).
- **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 automation](https://github.com/Budibase/budibase/discussions?discussions_q=category%3AIdeas).
- **Admin paradise.** Budibase is made to scale. With Budibase, you can self-host on your own infraastructure and globally manage users, onboarding, SMTP, apps, groups, theming and more. You can also provide users/groups with an app portal and disseminate user-management to the group manager.
<p align="center">
<img alt="Budibase design ui" src="https://imgur.com/v8m6v3q.png">
<img alt="Budibase design ui" src="https://i.imgur.com/5BnXPsN.png">
</p>
@ -80,7 +82,7 @@
## ⌛ Status
- [x] Alpha: We are demoing Budibase to users and receiving feedback
- [x] Private Beta: We are testing Budibase with a closed set of customers
- [x] Public Beta: Anyone can [sign-up and use Budibase](https://portal.budi.live/signup).
- [x] Public Beta: Anyone can [get started](https://docs.budibase.com/getting-started).
- [ ] Official Launch
Watch "releases" of this repo to get notified of major updates, and give the star button a click whilst you're there.

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/auth",
"version": "0.9.13",
"version": "0.9.21",
"description": "Authentication middlewares for budibase builder and apps",
"main": "src/index.js",
"author": "Budibase",

View File

@ -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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "0.9.13",
"version": "0.9.21",
"license": "AGPL-3.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",

View File

@ -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.
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.
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.
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.
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.
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.
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.
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) <year> <name of author>
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 <https://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<https://www.gnu.org/licenses/>.
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
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.1.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">
<style type="text/css">
.st0{fill:#393C44;}
.st1{fill:#FFFFFF;}
.st2{fill:#4285F4;}
</style>
<rect x="-152.17" y="-24.17" class="st0" width="96.17" height="96.17"/>
<path class="st1" d="M-83.19,48h-41.79c-1.76,0-3.19-1.43-3.19-3.19V3.02c0-1.76,1.43-3.19,3.19-3.19h41.79
c1.76,0,3.19,1.43,3.19,3.19v41.79C-80,46.57-81.43,48-83.19,48z"/>
<g>
<g>
<path class="st0" d="M-99.62,12.57v9.94c1.15-1.21,2.59-1.81,4.32-1.81c1.03,0,1.97,0.19,2.82,0.58c0.86,0.39,1.59,0.91,2.19,1.57
c0.6,0.66,1.08,1.43,1.42,2.32c0.34,0.89,0.51,1.84,0.51,2.85c0,1.03-0.18,1.99-0.53,2.89c-0.35,0.9-0.84,1.68-1.47,2.35
c-0.63,0.67-1.37,1.19-2.23,1.58c-0.86,0.39-1.78,0.58-2.77,0.58c-1.8,0-3.22-0.66-4.27-1.97V35h-4.89V12.57H-99.62z
M-93.46,28.11c0-0.43-0.08-0.84-0.24-1.23c-0.16-0.39-0.39-0.72-0.68-1.01c-0.29-0.29-0.62-0.52-1-0.69
c-0.38-0.17-0.79-0.26-1.24-0.26c-0.43,0-0.84,0.08-1.22,0.24c-0.38,0.16-0.71,0.39-0.99,0.68c-0.28,0.29-0.5,0.63-0.68,1.01
c-0.17,0.39-0.26,0.8-0.26,1.23c0,0.43,0.08,0.84,0.24,1.22c0.16,0.38,0.39,0.71,0.68,0.99c0.29,0.28,0.63,0.5,1.01,0.68
c0.39,0.17,0.8,0.26,1.23,0.26c0.43,0,0.84-0.08,1.22-0.24c0.38-0.16,0.71-0.39,0.99-0.68c0.28-0.29,0.5-0.62,0.68-1
C-93.55,28.92-93.46,28.52-93.46,28.11z"/>
</g>
<g>
<path class="st0" d="M-114.76,12.57v9.94c1.15-1.21,2.59-1.81,4.32-1.81c1.03,0,1.97,0.19,2.82,0.58
c0.86,0.39,1.59,0.91,2.19,1.57c0.6,0.66,1.08,1.43,1.42,2.32c0.34,0.89,0.51,1.84,0.51,2.85c0,1.03-0.18,1.99-0.53,2.89
c-0.35,0.9-0.84,1.68-1.47,2.35c-0.63,0.67-1.37,1.19-2.23,1.58c-0.86,0.39-1.78,0.58-2.77,0.58c-1.8,0-3.22-0.66-4.27-1.97V35
h-4.89V12.57H-114.76z M-108.6,28.11c0-0.43-0.08-0.84-0.24-1.23c-0.16-0.39-0.39-0.72-0.68-1.01c-0.29-0.29-0.62-0.52-1-0.69
c-0.38-0.17-0.79-0.26-1.24-0.26c-0.43,0-0.84,0.08-1.22,0.24c-0.38,0.16-0.71,0.39-0.99,0.68c-0.28,0.29-0.5,0.63-0.68,1.01
c-0.17,0.39-0.26,0.8-0.26,1.23c0,0.43,0.08,0.84,0.24,1.22c0.16,0.38,0.39,0.71,0.68,0.99c0.29,0.28,0.63,0.5,1.01,0.68
c0.39,0.17,0.8,0.26,1.23,0.26c0.43,0,0.84-0.08,1.22-0.24c0.38-0.16,0.71-0.39,0.99-0.68c0.28-0.29,0.5-0.62,0.68-1
C-108.68,28.92-108.6,28.52-108.6,28.11z"/>
</g>
</g>
<path class="st2" d="M44.81,159H3.02c-1.76,0-3.19-1.43-3.19-3.19v-41.79c0-1.76,1.43-3.19,3.19-3.19h41.79
c1.76,0,3.19,1.43,3.19,3.19v41.79C48,157.57,46.57,159,44.81,159z"/>
<g>
<g>
<path class="st1" d="M28.38,123.57v9.94c1.15-1.21,2.59-1.81,4.32-1.81c1.03,0,1.97,0.19,2.82,0.58c0.86,0.39,1.59,0.91,2.19,1.57
c0.6,0.66,1.08,1.43,1.42,2.32c0.34,0.89,0.51,1.84,0.51,2.85c0,1.03-0.18,1.99-0.53,2.89c-0.35,0.9-0.84,1.68-1.47,2.35
c-0.63,0.67-1.37,1.19-2.23,1.58c-0.86,0.39-1.78,0.58-2.77,0.58c-1.8,0-3.22-0.66-4.27-1.97V146h-4.89v-22.43H28.38z
M34.54,139.11c0-0.43-0.08-0.84-0.24-1.23c-0.16-0.39-0.39-0.72-0.68-1.01c-0.29-0.29-0.62-0.52-1-0.69
c-0.38-0.17-0.79-0.26-1.24-0.26c-0.43,0-0.84,0.08-1.22,0.24c-0.38,0.16-0.71,0.39-0.99,0.68c-0.28,0.29-0.5,0.63-0.68,1.01
c-0.17,0.39-0.26,0.8-0.26,1.23c0,0.43,0.08,0.84,0.24,1.22c0.16,0.38,0.39,0.71,0.68,0.99c0.29,0.28,0.63,0.5,1.01,0.68
c0.39,0.17,0.8,0.26,1.23,0.26c0.43,0,0.84-0.08,1.22-0.24c0.38-0.16,0.71-0.39,0.99-0.68c0.28-0.29,0.5-0.62,0.68-1
C34.45,139.92,34.54,139.52,34.54,139.11z"/>
</g>
<g>
<path class="st1" d="M13.24,123.57v9.94c1.15-1.21,2.59-1.81,4.32-1.81c1.03,0,1.97,0.19,2.82,0.58c0.86,0.39,1.59,0.91,2.19,1.57
c0.6,0.66,1.08,1.43,1.42,2.32c0.34,0.89,0.51,1.84,0.51,2.85c0,1.03-0.18,1.99-0.53,2.89c-0.35,0.9-0.84,1.68-1.47,2.35
c-0.63,0.67-1.37,1.19-2.23,1.58c-0.86,0.39-1.78,0.58-2.77,0.58c-1.8,0-3.22-0.66-4.27-1.97V146H8.35v-22.43H13.24z M19.4,139.11
c0-0.43-0.08-0.84-0.24-1.23c-0.16-0.39-0.39-0.72-0.68-1.01c-0.29-0.29-0.62-0.52-1-0.69c-0.38-0.17-0.79-0.26-1.24-0.26
c-0.43,0-0.84,0.08-1.22,0.24c-0.38,0.16-0.71,0.39-0.99,0.68c-0.28,0.29-0.5,0.63-0.68,1.01c-0.17,0.39-0.26,0.8-0.26,1.23
c0,0.43,0.08,0.84,0.24,1.22c0.16,0.38,0.39,0.71,0.68,0.99c0.29,0.28,0.63,0.5,1.01,0.68c0.39,0.17,0.8,0.26,1.23,0.26
c0.43,0,0.84-0.08,1.22-0.24c0.38-0.16,0.71-0.39,0.99-0.68c0.28-0.29,0.5-0.62,0.68-1C19.32,139.92,19.4,139.52,19.4,139.11z"/>
</g>
</g>
<g>
<path class="st0" d="M44,48H4c-2.21,0-4-1.79-4-4V4c0-2.21,1.79-4,4-4h40c2.21,0,4,1.79,4,4v40C48,46.21,46.21,48,44,48z"/>
<g>
<path class="st1" d="M28.48,12v10.44c1.18-1.27,2.65-1.9,4.42-1.9c1.05,0,2.01,0.2,2.89,0.61c0.87,0.41,1.62,0.96,2.24,1.65
c0.62,0.69,1.1,1.5,1.45,2.44c0.35,0.94,0.52,1.93,0.52,2.99c0,1.08-0.18,2.09-0.54,3.04c-0.36,0.95-0.86,1.77-1.51,2.47
c-0.64,0.7-1.4,1.25-2.28,1.66C34.8,35.8,33.86,36,32.84,36c-1.84,0-3.3-0.69-4.37-2.07v1.62h-5V12H28.48z M34.78,28.31
c0-0.45-0.08-0.88-0.25-1.29c-0.17-0.41-0.4-0.76-0.69-1.06c-0.3-0.3-0.64-0.54-1.02-0.72c-0.39-0.18-0.81-0.27-1.27-0.27
c-0.44,0-0.86,0.09-1.24,0.26c-0.39,0.17-0.72,0.41-1.01,0.71c-0.29,0.3-0.52,0.66-0.69,1.06c-0.18,0.41-0.26,0.84-0.26,1.29
s0.08,0.88,0.25,1.28c0.17,0.4,0.4,0.74,0.69,1.04c0.29,0.29,0.64,0.53,1.04,0.71c0.4,0.18,0.82,0.27,1.26,0.27
c0.44,0,0.86-0.09,1.24-0.26c0.39-0.17,0.72-0.41,1.01-0.71c0.29-0.3,0.52-0.65,0.69-1.05C34.69,29.16,34.78,28.75,34.78,28.31z"
/>
</g>
<g>
<path class="st1" d="M13,12v10.44c1.18-1.27,2.65-1.9,4.42-1.9c1.05,0,2.01,0.2,2.89,0.61c0.87,0.41,1.62,0.96,2.24,1.65
c0.62,0.69,1.1,1.5,1.45,2.44c0.35,0.94,0.52,1.93,0.52,2.99c0,1.08-0.18,2.09-0.54,3.04c-0.36,0.95-0.86,1.77-1.51,2.47
c-0.64,0.7-1.4,1.25-2.28,1.66C19.32,35.8,18.38,36,17.37,36c-1.84,0-3.3-0.69-4.37-2.07v1.62H8V12H13z M19.3,28.31
c0-0.45-0.08-0.88-0.25-1.29c-0.17-0.41-0.4-0.76-0.69-1.06c-0.3-0.3-0.64-0.54-1.02-0.72c-0.39-0.18-0.81-0.27-1.27-0.27
c-0.44,0-0.86,0.09-1.24,0.26c-0.39,0.17-0.72,0.41-1.01,0.71c-0.29,0.3-0.52,0.66-0.69,1.06c-0.18,0.41-0.26,0.84-0.26,1.29
s0.08,0.88,0.25,1.28c0.17,0.4,0.4,0.74,0.69,1.04c0.29,0.29,0.64,0.53,1.04,0.71c0.4,0.18,0.82,0.27,1.26,0.27
c0.44,0,0.86-0.09,1.24-0.26c0.39-0.17,0.72-0.41,1.01-0.71c0.29-0.3,0.52-0.65,0.69-1.05C19.21,29.16,19.3,28.75,19.3,28.31z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "0.9.13",
"version": "0.9.21",
"license": "AGPL-3.0",
"private": true,
"scripts": {
@ -65,10 +65,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^0.9.13",
"@budibase/client": "^0.9.13",
"@budibase/bbui": "^0.9.21",
"@budibase/client": "^0.9.21",
"@budibase/colorpicker": "1.1.2",
"@budibase/string-templates": "^0.9.13",
"@budibase/string-templates": "^0.9.21",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -291,7 +291,7 @@
/>
{#if relationshipOptions && relationshipOptions.length > 0}
<RadioGroup
disabled={originalName}
disabled={originalName != null}
label="Define the relationship"
bind:value={field.relationshipType}
options={relationshipOptions}

View File

@ -1,5 +1,5 @@
<script>
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"}
<div class="form-row">
<Label>{capitalise(configKey)}</Label>
<Toggle text="" bind:value={integration[configKey]} />
</div>
{:else}
<div class="form-row">
<Label>{capitalise(configKey)}</Label>

View File

@ -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

View File

@ -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

View File

@ -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)
</script>
{#if $auth.user && loaded}

View File

@ -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("../")
}
})
</script>
{#if !$auth.user}
{#if !$auth.user || $auth.user.forceResetPassword}
<slot />
{/if}

View File

@ -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 = ""

View File

@ -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 = ""

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "0.9.13",
"version": "0.9.21",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {

View File

@ -1,7 +1,7 @@
Mozilla Public License Version 2.0
==================================
Copyright 2019-2021, Budibase Ltd
Copyright 2019-2021, Budibase Inc
1. Definitions
--------------

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "0.9.13",
"version": "0.9.21",
"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.13",
"@budibase/string-templates": "^0.9.21",
"regexparam": "^1.3.0",
"shortid": "^2.2.15",
"svelte-spa-router": "^3.0.5"
},
"devDependencies": {
"@budibase/standard-components": "^0.9.13",
"@budibase/standard-components": "^0.9.21",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"fs-extra": "^8.1.0",

View File

@ -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.

View File

@ -0,0 +1,3 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "0.9.13",
"version": "0.9.21",
"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.13",
"@budibase/client": "^0.9.13",
"@budibase/string-templates": "^0.9.13",
"@budibase/auth": "^0.9.21",
"@budibase/client": "^0.9.21",
"@budibase/string-templates": "^0.9.21",
"@elastic/elasticsearch": "7.10.0",
"@koa/router": "8.0.0",
"@sendgrid/mail": "7.1.1",
@ -107,8 +107,11 @@
"zlib": "1.0.5"
},
"devDependencies": {
"@budibase/standard-components": "^0.9.13",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@budibase/standard-components": "^0.9.21",
"@jest/test-sequencer": "^24.8.0",
"babel-jest": "^27.0.2",
"docker-compose": "^0.23.6",
"eslint": "^6.8.0",
"express": "^4.17.1",

View File

@ -27,7 +27,10 @@ const { cloneDeep } = require("lodash/fp")
const { processObject } = require("@budibase/string-templates")
const { getAllApps } = require("../../utilities")
const { USERS_TABLE_SCHEMA } = require("../../constants")
const { getDeployedApps } = require("../../utilities/workerRequests")
const {
getDeployedApps,
removeAppFromUserRoles,
} = require("../../utilities/workerRequests")
const { clientLibraryPath } = require("../../utilities")
const { getAllLocks } = require("../../utilities/redis")
@ -101,6 +104,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 +115,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 +201,9 @@ exports.create = async function (ctx) {
type: "cloud",
},
}
if (instance._rev) {
newApplication._rev = instance._rev
}
const instanceDb = new CouchDB(appId)
await instanceDb.put(newApplication)
@ -241,6 +248,8 @@ exports.delete = async function (ctx) {
if (!env.isTest()) {
await deleteApp(ctx.params.appId)
}
// make sure the app/role doesn't stick around after the app has been deleted
await removeAppFromUserRoles(ctx.params.appId)
ctx.status = 200
ctx.body = result

View File

@ -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 source = integrations[datasource.source]
if (source && source.pool) {
await source.pool.end()
}
ctx.status = 200
ctx.message = "Datasource saved successfully."
ctx.body = datasource

View File

@ -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

View File

@ -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)

View File

@ -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", () => {

View File

@ -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(),
}))

View File

@ -8,6 +8,12 @@ jest.mock("../../../../utilities/workerRequests", () => ({
_id: "us_uuid1",
}
}),
getGlobalSelf: jest.fn(() => {
return {
_id: "us_uuid1",
}
}),
removeAppFromUserRoles: jest.fn(),
}))
exports.delay = ms => new Promise(resolve => setTimeout(resolve, ms))

View File

@ -6,6 +6,7 @@ exports.QUERY_TYPES = {
exports.FIELD_TYPES = {
STRING: "string",
BOOLEAN: "boolean",
NUMBER: "number",
PASSWORD: "password",
LIST: "list",

View File

@ -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()
}

View File

@ -1,8 +1,6 @@
const { Pool } = require("pg")
const { FIELD_TYPES } = require("./Integration")
let pool
const SCHEMA = {
docs: "https://node-postgres.com",
friendlyName: "PostgreSQL",
@ -35,7 +33,8 @@ const SCHEMA = {
required: true,
},
ssl: {
type: FIELD_TYPES.OBJECT,
type: FIELD_TYPES.BOOLEAN,
default: false,
required: false,
},
},
@ -56,28 +55,28 @@ const SCHEMA = {
}
class PostgresIntegration {
static pool
constructor(config) {
this.config = config
if (this.config.ssl.rejectUnauthorized) {
this.config.ssl.rejectUnauthorized =
this.config.ssl.rejectUnauthorized === "true" ? true : false
if (this.config.ssl) {
this.config.ssl = {
rejectUnauthorized: true,
}
}
if (!pool) {
pool = new Pool(this.config)
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 {
if (this.client) {
this.client.release()
}
}
}

View File

@ -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: {

View File

@ -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),
}
}

View File

@ -5,7 +5,7 @@ jest.mock("../../environment", () => ({
prod: false,
isTest: () => true,
isProd: () => this.prod,
_set: (key, value) => {
_set: function(key, value) {
this.prod = value === "production"
}
})

View File

@ -3,7 +3,7 @@ mockWorker()
function mockWorker() {
jest.mock("../../utilities/workerRequests", () => ({
getGlobalUsers: () => {
getGlobalSelf: () => {
return {
_id: "us_uuid1",
roles: {

View File

@ -91,7 +91,7 @@ describe("resourceId middleware", () => {
.mainResource("custom")
.subResource("customSub")
.build()
config = new TestConfiguration(middleware)
let config = new TestConfiguration(middleware)
config.setBody({
custom: "test",
customSub: "subtest"

View File

@ -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
}
@ -56,11 +57,10 @@ exports.sendSmtpEmail = async (to, from, subject, contents) => {
})
)
const json = await response.json()
if (json.status !== 200 && response.status !== 200) {
if (response.status !== 200) {
throw "Unable to send email."
}
return json
return response.json()
}
exports.getDeployedApps = async ctx => {
@ -97,8 +97,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 +117,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()
if (json.status !== 200 && response.status !== 200) {
if (response.status !== 200) {
ctx.throw(400, "Unable to get self globally.")
}
let json = await response.json()
if (appId) {
json = getAppRole(appId, json)
}
return json
}
exports.addAppRoleToUser = async (ctx, appId, roleId, userId = null) => {
appId = getDeployedAppID(appId)
let user,
endpoint,
body = {}
@ -150,7 +150,7 @@ exports.addAppRoleToUser = async (ctx, appId, roleId, userId = null) => {
...body,
roles: {
...user.roles,
[appId]: roleId,
[getDeployedAppID(appId)]: roleId,
},
}
const response = await fetch(
@ -160,9 +160,25 @@ exports.addAppRoleToUser = async (ctx, appId, roleId, userId = null) => {
body,
})
)
const json = await response.json()
if (json.status !== 200 && response.status !== 200) {
if (response.status !== 200) {
ctx.throw(400, "Unable to save self globally.")
}
return json
return response.json()
}
exports.removeAppFromUserRoles = async appId => {
const deployedAppId = getDeployedAppID(appId)
const response = await fetch(
checkSlashesInUrl(env.WORKER_URL + `/api/admin/roles/${deployedAppId}`),
request(null, {
method: "DELETE",
headers: {
"x-budibase-api-key": env.INTERNAL_API_KEY,
},
})
)
if (response.status !== 200) {
throw "Unable to remove app role"
}
return response.json()
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
Mozilla Public License Version 2.0
==================================
Copyright 2019-2021, Budibase Ltd
Copyright 2019-2021, Budibase Inc
1. Definitions
--------------

View File

@ -29,11 +29,11 @@
"keywords": [
"svelte"
],
"version": "0.9.13",
"version": "0.9.21",
"license": "MIT",
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc",
"dependencies": {
"@budibase/bbui": "^0.9.13",
"@budibase/bbui": "^0.9.21",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",
"apexcharts": "^3.22.1",

View File

@ -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
</script>
@ -15,7 +18,7 @@
<img
class="logo"
alt="logo"
src={logoUrl || "https://i.imgur.com/Dn7Xt1G.png"}
src={logoUrl || "https://i.imgur.com/Xhdt1YP.png"}
height="48"
/>
</a>

View File

@ -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"
}

View File

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

View File

@ -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) => {

View File

@ -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("-")

View File

@ -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
}
}

View File

@ -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")
})
})

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "0.9.13",
"version": "0.9.21",
"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.13",
"@budibase/string-templates": "^0.9.13",
"@budibase/auth": "^0.9.21",
"@budibase/string-templates": "^0.9.21",
"@koa/router": "^8.0.0",
"aws-sdk": "^2.811.0",
"bcryptjs": "^2.4.3",

View File

@ -11,6 +11,16 @@ const { sendEmail } = require("../../../utilities/email")
const GLOBAL_DB = StaticDatabases.GLOBAL.name
async function allUsers() {
const db = new CouchDB(GLOBAL_DB)
const response = await db.allDocs(
getGlobalUserParams(null, {
include_docs: true,
})
)
return response.rows.map(row => row.doc)
}
exports.save = async ctx => {
const db = new CouchDB(GLOBAL_DB)
const { email, password, _id } = ctx.request.body
@ -105,6 +115,23 @@ exports.destroy = async ctx => {
}
}
exports.removeAppRole = async ctx => {
const { appId } = ctx.params
const db = new CouchDB(GLOBAL_DB)
const users = await allUsers()
const bulk = []
for (let user of users) {
if (user.roles[appId]) {
delete user.roles[appId]
bulk.push(user)
}
}
await db.bulkDocs(bulk)
ctx.body = {
message: "App role removed from all users",
}
}
exports.getSelf = async ctx => {
ctx.params = {
id: ctx.user._id,
@ -134,13 +161,7 @@ exports.updateSelf = async ctx => {
// called internally by app server user fetch
exports.fetch = async ctx => {
const db = new CouchDB(GLOBAL_DB)
const response = await db.allDocs(
getGlobalUserParams(null, {
include_docs: true,
})
)
const users = response.rows.map(row => row.doc)
const users = await allUsers()
// user hashed password shouldn't ever be returned
for (let user of users) {
if (user) {

View File

@ -67,6 +67,7 @@ router
controller.save
)
.get("/api/admin/users", adminOnly, controller.fetch)
.delete("/api/admin/roles/:appId", adminOnly, controller.removeAppRole)
.delete("/api/admin/users/:id", adminOnly, controller.destroy)
.get("/api/admin/roles/:appId")
.post(