Merge remote-tracking branch 'origin/develop' into feature/export-from-client

This commit is contained in:
Peter Clement 2022-03-08 13:56:56 +00:00
commit c3b6d74c8b
22 changed files with 2860 additions and 107 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.0.80-alpha.2",
"version": "1.0.81-alpha.0",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.0.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"@budibase/string-templates": "^1.0.81-alpha.0",
"@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.80-alpha.2",
"version": "1.0.81-alpha.0",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -65,10 +65,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^1.0.80-alpha.2",
"@budibase/client": "^1.0.80-alpha.2",
"@budibase/frontend-core": "^1.0.80-alpha.2",
"@budibase/string-templates": "^1.0.80-alpha.2",
"@budibase/bbui": "^1.0.81-alpha.0",
"@budibase/client": "^1.0.81-alpha.0",
"@budibase/frontend-core": "^1.0.81-alpha.0",
"@budibase/string-templates": "^1.0.81-alpha.0",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -20,7 +20,9 @@
$goto(`./datasource/${resp._id}`)
notifications.success(`Datasource updated successfully.`)
} catch (err) {
notifications.error("Error saving datasource")
notifications.error(err?.message ?? "Error saving datasource")
// prevent the modal from closing
return false
}
}

View File

@ -134,8 +134,9 @@
// Remove all iframe event listeners on component destroy
onDestroy(() => {
if (iframe.contentWindow) {
window.removeEventListener("message", receiveMessage)
if (iframe.contentWindow) {
if (!$store.clientFeatures.messagePassing) {
// Legacy - remove in later versions of BB
iframe.contentWindow.removeEventListener(

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.0.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"version": "1.0.81-alpha.0",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,26 +19,12 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.0.80-alpha.2",
"@budibase/frontend-core": "^1.0.80-alpha.2",
"@budibase/string-templates": "^1.0.80-alpha.2",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",
"@spectrum-css/link": "^3.1.3",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/tag": "^3.1.4",
"@spectrum-css/typography": "^3.0.2",
"@spectrum-css/vars": "^3.0.1",
"apexcharts": "^3.22.1",
"dayjs": "^1.10.5",
"downloadjs": "1.4.7",
"@budibase/bbui": "^1.0.81-alpha.0",
"@budibase/frontend-core": "^1.0.81-alpha.0",
"@budibase/string-templates": "^1.0.81-alpha.0",
"regexparam": "^1.3.0",
"rollup-plugin-polyfill-node": "^0.8.0",
"shortid": "^2.2.15",
"svelte": "^3.38.2",
"svelte-apexcharts": "^1.0.2",
"svelte-flatpickr": "^3.1.0",
"svelte-spa-router": "^3.0.5"
},
"devDependencies": {

View File

@ -81,7 +81,10 @@
loading = false
return res
} catch (error) {
notificationStore.actions.error(`Error uploading file: ${error}`)
notificationStore.actions.error(
`Error uploading file: ${error?.message || error}`
)
loading = false
}
}

2689
packages/client/stats.html Normal file

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,4 +1,20 @@
export const buildAttachmentEndpoints = API => ({
export const buildAttachmentEndpoints = API => {
/**
* Generates a signed URL to upload a file to an external datasource.
* @param datasourceId the ID of the datasource to upload to
* @param bucket the name of the bucket to upload to
* @param key the name of the file to upload to
*/
const getSignedDatasourceURL = async ({ datasourceId, bucket, key }) => {
return await API.post({
url: `/api/attachments/${datasourceId}/url`,
body: { bucket, key },
})
}
return {
getSignedDatasourceURL,
/**
* Uploads an attachment to the server.
* @param data the attachment to upload
@ -24,19 +40,6 @@ export const buildAttachmentEndpoints = API => ({
})
},
/**
* Generates a signed URL to upload a file to an external datasource.
* @param datasourceId the ID of the datasource to upload to
* @param bucket the name of the bucket to upload to
* @param key the name of the file to upload to
*/
getSignedDatasourceURL: async ({ datasourceId, bucket, key }) => {
return await API.post({
url: `/api/attachments/${datasourceId}/url`,
body: { bucket, key },
})
},
/**
* Uploads a file to an external datasource.
* @param datasourceId the ID of the datasource to upload to
@ -45,7 +48,8 @@ export const buildAttachmentEndpoints = API => ({
* @param data the file to upload
*/
externalUpload: async ({ datasourceId, bucket, key, data }) => {
const { signedUrl, publicUrl } = await API.getSignedDatasourceURL({
console.log(API)
const { signedUrl, publicUrl } = await getSignedDatasourceURL({
datasourceId,
bucket,
key,
@ -58,4 +62,5 @@ export const buildAttachmentEndpoints = API => ({
})
return { publicUrl }
},
})
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.0.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"@budibase/client": "^1.0.80-alpha.2",
"@budibase/string-templates": "^1.0.80-alpha.2",
"@budibase/backend-core": "^1.0.81-alpha.0",
"@budibase/client": "^1.0.81-alpha.0",
"@budibase/string-templates": "^1.0.81-alpha.0",
"@bull-board/api": "^3.7.0",
"@bull-board/koa": "^3.7.0",
"@elastic/elasticsearch": "7.10.0",

View File

@ -17,12 +17,23 @@ const options = {
},
servers: [
{
url: "http://budibase.app/api/public/v1",
url: "https://budibase.app/api/public/v1",
description: "Budibase Cloud API",
},
{
url: "{protocol}://{hostname}:10000/api/public/v1",
url: "{protocol}://{hostname}/api/public/v1",
description: "Budibase self hosted API",
variables: {
protocol: {
default: "http",
description:
"Whether HTTP or HTTPS should be used to communicate with your Budibase instance.",
},
hostname: {
default: "localhost:10000",
description: "The URL of your Budibase instance.",
},
},
},
],
components: {

View File

@ -7,12 +7,22 @@
},
"servers": [
{
"url": "http://budibase.app/api/public/v1",
"url": "https://budibase.app/api/public/v1",
"description": "Budibase Cloud API"
},
{
"url": "{protocol}://{hostname}:10000/api/public/v1",
"description": "Budibase self hosted API"
"url": "{protocol}://{hostname}/api/public/v1",
"description": "Budibase self hosted API",
"variables": {
"protocol": {
"default": "http",
"description": "Whether HTTP or HTTPS should be used to communicate with your Budibase instance."
},
"hostname": {
"default": "localhost:10000",
"description": "The URL of your Budibase instance."
}
}
}
],
"components": {

View File

@ -4,10 +4,18 @@ info:
description: The public API for Budibase apps and its services.
version: 1.0.0
servers:
- url: http://budibase.app/api/public/v1
- url: https://budibase.app/api/public/v1
description: Budibase Cloud API
- url: "{protocol}://{hostname}:10000/api/public/v1"
- url: "{protocol}://{hostname}/api/public/v1"
description: Budibase self hosted API
variables:
protocol:
default: http
description: Whether HTTP or HTTPS should be used to communicate with your
Budibase instance.
hostname:
default: localhost:10000
description: The URL of your Budibase instance.
components:
parameters:
tableId:

View File

@ -25,7 +25,8 @@ async function makeTableRequest(
operation,
table,
tables,
oldTable = null
oldTable = null,
renamed = null
) {
const json = {
endpoint: {
@ -41,6 +42,9 @@ async function makeTableRequest(
if (oldTable) {
json.meta.table = oldTable
}
if (renamed) {
json.meta.renamed = renamed
}
return makeExternalQuery(datasource, json)
}
@ -160,6 +164,7 @@ function isRelationshipSetup(column) {
exports.save = async function (ctx) {
const table = ctx.request.body
const { _rename: renamed } = table
// can't do this right now
delete table.dataImport
const datasourceId = getDatasourceId(ctx.request.body)
@ -241,7 +246,14 @@ exports.save = async function (ctx) {
const operation = oldTable
? DataSourceOperation.UPDATE_TABLE
: DataSourceOperation.CREATE_TABLE
await makeTableRequest(datasource, operation, tableToSave, tables, oldTable)
await makeTableRequest(
datasource,
operation,
tableToSave,
tables,
oldTable,
renamed
)
// update any extra tables (like foreign keys in other tables)
for (let extraTable of extraTablesToUpdate) {
const oldExtraTable = oldTables[extraTable.name]
@ -258,6 +270,8 @@ exports.save = async function (ctx) {
)
}
// remove the rename prop
delete tableToSave._rename
// store it into couch now for budibase reference
datasource.entities[tableToSave.name] = tableToSave
await db.put(datasource)

View File

@ -138,6 +138,11 @@ export interface PaginationJson {
page?: string | number
}
export interface RenameColumn {
old: string
updated: string
}
export interface RelationshipsJson {
through?: string
from?: string
@ -166,6 +171,7 @@ export interface QueryJson {
meta?: {
table?: Table
tables?: Record<string, Table>
renamed: RenameColumn
}
extra?: {
idFilter?: SearchFilters

View File

@ -1,6 +1,10 @@
import { Knex, knex } from "knex"
import { Table } from "../../definitions/common"
import { Operation, QueryJson } from "../../definitions/datasource"
import {
Operation,
QueryJson,
RenameColumn,
} from "../../definitions/datasource"
import { breakExternalTableId } from "../utils"
import SchemaBuilder = Knex.SchemaBuilder
import CreateTableBuilder = Knex.CreateTableBuilder
@ -10,7 +14,8 @@ function generateSchema(
schema: CreateTableBuilder,
table: Table,
tables: Record<string, Table>,
oldTable: null | Table = null
oldTable: null | Table = null,
renamed?: RenameColumn
) {
let primaryKey = table && table.primary ? table.primary[0] : null
const columns = Object.values(table.schema)
@ -29,7 +34,11 @@ function generateSchema(
for (let [key, column] of Object.entries(table.schema)) {
// skip things that are already correct
const oldColumn = oldTable ? oldTable.schema[key] : null
if ((oldColumn && oldColumn.type) || (primaryKey === key && !isJunction)) {
if (
(oldColumn && oldColumn.type) ||
(primaryKey === key && !isJunction) ||
renamed?.updated === key
) {
continue
}
switch (column.type) {
@ -81,6 +90,10 @@ function generateSchema(
}
}
if (renamed) {
schema.renameColumn(renamed.old, renamed.updated)
}
// need to check if any columns have been deleted
if (oldTable) {
const deletedColumns = Object.entries(oldTable.schema)
@ -90,6 +103,9 @@ function generateSchema(
)
.map(([key]) => key)
deletedColumns.forEach(key => {
if (renamed?.old === key) {
return
}
if (oldTable.constrained && oldTable.constrained.indexOf(key) !== -1) {
schema.dropForeign(key)
}
@ -114,10 +130,11 @@ function buildUpdateTable(
knex: SchemaBuilder,
table: Table,
tables: Record<string, Table>,
oldTable: Table
oldTable: Table,
renamed: RenameColumn
): SchemaBuilder {
return knex.alterTable(table.name, schema => {
generateSchema(schema, table, tables, oldTable)
generateSchema(schema, table, tables, oldTable, renamed)
})
}
@ -167,7 +184,8 @@ class SqlTableQueryBuilder {
client,
json.table,
json.meta.tables,
json.meta.table
json.meta.table,
json.meta.renamed
)
break
case Operation.DELETE_TABLE:

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.0.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"version": "1.0.81-alpha.0",
"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.80-alpha.2",
"@budibase/string-templates": "^1.0.80-alpha.2",
"@budibase/backend-core": "^1.0.81-alpha.0",
"@budibase/string-templates": "^1.0.81-alpha.0",
"@koa/router": "^8.0.0",
"@sentry/node": "^6.0.0",
"@techpass/passport-openidconnect": "^0.3.0",