1
0
Fork 0
mirror of synced 2024-06-22 04:10:54 +12:00

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

This commit is contained in:
mike12345567 2022-09-16 16:13:20 +01:00
commit fa7702044d
29 changed files with 234 additions and 229 deletions

View file

@ -1,5 +1,5 @@
{
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"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.3.19-alpha.7",
"@budibase/types": "1.3.20",
"@shopify/jest-koa-mocks": "5.0.1",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",

View file

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

View file

@ -78,7 +78,7 @@
bottom: 0;
background: var(--background);
border-top: var(--border-light);
z-index: 2;
z-index: 3;
}
.fillWidth {

View file

@ -48,7 +48,7 @@
display: flex;
justify-content: center;
top: 15px;
z-index: 100;
z-index: 200;
width: 160px;
}
.icon {

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -9,6 +9,7 @@
"dev:builder": "routify -c dev:vite",
"dev:vite": "vite --host 0.0.0.0",
"rollup": "rollup -c -w",
"test": "jest",
"cy:setup": "ts-node ./cypress/ts/setup.ts",
"cy:setup:ci": "node ./cypress/setup.js",
"cy:open": "cypress open",
@ -36,7 +37,8 @@
"components(.*)$": "<rootDir>/src/components$1",
"builderStore(.*)$": "<rootDir>/src/builderStore$1",
"stores(.*)$": "<rootDir>/src/stores$1",
"analytics(.*)$": "<rootDir>/src/analytics$1"
"analytics(.*)$": "<rootDir>/src/analytics$1",
"constants/backend": "<rootDir>/src/constants/backend/index.js"
},
"moduleFileExtensions": [
"js",
@ -69,10 +71,10 @@
}
},
"dependencies": {
"@budibase/bbui": "1.3.19-alpha.7",
"@budibase/client": "1.3.19-alpha.7",
"@budibase/frontend-core": "1.3.19-alpha.7",
"@budibase/string-templates": "1.3.19-alpha.7",
"@budibase/bbui": "1.3.20",
"@budibase/client": "1.3.20",
"@budibase/frontend-core": "1.3.20",
"@budibase/string-templates": "1.3.20",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View file

@ -9,14 +9,14 @@ import {
import { store } from "builderStore"
import {
queries as queriesStores,
tables as tablesStore,
roles as rolesStore,
tables as tablesStore,
} from "stores/backend"
import {
makePropSafe,
isJSBinding,
decodeJSBinding,
encodeJSBinding,
isJSBinding,
makePropSafe,
} from "@budibase/string-templates"
import { TableNames } from "../constants"
import { JSONUtils } from "@budibase/frontend-core"
@ -118,8 +118,7 @@ export const readableToRuntimeMap = (bindings, ctx) => {
return {}
}
return Object.keys(ctx).reduce((acc, key) => {
let parsedQuery = readableToRuntimeBinding(bindings, ctx[key])
acc[key] = parsedQuery
acc[key] = readableToRuntimeBinding(bindings, ctx[key])
return acc
}, {})
}
@ -132,8 +131,7 @@ export const runtimeToReadableMap = (bindings, ctx) => {
return {}
}
return Object.keys(ctx).reduce((acc, key) => {
let parsedQuery = runtimeToReadableBinding(bindings, ctx[key])
acc[key] = parsedQuery
acc[key] = runtimeToReadableBinding(bindings, ctx[key])
return acc
}, {})
}
@ -379,7 +377,7 @@ const getProviderContextBindings = (asset, dataProviders) => {
/**
* Gets all bindable properties from the logged in user.
*/
const getUserBindings = () => {
export const getUserBindings = () => {
let bindings = []
const { schema } = getSchemaForTable(TableNames.USERS)
const keys = Object.keys(schema).sort()

View file

@ -1,31 +1,20 @@
<script>
import { Body, Button, Heading, Icon, Input, Layout } from "@budibase/bbui"
import {
readableToRuntimeBinding,
runtimeToReadableBinding,
} from "builderStore/dataBinding"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import { Body, Button, Heading, Layout } from "@budibase/bbui"
import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte"
import { getUserBindings } from "builderStore/dataBinding"
export let bindable = true
export let queryBindings = []
export let bindings = []
export let customParams = {}
const userBindings = getUserBindings()
let internalBindings = queryBindings.reduce((acc, binding) => {
acc[binding.name] = binding.default
return acc
}, {})
function newQueryBinding() {
queryBindings = [...queryBindings, {}]
}
function deleteQueryBinding(idx) {
queryBindings.splice(idx, 1)
queryBindings = queryBindings
}
// This is necessary due to the way readable and writable bindings are stored.
// The readable binding in the UI gets converted to a UUID value that the client understands
// for parsing, then converted back so we can display it the readable form in the UI
function onBindingChange(param, valueToParse) {
customParams[param] = readableToRuntimeBinding(bindings, valueToParse)
}
</script>
<Layout noPadding={bindable} gap="S">
@ -46,57 +35,34 @@
{/if}
</Body>
<div class="bindings" class:bindable>
{#each queryBindings as binding, idx}
<Input
placeholder="Binding Name"
thin
disabled={bindable}
bind:value={binding.name}
/>
<Input
placeholder="Default"
thin
disabled={bindable}
on:change={evt => onBindingChange(binding.name, evt.detail)}
bind:value={binding.default}
/>
{#if bindable}
<DrawerBindableInput
title={`Query binding "${binding.name}"`}
placeholder="Value"
thin
on:change={evt => onBindingChange(binding.name, evt.detail)}
value={runtimeToReadableBinding(
bindings,
customParams?.[binding.name]
)}
{bindings}
/>
{:else}
<Icon hoverable name="Close" on:click={() => deleteQueryBinding(idx)} />
{/if}
{/each}
<KeyValueBuilder
bind:object={internalBindings}
tooltip="Set the name of the binding which can be used in Handlebars statements throughout your query"
name="binding"
headings
keyPlaceholder="Binding name"
valuePlaceholder="Default"
bindings={[...userBindings]}
bindingDrawerLeft="260px"
on:change={e => {
queryBindings = e.detail.map(binding => {
return {
name: binding.name,
default: binding.value,
}
})
}}
/>
</div>
</Layout>
<style>
.bindings.bindable {
grid-template-columns: 1fr 1fr 1fr;
}
.controls {
display: flex;
align-items: center;
justify-content: space-between;
}
.bindings {
display: grid;
grid-template-columns: 1fr 1fr 5%;
grid-gap: 10px;
align-items: center;
}
.height {
height: 40px;
}

View file

@ -1,4 +1,5 @@
import { IntegrationTypes } from "constants/backend"
import { findHBSBlocks } from "@budibase/string-templates"
export function schemaToFields(schema) {
const response = {}
@ -31,7 +32,7 @@ export function breakQueryString(qs) {
let paramObj = {}
for (let param of params) {
const split = param.split("=")
paramObj[split[0]] = split.slice(1).join("=")
paramObj[split[0]] = decodeURIComponent(split.slice(1).join("="))
}
return paramObj
}
@ -46,7 +47,19 @@ export function buildQueryString(obj) {
if (str !== "") {
str += "&"
}
str += `${key}=${encodeURIComponent(value || "")}`
const bindings = findHBSBlocks(value)
let count = 0
const bindingMarkers = {}
bindings.forEach(binding => {
const marker = `BINDING...${count++}`
value = value.replace(binding, marker)
bindingMarkers[marker] = binding
})
let encoded = encodeURIComponent(value || "")
Object.entries(bindingMarkers).forEach(([marker, binding]) => {
encoded = encoded.replace(marker, binding)
})
str += `${key}=${encoded}`
}
}
return str

View file

@ -0,0 +1,37 @@
import { breakQueryString, buildQueryString } from "../data/utils"
describe("check query string utils", () => {
const obj1 = {
key1: "123",
key2: " ",
key3: "333",
}
const obj2 = {
key1: "{{ binding.awd }}",
key2: "{{ binding.sed }} ",
}
it("should build a basic query string", () => {
const queryString = buildQueryString(obj1)
expect(queryString).toBe("key1=123&key2=%20%20%20&key3=333")
})
it("should be able to break a basic query string", () => {
const broken = breakQueryString("key1=123&key2=%20%20%20&key3=333")
expect(broken.key1).toBe(obj1.key1)
expect(broken.key2).toBe(obj1.key2)
expect(broken.key3).toBe(obj1.key3)
})
it("should be able to build with a binding", () => {
const queryString = buildQueryString(obj2)
expect(queryString).toBe("key1={{ binding.awd }}&key2={{ binding.sed }}%20%20")
})
it("should be able to break with a binding", () => {
const broken = breakQueryString("key1={{ binding.awd }}&key2={{ binding.sed }}%20%20")
expect(broken.key1).toBe(obj2.key1)
expect(broken.key2).toBe(obj2.key2)
})
})

View file

@ -708,6 +708,7 @@
.url-block {
display: flex;
gap: var(--spacing-s);
z-index: 200;
}
.verb {
flex: 1;

View file

@ -1,7 +1,7 @@
import { writable, get } from "svelte/store"
import { datasources, integrations, tables, views } from "./"
import { API } from "api"
import { duplicateName } from "../../helpers/duplicate"
import { duplicateName } from "helpers/duplicate"
const sortQueries = queryList => {
queryList.sort((q1, q2) => {

View file

@ -2,7 +2,7 @@ import { get, writable } from "svelte/store"
import { datasources, queries, views } from "./"
import { cloneDeep } from "lodash/fp"
import { API } from "api"
import { SWITCHABLE_TYPES } from "../../constants/backend"
import { SWITCHABLE_TYPES } from "constants/backend"
export function createTablesStore() {
const store = writable({})

View file

@ -1,9 +1,9 @@
import { get } from 'svelte/store'
import api from 'builderStore/api'
import { get } from "svelte/store"
import { API } from "api"
jest.mock('builderStore/api');
jest.mock("api")
import { SOME_DATASOURCE, SAVE_DATASOURCE} from './fixtures/datasources'
import { SOME_DATASOURCE, SAVE_DATASOURCE } from "./fixtures/datasources"
import { createDatasourcesStore } from "../datasources"
import { queries } from '../queries'
@ -12,39 +12,39 @@ describe("Datasources Store", () => {
let store = createDatasourcesStore()
beforeEach(async () => {
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE]})
API.getDatasources.mockReturnValue({ json: () => [SOME_DATASOURCE]})
await store.init()
})
it("Initialises correctly", async () => {
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE]})
API.getDatasources.mockReturnValue({ json: () => [SOME_DATASOURCE]})
await store.init()
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null})
})
it("fetches all the datasources and updates the store", async () => {
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE] })
API.getDatasources.mockReturnValue({ json: () => [SOME_DATASOURCE] })
await store.fetch()
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null })
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null })
})
it("selects a datasource", async () => {
store.select(SOME_DATASOURCE._id)
expect(get(store).select).toEqual(SOME_DATASOURCE._id)
expect(get(store).select).toEqual(SOME_DATASOURCE._id)
})
it("resets the queries store when new datasource is selected", async () => {
await store.select(SOME_DATASOURCE._id)
const queriesValue = get(queries)
expect(queriesValue.selected).toEqual(null)
expect(queriesValue.selected).toEqual(null)
})
it("saves the datasource, updates the store and returns status message", async () => {
api.post.mockReturnValue({ status: 200, json: () => SAVE_DATASOURCE})
API.createDatasource.mockReturnValue({ status: 200, json: () => SAVE_DATASOURCE})
await store.save({
name: 'CoolDB',
@ -56,13 +56,13 @@ describe("Datasources Store", () => {
expect(get(store).list).toEqual(expect.arrayContaining([SAVE_DATASOURCE.datasource]))
})
it("deletes a datasource, updates the store and returns status message", async () => {
api.get.mockReturnValue({ json: () => SOME_DATASOURCE})
API.getDatasources.mockReturnValue({ json: () => SOME_DATASOURCE})
await store.fetch()
api.delete.mockReturnValue({status: 200, message: 'Datasource deleted.'})
API.deleteDatasource.mockReturnValue({status: 200, message: 'Datasource deleted.'})
await store.delete(SOME_DATASOURCE[0])
expect(get(store)).toEqual({ list: [], selected: null})
expect(get(store)).toEqual({ list: [], selected: null})
})
})

View file

@ -1,6 +1,6 @@
import api from 'builderStore/api'
import { API } from "api"
jest.mock('builderStore/api');
jest.mock("api")
const PERMISSIONS_FOR_RESOURCE = {
"write": "BASIC",
@ -13,13 +13,12 @@ describe("Permissions Store", () => {
const store = createPermissionStore()
it("fetches permissions for specific resource", async () => {
api.get.mockReturnValueOnce({ json: () => PERMISSIONS_FOR_RESOURCE})
API.getPermissionForResource.mockReturnValueOnce({ json: () => PERMISSIONS_FOR_RESOURCE})
const resourceId = "ta_013657543b4043b89dbb17e9d3a4723a"
const permissions = await store.forResource(resourceId)
expect(api.get).toBeCalledWith(`/api/permission/${resourceId}`)
expect(permissions).toEqual(PERMISSIONS_FOR_RESOURCE)
})
})

View file

@ -1,9 +1,9 @@
import { get } from 'svelte/store'
import api from 'builderStore/api'
import { get } from "svelte/store"
import { API } from "api"
jest.mock('builderStore/api');
jest.mock("api")
import { SOME_QUERY, SAVE_QUERY_RESPONSE } from './fixtures/queries'
import { SOME_QUERY, SAVE_QUERY_RESPONSE } from "./fixtures/queries"
import { createQueriesStore } from "../queries"
@ -11,36 +11,36 @@ describe("Queries Store", () => {
let store = createQueriesStore()
beforeEach(async () => {
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
await store.init()
})
it("Initialises correctly", async () => {
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
await store.init()
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
})
it("fetches all the queries", async () => {
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
await store.fetch()
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
})
it("saves the query, updates the store and returns status message", async () => {
api.post.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE})
API.saveQuery.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE})
await store.select(SOME_QUERY.datasourceId, SOME_QUERY)
expect(get(store).list).toEqual(expect.arrayContaining([SOME_QUERY]))
})
it("deletes a query, updates the store and returns status message", async () => {
api.delete.mockReturnValue({status: 200, message: `Query deleted.`})
API.deleteQuery.mockReturnValue({status: 200, message: `Query deleted.`})
await store.delete(SOME_QUERY)
expect(get(store)).toEqual({ list: [], selected: null})
expect(get(store)).toEqual({ list: [], selected: null})
})
})

View file

@ -1,10 +1,10 @@
import { get } from 'svelte/store'
import api from 'builderStore/api'
import { get } from "svelte/store"
import { API } from "api"
jest.mock('builderStore/api');
jest.mock("api")
import { createRolesStore } from "../roles"
import { ROLES } from './fixtures/roles'
import { ROLES } from "./fixtures/roles"
describe("Roles Store", () => {
let store = createRolesStore()
@ -14,19 +14,18 @@ describe("Roles Store", () => {
})
it("fetches roles from backend", async () => {
api.get.mockReturnValue({ json: () => ROLES})
API.getRoles.mockReturnValue({ json: () => ROLES})
await store.fetch()
expect(api.get).toBeCalledWith("/api/roles")
expect(get(store)).toEqual(ROLES)
})
it("deletes a role", async () => {
api.get.mockReturnValueOnce({ json: () => ROLES})
API.getRoles.mockReturnValueOnce({ json: () => ROLES})
await store.fetch()
api.delete.mockReturnValue({status: 200, message: `Role deleted.`})
API.deleteRole.mockReturnValue({status: 200, message: `Role deleted.`})
const updatedRoles = [...ROLES.slice(1)]
await store.delete(ROLES[0])

View file

@ -1,18 +1,16 @@
import { get } from 'svelte/store'
import api from 'builderStore/api'
import { get } from "svelte/store"
import { API } from "api"
jest.mock('builderStore/api');
import { SOME_TABLES, SAVE_TABLES_RESPONSE, A_TABLE } from './fixtures/tables'
jest.mock("api")
import { SOME_TABLES, SAVE_TABLES_RESPONSE, A_TABLE } from "./fixtures/tables"
import { createTablesStore } from "../tables"
import { views } from '../views'
describe("Tables Store", () => {
let store = createTablesStore()
beforeEach(async () => {
api.get.mockReturnValue({ json: () => SOME_TABLES})
API.getTables.mockReturnValue({ json: () => SOME_TABLES})
await store.init()
})
@ -21,46 +19,46 @@ describe("Tables Store", () => {
})
it("fetches all the tables", async () => {
api.get.mockReturnValue({ json: () => SOME_TABLES})
API.getTables.mockReturnValue({ json: () => SOME_TABLES})
await store.fetch()
expect(get(store)).toEqual({ list: SOME_TABLES, selected: {}, draft: {}})
expect(get(store)).toEqual({ list: SOME_TABLES, selected: {}, draft: {}})
})
it("selects a table", async () => {
const tableToSelect = SOME_TABLES[0]
await store.select(tableToSelect)
expect(get(store).selected).toEqual(tableToSelect)
expect(get(store).draft).toEqual(tableToSelect)
expect(get(store).selected).toEqual(tableToSelect)
expect(get(store).draft).toEqual(tableToSelect)
})
it("selecting without a param resets the selected property", async () => {
await store.select()
expect(get(store).draft).toEqual({})
expect(get(store).draft).toEqual({})
})
it("saving a table also selects it", async () => {
api.post.mockReturnValue({ status: 200, json: () => SAVE_TABLES_RESPONSE})
API.post.mockReturnValue({ status: 200, json: () => SAVE_TABLES_RESPONSE})
await store.save(A_TABLE)
expect(get(store).selected).toEqual(SAVE_TABLES_RESPONSE)
expect(get(store).selected).toEqual(SAVE_TABLES_RESPONSE)
})
it("saving the table returns a response", async () => {
api.post.mockReturnValue({ status: 200, json: () => SAVE_TABLES_RESPONSE})
API.saveTable.mockReturnValue({ status: 200, json: () => SAVE_TABLES_RESPONSE})
const response = await store.save(A_TABLE)
expect(response).toEqual(SAVE_TABLES_RESPONSE)
expect(response).toEqual(SAVE_TABLES_RESPONSE)
})
it("deleting a table removes it from the store", async () => {
api.delete.mockReturnValue({status: 200, message: `Table deleted.`})
API.deleteTable.mockReturnValue({status: 200, message: `Table deleted.`})
await store.delete(A_TABLE)
expect(get(store).list).toEqual(expect.not.arrayContaining([A_TABLE]))
expect(get(store).list).toEqual(expect.not.arrayContaining([A_TABLE]))
})
// TODO: Write tests for saving and deleting fields

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {
@ -26,9 +26,9 @@
"outputPath": "build"
},
"dependencies": {
"@budibase/backend-core": "1.3.19-alpha.7",
"@budibase/string-templates": "1.3.19-alpha.7",
"@budibase/types": "1.3.19-alpha.7",
"@budibase/backend-core": "1.3.20",
"@budibase/string-templates": "1.3.20",
"@budibase/types": "1.3.20",
"axios": "0.21.2",
"chalk": "4.1.0",
"cli-progress": "3.11.2",

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"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.3.19-alpha.7",
"@budibase/frontend-core": "1.3.19-alpha.7",
"@budibase/string-templates": "1.3.19-alpha.7",
"@budibase/bbui": "1.3.20",
"@budibase/frontend-core": "1.3.20",
"@budibase/string-templates": "1.3.20",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View file

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

View file

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"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.3.19-alpha.7",
"@budibase/client": "1.3.19-alpha.7",
"@budibase/pro": "1.3.19-alpha.7",
"@budibase/string-templates": "1.3.19-alpha.7",
"@budibase/types": "1.3.19-alpha.7",
"@budibase/backend-core": "1.3.20",
"@budibase/client": "1.3.20",
"@budibase/pro": "1.3.20",
"@budibase/string-templates": "1.3.20",
"@budibase/types": "1.3.20",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View file

@ -1094,17 +1094,16 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.19-alpha.7.tgz#d5bd80676deb03082e186f793f54fe011e6d1e25"
integrity sha512-Y8XHjLdfkM1VqHTuxTw0Lpr5uYzhV2+vKnrEIcrXKYZaK94ZTTjP0p2q24Ptm6kyK9Jx69KydAFSTA9Zc+deXQ==
"@budibase/backend-core@1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.20.tgz#eb8202b6b68682a0db8d99779ea4056671b9bec8"
integrity sha512-s9z/UgRcuwDGAXjyTD7jsaW8ArbFhoBJkfwX5wTOE/CHsYMtaIARPco2QDiTi5XkmgpQdwWCADaE3n0vha7KsQ==
dependencies:
"@budibase/types" "1.3.19-alpha.7"
"@budibase/types" "^1.3.20"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
bcryptjs "2.4.3"
dotenv "16.0.1"
emitter-listener "1.1.2"
ioredis "4.28.0"
@ -1180,13 +1179,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.19-alpha.7.tgz#f69783cd178f355888e30b8fda14bd42588d8eff"
integrity sha512-0/uCBVduAtl5JTEo7dvTt8L4yWWWr6Li9hJA9FzITRgQ163A10BofTQxzMW7/JcO6kDz1p1bUW74JlXb02z96w==
"@budibase/pro@1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.20.tgz#c6848287fcd0adcb350b90e999f1d4038b025262"
integrity sha512-Xp/fgP5B+pxHqVhKukgyMXK7eHlLhsZV9/u0osB7KfOh42sRgst7HSra6ZjMAOmNY/kWQvvtt0KCmER13uYtbA==
dependencies:
"@budibase/backend-core" "1.3.19-alpha.7"
"@budibase/types" "1.3.19-alpha.7"
"@budibase/backend-core" "1.3.20"
"@budibase/types" "1.3.20"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
@ -1209,10 +1208,10 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.19-alpha.7.tgz#81a0d667110e80092e364c53c776949c7a722599"
integrity sha512-xgAxtcDnyZLC+Mi1yD3mnVCdg0S+FxYPwd2CMX8Qw98bnJU0LJ6cB9wF8iLafsOjyGmezDOjiuzT977WesTMUw==
"@budibase/types@1.3.20", "@budibase/types@^1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.20.tgz#58efe3d10693faa939e6068b95c17f8c2b064729"
integrity sha512-LlbqS4JMKtSPbYoTE7BEUDEutvhleUSPd2aLBOYlkMPcPB9hNM4PSwC5UTGZeBJNRaE2nM+iz+5huVYKLzD9cQ==
"@bull-board/api@3.7.0":
version "3.7.0"

View file

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.3.19-alpha.7",
"version": "1.3.20",
"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.3.19-alpha.7",
"version": "1.3.20",
"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.3.19-alpha.7",
"version": "1.3.20",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -36,10 +36,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "1.3.19-alpha.7",
"@budibase/pro": "1.3.19-alpha.7",
"@budibase/string-templates": "1.3.19-alpha.7",
"@budibase/types": "1.3.19-alpha.7",
"@budibase/backend-core": "1.3.20",
"@budibase/pro": "1.3.20",
"@budibase/string-templates": "1.3.20",
"@budibase/types": "1.3.20",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View file

@ -95,16 +95,15 @@ const addSessionAttributesToUser = ctx => {
ctx.body.csrfToken = ctx.user.csrfToken
}
/**
* Remove the attributes that are session based from the current user,
* so that stale values are not written to the db
*/
const removeSessionAttributesFromUser = ctx => {
delete ctx.request.body.csrfToken
delete ctx.request.body.account
delete ctx.request.body.accountPortalAccess
delete ctx.request.body.budibaseAccess
delete ctx.request.body.license
const sanitiseUserUpdate = ctx => {
const allowed = ["firstName", "lastName", "password", "forceResetPassword"]
const resp = {}
for (let [key, value] of Object.entries(ctx.request.body)) {
if (allowed.includes(key)) {
resp[key] = value
}
}
return resp
}
exports.getSelf = async ctx => {
@ -132,10 +131,12 @@ exports.updateSelf = async ctx => {
const db = getGlobalDB()
const user = await db.get(ctx.user._id)
let passwordChange = false
if (ctx.request.body.password) {
const userUpdateObj = sanitiseUserUpdate(ctx)
if (userUpdateObj.password) {
// changing password
passwordChange = true
ctx.request.body.password = await hash(ctx.request.body.password)
userUpdateObj.password = await hash(userUpdateObj.password)
// Log all other sessions out apart from the current one
await platformLogout({
ctx,
@ -143,14 +144,10 @@ exports.updateSelf = async ctx => {
keepActiveSession: true,
})
}
// don't allow sending up an ID/Rev, always use the existing one
delete ctx.request.body._id
delete ctx.request.body._rev
removeSessionAttributesFromUser(ctx)
const response = await db.put({
...user,
...ctx.request.body,
...userUpdateObj,
})
await userCache.invalidateUser(user._id)
ctx.body = {

View file

@ -14,7 +14,6 @@ import {
errors,
events,
tenancy,
users as usersCore,
} from "@budibase/backend-core"
import { checkAnyUserExists } from "../../../utilities/users"
import { groups as groupUtils } from "@budibase/pro"
@ -148,9 +147,7 @@ export const bulkDelete = async (ctx: any) => {
}
try {
let response = await users.bulkDelete(userIds)
ctx.body = response
ctx.body = await users.bulkDelete(userIds)
} catch (err) {
ctx.throw(err)
}

View file

@ -291,17 +291,16 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.19-alpha.7.tgz#d5bd80676deb03082e186f793f54fe011e6d1e25"
integrity sha512-Y8XHjLdfkM1VqHTuxTw0Lpr5uYzhV2+vKnrEIcrXKYZaK94ZTTjP0p2q24Ptm6kyK9Jx69KydAFSTA9Zc+deXQ==
"@budibase/backend-core@1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.20.tgz#eb8202b6b68682a0db8d99779ea4056671b9bec8"
integrity sha512-s9z/UgRcuwDGAXjyTD7jsaW8ArbFhoBJkfwX5wTOE/CHsYMtaIARPco2QDiTi5XkmgpQdwWCADaE3n0vha7KsQ==
dependencies:
"@budibase/types" "1.3.19-alpha.7"
"@budibase/types" "^1.3.20"
"@shopify/jest-koa-mocks" "5.0.1"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
bcryptjs "2.4.3"
dotenv "16.0.1"
emitter-listener "1.1.2"
ioredis "4.28.0"
@ -327,21 +326,21 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.19-alpha.7.tgz#f69783cd178f355888e30b8fda14bd42588d8eff"
integrity sha512-0/uCBVduAtl5JTEo7dvTt8L4yWWWr6Li9hJA9FzITRgQ163A10BofTQxzMW7/JcO6kDz1p1bUW74JlXb02z96w==
"@budibase/pro@1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.20.tgz#c6848287fcd0adcb350b90e999f1d4038b025262"
integrity sha512-Xp/fgP5B+pxHqVhKukgyMXK7eHlLhsZV9/u0osB7KfOh42sRgst7HSra6ZjMAOmNY/kWQvvtt0KCmER13uYtbA==
dependencies:
"@budibase/backend-core" "1.3.19-alpha.7"
"@budibase/types" "1.3.19-alpha.7"
"@budibase/backend-core" "1.3.20"
"@budibase/types" "1.3.20"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
"@budibase/types@1.3.19-alpha.7":
version "1.3.19-alpha.7"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.19-alpha.7.tgz#81a0d667110e80092e364c53c776949c7a722599"
integrity sha512-xgAxtcDnyZLC+Mi1yD3mnVCdg0S+FxYPwd2CMX8Qw98bnJU0LJ6cB9wF8iLafsOjyGmezDOjiuzT977WesTMUw==
"@budibase/types@1.3.20", "@budibase/types@^1.3.20":
version "1.3.20"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.20.tgz#58efe3d10693faa939e6068b95c17f8c2b064729"
integrity sha512-LlbqS4JMKtSPbYoTE7BEUDEutvhleUSPd2aLBOYlkMPcPB9hNM4PSwC5UTGZeBJNRaE2nM+iz+5huVYKLzD9cQ==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"