Merge branch 'develop' into rest-import

This commit is contained in:
Rory Powell 2021-12-08 11:08:32 +00:00
commit 6b7f94a358
21 changed files with 57 additions and 91 deletions

View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/auth", "name": "@budibase/auth",
"version": "1.0.6-alpha.0", "version": "1.0.8-alpha.1",
"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

@ -34,4 +34,5 @@ exports.Configs = {
OIDC_LOGOS: "logos_oidc", OIDC_LOGOS: "logos_oidc",
} }
exports.MAX_VALID_DATE = new Date(2147483647000)
exports.DEFAULT_TENANT_ID = "default" exports.DEFAULT_TENANT_ID = "default"

View File

@ -1,6 +1,7 @@
const redis = require("../redis/authRedis") const redis = require("../redis/authRedis")
const EXPIRY_SECONDS = 86400 // a week in seconds
const EXPIRY_SECONDS = 86400 * 7
async function getSessionsForUser(userId) { async function getSessionsForUser(userId) {
const client = await redis.getSessionClient() const client = await redis.getSessionClient()

View File

@ -7,7 +7,7 @@ const {
const jwt = require("jsonwebtoken") const jwt = require("jsonwebtoken")
const { options } = require("./middleware/passport/jwt") const { options } = require("./middleware/passport/jwt")
const { createUserEmailView } = require("./db/views") const { createUserEmailView } = require("./db/views")
const { Headers, UserStatus, Cookies } = require("./constants") const { Headers, UserStatus, Cookies, MAX_VALID_DATE } = require("./constants")
const { const {
getGlobalDB, getGlobalDB,
updateTenantId, updateTenantId,
@ -83,14 +83,15 @@ exports.getCookie = (ctx, name) => {
* @param {object} ctx The request which is to be manipulated. * @param {object} ctx The request which is to be manipulated.
* @param {string} name The name of the cookie to set. * @param {string} name The name of the cookie to set.
* @param {string|object} value The value of cookie which will be set. * @param {string|object} value The value of cookie which will be set.
* @param {object} opts options like whether to sign.
*/ */
exports.setCookie = (ctx, value, name = "builder") => { exports.setCookie = (ctx, value, name = "builder", opts = { sign: true }) => {
if (value) { if (value && opts && opts.sign) {
value = jwt.sign(value, options.secretOrKey) value = jwt.sign(value, options.secretOrKey)
} }
const config = { const config = {
maxAge: Number.MAX_SAFE_INTEGER, expires: MAX_VALID_DATE,
path: "/", path: "/",
httpOnly: false, httpOnly: false,
overwrite: true, overwrite: true,

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

@ -1,6 +1,5 @@
<script> <script>
import { goto, url } from "@roxi/routify" import { goto, url } from "@roxi/routify"
import { store } from "builderStore"
import { tables } from "stores/backend" import { tables } from "stores/backend"
import { notifications } from "@budibase/bbui" import { notifications } from "@budibase/bbui"
import { import {
@ -13,24 +12,13 @@
} from "@budibase/bbui" } from "@budibase/bbui"
import TableDataImport from "../TableDataImport.svelte" import TableDataImport from "../TableDataImport.svelte"
import analytics, { Events } from "analytics" import analytics, { Events } from "analytics"
import screenTemplates from "builderStore/store/screenTemplates"
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils" import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
import { NEW_ROW_TEMPLATE } from "builderStore/store/screenTemplates/newRowScreen"
import { ROW_DETAIL_TEMPLATE } from "builderStore/store/screenTemplates/rowDetailScreen"
import { ROW_LIST_TEMPLATE } from "builderStore/store/screenTemplates/rowListScreen"
const defaultScreens = [
NEW_ROW_TEMPLATE,
ROW_DETAIL_TEMPLATE,
ROW_LIST_TEMPLATE,
]
$: tableNames = $tables.list.map(table => table.name) $: tableNames = $tables.list.map(table => table.name)
export let name export let name
let dataImport let dataImport
let error = "" let error = ""
let createAutoscreens = true
let autoColumns = getAutoColumnInformation() let autoColumns = getAutoColumnInformation()
function addAutoColumns(tableName, schema) { function addAutoColumns(tableName, schema) {
@ -69,27 +57,6 @@
notifications.success(`Table ${name} created successfully.`) notifications.success(`Table ${name} created successfully.`)
analytics.captureEvent(Events.TABLE.CREATED, { name }) analytics.captureEvent(Events.TABLE.CREATED, { name })
// Create auto screens
if (createAutoscreens) {
const screens = screenTemplates($store, [table])
.filter(template => defaultScreens.includes(template.id))
.map(template => template.create())
for (let screen of screens) {
// Record the table that created this screen so we can link it later
screen.autoTableId = table._id
await store.actions.screens.create(screen)
}
// Create autolink to newly created list screen
const listScreen = screens.find(screen =>
screen.props._instanceName.endsWith("List")
)
await store.actions.components.links.save(
listScreen.routing.route,
table.name
)
}
// Navigate to new table // Navigate to new table
const currentUrl = $url() const currentUrl = $url()
const path = currentUrl.endsWith("data") const path = currentUrl.endsWith("data")
@ -128,10 +95,6 @@
</div> </div>
<Divider /> <Divider />
</div> </div>
<Toggle
text="Generate screens in Design section"
bind:value={createAutoscreens}
/>
<div> <div>
<Layout gap="XS" noPadding> <Layout gap="XS" noPadding>
<Label grey extraSmall>Create Table from CSV (Optional)</Label> <Label grey extraSmall>Create Table from CSV (Optional)</Label>

View File

@ -70,7 +70,7 @@
disabled={!selectedScreens.length} disabled={!selectedScreens.length}
size="L" size="L"
> >
<Body size="XS" <Body size="S"
>Please select the screens you would like to add to your application. >Please select the screens you would like to add to your application.
Autogenerated screens come with CRUD functionality.</Body Autogenerated screens come with CRUD functionality.</Body
> >

View File

@ -179,7 +179,7 @@
<Layout gap="S" justifyItems="center"> <Layout gap="S" justifyItems="center">
<img class="img-size" alt="logo" src={Logo} /> <img class="img-size" alt="logo" src={Logo} />
<div class="new-screen-text"> <div class="new-screen-text">
<Detail size="M">Let's add some life to this screen</Detail> <Detail size="M">LETS BRING THIS APP TO LIFE</Detail>
</div> </div>
<Button on:click={() => showModal()} size="M" cta> <Button on:click={() => showModal()} size="M" cta>
<div class="new-screen-button"> <div class="new-screen-button">
@ -290,12 +290,9 @@
} }
.centered { .centered {
top: 0; width: calc(100% - 350px);
bottom: 0; height: calc(100% - 100px);
left: 10%; position: absolute;
right: 0;
width: 100%;
height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.0.6-alpha.0", "version": "1.0.8-alpha.1",
"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.6-alpha.0", "version": "1.0.8-alpha.1",
"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.6-alpha.0", "@budibase/bbui": "^1.0.8-alpha.1",
"@budibase/standard-components": "^0.9.139", "@budibase/standard-components": "^0.9.139",
"@budibase/string-templates": "^1.0.6-alpha.0", "@budibase/string-templates": "^1.0.8-alpha.1",
"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"

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.0.6-alpha.0", "version": "1.0.8-alpha.1",
"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/auth": "^1.0.6-alpha.0", "@budibase/auth": "^1.0.8-alpha.1",
"@budibase/client": "^1.0.6-alpha.0", "@budibase/client": "^1.0.8-alpha.1",
"@budibase/string-templates": "^1.0.6-alpha.0", "@budibase/string-templates": "^1.0.8-alpha.1",
"@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

@ -84,7 +84,7 @@ The `HR` schema is populated with dummy data by default in oracle for testing pu
To connect to the HR schema first update the user password and unlock the account by performing To connect to the HR schema first update the user password and unlock the account by performing
```sql ```sql
ALTER USER hr ACCOUNT UNLOCK; ALTER USER hr ACCOUNT UNLOCK;
ALTER USER hr IDENTIFIED BY hr ALTER USER hr IDENTIFIED BY hr;
``` ```
You should now be able to connect to the hr schema using the credentials hr/hr You should now be able to connect to the hr schema using the credentials hr/hr

View File

@ -75,6 +75,7 @@ exports.handleDataImport = async (appId, user, table, dataImport) => {
if (!dataImport || !dataImport.csvString) { if (!dataImport || !dataImport.csvString) {
return table return table
} }
const db = new CouchDB(appId) const db = new CouchDB(appId)
// Populate the table with rows imported from CSV in a bulk update // Populate the table with rows imported from CSV in a bulk update
const data = await csvParser.transform({ const data = await csvParser.transform({

View File

@ -5,6 +5,7 @@ const exporters = require("./exporters")
const { saveView, getView, getViews, deleteView } = require("./utils") const { saveView, getView, getViews, deleteView } = require("./utils")
const { fetchView } = require("../row") const { fetchView } = require("../row")
const { getTable } = require("../table/utils") const { getTable } = require("../table/utils")
const { FieldTypes } = require("../../../constants")
exports.fetch = async ctx => { exports.fetch = async ctx => {
const db = new CouchDB(ctx.appId) const db = new CouchDB(ctx.appId)
@ -77,6 +78,7 @@ exports.exportView = async ctx => {
} }
await fetchView(ctx) await fetchView(ctx)
let rows = ctx.body
let schema = view && view.meta && view.meta.schema let schema = view && view.meta && view.meta.schema
if (!schema) { if (!schema) {
@ -85,11 +87,23 @@ exports.exportView = async ctx => {
schema = table.schema schema = table.schema
} }
// remove any relationships
const relationships = Object.entries(schema)
.filter(entry => entry[1].type === FieldTypes.LINK)
.map(entry => entry[0])
// iterate relationship columns and remove from and row and schema
relationships.forEach(column => {
rows.forEach(row => {
delete row[column]
})
delete schema[column]
})
// make sure no "undefined" entries appear in the CSV // make sure no "undefined" entries appear in the CSV
if (format === exporters.ExportFormats.CSV) { if (format === exporters.ExportFormats.CSV) {
const schemaKeys = Object.keys(schema) const schemaKeys = Object.keys(schema)
for (let key of schemaKeys) { for (let key of schemaKeys) {
for (let row of ctx.body) { for (let row of rows) {
if (row[key] == null) { if (row[key] == null) {
row[key] = "" row[key] = ""
} }
@ -103,5 +117,5 @@ exports.exportView = async ctx => {
const filename = `${viewName}.${format}` const filename = `${viewName}.${format}`
// send down the file // send down the file
ctx.attachment(filename) ctx.attachment(filename)
ctx.body = apiFileReturn(exporter(headers, ctx.body)) ctx.body = apiFileReturn(exporter(headers, rows))
} }

View File

@ -381,7 +381,7 @@ module OracleModule {
}` }`
const attributes: ConnectionAttributes = { const attributes: ConnectionAttributes = {
user: this.config.user, user: this.config.user,
password: this.config.user, password: this.config.password,
connectString, connectString,
} }
return oracledb.getConnection(attributes) return oracledb.getConnection(attributes)

View File

@ -102,8 +102,11 @@ async function transform({ schema, csvString, existingTable }) {
schema = updateSchema({ schema, existingTable }) schema = updateSchema({ schema, existingTable })
} }
for (let key of Object.keys(schema)) { for (let [key, field] of Object.entries(schema)) {
colParser[key] = PARSERS[schema[key].type] || schema[key].type // don't import data to auto columns
if (!field.autocolumn) {
colParser[key] = PARSERS[field.type] || field.type
}
} }
try { try {

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.0.6-alpha.0", "version": "1.0.8-alpha.1",
"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.6-alpha.0", "version": "1.0.8-alpha.1",
"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/auth": "^1.0.6-alpha.0", "@budibase/auth": "^1.0.8-alpha.1",
"@budibase/string-templates": "^1.0.6-alpha.0", "@budibase/string-templates": "^1.0.8-alpha.1",
"@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",

View File

@ -56,26 +56,11 @@ async function authInternal(ctx, user, err = null, info = null) {
return ctx.throw(403, info ? info : "Unauthorized") return ctx.throw(403, info ? info : "Unauthorized")
} }
const expires = new Date()
expires.setDate(expires.getDate() + 1)
if (!user) { if (!user) {
return ctx.throw(403, info ? info : "Unauthorized") return ctx.throw(403, info ? info : "Unauthorized")
} }
const config = { setCookie(ctx, user.token, Cookies.Auth, { sign: false })
expires,
path: "/",
httpOnly: false,
overwrite: true,
}
if (env.COOKIE_DOMAIN) {
config.domain = env.COOKIE_DOMAIN
}
// just store the user ID
ctx.cookies.set(Cookies.Auth, user.token, config)
// get rid of any app cookies on login // get rid of any app cookies on login
// have to check test because this breaks cypress // have to check test because this breaks cypress
if (!env.isTest()) { if (!env.isTest()) {