Merge branch 'develop' of github.com:Budibase/budibase into examples/nextjs

This commit is contained in:
mike12345567 2022-03-10 13:16:47 +00:00
commit 56e119168a
28 changed files with 211 additions and 33 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/backend-core", "name": "@budibase/backend-core",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"description": "Budibase backend core libraries used in server and worker", "description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js", "main": "src/index.js",
"author": "Budibase", "author": "Budibase",

View File

@ -22,3 +22,18 @@ exports.getAccount = async email => {
return json[0] return json[0]
} }
exports.getStatus = async () => {
const response = await api.get(`/api/status`, {
headers: {
[Headers.API_KEY]: env.ACCOUNT_PORTAL_API_KEY,
},
})
const json = await response.json()
if (response.status !== 200) {
throw new Error(`Error getting status`)
}
return json
}

View File

@ -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": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
], ],
"dependencies": { "dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1", "@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.0.81-alpha.4", "@budibase/string-templates": "^1.0.81-alpha.7",
"@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2", "@spectrum-css/avatar": "^3.0.2",

View File

@ -57,3 +57,10 @@
</div> </div>
</div> </div>
{/if} {/if}
<style>
.spectrum-Toast {
pointer-events: all;
width: 100%;
}
</style>

View File

@ -0,0 +1,31 @@
<script>
import "@spectrum-css/toast/dist/index-vars.css"
import Portal from "svelte-portal"
import { banner } from "../Stores/banner"
import Banner from "./Banner.svelte"
import { fly } from "svelte/transition"
</script>
<Portal target=".banner-container">
<div class="banner">
{#if $banner.message}
<div transition:fly={{ y: -30 }}>
<Banner
type={$banner.type}
extraButtonText={$banner.extraButtonText}
extraButtonAction={$banner.extraButtonAction}
on:change={$banner.onChange}
>
{$banner.message}
</Banner>
</div>
{/if}
</div>
</Portal>
<style>
.banner {
pointer-events: none;
width: 100%;
}
</style>

View File

@ -0,0 +1,37 @@
import { writable } from "svelte/store"
export function createBannerStore() {
const DEFAULT_CONFIG = {}
const banner = writable(DEFAULT_CONFIG)
const show = async (
// eslint-disable-next-line
config = { message, type, extraButtonText, extraButtonAction, onChange }
) => {
banner.update(store => {
return {
...store,
...config,
}
})
}
const showStatus = async () => {
const config = {
message: "Some systems are experiencing issues",
type: "negative",
extraButtonText: "View Status",
extraButtonAction: () => window.open("https://status.budibase.com/"),
}
await show(config)
}
return {
subscribe: banner.subscribe,
showStatus,
}
}
export const banner = createBannerStore()

View File

@ -60,7 +60,7 @@ export const createNotificationStore = () => {
} }
function id() { function id() {
return "_" + Math.random().toString(36).substr(2, 9) return "_" + Math.random().toString(36).slice(2, 9)
} }
export const notifications = createNotificationStore() export const notifications = createNotificationStore()

View File

@ -68,7 +68,7 @@
}) })
function id() { function id() {
return "_" + Math.random().toString(36).substr(2, 9) return "_" + Math.random().toString(36).slice(2, 9)
} }
</script> </script>

View File

@ -60,6 +60,7 @@ export { default as StatusLight } from "./StatusLight/StatusLight.svelte"
export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte" export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte"
export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte" export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte"
export { default as Banner } from "./Banner/Banner.svelte" export { default as Banner } from "./Banner/Banner.svelte"
export { default as BannerDisplay } from "./Banner/BannerDisplay.svelte"
export { default as MarkdownEditor } from "./Markdown/MarkdownEditor.svelte" export { default as MarkdownEditor } from "./Markdown/MarkdownEditor.svelte"
export { default as MarkdownViewer } from "./Markdown/MarkdownViewer.svelte" export { default as MarkdownViewer } from "./Markdown/MarkdownViewer.svelte"
export { default as RichTextField } from "./Form/RichTextField.svelte" export { default as RichTextField } from "./Form/RichTextField.svelte"
@ -84,6 +85,7 @@ export { default as clickOutside } from "./Actions/click_outside"
// Stores // Stores
export { notifications, createNotificationStore } from "./Stores/notifications" export { notifications, createNotificationStore } from "./Stores/notifications"
export { banner } from "./Stores/banner"
// Helpers // Helpers
export * as Helpers from "./helpers" export * as Helpers from "./helpers"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -65,10 +65,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.0.81-alpha.4", "@budibase/bbui": "^1.0.81-alpha.7",
"@budibase/client": "^1.0.81-alpha.4", "@budibase/client": "^1.0.81-alpha.7",
"@budibase/frontend-core": "^1.0.81-alpha.4", "@budibase/frontend-core": "^1.0.81-alpha.7",
"@budibase/string-templates": "^1.0.81-alpha.4", "@budibase/string-templates": "^1.0.81-alpha.7",
"@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",

View File

@ -1,13 +1,16 @@
<script> <script>
import { Router } from "@roxi/routify" import { Router } from "@roxi/routify"
import { routes } from "../.routify/routes" import { routes } from "../.routify/routes"
import { NotificationDisplay } from "@budibase/bbui" import { NotificationDisplay, BannerDisplay } from "@budibase/bbui"
import { parse, stringify } from "qs" import { parse, stringify } from "qs"
import HelpIcon from "components/common/HelpIcon.svelte" import HelpIcon from "components/common/HelpIcon.svelte"
const queryHandler = { parse, stringify } const queryHandler = { parse, stringify }
</script> </script>
<div class="banner-container" />
<BannerDisplay />
<NotificationDisplay /> <NotificationDisplay />
<Router {routes} config={{ queryHandler }} /> <Router {routes} config={{ queryHandler }} />
<div class="modal-container" /> <div class="modal-container" />

View File

@ -11,7 +11,7 @@
import { users } from "stores/portal" import { users } from "stores/portal"
const [email, error, touched] = createValidationStore("", emailValidator) const [email, error, touched] = createValidationStore("", emailValidator)
const password = Math.random().toString(36).substr(2, 20) const password = Math.random().toString(36).slice(2, 20)
let builder = false, let builder = false,
admin = false admin = false

View File

@ -7,7 +7,7 @@
export let user export let user
const password = Math.random().toString(36).substr(2, 20) const password = Math.random().toString(36).slice(2, 20)
async function resetPassword() { async function resetPassword() {
try { try {

View File

@ -1,6 +1,7 @@
import { writable, get } from "svelte/store" import { writable, get } from "svelte/store"
import { API } from "api" import { API } from "api"
import { auth } from "stores/portal" import { auth } from "stores/portal"
import { banner } from "@budibase/bbui"
export function createAdminStore() { export function createAdminStore() {
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
@ -30,6 +31,13 @@ export function createAdminStore() {
x => x?.checked x => x?.checked
).length ).length
await getEnvironment() await getEnvironment()
// enable system status checks in the cloud
if (get(admin).cloud) {
await getSystemStatus()
checkStatus()
}
admin.update(store => { admin.update(store => {
store.loaded = true store.loaded = true
store.checklist = checklist store.checklist = checklist
@ -58,6 +66,21 @@ export function createAdminStore() {
}) })
} }
const checkStatus = async () => {
const health = get(admin)?.status?.health
if (!health?.passing) {
await banner.showStatus()
}
}
async function getSystemStatus() {
const status = await API.getSystemStatus()
admin.update(store => {
store.status = status
return store
})
}
function unload() { function unload() {
admin.update(store => { admin.update(store => {
store.loaded = false store.loaded = false

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"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": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"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": "^1.0.81-alpha.4", "@budibase/bbui": "^1.0.81-alpha.7",
"@budibase/frontend-core": "^1.0.81-alpha.4", "@budibase/frontend-core": "^1.0.81-alpha.7",
"@budibase/string-templates": "^1.0.81-alpha.4", "@budibase/string-templates": "^1.0.81-alpha.7",
"@spectrum-css/button": "^3.0.3", "@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3", "@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3", "@spectrum-css/divider": "^1.0.3",

View File

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

View File

@ -17,6 +17,15 @@ export const buildOtherEndpoints = API => ({
}) })
}, },
/**
* Gets the current system status.
*/
getSystemStatus: async () => {
return await API.get({
url: "/api/system/status",
})
},
/** /**
* Gets the list of available integrations. * Gets the list of available integrations.
*/ */

View File

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

View File

@ -51,7 +51,7 @@ function extractPaths(apidocJson) {
// Surrounds URL parameters with curly brackets -> :email with {email} // Surrounds URL parameters with curly brackets -> :email with {email}
let pathKeys = [] let pathKeys = []
for (let j = 1; j < matches.length; j++) { for (let j = 1; j < matches.length; j++) {
let key = matches[j].substr(1) let key = matches[j].slice(1)
url = url.replace(matches[j], "{" + key + "}") url = url.replace(matches[j], "{" + key + "}")
pathKeys.push(key) pathKeys.push(key)
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"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",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.81-alpha.4", "version": "1.0.81-alpha.7",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -34,8 +34,8 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.0.81-alpha.4", "@budibase/backend-core": "^1.0.81-alpha.7",
"@budibase/string-templates": "^1.0.81-alpha.4", "@budibase/string-templates": "^1.0.81-alpha.7",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"@sentry/node": "^6.0.0", "@sentry/node": "^6.0.0",
"@techpass/passport-openidconnect": "^0.3.0", "@techpass/passport-openidconnect": "^0.3.0",

View File

@ -1,10 +1,20 @@
const { getGlobalDB, getTenantId } = require("@budibase/backend-core/tenancy") const {
getGlobalDB,
getTenantId,
isUserInAppTenant,
} = require("@budibase/backend-core/tenancy")
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db") const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
const { user: userCache } = require("@budibase/backend-core/cache") const { user: userCache } = require("@budibase/backend-core/cache")
const { hash, platformLogout } = require("@budibase/backend-core/utils") const {
hash,
platformLogout,
getCookie,
clearCookie,
} = require("@budibase/backend-core/utils")
const { encrypt } = require("@budibase/backend-core/encryption") const { encrypt } = require("@budibase/backend-core/encryption")
const { newid } = require("@budibase/backend-core/utils") const { newid } = require("@budibase/backend-core/utils")
const { getUser } = require("../../utilities") const { getUser } = require("../../utilities")
const { Cookies } = require("@budibase/backend-core/constants")
function newApiKey() { function newApiKey() {
return encrypt(`${getTenantId()}${SEPARATOR}${newid()}`) return encrypt(`${getTenantId()}${SEPARATOR}${newid()}`)
@ -48,6 +58,16 @@ exports.fetchAPIKey = async ctx => {
ctx.body = cleanupDevInfo(devInfo) ctx.body = cleanupDevInfo(devInfo)
} }
const checkCurrentApp = ctx => {
const appCookie = getCookie(ctx, Cookies.CurrentApp)
if (appCookie && !isUserInAppTenant(appCookie.appId)) {
// there is a currentapp cookie from another tenant
// remove the cookie as this is incompatible with the builder
// due to builder and admin permissions being removed
clearCookie(ctx, Cookies.CurrentApp)
}
}
exports.getSelf = async ctx => { exports.getSelf = async ctx => {
if (!ctx.user) { if (!ctx.user) {
ctx.throw(403, "User not logged in") ctx.throw(403, "User not logged in")
@ -56,6 +76,9 @@ exports.getSelf = async ctx => {
ctx.params = { ctx.params = {
id: userId, id: userId,
} }
checkCurrentApp(ctx)
// get the main body of the user // get the main body of the user
ctx.body = await getUser(userId) ctx.body = await getUser(userId)
// forward session information not found in db // forward session information not found in db

View File

@ -0,0 +1,15 @@
const accounts = require("@budibase/backend-core/accounts")
const env = require("../../../environment")
exports.fetch = async ctx => {
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
const status = await accounts.getStatus()
ctx.body = status
} else {
ctx.body = {
health: {
passing: true,
},
}
}
}

View File

@ -39,7 +39,6 @@ const PUBLIC_ENDPOINTS = [
method: "GET", method: "GET",
}, },
{ {
// TODO: Add an provisioning API key to this endpoint in the cloud
route: "/api/global/users/init", route: "/api/global/users/init",
method: "POST", method: "POST",
}, },
@ -51,6 +50,10 @@ const PUBLIC_ENDPOINTS = [
route: "api/system/environment", route: "api/system/environment",
method: "GET", method: "GET",
}, },
{
route: "api/system/status",
method: "GET",
},
{ {
route: "/api/global/users/tenant/:id", route: "/api/global/users/tenant/:id",
method: "GET", method: "GET",

View File

@ -8,6 +8,7 @@ const roleRoutes = require("./global/roles")
const sessionRoutes = require("./global/sessions") const sessionRoutes = require("./global/sessions")
const environmentRoutes = require("./system/environment") const environmentRoutes = require("./system/environment")
const tenantsRoutes = require("./system/tenants") const tenantsRoutes = require("./system/tenants")
const statusRoutes = require("./system/status")
const selfRoutes = require("./global/self") const selfRoutes = require("./global/self")
exports.routes = [ exports.routes = [
@ -21,5 +22,6 @@ exports.routes = [
sessionRoutes, sessionRoutes,
roleRoutes, roleRoutes,
environmentRoutes, environmentRoutes,
statusRoutes,
selfRoutes, selfRoutes,
] ]

View File

@ -0,0 +1,8 @@
const Router = require("@koa/router")
const controller = require("../../controllers/system/status")
const router = Router()
router.get("/api/system/status", controller.fetch)
module.exports = router