diff --git a/lerna.json b/lerna.json
index 591565b377..e492e58a75 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.27-alpha.5",
+ "version": "1.0.27-alpha.13",
"npmClient": "yarn",
"packages": [
"packages/*"
diff --git a/packages/auth/.gitignore b/packages/backend-core/.gitignore
similarity index 100%
rename from packages/auth/.gitignore
rename to packages/backend-core/.gitignore
diff --git a/packages/auth/LICENSE b/packages/backend-core/LICENSE
similarity index 100%
rename from packages/auth/LICENSE
rename to packages/backend-core/LICENSE
diff --git a/packages/auth/README.md b/packages/backend-core/README.md
similarity index 78%
rename from packages/auth/README.md
rename to packages/backend-core/README.md
index 4c6a474b5b..f36f80f84d 100644
--- a/packages/auth/README.md
+++ b/packages/backend-core/README.md
@@ -4,7 +4,7 @@ This library contains core functionality, like auth and security features
which are shared between backend services.
#### Note about top level JS files
-For the purposes of being able to do say `require("@budibase/auth/permissions")` we need to
+For the purposes of being able to do say `require("@budibase/backend-core/permissions")` we need to
specify the exports at the top-level of the module.
For these files they should be limited to a single `require` of the file that should
diff --git a/packages/auth/accounts.js b/packages/backend-core/accounts.js
similarity index 100%
rename from packages/auth/accounts.js
rename to packages/backend-core/accounts.js
diff --git a/packages/backend-core/auth.js b/packages/backend-core/auth.js
new file mode 100644
index 0000000000..bbfe3d41dd
--- /dev/null
+++ b/packages/backend-core/auth.js
@@ -0,0 +1 @@
+module.exports = require("./src/auth")
diff --git a/packages/auth/cache.js b/packages/backend-core/cache.js
similarity index 100%
rename from packages/auth/cache.js
rename to packages/backend-core/cache.js
diff --git a/packages/auth/constants.js b/packages/backend-core/constants.js
similarity index 100%
rename from packages/auth/constants.js
rename to packages/backend-core/constants.js
diff --git a/packages/auth/db.js b/packages/backend-core/db.js
similarity index 100%
rename from packages/auth/db.js
rename to packages/backend-core/db.js
diff --git a/packages/auth/deprovision.js b/packages/backend-core/deprovision.js
similarity index 100%
rename from packages/auth/deprovision.js
rename to packages/backend-core/deprovision.js
diff --git a/packages/backend-core/middleware.js b/packages/backend-core/middleware.js
new file mode 100644
index 0000000000..30fec96239
--- /dev/null
+++ b/packages/backend-core/middleware.js
@@ -0,0 +1 @@
+module.exports = require("./src/middleware")
diff --git a/packages/backend-core/objectStore.js b/packages/backend-core/objectStore.js
new file mode 100644
index 0000000000..3ee433f224
--- /dev/null
+++ b/packages/backend-core/objectStore.js
@@ -0,0 +1,4 @@
+module.exports = {
+ ...require("./src/objectStore"),
+ ...require("./src/objectStore/utils"),
+}
diff --git a/packages/auth/package.json b/packages/backend-core/package.json
similarity index 87%
rename from packages/auth/package.json
rename to packages/backend-core/package.json
index 058d5fe43d..c358c7f9d4 100644
--- a/packages/auth/package.json
+++ b/packages/backend-core/package.json
@@ -1,7 +1,7 @@
{
- "name": "@budibase/auth",
- "version": "1.0.27-alpha.5",
- "description": "Authentication middlewares for budibase builder and apps",
+ "name": "@budibase/backend-core",
+ "version": "1.0.27-alpha.13",
+ "description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js",
"author": "Budibase",
"license": "GPL-3.0",
diff --git a/packages/auth/permissions.js b/packages/backend-core/permissions.js
similarity index 100%
rename from packages/auth/permissions.js
rename to packages/backend-core/permissions.js
diff --git a/packages/auth/redis.js b/packages/backend-core/redis.js
similarity index 100%
rename from packages/auth/redis.js
rename to packages/backend-core/redis.js
diff --git a/packages/auth/roles.js b/packages/backend-core/roles.js
similarity index 100%
rename from packages/auth/roles.js
rename to packages/backend-core/roles.js
diff --git a/packages/auth/scripts/jestSetup.js b/packages/backend-core/scripts/jestSetup.js
similarity index 100%
rename from packages/auth/scripts/jestSetup.js
rename to packages/backend-core/scripts/jestSetup.js
diff --git a/packages/auth/sessions.js b/packages/backend-core/sessions.js
similarity index 100%
rename from packages/auth/sessions.js
rename to packages/backend-core/sessions.js
diff --git a/packages/auth/src/index.js b/packages/backend-core/src/auth.js
similarity index 52%
rename from packages/auth/src/index.js
rename to packages/backend-core/src/auth.js
index 4aa2c8ab96..7f66d887ae 100644
--- a/packages/auth/src/index.js
+++ b/packages/backend-core/src/auth.js
@@ -1,7 +1,6 @@
const passport = require("koa-passport")
const LocalStrategy = require("passport-local").Strategy
const JwtStrategy = require("passport-jwt").Strategy
-const { StaticDatabases } = require("./db/utils")
const { getGlobalDB } = require("./tenancy")
const {
jwt,
@@ -14,8 +13,6 @@ const {
appTenancy,
authError,
} = require("./middleware")
-const { setDB } = require("./db")
-const userCache = require("./cache/user")
// Strategies
passport.use(new LocalStrategy(local.options, local.authenticate))
@@ -36,36 +33,13 @@ passport.deserializeUser(async (user, done) => {
})
module.exports = {
- init(pouch) {
- setDB(pouch)
- },
- db: require("./db/utils"),
- redis: {
- Client: require("./redis"),
- utils: require("./redis/utils"),
- },
- objectStore: {
- ...require("./objectStore"),
- ...require("./objectStore/utils"),
- },
- utils: {
- ...require("./utils"),
- ...require("./hashing"),
- },
- auth: {
- buildAuthMiddleware: authenticated,
- passport,
- google,
- oidc,
- jwt: require("jsonwebtoken"),
- buildTenancyMiddleware: tenancy,
- buildAppTenancyMiddleware: appTenancy,
- auditLog,
- authError,
- },
- cache: {
- user: userCache,
- },
- StaticDatabases,
- constants: require("./constants"),
+ buildAuthMiddleware: authenticated,
+ passport,
+ google,
+ oidc,
+ jwt: require("jsonwebtoken"),
+ buildTenancyMiddleware: tenancy,
+ buildAppTenancyMiddleware: appTenancy,
+ auditLog,
+ authError,
}
diff --git a/packages/auth/src/cache/appMetadata.js b/packages/backend-core/src/cache/appMetadata.js
similarity index 100%
rename from packages/auth/src/cache/appMetadata.js
rename to packages/backend-core/src/cache/appMetadata.js
diff --git a/packages/auth/src/cache/user.js b/packages/backend-core/src/cache/user.js
similarity index 100%
rename from packages/auth/src/cache/user.js
rename to packages/backend-core/src/cache/user.js
diff --git a/packages/auth/src/cloud/accounts.js b/packages/backend-core/src/cloud/accounts.js
similarity index 100%
rename from packages/auth/src/cloud/accounts.js
rename to packages/backend-core/src/cloud/accounts.js
diff --git a/packages/auth/src/cloud/api.js b/packages/backend-core/src/cloud/api.js
similarity index 100%
rename from packages/auth/src/cloud/api.js
rename to packages/backend-core/src/cloud/api.js
diff --git a/packages/auth/src/constants.js b/packages/backend-core/src/constants.js
similarity index 100%
rename from packages/auth/src/constants.js
rename to packages/backend-core/src/constants.js
diff --git a/packages/auth/src/db/Replication.js b/packages/backend-core/src/db/Replication.js
similarity index 100%
rename from packages/auth/src/db/Replication.js
rename to packages/backend-core/src/db/Replication.js
diff --git a/packages/auth/src/db/constants.js b/packages/backend-core/src/db/constants.js
similarity index 100%
rename from packages/auth/src/db/constants.js
rename to packages/backend-core/src/db/constants.js
diff --git a/packages/auth/src/db/index.js b/packages/backend-core/src/db/index.js
similarity index 100%
rename from packages/auth/src/db/index.js
rename to packages/backend-core/src/db/index.js
diff --git a/packages/auth/src/db/utils.js b/packages/backend-core/src/db/utils.js
similarity index 97%
rename from packages/auth/src/db/utils.js
rename to packages/backend-core/src/db/utils.js
index 2bad09c306..5830de4721 100644
--- a/packages/auth/src/db/utils.js
+++ b/packages/backend-core/src/db/utils.js
@@ -224,8 +224,15 @@ exports.getAllDbs = async () => {
}
}
let couchUrl = `${exports.getCouchUrl()}/_all_dbs`
- if (env.MULTI_TENANCY) {
- let tenantId = getTenantId()
+ let tenantId = getTenantId()
+ if (!env.MULTI_TENANCY || tenantId == DEFAULT_TENANT_ID) {
+ // just get all DBs when:
+ // - single tenancy
+ // - default tenant
+ // - apps dbs don't contain tenant id
+ // - non-default tenant dbs are filtered out application side in getAllApps
+ await addDbs(couchUrl)
+ } else {
// get prod apps
await addDbs(
exports.getStartEndKeyURL(couchUrl, DocumentTypes.APP, tenantId)
@@ -236,9 +243,6 @@ exports.getAllDbs = async () => {
)
// add global db name
dbs.push(getGlobalDBName(tenantId))
- } else {
- // just get all DBs in self host
- await addDbs(couchUrl)
}
return dbs
}
diff --git a/packages/auth/src/db/views.js b/packages/backend-core/src/db/views.js
similarity index 100%
rename from packages/auth/src/db/views.js
rename to packages/backend-core/src/db/views.js
diff --git a/packages/auth/src/environment.js b/packages/backend-core/src/environment.js
similarity index 100%
rename from packages/auth/src/environment.js
rename to packages/backend-core/src/environment.js
diff --git a/packages/auth/src/hashing.js b/packages/backend-core/src/hashing.js
similarity index 100%
rename from packages/auth/src/hashing.js
rename to packages/backend-core/src/hashing.js
diff --git a/packages/auth/src/helpers.js b/packages/backend-core/src/helpers.js
similarity index 100%
rename from packages/auth/src/helpers.js
rename to packages/backend-core/src/helpers.js
diff --git a/packages/backend-core/src/index.js b/packages/backend-core/src/index.js
new file mode 100644
index 0000000000..cd3a3f5c97
--- /dev/null
+++ b/packages/backend-core/src/index.js
@@ -0,0 +1,17 @@
+const { setDB } = require("./db")
+
+module.exports = {
+ init(pouch) {
+ setDB(pouch)
+ },
+ // some default exports from the library, however these ideally shouldn't
+ // be used, instead the syntax require("@budibase/backend-core/db") should be used
+ StaticDatabases: require("./db/utils").StaticDatabases,
+ db: require("../db"),
+ redis: require("../redis"),
+ objectStore: require("../objectStore"),
+ utils: require("../utils"),
+ cache: require("../cache"),
+ auth: require("../auth"),
+ constants: require("../constants"),
+}
diff --git a/packages/auth/src/middleware/appTenancy.js b/packages/backend-core/src/middleware/appTenancy.js
similarity index 100%
rename from packages/auth/src/middleware/appTenancy.js
rename to packages/backend-core/src/middleware/appTenancy.js
diff --git a/packages/auth/src/middleware/auditLog.js b/packages/backend-core/src/middleware/auditLog.js
similarity index 100%
rename from packages/auth/src/middleware/auditLog.js
rename to packages/backend-core/src/middleware/auditLog.js
diff --git a/packages/auth/src/middleware/authenticated.js b/packages/backend-core/src/middleware/authenticated.js
similarity index 100%
rename from packages/auth/src/middleware/authenticated.js
rename to packages/backend-core/src/middleware/authenticated.js
diff --git a/packages/auth/src/middleware/index.js b/packages/backend-core/src/middleware/index.js
similarity index 100%
rename from packages/auth/src/middleware/index.js
rename to packages/backend-core/src/middleware/index.js
diff --git a/packages/auth/src/middleware/matchers.js b/packages/backend-core/src/middleware/matchers.js
similarity index 100%
rename from packages/auth/src/middleware/matchers.js
rename to packages/backend-core/src/middleware/matchers.js
diff --git a/packages/auth/src/middleware/passport/google.js b/packages/backend-core/src/middleware/passport/google.js
similarity index 100%
rename from packages/auth/src/middleware/passport/google.js
rename to packages/backend-core/src/middleware/passport/google.js
diff --git a/packages/auth/src/middleware/passport/jwt.js b/packages/backend-core/src/middleware/passport/jwt.js
similarity index 100%
rename from packages/auth/src/middleware/passport/jwt.js
rename to packages/backend-core/src/middleware/passport/jwt.js
diff --git a/packages/auth/src/middleware/passport/local.js b/packages/backend-core/src/middleware/passport/local.js
similarity index 100%
rename from packages/auth/src/middleware/passport/local.js
rename to packages/backend-core/src/middleware/passport/local.js
diff --git a/packages/auth/src/middleware/passport/oidc.js b/packages/backend-core/src/middleware/passport/oidc.js
similarity index 100%
rename from packages/auth/src/middleware/passport/oidc.js
rename to packages/backend-core/src/middleware/passport/oidc.js
diff --git a/packages/auth/src/middleware/passport/tests/google.spec.js b/packages/backend-core/src/middleware/passport/tests/google.spec.js
similarity index 100%
rename from packages/auth/src/middleware/passport/tests/google.spec.js
rename to packages/backend-core/src/middleware/passport/tests/google.spec.js
diff --git a/packages/auth/src/middleware/passport/tests/oidc.spec.js b/packages/backend-core/src/middleware/passport/tests/oidc.spec.js
similarity index 100%
rename from packages/auth/src/middleware/passport/tests/oidc.spec.js
rename to packages/backend-core/src/middleware/passport/tests/oidc.spec.js
diff --git a/packages/auth/src/middleware/passport/tests/third-party-common.spec.js b/packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js
similarity index 100%
rename from packages/auth/src/middleware/passport/tests/third-party-common.spec.js
rename to packages/backend-core/src/middleware/passport/tests/third-party-common.spec.js
diff --git a/packages/auth/src/middleware/passport/tests/utilities/mock-data.js b/packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js
similarity index 100%
rename from packages/auth/src/middleware/passport/tests/utilities/mock-data.js
rename to packages/backend-core/src/middleware/passport/tests/utilities/mock-data.js
diff --git a/packages/auth/src/middleware/passport/third-party-common.js b/packages/backend-core/src/middleware/passport/third-party-common.js
similarity index 100%
rename from packages/auth/src/middleware/passport/third-party-common.js
rename to packages/backend-core/src/middleware/passport/third-party-common.js
diff --git a/packages/auth/src/middleware/passport/utils.js b/packages/backend-core/src/middleware/passport/utils.js
similarity index 100%
rename from packages/auth/src/middleware/passport/utils.js
rename to packages/backend-core/src/middleware/passport/utils.js
diff --git a/packages/auth/src/middleware/tenancy.js b/packages/backend-core/src/middleware/tenancy.js
similarity index 100%
rename from packages/auth/src/middleware/tenancy.js
rename to packages/backend-core/src/middleware/tenancy.js
diff --git a/packages/auth/src/migrations/index.js b/packages/backend-core/src/migrations/index.js
similarity index 100%
rename from packages/auth/src/migrations/index.js
rename to packages/backend-core/src/migrations/index.js
diff --git a/packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap b/packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap
similarity index 100%
rename from packages/auth/src/migrations/tests/__snapshots__/index.spec.js.snap
rename to packages/backend-core/src/migrations/tests/__snapshots__/index.spec.js.snap
diff --git a/packages/auth/src/migrations/tests/index.spec.js b/packages/backend-core/src/migrations/tests/index.spec.js
similarity index 100%
rename from packages/auth/src/migrations/tests/index.spec.js
rename to packages/backend-core/src/migrations/tests/index.spec.js
diff --git a/packages/auth/src/objectStore/index.js b/packages/backend-core/src/objectStore/index.js
similarity index 91%
rename from packages/auth/src/objectStore/index.js
rename to packages/backend-core/src/objectStore/index.js
index 87b67d464e..b5d8475cee 100644
--- a/packages/auth/src/objectStore/index.js
+++ b/packages/backend-core/src/objectStore/index.js
@@ -206,6 +206,34 @@ exports.retrieveToTmp = async (bucketName, filepath) => {
return outputPath
}
+/**
+ * Delete a single file.
+ */
+exports.deleteFile = async (bucketName, filepath) => {
+ const objectStore = exports.ObjectStore(bucketName)
+ await exports.makeSureBucketExists(objectStore, bucketName)
+ const params = {
+ Bucket: bucketName,
+ Key: filepath,
+ }
+ return objectStore.deleteObject(params)
+}
+
+exports.deleteFiles = async (bucketName, filepaths) => {
+ const objectStore = exports.ObjectStore(bucketName)
+ await exports.makeSureBucketExists(objectStore, bucketName)
+ const params = {
+ Bucket: bucketName,
+ Delete: {
+ Objects: filepaths.map(path => ({ Key: path })),
+ },
+ }
+ return objectStore.deleteObjects(params).promise()
+}
+
+/**
+ * Delete a path, including everything within.
+ */
exports.deleteFolder = async (bucketName, folder) => {
bucketName = sanitizeBucket(bucketName)
folder = sanitizeKey(folder)
diff --git a/packages/auth/src/objectStore/utils.js b/packages/backend-core/src/objectStore/utils.js
similarity index 100%
rename from packages/auth/src/objectStore/utils.js
rename to packages/backend-core/src/objectStore/utils.js
diff --git a/packages/auth/src/redis/authRedis.js b/packages/backend-core/src/redis/authRedis.js
similarity index 100%
rename from packages/auth/src/redis/authRedis.js
rename to packages/backend-core/src/redis/authRedis.js
diff --git a/packages/auth/src/redis/index.js b/packages/backend-core/src/redis/index.js
similarity index 100%
rename from packages/auth/src/redis/index.js
rename to packages/backend-core/src/redis/index.js
diff --git a/packages/auth/src/redis/utils.js b/packages/backend-core/src/redis/utils.js
similarity index 100%
rename from packages/auth/src/redis/utils.js
rename to packages/backend-core/src/redis/utils.js
diff --git a/packages/auth/src/security/permissions.js b/packages/backend-core/src/security/permissions.js
similarity index 100%
rename from packages/auth/src/security/permissions.js
rename to packages/backend-core/src/security/permissions.js
diff --git a/packages/auth/src/security/roles.js b/packages/backend-core/src/security/roles.js
similarity index 100%
rename from packages/auth/src/security/roles.js
rename to packages/backend-core/src/security/roles.js
diff --git a/packages/auth/src/security/sessions.js b/packages/backend-core/src/security/sessions.js
similarity index 100%
rename from packages/auth/src/security/sessions.js
rename to packages/backend-core/src/security/sessions.js
diff --git a/packages/auth/src/tenancy/FunctionContext.js b/packages/backend-core/src/tenancy/FunctionContext.js
similarity index 100%
rename from packages/auth/src/tenancy/FunctionContext.js
rename to packages/backend-core/src/tenancy/FunctionContext.js
diff --git a/packages/auth/src/tenancy/context.js b/packages/backend-core/src/tenancy/context.js
similarity index 100%
rename from packages/auth/src/tenancy/context.js
rename to packages/backend-core/src/tenancy/context.js
diff --git a/packages/auth/src/tenancy/deprovision.js b/packages/backend-core/src/tenancy/deprovision.js
similarity index 100%
rename from packages/auth/src/tenancy/deprovision.js
rename to packages/backend-core/src/tenancy/deprovision.js
diff --git a/packages/auth/src/tenancy/index.js b/packages/backend-core/src/tenancy/index.js
similarity index 100%
rename from packages/auth/src/tenancy/index.js
rename to packages/backend-core/src/tenancy/index.js
diff --git a/packages/auth/src/tenancy/tenancy.js b/packages/backend-core/src/tenancy/tenancy.js
similarity index 100%
rename from packages/auth/src/tenancy/tenancy.js
rename to packages/backend-core/src/tenancy/tenancy.js
diff --git a/packages/auth/src/tests/utilities/db.js b/packages/backend-core/src/tests/utilities/db.js
similarity index 100%
rename from packages/auth/src/tests/utilities/db.js
rename to packages/backend-core/src/tests/utilities/db.js
diff --git a/packages/auth/src/tests/utilities/dbConfig.js b/packages/backend-core/src/tests/utilities/dbConfig.js
similarity index 100%
rename from packages/auth/src/tests/utilities/dbConfig.js
rename to packages/backend-core/src/tests/utilities/dbConfig.js
diff --git a/packages/auth/src/utils.js b/packages/backend-core/src/utils.js
similarity index 100%
rename from packages/auth/src/utils.js
rename to packages/backend-core/src/utils.js
diff --git a/packages/auth/tenancy.js b/packages/backend-core/tenancy.js
similarity index 100%
rename from packages/auth/tenancy.js
rename to packages/backend-core/tenancy.js
diff --git a/packages/backend-core/utils.js b/packages/backend-core/utils.js
new file mode 100644
index 0000000000..2ef920e103
--- /dev/null
+++ b/packages/backend-core/utils.js
@@ -0,0 +1,4 @@
+module.exports = {
+ ...require("./src/utils"),
+ ...require("./src/hashing"),
+}
diff --git a/packages/auth/yarn.lock b/packages/backend-core/yarn.lock
similarity index 100%
rename from packages/auth/yarn.lock
rename to packages/backend-core/yarn.lock
diff --git a/packages/bbui/package.json b/packages/bbui/package.json
index f53c314eaa..941127eb92 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": "1.0.27-alpha.5",
+ "version": "1.0.27-alpha.13",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
diff --git a/packages/bbui/src/Tabs/Tabs.svelte b/packages/bbui/src/Tabs/Tabs.svelte
index c68f715de0..40e02058c1 100644
--- a/packages/bbui/src/Tabs/Tabs.svelte
+++ b/packages/bbui/src/Tabs/Tabs.svelte
@@ -10,6 +10,8 @@
export let noHorizPadding = false
export let quiet = false
export let emphasized = false
+ // overlay content from the tab bar onto tabs e.g. for a dropdown
+ export let onTop = false
let thisSelected = undefined
@@ -78,6 +80,7 @@
'spectrum-Tabs--quiet'} spectrum-Tabs--{vertical
? 'vertical'
: 'horizontal'}"
+ class:onTop
>
{JSON.stringify(bindings, null, 2)}+
{JSON.stringify(bindings, null, 2)}+ {/if}