Merge branch 'develop' of github.com:Budibase/budibase into fix/june-fixes

This commit is contained in:
mike12345567 2022-07-08 19:12:43 +01:00
commit 24f416cdde
28 changed files with 125 additions and 84 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -5,4 +5,5 @@ module.exports = {
app: require("./src/cache/appMetadata"),
writethrough: require("./src/cache/writethrough"),
...generic,
cache: generic,
}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -20,7 +20,7 @@
"test:watch": "jest --watchAll"
},
"dependencies": {
"@budibase/types": "^1.0.219-alpha.11",
"@budibase/types": "^1.0.219-alpha.17",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.0.219-alpha.11",
"@budibase/string-templates": "^1.0.219-alpha.17",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

@ -10,6 +10,7 @@ filterTests(['all'], () => {
it("should add Radio Buttons options picker on form, add data, and confirm", () => {
cy.navigateToFrontend()
cy.wait(500)
cy.addComponent("Form", "Form")
cy.addComponent("Form", "Options Picker").then((componentId) => {
// Provide field setting

View File

@ -43,7 +43,7 @@ filterTests(["smoke", "all"], () => {
const uuid = () => Cypress._.random(0, 1e6)
const name = uuid()
if(i < 1){
cy.createApp(name)
cy.createApp(name, false)
} else {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000})
cy.wait(1000)
@ -56,7 +56,7 @@ filterTests(["smoke", "all"], () => {
// Navigate back to the user
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000})
cy.get(interact.SPECTRUM_SIDENAV).contains("Users").click()
cy.get(interact.SPECTRUM_TABLE, { timeout: 500 }).contains("bbuser").click()
cy.get(interact.SPECTRUM_TABLE, { timeout: 1000 }).contains("bbuser").click()
for (let i = 0; i < 3; i++) {
cy.get(interact.SPECTRUM_TABLE, { timeout: 3000})
.eq(1)
@ -65,24 +65,24 @@ filterTests(["smoke", "all"], () => {
.find(interact.SPECTRUM_TABLE_CELL)
.eq(0)
.click()
cy.get(interact.SPECTRUM_DIALOG_GRID, { timeout: 500 })
cy.get(interact.SPECTRUM_DIALOG_GRID, { timeout: 1000 })
.contains("Choose an option")
.click()
.then(() => {
if (i == 0) {
cy.get(interact.SPECTRUM_MENU, { timeout: 1000 }).contains("Admin").click({ force: true })
cy.get(interact.SPECTRUM_MENU, { timeout: 2000 }).contains("Admin").click({ force: true })
}
else if (i == 1) {
cy.get(interact.SPECTRUM_MENU, { timeout: 1000 }).contains("Power").click({ force: true })
cy.get(interact.SPECTRUM_MENU, { timeout: 2000 }).contains("Power").click({ force: true })
}
else if (i == 2) {
cy.get(interact.SPECTRUM_MENU, { timeout: 1000 }).contains("Basic").click({ force: true })
cy.get(interact.SPECTRUM_MENU, { timeout: 2000 }).contains("Basic").click({ force: true })
}
cy.get(interact.SPECTRUM_BUTTON, { timeout: 1000 })
cy.get(interact.SPECTRUM_BUTTON, { timeout: 2000 })
.contains("Update role")
.click({ force: true })
})
cy.reload()
cy.reload({ timeout: 5000 })
cy.wait(1000)
}
// Confirm roles exist within Configure roles table

View File

@ -6,7 +6,7 @@ filterTests(["all"], () => {
before(() => {
cy.login()
cy.deleteAllApps()
cy.createTestApp()
cy.createApp("Cypress Tests")
})
it("Should be accessible from the applications list", () => {
@ -82,13 +82,14 @@ filterTests(["all"], () => {
})
it("Should reflect the app deployment state", () => {
cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 5000 })
cy.get(".appTable .app-row-actions button")
.contains("Edit")
.eq(0)
.click({ force: true })
cy.get(".toprightnav button.spectrum-Button")
cy.wait(500)
cy.get(".toprightnav button.spectrum-Button", { timeout: 2000 })
.contains("Publish")
.click({ force: true })
cy.get(".spectrum-Modal [data-cy='deploy-app-modal']")

View File

@ -5,7 +5,6 @@ filterTests(['smoke', 'all'], () => {
context("Create a View", () => {
before(() => {
cy.login()
cy.createTestApp()
cy.createTable("data")
cy.addColumn("data", "group", "Text")

View File

@ -217,20 +217,21 @@ filterTests(["all"], () => {
it("should edit a query name", () => {
// Access query
cy.get(".hierarchy-items-container")
cy.get(".hierarchy-items-container", { timeout: 2000 })
.contains(queryName + " (1)")
.click()
// Rename query
cy.get(".spectrum-Form-item")
cy.wait(1000)
cy.get(".spectrum-Form-item", { timeout: 2000 })
.eq(0)
.within(() => {
cy.get("input").clear().type(queryRename)
})
// Run and Save query
cy.get(".spectrum-Button").contains("Run Query").click({ force: true })
cy.wait(500)
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Run Query").click({ force: true })
cy.wait(1000)
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Save Query").click({ force: true })
cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 2000 }).should("contain", queryRename)
@ -250,6 +251,7 @@ filterTests(["all"], () => {
.contains("Delete Query")
.click({ force: true })
// Confirm deletion
cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryName)
})

View File

@ -403,17 +403,19 @@ Cypress.Commands.add("createAppFromScratch", appName => {
Cypress.Commands.add("createTable", (tableName, initialTable) => {
if (!initialTable) {
cy.navigateToDataSection()
cy.get(`[data-cy="new-table"]`).click()
cy.get(`[data-cy="new-table"]`, { timeout: 2000 }).click()
}
cy.wait(2000)
cy.get(".item")
cy.get(".item", { timeout: 2000 })
.contains("Budibase DB")
.click({ force: true })
.then(() => {
cy.get(".spectrum-Button").contains("Continue").click({ force: true })
cy.get(".spectrum-Button", { timeout: 2000 })
.contains("Continue")
.click({ force: true })
})
cy.get(".spectrum-Modal").within(() => {
cy.get("input", { timeout: 1000 }).first().type(tableName).blur()
cy.get(".spectrum-Modal", { timeout: 2000 }).within(() => {
cy.get("input", { timeout: 2000 }).first().type(tableName).blur()
cy.get(".spectrum-ButtonGroup").contains("Create").click()
})
cy.contains(tableName).should("be.visible")
@ -507,12 +509,13 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
// DESIGN AREA
Cypress.Commands.add("addComponent", (category, component) => {
if (category) {
cy.get(`[data-cy="category-${category}"]`, { timeout: 1000 }).click({
cy.get(`[data-cy="category-${category}"]`, { timeout: 3000 }).click({
force: true,
})
}
cy.wait(500)
if (component) {
cy.get(`[data-cy="component-${component}"]`, { timeout: 1000 }).click({
cy.get(`[data-cy="component-${component}"]`, { timeout: 3000 }).click({
force: true,
})
}
@ -520,7 +523,7 @@ Cypress.Commands.add("addComponent", (category, component) => {
cy.location().then(loc => {
const params = loc.pathname.split("/")
const componentId = params[params.length - 1]
cy.getComponent(componentId).should("exist")
cy.getComponent(componentId, { timeout: 3000 }).should("exist")
return cy.wrap(componentId)
})
})
@ -624,8 +627,8 @@ Cypress.Commands.add("navigateToFrontend", () => {
// Clicks on Design tab and then the Home nav item
cy.wait(500)
cy.contains("Design").click()
cy.get(".spectrum-Search").type("/")
cy.get(".nav-item").contains("home").click()
cy.get(".spectrum-Search", { timeout: 2000 }).type("/")
cy.get(".nav-item", { timeout: 2000 }).contains("home").click()
})
Cypress.Commands.add("navigateToDataSection", () => {
@ -785,7 +788,7 @@ Cypress.Commands.add("createRestQuery", (method, restUrl, queryPrettyName) => {
// MISC
Cypress.Commands.add("closeModal", () => {
cy.get(".spectrum-Modal").within(() => {
cy.get(".spectrum-Modal", { timeout: 2000 }).within(() => {
cy.get(".close-icon").click()
cy.wait(1000) // Wait for modal to close
})

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -69,10 +69,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^1.0.219-alpha.11",
"@budibase/client": "^1.0.219-alpha.11",
"@budibase/frontend-core": "^1.0.219-alpha.11",
"@budibase/string-templates": "^1.0.219-alpha.11",
"@budibase/bbui": "^1.0.219-alpha.17",
"@budibase/client": "^1.0.219-alpha.17",
"@budibase/frontend-core": "^1.0.219-alpha.17",
"@budibase/string-templates": "^1.0.219-alpha.17",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -74,7 +74,10 @@
rev: smtpConfig._rev,
})
smtpConfig = {
config: {},
type: ConfigTypes.SMTP,
config: {
secure: true,
},
}
await admin.getChecklist()
notifications.success(`Settings cleared`)

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.0.219-alpha.11",
"@budibase/frontend-core": "^1.0.219-alpha.11",
"@budibase/string-templates": "^1.0.219-alpha.11",
"@budibase/bbui": "^1.0.219-alpha.17",
"@budibase/frontend-core": "^1.0.219-alpha.17",
"@budibase/string-templates": "^1.0.219-alpha.17",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -61,7 +61,9 @@
clonedSchema = schema
} else {
allowedFields?.forEach(field => {
clonedSchema[field] = schema[field]
if (schema[field]) {
clonedSchema[field] = schema[field]
}
})
}
return Object.values(clonedSchema || {})

View File

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

View File

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

View File

@ -166,14 +166,19 @@ export async function preview(ctx: any) {
}
}
async function execute(ctx: any, opts = { rowsOnly: false }) {
async function execute(
ctx: any,
opts: any = { rowsOnly: false, isAutomation: false }
) {
const db = getAppDB()
const query = await db.get(ctx.params.queryId)
const datasource = await db.get(query.datasourceId)
const authConfigCtx: any = getAuthConfig(ctx)
let authConfigCtx: any = {}
if (!opts.isAutomation) {
authConfigCtx = getAuthConfig(ctx)
}
const enrichedParameters = ctx.request.body.parameters || {}
// make sure parameters are fully enriched with defaults
if (query && query.parameters) {
@ -217,8 +222,11 @@ export async function executeV1(ctx: any) {
return execute(ctx, { rowsOnly: true })
}
export async function executeV2(ctx: any) {
return execute(ctx, { rowsOnly: false })
export async function executeV2(
ctx: any,
{ isAutomation }: { isAutomation?: boolean } = {}
) {
return execute(ctx, { rowsOnly: false, isAutomation })
}
const removeDynamicVariables = async (queryId: any) => {

View File

@ -218,7 +218,6 @@ describe("/queries", () => {
expect(res.body.schemaFields).toEqual(["a", "b"])
expect(res.body.rows.length).toEqual(1)
expect(events.query.previewed).toBeCalledTimes(1)
datasource.config = { schema: "public" }
expect(events.query.previewed).toBeCalledWith(datasource, query)
})

View File

@ -72,7 +72,7 @@ exports.run = async function ({ inputs, appId, emitter }) {
})
try {
await queryController.executeV2(ctx)
await queryController.executeV2(ctx, { isAutomation: true })
const { data, ...rest } = ctx.body
return {
response: data,

View File

@ -99,8 +99,12 @@ function generateSelectStatement(
const fieldNames = field.split(/\./g)
const tableName = fieldNames[0]
const columnName = fieldNames[1]
if (columnName && knex.client.config.client === SqlClients.POSTGRES) {
const externalType = schema?.[columnName].externalType
if (
columnName &&
schema?.[columnName] &&
knex.client.config.client === SqlClients.POSTGRES
) {
const externalType = schema[columnName].externalType
if (externalType?.includes("money")) {
return knex.raw(
`"${tableName}"."${columnName}"::money::numeric as "${field}"`

View File

@ -10,6 +10,7 @@ const {
} = require("@budibase/backend-core/auth")
const { user: userCache } = require("@budibase/backend-core/cache")
const { getGlobalIDFromUserMetadataID } = require("../db/utils")
const { cloneDeep } = require("lodash/fp")
const { isSQL } = require("../integrations/utils")
const {
@ -41,20 +42,22 @@ class QueryRunner {
async execute() {
let { datasource, fields, queryVerb, transformer } = this
const Integration = integrations[datasource.source]
let datasourceClone = cloneDeep(datasource)
let fieldsClone = cloneDeep(fields)
const Integration = integrations[datasourceClone.source]
if (!Integration) {
throw "Integration type does not exist."
}
if (datasource.config.authConfigs) {
datasource.config.authConfigs = datasource.config.authConfigs.map(
config => {
if (datasourceClone.config.authConfigs) {
datasourceClone.config.authConfigs =
datasourceClone.config.authConfigs.map(config => {
return enrichQueryFields(config, this.ctx)
}
)
})
}
const integration = new Integration(datasource.config)
const integration = new Integration(datasourceClone.config)
// pre-query, make sure datasource variables are added to parameters
const parameters = await this.addDatasourceVariables()
@ -65,19 +68,19 @@ class QueryRunner {
const enrichedContext = { ...enrichedParameters, ...this.ctx }
// Parse global headers
if (datasource.config.defaultHeaders) {
datasource.config.defaultHeaders = enrichQueryFields(
datasource.config.defaultHeaders,
if (datasourceClone.config.defaultHeaders) {
datasourceClone.config.defaultHeaders = enrichQueryFields(
datasourceClone.config.defaultHeaders,
enrichedContext
)
}
let query
// handle SQL injections by interpolating the variables
if (isSQL(datasource)) {
query = interpolateSQL(fields, enrichedParameters, integration)
if (isSQL(datasourceClone)) {
query = interpolateSQL(fieldsClone, enrichedParameters, integration)
} else {
query = enrichQueryFields(fields, enrichedContext)
query = enrichQueryFields(fieldsClone, enrichedContext)
}
// Add pagination values for REST queries
@ -116,9 +119,10 @@ class QueryRunner {
await this.refreshOAuth2(this.ctx)
// Attempt to refresh the access token from the provider
this.hasRefreshedOAuth = true
} else {
this.hasRerun = true
}
this.hasRerun = true
await threadUtils.invalidateDynamicVariables(this.cachedVariables)
return this.execute()
}
@ -187,8 +191,9 @@ class QueryRunner {
} else {
// In this event the user may have oAuth issues that
// could require re-authenticating with their provider.
let errorMessage = resp.err.data ? resp.err.data : resp.err.toString()
throw new Error(
"OAuth2 access token could not be refreshed: " + resp.err.toString()
"OAuth2 access token could not be refreshed: " + errorMessage
)
}

View File

@ -1100,6 +1100,7 @@
passport-google-oauth "2.0.0"
passport-jwt "4.0.0"
passport-local "1.0.0"
passport-oauth2-refresh "^2.1.0"
posthog-node "1.3.0"
pouchdb "7.3.0"
pouchdb-find "7.2.2"
@ -10564,6 +10565,11 @@ passport-oauth1@1.x.x:
passport-strategy "1.x.x"
utils-merge "1.x.x"
passport-oauth2-refresh@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/passport-oauth2-refresh/-/passport-oauth2-refresh-2.1.0.tgz#c31cd133826383f5539d16ad8ab4f35ca73ce4a4"
integrity sha512-4ML7ooCESCqiTgdDBzNUFTBcPR8zQq9iM6eppEUGMMvLdsjqRL93jKwWm4Az3OJcI+Q2eIVyI8sVRcPFvxcF/A==
passport-oauth2@1.x.x:
version "1.6.1"
resolved "https://registry.yarnpkg.com/passport-oauth2/-/passport-oauth2-1.6.1.tgz#c5aee8f849ce8bd436c7f81d904a3cd1666f181b"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.0.219-alpha.11",
"version": "1.0.219-alpha.17",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -34,10 +34,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.0.219-alpha.11",
"@budibase/pro": "1.0.219-alpha.11",
"@budibase/string-templates": "^1.0.219-alpha.11",
"@budibase/types": "^1.0.219-alpha.11",
"@budibase/backend-core": "^1.0.219-alpha.17",
"@budibase/pro": "1.0.219-alpha.17",
"@budibase/string-templates": "^1.0.219-alpha.17",
"@budibase/types": "^1.0.219-alpha.17",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View File

@ -17,6 +17,7 @@ const {
withCache,
CacheKeys,
bustCache,
cache,
} = require("@budibase/backend-core/cache")
const { events } = require("@budibase/backend-core")
const { checkAnyUserExists } = require("../../../utilities/users")
@ -365,9 +366,9 @@ exports.upload = async function (ctx) {
exports.destroy = async function (ctx) {
const db = getGlobalDB()
const { id, rev } = ctx.params
try {
await db.remove(id, rev)
await cache.delete(CacheKeys.CHECKLIST)
ctx.body = { message: "Config deleted successfully" }
} catch (err) {
ctx.throw(err.status, err)

View File

@ -313,6 +313,7 @@
passport-google-oauth "2.0.0"
passport-jwt "4.0.0"
passport-local "1.0.0"
passport-oauth2-refresh "^2.1.0"
posthog-node "1.3.0"
pouchdb "7.3.0"
pouchdb-find "7.2.2"
@ -4975,6 +4976,11 @@ passport-oauth1@1.x.x:
passport-strategy "1.x.x"
utils-merge "1.x.x"
passport-oauth2-refresh@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/passport-oauth2-refresh/-/passport-oauth2-refresh-2.1.0.tgz#c31cd133826383f5539d16ad8ab4f35ca73ce4a4"
integrity sha512-4ML7ooCESCqiTgdDBzNUFTBcPR8zQq9iM6eppEUGMMvLdsjqRL93jKwWm4Az3OJcI+Q2eIVyI8sVRcPFvxcF/A==
passport-oauth2@1.x.x:
version "1.6.1"
resolved "https://registry.yarnpkg.com/passport-oauth2/-/passport-oauth2-1.6.1.tgz#c5aee8f849ce8bd436c7f81d904a3cd1666f181b"