Merge branch 'master' of github.com:Budibase/budibase into plus-datasources

This commit is contained in:
Martin McKeaveney 2021-06-10 12:13:28 +01:00
commit dfceb02711
24 changed files with 107 additions and 66 deletions

View File

@ -14,7 +14,6 @@ services:
environment: environment:
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY} MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY} MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_BROWSER: "off"
command: server /data command: server /data
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]

View File

@ -1,5 +1,5 @@
{ {
"version": "0.9.38", "version": "0.9.42",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/auth", "name": "@budibase/auth",
"version": "0.9.38", "version": "0.9.42",
"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",

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": "0.9.38", "version": "0.9.42",
"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",

View File

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

@ -35,6 +35,7 @@ const createScreen = table => {
const form = makeMainForm() const form = makeMainForm()
.instanceName("Form") .instanceName("Form")
.customProps({ .customProps({
actionType: "Create",
theme: "spectrum--lightest", theme: "spectrum--lightest",
size: "spectrum--medium", size: "spectrum--medium",
dataSource: { dataSource: {

View File

@ -110,6 +110,7 @@ const createScreen = table => {
const form = makeMainForm() const form = makeMainForm()
.instanceName("Form") .instanceName("Form")
.customProps({ .customProps({
actionType: "Update",
theme: "spectrum--lightest", theme: "spectrum--lightest",
size: "spectrum--medium", size: "spectrum--medium",
dataSource: { dataSource: {

View File

@ -38,17 +38,21 @@
let loading let loading
async function saveSmtp() { async function saveSmtp() {
try { // Save your SMTP config
// Save your SMTP config const response = await api.post(`/api/admin/configs`, smtpConfig)
const response = await api.post(`/api/admin/configs`, smtpConfig)
if (response.status !== 200) {
const error = await response.text()
let message = error
try {
message = JSON.parse(error).message
} catch (err) {}
notifications.error(`Failed to save email settings, reason: ${message}`)
} else {
const json = await response.json() const json = await response.json()
if (response.status !== 200) throw new Error(json.message)
smtpConfig._rev = json._rev smtpConfig._rev = json._rev
smtpConfig._id = json._id smtpConfig._id = json._id
notifications.success(`Settings saved.`) notifications.success(`Settings saved.`)
} catch (err) {
notifications.error(`Failed to save email settings. ${err}`)
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "0.9.38", "version": "0.9.42",
"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": "0.9.38", "version": "0.9.42",
"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",
@ -18,13 +18,13 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/string-templates": "^0.9.38", "@budibase/string-templates": "^0.9.42",
"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"
}, },
"devDependencies": { "devDependencies": {
"@budibase/standard-components": "^0.9.38", "@budibase/standard-components": "^0.9.42",
"@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-node-resolve": "^11.2.1",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "0.9.38", "version": "0.9.42",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/electron.js", "main": "src/electron.js",
"repository": { "repository": {
@ -55,9 +55,9 @@
"author": "Budibase", "author": "Budibase",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@budibase/auth": "^0.9.38", "@budibase/auth": "^0.9.42",
"@budibase/client": "^0.9.38", "@budibase/client": "^0.9.42",
"@budibase/string-templates": "^0.9.38", "@budibase/string-templates": "^0.9.42",
"@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",
@ -109,7 +109,7 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.3", "@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4", "@babel/preset-env": "^7.14.4",
"@budibase/standard-components": "^0.9.38", "@budibase/standard-components": "^0.9.42",
"@jest/test-sequencer": "^24.8.0", "@jest/test-sequencer": "^24.8.0",
"babel-jest": "^27.0.2", "babel-jest": "^27.0.2",
"docker-compose": "^0.23.6", "docker-compose": "^0.23.6",

View File

@ -71,7 +71,7 @@ exports.uploadFile = async function (ctx) {
return prepareUpload({ return prepareUpload({
file, file,
s3Key: `assets/${ctx.appId}/attachments/${processedFileName}`, s3Key: `${ctx.appId}/attachments/${processedFileName}`,
bucket: ObjectStoreBuckets.APPS, bucket: ObjectStoreBuckets.APPS,
}) })
}) })

View File

@ -385,7 +385,7 @@ describe("/rows", () => {
name: "test", name: "test",
description: "test", description: "test",
attachment: [{ attachment: [{
key: `${config.getAppId()}/attachment/test/thing.csv`, key: `${config.getAppId()}/attachments/test/thing.csv`,
}], }],
tableId: table._id, tableId: table._id,
}) })
@ -393,7 +393,7 @@ describe("/rows", () => {
await setup.switchToSelfHosted(async () => { await setup.switchToSelfHosted(async () => {
const enriched = await outputProcessing(config.getAppId(), table, [row]) const enriched = await outputProcessing(config.getAppId(), table, [row])
expect(enriched[0].attachment[0].url).toBe( expect(enriched[0].attachment[0].url).toBe(
`/prod-budi-app-assets/${config.getAppId()}/attachment/test/thing.csv` `/prod-budi-app-assets/${config.getAppId()}/attachments/test/thing.csv`
) )
}) })
}) })

View File

@ -1023,6 +1023,13 @@
"ValidateForm" "ValidateForm"
], ],
"settings": [ "settings": [
{
"type": "select",
"label": "Type",
"key": "actionType",
"options": ["Create", "Update"],
"defaultValue": "Create"
},
{ {
"type": "schema", "type": "schema",
"label": "Schema", "label": "Schema",

View File

@ -29,11 +29,11 @@
"keywords": [ "keywords": [
"svelte" "svelte"
], ],
"version": "0.9.38", "version": "0.9.42",
"license": "MIT", "license": "MIT",
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc", "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc",
"dependencies": { "dependencies": {
"@budibase/bbui": "^0.9.38", "@budibase/bbui": "^0.9.42",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",
"apexcharts": "^3.22.1", "apexcharts": "^3.22.1",

View File

@ -8,6 +8,7 @@
export let theme export let theme
export let size export let size
export let disabled = false export let disabled = false
export let actionType = "Create"
const component = getContext("component") const component = getContext("component")
const context = getContext("context") const context = getContext("context")
@ -19,15 +20,29 @@
let fieldMap = {} let fieldMap = {}
// Returns the closes data context which isn't a built in context // Returns the closes data context which isn't a built in context
const getInitialValues = context => { const getInitialValues = (type, dataSource, context) => {
// Only inherit values for update forms
if (type !== "Update") {
return {}
}
// Only inherit values for forms targetting internal tables
if (!dataSource?.tableId) {
return {}
}
// Don't inherit values representing built in contexts
if (["user", "url"].includes(context.closestComponentId)) { if (["user", "url"].includes(context.closestComponentId)) {
return {} return {}
} }
return context[`${context.closestComponentId}`] || {} // Only inherit values if the table ID matches
const closestContext = context[`${context.closestComponentId}`] || {}
if (dataSource.tableId !== closestContext?.tableId) {
return {}
}
return closestContext
} }
// Use the closest data context as the initial form values // Use the closest data context as the initial form values
const initialValues = getInitialValues($context) const initialValues = getInitialValues(actionType, dataSource, $context)
// Form state contains observable data about the form // Form state contains observable data about the form
const formState = writable({ values: initialValues, errors: {}, valid: true }) const formState = writable({ values: initialValues, errors: {}, valid: true })
@ -42,22 +57,11 @@
// Auto columns are always disabled // Auto columns are always disabled
const isAutoColumn = !!schema?.[field]?.autocolumn const isAutoColumn = !!schema?.[field]?.autocolumn
if (fieldMap[field] != null) {
// Update disabled property just so that toggling the disabled field
// state in the builder makes updates in real time.
// We only need this because of optimisations which prevent fully
// remounting when settings change.
fieldMap[field].fieldState.update(state => {
state.disabled = disabled || fieldDisabled || isAutoColumn
return state
})
return fieldMap[field]
}
// Create validation function based on field schema // Create validation function based on field schema
const constraints = schema?.[field]?.constraints const constraints = schema?.[field]?.constraints
const validate = createValidatorFromConstraints(constraints, field, table) const validate = createValidatorFromConstraints(constraints, field, table)
// Construct field object
fieldMap[field] = { fieldMap[field] = {
fieldState: makeFieldState( fieldState: makeFieldState(
field, field,
@ -67,6 +71,17 @@
fieldApi: makeFieldApi(field, defaultValue, validate), fieldApi: makeFieldApi(field, defaultValue, validate),
fieldSchema: schema?.[field] ?? {}, fieldSchema: schema?.[field] ?? {},
} }
// Set initial value
const initialValue = get(fieldMap[field].fieldState).value
formState.update(state => ({
...state,
values: {
...state.values,
[field]: initialValue,
},
}))
return fieldMap[field] return fieldMap[field]
}, },
validate: () => { validate: () => {

View File

@ -13,7 +13,9 @@ export const buildLuceneQuery = filter => {
notEmpty: {}, notEmpty: {},
} }
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
filter.forEach(({ operator, field, type, value }) => { // Build up proper range filters
filter.forEach(expression => {
const { operator, field, type, value } = expression
if (operator.startsWith("range")) { if (operator.startsWith("range")) {
if (!query.range[field]) { if (!query.range[field]) {
query.range[field] = { query.range[field] = {
@ -33,10 +35,24 @@ export const buildLuceneQuery = filter => {
query.range[field].high = value query.range[field].high = value
} }
} else if (query[operator]) { } else if (query[operator]) {
query[operator][field] = value if (type === "boolean") {
// Transform boolean filters to cope with null.
// "equals false" needs to be "not equals true"
// "not equals false" needs to be "equals true"
if (operator === "equal" && value === "false") {
query.notEqual[field] = "true"
} else if (operator === "notEqual" && value === "false") {
query.equal[field] = "true"
} else {
query[operator][field] = value
}
} else {
query[operator][field] = value
}
} }
}) })
} }
return query return query
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "0.9.38", "version": "0.9.42",
"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

@ -16,9 +16,6 @@ registerAll(hbsInstance)
* utility function to check if the object is valid * utility function to check if the object is valid
*/ */
function testObject(object) { function testObject(object) {
if (object == null) {
throw "Unable to process null object"
}
// JSON stringify will fail if there are any cycles, stops infinite recursion // JSON stringify will fail if there are any cycles, stops infinite recursion
try { try {
JSON.stringify(object) JSON.stringify(object)

View File

@ -81,14 +81,14 @@ describe("Test that the object processing works correctly", () => {
expect(error).not.toBeNull() expect(error).not.toBeNull()
}) })
it("should fail gracefully when wrong type is passed in", async () => { it("should be able to handle null objects", async () => {
let error = null let error = null
try { try {
await processObject(null, null) await processObject(null, null)
} catch (err) { } catch (err) {
error = err error = err
} }
expect(error).not.toBeNull() expect(error).toBeNull()
}) })
}) })

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "0.9.38", "version": "0.9.42",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.js", "main": "src/index.js",
"repository": { "repository": {
@ -21,8 +21,8 @@
"author": "Budibase", "author": "Budibase",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"@budibase/auth": "^0.9.38", "@budibase/auth": "^0.9.42",
"@budibase/string-templates": "^0.9.38", "@budibase/string-templates": "^0.9.42",
"@koa/router": "^8.0.0", "@koa/router": "^8.0.0",
"aws-sdk": "^2.811.0", "aws-sdk": "^2.811.0",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",

View File

@ -27,11 +27,15 @@ exports.save = async function (ctx) {
}) })
} }
// verify the configuration try {
switch (type) { // verify the configuration
case Configs.SMTP: switch (type) {
await email.verifyConfig(config) case Configs.SMTP:
break await email.verifyConfig(config)
break
}
} catch (err) {
ctx.throw(400, err)
} }
try { try {
@ -42,7 +46,7 @@ exports.save = async function (ctx) {
_rev: response.rev, _rev: response.rev,
} }
} catch (err) { } catch (err) {
ctx.throw(err.status, err) ctx.throw(400, err)
} }
} }

View File

@ -14,7 +14,6 @@ function smtpValidation() {
host: Joi.string().required(), host: Joi.string().required(),
from: Joi.string().email().required(), from: Joi.string().email().required(),
secure: Joi.boolean().optional(), secure: Joi.boolean().optional(),
selfSigned: Joi.boolean().optional(),
auth: Joi.object({ auth: Joi.object({
type: Joi.string().valid("login", "oauth2", null), type: Joi.string().valid("login", "oauth2", null),
user: Joi.string().required(), user: Joi.string().required(),

View File

@ -27,10 +27,8 @@ function createSMTPTransport(config) {
secure: config.secure || false, secure: config.secure || false,
auth: config.auth, auth: config.auth,
} }
if (config.selfSigned) { options.tls = {
options.tls = { rejectUnauthorized: false,
rejectUnauthorized: false,
}
} }
} else { } else {
options = { options = {