Merge branch 'develop' of github.com:Budibase/budibase into custom-theming
This commit is contained in:
commit
989652bc0b
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/auth",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"description": "Authentication middlewares for budibase builder and apps",
|
||||
"main": "src/index.js",
|
||||
"author": "Budibase",
|
||||
|
|
|
@ -18,6 +18,10 @@ exports.getUser = async (userId, tenantId = null) => {
|
|||
user = await getGlobalDB(tenantId).get(userId)
|
||||
client.store(userId, user, EXPIRY_SECONDS)
|
||||
}
|
||||
if (user && !user.tenantId && tenantId) {
|
||||
// make sure the tenant ID is always correct/set
|
||||
user.tenantId = tenantId
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@ const { setTenantId } = require("../tenancy")
|
|||
const ContextFactory = require("../tenancy/FunctionContext")
|
||||
const { buildMatcherRegex, matches } = require("./matchers")
|
||||
|
||||
module.exports = (allowQueryStringPatterns, noTenancyPatterns) => {
|
||||
module.exports = (allowQueryStringPatterns, noTenancyPatterns, opts = {}) => {
|
||||
const allowQsOptions = buildMatcherRegex(allowQueryStringPatterns)
|
||||
const noTenancyOptions = buildMatcherRegex(noTenancyPatterns)
|
||||
|
||||
return ContextFactory.getMiddleware(ctx => {
|
||||
const allowNoTenant = !!matches(ctx, noTenancyOptions)
|
||||
const allowNoTenant =
|
||||
opts.noTenancyRequired || !!matches(ctx, noTenancyOptions)
|
||||
const allowQs = !!matches(ctx, allowQsOptions)
|
||||
setTenantId(ctx, { allowQs, allowNoTenant })
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/bbui",
|
||||
"description": "A UI solution used in the different Budibase projects.",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"license": "AGPL-3.0",
|
||||
"svelte": "src/index.js",
|
||||
"module": "dist/bbui.es.js",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/builder",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"license": "AGPL-3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -65,10 +65,10 @@
|
|||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^0.9.120-alpha.4",
|
||||
"@budibase/client": "^0.9.120-alpha.4",
|
||||
"@budibase/bbui": "^0.9.123-alpha.0",
|
||||
"@budibase/client": "^0.9.123-alpha.0",
|
||||
"@budibase/colorpicker": "1.1.2",
|
||||
"@budibase/string-templates": "^0.9.120-alpha.4",
|
||||
"@budibase/string-templates": "^0.9.123-alpha.0",
|
||||
"@sentry/browser": "5.19.1",
|
||||
"@spectrum-css/page": "^3.0.1",
|
||||
"@spectrum-css/vars": "^3.0.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/cli",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||
"main": "src/index.js",
|
||||
"bin": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/client",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"license": "MPL-2.0",
|
||||
"module": "dist/budibase-client.js",
|
||||
"main": "dist/budibase-client.js",
|
||||
|
@ -19,14 +19,13 @@
|
|||
"dev:builder": "rollup -cw"
|
||||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^0.9.120-alpha.4",
|
||||
"@budibase/string-templates": "^0.9.120-alpha.4",
|
||||
"@budibase/bbui": "^0.9.123-alpha.0",
|
||||
"@budibase/string-templates": "^0.9.123-alpha.0",
|
||||
"regexparam": "^1.3.0",
|
||||
"shortid": "^2.2.15",
|
||||
"svelte-spa-router": "^3.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@budibase/bbui": "^0.9.120-alpha.4",
|
||||
"@rollup/plugin-alias": "^3.1.5",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/server",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"description": "Budibase Web Server",
|
||||
"main": "src/index.js",
|
||||
"repository": {
|
||||
|
@ -62,9 +62,9 @@
|
|||
"author": "Budibase",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@budibase/auth": "^0.9.120-alpha.4",
|
||||
"@budibase/client": "^0.9.120-alpha.4",
|
||||
"@budibase/string-templates": "^0.9.120-alpha.4",
|
||||
"@budibase/auth": "^0.9.123-alpha.0",
|
||||
"@budibase/client": "^0.9.123-alpha.0",
|
||||
"@budibase/string-templates": "^0.9.123-alpha.0",
|
||||
"@elastic/elasticsearch": "7.10.0",
|
||||
"@koa/router": "8.0.0",
|
||||
"@sendgrid/mail": "7.1.1",
|
||||
|
@ -117,7 +117,7 @@
|
|||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/preset-env": "^7.14.4",
|
||||
"@budibase/client": "^0.9.120-alpha.4",
|
||||
"@budibase/client": "^0.9.123-alpha.0",
|
||||
"@jest/test-sequencer": "^24.8.0",
|
||||
"@types/bull": "^3.15.1",
|
||||
"@types/jest": "^26.0.23",
|
||||
|
|
|
@ -6,8 +6,16 @@ import {
|
|||
SearchFilters,
|
||||
SortJson,
|
||||
} from "../../../definitions/datasource"
|
||||
import {Datasource, FieldSchema, Row, Table} from "../../../definitions/common"
|
||||
import {breakRowIdField, generateRowIdField} from "../../../integrations/utils"
|
||||
import {
|
||||
Datasource,
|
||||
FieldSchema,
|
||||
Row,
|
||||
Table,
|
||||
} from "../../../definitions/common"
|
||||
import {
|
||||
breakRowIdField,
|
||||
generateRowIdField,
|
||||
} from "../../../integrations/utils"
|
||||
import { RelationshipTypes } from "../../../constants"
|
||||
|
||||
interface ManyRelationship {
|
||||
|
@ -348,7 +356,7 @@ module External {
|
|||
* information.
|
||||
*/
|
||||
async lookupRelations(tableId: string, row: Row) {
|
||||
const related: {[key: string]: any} = {}
|
||||
const related: { [key: string]: any } = {}
|
||||
const { tableName } = breakExternalTableId(tableId)
|
||||
const table = this.tables[tableName]
|
||||
// @ts-ignore
|
||||
|
@ -387,7 +395,11 @@ module External {
|
|||
* isn't supposed to exist anymore and delete those. This is better than the usual method of delete them
|
||||
* all and then re-create, as theres no chance of losing data (e.g. delete succeed, but write fail).
|
||||
*/
|
||||
async handleManyRelationships(mainTableId: string, row: Row, relationships: ManyRelationship[]) {
|
||||
async handleManyRelationships(
|
||||
mainTableId: string,
|
||||
row: Row,
|
||||
relationships: ManyRelationship[]
|
||||
) {
|
||||
const { appId } = this
|
||||
// if we're creating (in a through table) need to wipe the existing ones first
|
||||
const promises = []
|
||||
|
@ -399,8 +411,10 @@ module External {
|
|||
// @ts-ignore
|
||||
const linkPrimary = linkTable.primary[0]
|
||||
const rows = related[key].rows || []
|
||||
const found = rows.find((row: { [key: string]: any }) =>
|
||||
row[linkPrimary] === relationship.id || row[linkPrimary] === body[linkPrimary]
|
||||
const found = rows.find(
|
||||
(row: { [key: string]: any }) =>
|
||||
row[linkPrimary] === relationship.id ||
|
||||
row[linkPrimary] === body[linkPrimary]
|
||||
)
|
||||
const operation = isUpdate
|
||||
? DataSourceOperation.UPDATE
|
||||
|
@ -420,13 +434,17 @@ module External {
|
|||
}
|
||||
}
|
||||
// finally cleanup anything that needs to be removed
|
||||
for (let [colName, {isMany, rows, tableId}] of Object.entries(related)) {
|
||||
for (let [colName, { isMany, rows, tableId }] of Object.entries(
|
||||
related
|
||||
)) {
|
||||
const table = this.getTable(tableId)
|
||||
for (let row of rows) {
|
||||
const filters = buildFilters(generateIdForRow(row, table), {}, table)
|
||||
// safety check, if there are no filters on deletion bad things happen
|
||||
if (Object.keys(filters).length !== 0) {
|
||||
const op = isMany ? DataSourceOperation.DELETE : DataSourceOperation.UPDATE
|
||||
const op = isMany
|
||||
? DataSourceOperation.DELETE
|
||||
: DataSourceOperation.UPDATE
|
||||
const body = isMany ? null : { [colName]: null }
|
||||
promises.push(
|
||||
makeExternalQuery(this.appId, {
|
||||
|
@ -448,7 +466,10 @@ module External {
|
|||
* Creating the specific list of fields that we desire, and excluding the ones that are no use to us
|
||||
* is more performant and has the added benefit of protecting against this scenario.
|
||||
*/
|
||||
buildFields(table: Table, includeRelations: IncludeRelationships = IncludeRelationships.INCLUDE) {
|
||||
buildFields(
|
||||
table: Table,
|
||||
includeRelations: IncludeRelationships = IncludeRelationships.INCLUDE
|
||||
) {
|
||||
function extractNonLinkFieldNames(table: Table, existing: string[] = []) {
|
||||
return Object.entries(table.schema)
|
||||
.filter(
|
||||
|
@ -523,7 +544,10 @@ module External {
|
|||
// can't really use response right now
|
||||
const response = await makeExternalQuery(appId, json)
|
||||
// handle many to many relationships now if we know the ID (could be auto increment)
|
||||
if (operation !== DataSourceOperation.READ && processed.manyRelationships) {
|
||||
if (
|
||||
operation !== DataSourceOperation.READ &&
|
||||
processed.manyRelationships
|
||||
) {
|
||||
await this.handleManyRelationships(
|
||||
table._id || "",
|
||||
response[0],
|
||||
|
|
|
@ -10,13 +10,6 @@ const env = require("../environment")
|
|||
|
||||
const router = new Router()
|
||||
|
||||
const NO_TENANCY_ENDPOINTS = [
|
||||
{
|
||||
route: "/api/analytics",
|
||||
method: "GET",
|
||||
},
|
||||
]
|
||||
|
||||
router
|
||||
.use(
|
||||
compress({
|
||||
|
@ -39,13 +32,21 @@ router
|
|||
})
|
||||
.use("/health", ctx => (ctx.status = 200))
|
||||
.use("/version", ctx => (ctx.body = pkg.version))
|
||||
// re-direct before any middlewares occur
|
||||
.redirect("/", "/builder")
|
||||
.use(
|
||||
buildAuthMiddleware(null, {
|
||||
publicAllowed: true,
|
||||
})
|
||||
)
|
||||
// nothing in the server should allow query string tenants
|
||||
.use(buildTenancyMiddleware(null, NO_TENANCY_ENDPOINTS))
|
||||
// the server can be public anywhere, so nowhere should throw errors
|
||||
// if the tenancy has not been set, it'll have to be discovered at application layer
|
||||
.use(
|
||||
buildTenancyMiddleware(null, null, {
|
||||
noTenancyRequired: true,
|
||||
})
|
||||
)
|
||||
.use(currentApp)
|
||||
.use(auditLog)
|
||||
|
||||
|
@ -79,7 +80,4 @@ for (let route of mainRoutes) {
|
|||
router.use(staticRoutes.routes())
|
||||
router.use(staticRoutes.allowedMethods())
|
||||
|
||||
// add a redirect for when hitting server directly
|
||||
router.redirect("/", "/builder")
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -42,7 +42,7 @@ export enum SourceNames {
|
|||
|
||||
export enum IncludeRelationships {
|
||||
INCLUDE = 1,
|
||||
EXCLUDE = 0
|
||||
EXCLUDE = 0,
|
||||
}
|
||||
|
||||
export interface QueryDefinition {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/string-templates",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"description": "Handlebars wrapper for Budibase templating.",
|
||||
"main": "src/index.cjs",
|
||||
"module": "dist/bundle.mjs",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/worker",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "0.9.120-alpha.4",
|
||||
"version": "0.9.123-alpha.0",
|
||||
"description": "Budibase background service",
|
||||
"main": "src/index.js",
|
||||
"repository": {
|
||||
|
@ -23,8 +23,8 @@
|
|||
"author": "Budibase",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@budibase/auth": "^0.9.120-alpha.4",
|
||||
"@budibase/string-templates": "^0.9.120-alpha.4",
|
||||
"@budibase/auth": "^0.9.123-alpha.0",
|
||||
"@budibase/string-templates": "^0.9.123-alpha.0",
|
||||
"@koa/router": "^8.0.0",
|
||||
"@techpass/passport-openidconnect": "^0.3.0",
|
||||
"aws-sdk": "^2.811.0",
|
||||
|
|
Loading…
Reference in New Issue