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

This commit is contained in:
mike12345567 2022-03-16 12:26:33 +00:00
commit 70fe4e606c
16 changed files with 83 additions and 31 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js",
"author": "Budibase",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"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.89-alpha.0",
"@budibase/string-templates": "^1.0.90",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"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.89-alpha.0",
"version": "1.0.90",
"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.89-alpha.0",
"@budibase/frontend-core": "^1.0.89-alpha.0",
"@budibase/string-templates": "^1.0.89-alpha.0",
"@budibase/bbui": "^1.0.90",
"@budibase/frontend-core": "^1.0.90",
"@budibase/string-templates": "^1.0.90",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -250,9 +250,9 @@ const exportDataHandler = async action => {
const data = await API.exportRows({
tableId: selection.tableId,
rows: selection.selectedRows,
format: action.parameters.type,
})
download(JSON.stringify(data), `export.${action.parameters.type}`)
download(data, `${selection.tableId}.${action.parameters.type}`)
} catch (error) {
notificationStore.actions.error("There was an error exporting the data")
}

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"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.89-alpha.0",
"@budibase/bbui": "^1.0.90",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -66,12 +66,15 @@ export const buildRowEndpoints = API => ({
* @param tableId the table ID to export the rows from
* @param rows the array of rows to export
*/
exportRows: async ({ tableId, rows }) => {
exportRows: async ({ tableId, rows, format }) => {
return await API.post({
url: `/api/${tableId}/rows/exportRows`,
url: `/api/${tableId}/rows/exportRows?format=${format}`,
body: {
rows,
},
parseResponse: async response => {
return await response.text()
},
})
},
})

View File

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

View File

@ -10,6 +10,8 @@ const {
} = require("../../../integrations/utils")
const ExternalRequest = require("./ExternalRequest")
const { getAppDB } = require("@budibase/backend-core/context")
const exporters = require("../view/exporters")
const { apiFileReturn } = require("../../../utilities/fileSystem")
async function handleRequest(operation, tableId, opts = {}) {
// make sure the filters are cleaned up, no empty strings for equals, fuzzy or string
@ -155,6 +157,7 @@ exports.validate = async () => {
exports.exportRows = async ctx => {
const { datasourceId, tableName } = breakExternalTableId(ctx.params.tableId)
const db = getAppDB()
let format = ctx.query.format
const datasource = await db.get(datasourceId)
if (!datasource || !datasource.entities) {
ctx.throw(400, "Datasource has not been configured for plus API.")
@ -164,13 +167,22 @@ exports.exportRows = async ctx => {
ctx.request.body = {
query: {
oneOf: {
[table.primaryDisplay]: ctx.request.body.map(
[table.primaryDisplay]: ctx.request.body.rows.map(
id => breakRowIdField(id)[0]
),
},
},
}
return exports.search(ctx)
let result = await exports.search(ctx)
let headers = Object.keys(result.rows[0])
const exporter = exporters[format]
const filename = `export.${format}`
// send down the file
ctx.attachment(filename)
return apiFileReturn(exporter(headers, result.rows))
}
exports.fetchEnrichedRow = async ctx => {

View File

@ -27,6 +27,8 @@ const {
const { cloneDeep } = require("lodash/fp")
const { getAppDB } = require("@budibase/backend-core/context")
const { finaliseRow, updateRelatedFormula } = require("./staticFormula")
const exporters = require("../view/exporters")
const { apiFileReturn } = require("../../../utilities/fileSystem")
const CALCULATION_TYPES = {
SUM: "sum",
@ -366,6 +368,7 @@ exports.exportRows = async ctx => {
const db = getAppDB()
const table = await db.get(ctx.params.tableId)
const rowIds = ctx.request.body.rows
let format = ctx.query.format
let response = (
await db.allDocs({
include_docs: true,
@ -375,7 +378,13 @@ exports.exportRows = async ctx => {
let rows = await outputProcessing(table, response)
return rows
let headers = Object.keys(rows[0])
const exporter = exporters[format]
const filename = `export.${format}`
// send down the file
ctx.attachment(filename)
return apiFileReturn(exporter(headers, rows))
}
exports.fetchEnrichedRow = async ctx => {

View File

@ -5,6 +5,7 @@ import rowEndpoints from "./rows"
import userEndpoints from "./users"
import usage from "../../../middleware/usageQuota"
import authorized from "../../../middleware/authorized"
import publicApi from "../../../middleware/publicApi"
import { paramResource, paramSubResource } from "../../../middleware/resourceId"
import { CtxFn } from "./utils/Endpoint"
import mapperMiddleware from "./middleware/mapper"
@ -101,6 +102,12 @@ function applyRoutes(
const paramMiddleware = subResource
? paramSubResource(resource, subResource)
: paramResource(resource)
const publicApiMiddleware = publicApi({
requiresAppId:
permType !== PermissionTypes.APP && permType !== PermissionTypes.USER,
})
addMiddleware(endpoints.read, publicApiMiddleware)
addMiddleware(endpoints.write, publicApiMiddleware)
// add the parameter capture middleware
addMiddleware(endpoints.read, paramMiddleware)
addMiddleware(endpoints.write, paramMiddleware)

View File

@ -0,0 +1,21 @@
const { Headers } = require("@budibase/backend-core/constants")
const { getAppId } = require("@budibase/backend-core/utils")
module.exports = function ({ requiresAppId } = {}) {
return async (ctx, next) => {
const appId = getAppId(ctx)
if (requiresAppId && !appId) {
ctx.throw(
400,
`Invalid app ID provided, please check the ${Headers.APP_ID} header.`
)
}
if (!ctx.headers[Headers.API_KEY]) {
ctx.throw(
400,
`Invalid API key provided, please check the ${Headers.API_KEY} header.`
)
}
return next()
}
}

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.0.89-alpha.0",
"version": "1.0.90",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -34,8 +34,8 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.0.89-alpha.0",
"@budibase/string-templates": "^1.0.89-alpha.0",
"@budibase/backend-core": "^1.0.90",
"@budibase/string-templates": "^1.0.90",
"@koa/router": "^8.0.0",
"@sentry/node": "^6.0.0",
"@techpass/passport-openidconnect": "^0.3.0",