Merge branch 'master' of github.com:Budibase/budibase into develop
This commit is contained in:
commit
bfdbcb1a47
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/auth",
|
"name": "@budibase/auth",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"description": "Authentication middlewares for budibase builder and apps",
|
"description": "Authentication middlewares for budibase builder and apps",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/bbui",
|
"name": "@budibase/bbui",
|
||||||
"description": "A UI solution used in the different Budibase projects.",
|
"description": "A UI solution used in the different Budibase projects.",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"module": "dist/bbui.es.js",
|
"module": "dist/bbui.es.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -65,10 +65,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^0.9.160-alpha.4",
|
"@budibase/bbui": "^0.9.163",
|
||||||
"@budibase/client": "^0.9.160-alpha.4",
|
"@budibase/client": "^0.9.163",
|
||||||
"@budibase/colorpicker": "1.1.2",
|
"@budibase/colorpicker": "1.1.2",
|
||||||
"@budibase/string-templates": "^0.9.160-alpha.4",
|
"@budibase/string-templates": "^0.9.163",
|
||||||
"@sentry/browser": "5.19.1",
|
"@sentry/browser": "5.19.1",
|
||||||
"@spectrum-css/page": "^3.0.1",
|
"@spectrum-css/page": "^3.0.1",
|
||||||
"@spectrum-css/vars": "^3.0.1",
|
"@spectrum-css/vars": "^3.0.1",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { notifications, ModalContent, Dropzone, Body } from "@budibase/bbui"
|
import { notifications, ModalContent, Dropzone, Body } from "@budibase/bbui"
|
||||||
import { post } from "builderStore/api"
|
import { post } from "builderStore/api"
|
||||||
|
import { admin } from "stores/portal"
|
||||||
|
|
||||||
let submitting = false
|
let submitting = false
|
||||||
|
|
||||||
|
@ -20,8 +21,8 @@
|
||||||
if (!importResp.ok) {
|
if (!importResp.ok) {
|
||||||
throw new Error(importJson.message)
|
throw new Error(importJson.message)
|
||||||
}
|
}
|
||||||
// now reload to get to login
|
await admin.checkImportComplete()
|
||||||
window.location.reload()
|
notifications.success("Import complete, please finish registration!")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error(error)
|
notifications.error(error)
|
||||||
submitting = false
|
submitting = false
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte"
|
import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte"
|
||||||
import ImportAppsModal from "./_components/ImportAppsModal.svelte"
|
import ImportAppsModal from "./_components/ImportAppsModal.svelte"
|
||||||
import Logo from "assets/bb-emblem.svg"
|
import Logo from "assets/bb-emblem.svg"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
let adminUser = {}
|
let adminUser = {}
|
||||||
let error
|
let error
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
$: tenantId = $auth.tenantId
|
$: tenantId = $auth.tenantId
|
||||||
$: multiTenancyEnabled = $admin.multiTenancy
|
$: multiTenancyEnabled = $admin.multiTenancy
|
||||||
$: cloud = $admin.cloud
|
$: cloud = $admin.cloud
|
||||||
|
$: imported = $admin.importComplete
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
try {
|
try {
|
||||||
|
@ -40,6 +42,12 @@
|
||||||
notifications.error(`Failed to create admin user`)
|
notifications.error(`Failed to create admin user`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
if (!cloud) {
|
||||||
|
await admin.checkImportComplete()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:this={modal} padding={false} width="600px">
|
<Modal bind:this={modal} padding={false} width="600px">
|
||||||
|
@ -73,7 +81,7 @@
|
||||||
>
|
>
|
||||||
Change organisation
|
Change organisation
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
{:else if !cloud}
|
{:else if !cloud && !imported}
|
||||||
<ActionButton
|
<ActionButton
|
||||||
quiet
|
quiet
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
|
@ -9,6 +9,7 @@ export function createAdminStore() {
|
||||||
cloud: false,
|
cloud: false,
|
||||||
disableAccountPortal: false,
|
disableAccountPortal: false,
|
||||||
accountPortalUrl: "",
|
accountPortalUrl: "",
|
||||||
|
importComplete: false,
|
||||||
onboardingProgress: 0,
|
onboardingProgress: 0,
|
||||||
checklist: {
|
checklist: {
|
||||||
apps: { checked: false },
|
apps: { checked: false },
|
||||||
|
@ -45,6 +46,17 @@ export function createAdminStore() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkImportComplete() {
|
||||||
|
const response = await api.get(`/api/cloud/import/complete`)
|
||||||
|
if (response.status === 200) {
|
||||||
|
const json = await response.json()
|
||||||
|
admin.update(store => {
|
||||||
|
store.importComplete = json ? json.imported : false
|
||||||
|
return store
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getEnvironment() {
|
async function getEnvironment() {
|
||||||
let multiTenancyEnabled = false
|
let multiTenancyEnabled = false
|
||||||
let cloud = false
|
let cloud = false
|
||||||
|
@ -79,6 +91,7 @@ export function createAdminStore() {
|
||||||
return {
|
return {
|
||||||
subscribe: admin.subscribe,
|
subscribe: admin.subscribe,
|
||||||
init,
|
init,
|
||||||
|
checkImportComplete,
|
||||||
unload,
|
unload,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"module": "dist/budibase-client.js",
|
"module": "dist/budibase-client.js",
|
||||||
"main": "dist/budibase-client.js",
|
"main": "dist/budibase-client.js",
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
"dev:builder": "rollup -cw"
|
"dev:builder": "rollup -cw"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "^0.9.160-alpha.4",
|
"@budibase/bbui": "^0.9.163",
|
||||||
"@budibase/standard-components": "^0.9.139",
|
"@budibase/standard-components": "^0.9.139",
|
||||||
"@budibase/string-templates": "^0.9.160-alpha.4",
|
"@budibase/string-templates": "^0.9.163",
|
||||||
"regexparam": "^1.3.0",
|
"regexparam": "^1.3.0",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"svelte-spa-router": "^3.0.5"
|
"svelte-spa-router": "^3.0.5"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -68,9 +68,9 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/auth": "^0.9.160-alpha.4",
|
"@budibase/auth": "^0.9.163",
|
||||||
"@budibase/client": "^0.9.160-alpha.4",
|
"@budibase/client": "^0.9.163",
|
||||||
"@budibase/string-templates": "^0.9.160-alpha.4",
|
"@budibase/string-templates": "^0.9.163",
|
||||||
"@elastic/elasticsearch": "7.10.0",
|
"@elastic/elasticsearch": "7.10.0",
|
||||||
"@koa/router": "8.0.0",
|
"@koa/router": "8.0.0",
|
||||||
"@sendgrid/mail": "7.1.1",
|
"@sendgrid/mail": "7.1.1",
|
||||||
|
|
|
@ -86,6 +86,7 @@ async function getAppUrlIfNotInUse(ctx) {
|
||||||
if (
|
if (
|
||||||
url &&
|
url &&
|
||||||
deployedApps[url] != null &&
|
deployedApps[url] != null &&
|
||||||
|
ctx.params != null &&
|
||||||
deployedApps[url].appId !== ctx.params.appId
|
deployedApps[url].appId !== ctx.params.appId
|
||||||
) {
|
) {
|
||||||
ctx.throw(400, "App name/URL is already in use.")
|
ctx.throw(400, "App name/URL is already in use.")
|
||||||
|
|
|
@ -28,15 +28,18 @@ exports.exportApps = async ctx => {
|
||||||
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
||||||
}
|
}
|
||||||
const apps = await getAllApps(CouchDB, { all: true })
|
const apps = await getAllApps(CouchDB, { all: true })
|
||||||
const globalDBString = await exportDB(getGlobalDBName())
|
const globalDBString = await exportDB(getGlobalDBName(), {
|
||||||
|
filter: doc => !doc._id.startsWith(DocumentTypes.USER),
|
||||||
|
})
|
||||||
let allDBs = {
|
let allDBs = {
|
||||||
global: globalDBString,
|
global: globalDBString,
|
||||||
}
|
}
|
||||||
for (let app of apps) {
|
for (let app of apps) {
|
||||||
|
const appId = app.appId || app._id
|
||||||
// only export the dev apps as they will be the latest, the user can republish the apps
|
// only export the dev apps as they will be the latest, the user can republish the apps
|
||||||
// in their self hosted environment
|
// in their self hosted environment
|
||||||
if (isDevAppID(app._id)) {
|
if (isDevAppID(appId)) {
|
||||||
allDBs[app.name] = await exportDB(app._id)
|
allDBs[app.name] = await exportDB(appId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const filename = `cloud-export-${new Date().getTime()}.txt`
|
const filename = `cloud-export-${new Date().getTime()}.txt`
|
||||||
|
@ -53,16 +56,26 @@ async function getAllDocType(db, docType) {
|
||||||
return response.rows.map(row => row.doc)
|
return response.rows.map(row => row.doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function hasBeenImported() {
|
||||||
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const apps = await getAllApps(CouchDB, { all: true })
|
||||||
|
return apps.length !== 0
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.hasBeenImported = async ctx => {
|
||||||
|
ctx.body = {
|
||||||
|
imported: await hasBeenImported(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exports.importApps = async ctx => {
|
exports.importApps = async ctx => {
|
||||||
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
if (!env.SELF_HOSTED || env.MULTI_TENANCY) {
|
||||||
ctx.throw(400, "Importing only allowed in self hosted environments.")
|
ctx.throw(400, "Importing only allowed in self hosted environments.")
|
||||||
}
|
}
|
||||||
const apps = await getAllApps(CouchDB, { all: true })
|
const beenImported = await hasBeenImported()
|
||||||
if (
|
if (beenImported || !ctx.request.files || !ctx.request.files.importFile) {
|
||||||
apps.length !== 0 ||
|
|
||||||
!ctx.request.files ||
|
|
||||||
!ctx.request.files.importFile
|
|
||||||
) {
|
|
||||||
ctx.throw(
|
ctx.throw(
|
||||||
400,
|
400,
|
||||||
"Import file is required and environment must be fresh to import apps."
|
"Import file is required and environment must be fresh to import apps."
|
||||||
|
@ -80,11 +93,17 @@ exports.importApps = async ctx => {
|
||||||
for (let [appName, appImport] of Object.entries(dbs)) {
|
for (let [appName, appImport] of Object.entries(dbs)) {
|
||||||
await createApp(appName, appImport)
|
await createApp(appName, appImport)
|
||||||
}
|
}
|
||||||
// once apps are created clean up the global db
|
|
||||||
|
// if there are any users make sure to remove them
|
||||||
let users = await getAllDocType(globalDb, DocumentTypes.USER)
|
let users = await getAllDocType(globalDb, DocumentTypes.USER)
|
||||||
|
let userDeletionPromises = []
|
||||||
for (let user of users) {
|
for (let user of users) {
|
||||||
delete user.tenantId
|
userDeletionPromises.push(globalDb.remove(user._id, user._rev))
|
||||||
}
|
}
|
||||||
|
if (userDeletionPromises.length > 0) {
|
||||||
|
await Promise.all(userDeletionPromises)
|
||||||
|
}
|
||||||
|
|
||||||
await globalDb.bulkDocs(users)
|
await globalDb.bulkDocs(users)
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
message: "Apps successfully imported.",
|
message: "Apps successfully imported.",
|
||||||
|
|
|
@ -9,5 +9,6 @@ router
|
||||||
.get("/api/cloud/export", authorized(BUILDER), controller.exportApps)
|
.get("/api/cloud/export", authorized(BUILDER), controller.exportApps)
|
||||||
// has to be public, only run if apps don't exist
|
// has to be public, only run if apps don't exist
|
||||||
.post("/api/cloud/import", controller.importApps)
|
.post("/api/cloud/import", controller.importApps)
|
||||||
|
.get("/api/cloud/import/complete", controller.hasBeenImported)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
|
@ -74,9 +74,10 @@ module.exports = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert any strings to numbers if required, like "0" would be true otherwise
|
// clean up any environment variable edge cases
|
||||||
for (let [key, value] of Object.entries(module.exports)) {
|
for (let [key, value] of Object.entries(module.exports)) {
|
||||||
if (typeof value === "string" && !isNaN(parseInt(value))) {
|
// handle the edge case of "0" to disable an environment variable
|
||||||
module.exports[key] = parseInt(value)
|
if (value === "0") {
|
||||||
|
module.exports[key] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/string-templates",
|
"name": "@budibase/string-templates",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"description": "Handlebars wrapper for Budibase templating.",
|
"description": "Handlebars wrapper for Budibase templating.",
|
||||||
"main": "src/index.cjs",
|
"main": "src/index.cjs",
|
||||||
"module": "dist/bundle.mjs",
|
"module": "dist/bundle.mjs",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/worker",
|
"name": "@budibase/worker",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "0.9.160-alpha.4",
|
"version": "0.9.163",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/auth": "^0.9.160-alpha.4",
|
"@budibase/auth": "^0.9.163",
|
||||||
"@budibase/string-templates": "^0.9.160-alpha.4",
|
"@budibase/string-templates": "^0.9.163",
|
||||||
"@koa/router": "^8.0.0",
|
"@koa/router": "^8.0.0",
|
||||||
"@techpass/passport-openidconnect": "^0.3.0",
|
"@techpass/passport-openidconnect": "^0.3.0",
|
||||||
"aws-sdk": "^2.811.0",
|
"aws-sdk": "^2.811.0",
|
||||||
|
|
|
@ -52,3 +52,11 @@ module.exports = {
|
||||||
return !isDev()
|
return !isDev()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean up any environment variable edge cases
|
||||||
|
for (let [key, value] of Object.entries(module.exports)) {
|
||||||
|
// handle the edge case of "0" to disable an environment variable
|
||||||
|
if (value === "0") {
|
||||||
|
module.exports[key] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ const { Headers } = require("@budibase/auth").constants
|
||||||
* Ensure that the correct API key has been supplied.
|
* Ensure that the correct API key has been supplied.
|
||||||
*/
|
*/
|
||||||
module.exports = async (ctx, next) => {
|
module.exports = async (ctx, next) => {
|
||||||
if (!env.SELF_HOSTED) {
|
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
|
||||||
const apiKey = ctx.request.headers[Headers.API_KEY]
|
const apiKey = ctx.request.headers[Headers.API_KEY]
|
||||||
if (apiKey !== env.INTERNAL_API_KEY) {
|
if (apiKey !== env.INTERNAL_API_KEY) {
|
||||||
ctx.throw(403, "Unauthorized")
|
ctx.throw(403, "Unauthorized")
|
||||||
|
|
Loading…
Reference in New Issue