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

This commit is contained in:
mike12345567 2022-01-31 14:29:02 +00:00
commit 712382af07
16 changed files with 77 additions and 40 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.0.46-alpha.8", "version": "1.0.48",
"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.46-alpha.8", "version": "1.0.48",
"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

@ -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.46-alpha.8", "version": "1.0.48",
"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",

View File

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

@ -22,8 +22,10 @@
RelationshipTypes, RelationshipTypes,
ALLOWABLE_STRING_OPTIONS, ALLOWABLE_STRING_OPTIONS,
ALLOWABLE_NUMBER_OPTIONS, ALLOWABLE_NUMBER_OPTIONS,
ALLOWABLE_JSON_OPTIONS,
ALLOWABLE_STRING_TYPES, ALLOWABLE_STRING_TYPES,
ALLOWABLE_NUMBER_TYPES, ALLOWABLE_NUMBER_TYPES,
ALLOWABLE_JSON_TYPES,
SWITCHABLE_TYPES, SWITCHABLE_TYPES,
} from "constants/backend" } from "constants/backend"
import { getAutoColumnInformation, buildAutoColumn } from "builderStore/utils" import { getAutoColumnInformation, buildAutoColumn } from "builderStore/utils"
@ -241,6 +243,11 @@
ALLOWABLE_NUMBER_TYPES.indexOf(field.type) !== -1 ALLOWABLE_NUMBER_TYPES.indexOf(field.type) !== -1
) { ) {
return ALLOWABLE_NUMBER_OPTIONS return ALLOWABLE_NUMBER_OPTIONS
} else if (
originalName &&
ALLOWABLE_JSON_TYPES.indexOf(field.type) !== -1
) {
return ALLOWABLE_JSON_OPTIONS
} else if (!external) { } else if (!external) {
return [ return [
...Object.values(fieldDefinitions), ...Object.values(fieldDefinitions),

View File

@ -1,16 +1,14 @@
<script> <script>
import { Label, Select } from "@budibase/bbui" import { Label, Select } from "@budibase/bbui"
import { permissions, roles } from "stores/backend" import { permissions, roles } from "stores/backend"
import { onMount } from "svelte"
import { Roles } from "constants/backend" import { Roles } from "constants/backend"
export let query export let query
export let saveId
export let label export let label
$: updateRole(roleId, saveId) $: getPermissions(query)
let roleId, loaded let roleId, loaded, fetched
async function updateRole(role, id) { async function updateRole(role, id) {
roleId = role roleId = role
@ -26,19 +24,23 @@
} }
} }
onMount(async () => { async function getPermissions(queryToFetch) {
if (!query || !query._id) { if (fetched?._id === queryToFetch?._id) {
return
}
fetched = queryToFetch
if (!queryToFetch || !queryToFetch._id) {
roleId = Roles.BASIC roleId = Roles.BASIC
loaded = true loaded = true
return return
} }
try { try {
roleId = (await permissions.forResource(query._id))["read"] roleId = (await permissions.forResource(queryToFetch._id))["read"]
} catch (err) { } catch (err) {
roleId = Roles.BASIC roleId = Roles.BASIC
} }
loaded = true loaded = true
}) }
</script> </script>
{#if loaded} {#if loaded}

View File

@ -148,20 +148,23 @@ export const RelationshipTypes = {
} }
export const ALLOWABLE_STRING_OPTIONS = [FIELDS.STRING, FIELDS.OPTIONS] export const ALLOWABLE_STRING_OPTIONS = [FIELDS.STRING, FIELDS.OPTIONS]
export const ALLOWABLE_STRING_TYPES = ALLOWABLE_STRING_OPTIONS.map( export const ALLOWABLE_STRING_TYPES = ALLOWABLE_STRING_OPTIONS.map(
opt => opt.type opt => opt.type
) )
export const ALLOWABLE_NUMBER_OPTIONS = [FIELDS.NUMBER, FIELDS.BOOLEAN] export const ALLOWABLE_NUMBER_OPTIONS = [FIELDS.NUMBER, FIELDS.BOOLEAN]
export const ALLOWABLE_NUMBER_TYPES = ALLOWABLE_NUMBER_OPTIONS.map( export const ALLOWABLE_NUMBER_TYPES = ALLOWABLE_NUMBER_OPTIONS.map(
opt => opt.type opt => opt.type
) )
export const SWITCHABLE_TYPES = ALLOWABLE_NUMBER_TYPES.concat( export const ALLOWABLE_JSON_OPTIONS = [FIELDS.JSON, FIELDS.ARRAY]
ALLOWABLE_STRING_TYPES export const ALLOWABLE_JSON_TYPES = ALLOWABLE_JSON_OPTIONS.map(opt => opt.type)
)
export const SWITCHABLE_TYPES = [
...ALLOWABLE_STRING_TYPES,
...ALLOWABLE_NUMBER_TYPES,
...ALLOWABLE_JSON_TYPES,
]
export const IntegrationTypes = { export const IntegrationTypes = {
POSTGRES: "POSTGRES", POSTGRES: "POSTGRES",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.0.46-alpha.8", "version": "1.0.48",
"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.46-alpha.8", "version": "1.0.48",
"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.46-alpha.8", "@budibase/bbui": "^1.0.48",
"@budibase/standard-components": "^0.9.139", "@budibase/standard-components": "^0.9.139",
"@budibase/string-templates": "^1.0.46-alpha.8", "@budibase/string-templates": "^1.0.48",
"regexparam": "^1.3.0", "regexparam": "^1.3.0",
"rollup-plugin-polyfill-node": "^0.8.0", "rollup-plugin-polyfill-node": "^0.8.0",
"shortid": "^2.2.15", "shortid": "^2.2.15",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.46-alpha.8", "version": "1.0.48",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -70,9 +70,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.46-alpha.8", "@budibase/backend-core": "^1.0.48",
"@budibase/client": "^1.0.46-alpha.8", "@budibase/client": "^1.0.48",
"@budibase/string-templates": "^1.0.46-alpha.8", "@budibase/string-templates": "^1.0.48",
"@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

@ -525,7 +525,7 @@ module External {
const linkTable = this.getTable(tableId) const linkTable = this.getTable(tableId)
// @ts-ignore // @ts-ignore
const linkPrimary = linkTable.primary[0] const linkPrimary = linkTable.primary[0]
const rows = related[key].rows || [] const rows = related[key]?.rows || []
const found = rows.find( const found = rows.find(
(row: { [key: string]: any }) => (row: { [key: string]: any }) =>
row[linkPrimary] === relationship.id || row[linkPrimary] === relationship.id ||

View File

@ -8,7 +8,11 @@ const {
const { isEqual } = require("lodash/fp") const { isEqual } = require("lodash/fp")
const { AutoFieldSubTypes, FieldTypes } = require("../../../constants") const { AutoFieldSubTypes, FieldTypes } = require("../../../constants")
const { inputProcessing } = require("../../../utilities/rowProcessor") const { inputProcessing } = require("../../../utilities/rowProcessor")
const { USERS_TABLE_SCHEMA, SwitchableTypes } = require("../../../constants") const {
USERS_TABLE_SCHEMA,
SwitchableTypes,
CanSwitchTypes,
} = require("../../../constants")
const { const {
isExternalTable, isExternalTable,
breakExternalTableId, breakExternalTableId,
@ -348,6 +352,23 @@ exports.foreignKeyStructure = (keyName, meta = null) => {
return structure return structure
} }
exports.areSwitchableTypes = (type1, type2) => {
if (
SwitchableTypes.indexOf(type1) === -1 &&
SwitchableTypes.indexOf(type2) === -1
) {
return false
}
for (let option of CanSwitchTypes) {
const index1 = option.indexOf(type1),
index2 = option.indexOf(type2)
if (index1 !== -1 && index2 !== -1 && index1 !== index2) {
return true
}
}
return false
}
exports.hasTypeChanged = (table, oldTable) => { exports.hasTypeChanged = (table, oldTable) => {
if (!oldTable) { if (!oldTable) {
return false return false
@ -358,7 +379,7 @@ exports.hasTypeChanged = (table, oldTable) => {
continue continue
} }
const newType = table.schema[key].type const newType = table.schema[key].type
if (oldType !== newType && SwitchableTypes.indexOf(oldType) === -1) { if (oldType !== newType && !exports.areSwitchableTypes(oldType, newType)) {
return true return true
} }
} }

View File

@ -45,13 +45,16 @@ exports.FieldTypes = {
INTERNAL: "internal", INTERNAL: "internal",
} }
exports.SwitchableTypes = [ exports.CanSwitchTypes = [
exports.FieldTypes.STRING, [exports.FieldTypes.JSON, exports.FieldTypes.ARRAY],
exports.FieldTypes.OPTIONS, [exports.FieldTypes.STRING, exports.FieldTypes.OPTIONS],
exports.FieldTypes.NUMBER, [exports.FieldTypes.BOOLEAN, exports.FieldTypes.NUMBER],
exports.FieldTypes.BOOLEAN,
] ]
exports.SwitchableTypes = exports.CanSwitchTypes.reduce((prev, current) =>
prev ? prev.concat(current) : current
)
exports.RelationshipTypes = { exports.RelationshipTypes = {
ONE_TO_MANY: "one-to-many", ONE_TO_MANY: "one-to-many",
MANY_TO_ONE: "many-to-one", MANY_TO_ONE: "many-to-one",

View File

@ -178,6 +178,7 @@ function shouldCopySpecialColumn(
) { ) {
return ( return (
column.type === FieldTypes.OPTIONS || column.type === FieldTypes.OPTIONS ||
column.type === FieldTypes.ARRAY ||
((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) && ((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) &&
column.type === FieldTypes.BOOLEAN) column.type === FieldTypes.BOOLEAN)
) )

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.0.46-alpha.8", "version": "1.0.48",
"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.46-alpha.8", "version": "1.0.48",
"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": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.0.46-alpha.8", "@budibase/backend-core": "^1.0.48",
"@budibase/string-templates": "^1.0.46-alpha.8", "@budibase/string-templates": "^1.0.48",
"@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",