Merge branch 'develop' into Cypress-Smoke
This commit is contained in:
commit
3be14d4d80
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/backend-core",
|
"name": "@budibase/backend-core",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"description": "Budibase backend core libraries used in server and worker",
|
"description": "Budibase backend core libraries used in server and worker",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"test:watch": "jest --watchAll"
|
"test:watch": "jest --watchAll"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/types": "1.3.19-alpha.5",
|
"@budibase/types": "1.3.21-alpha.0",
|
||||||
"@shopify/jest-koa-mocks": "5.0.1",
|
"@shopify/jest-koa-mocks": "5.0.1",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
|
|
|
@ -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.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"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",
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@spectrum-css/actionbutton": "^1.0.1",
|
"@spectrum-css/actionbutton": "^1.0.1",
|
||||||
"@spectrum-css/actiongroup": "^1.0.1",
|
"@spectrum-css/actiongroup": "^1.0.1",
|
||||||
"@spectrum-css/avatar": "^3.0.2",
|
"@spectrum-css/avatar": "^3.0.2",
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
border-top: var(--border-light);
|
border-top: var(--border-light);
|
||||||
z-index: 2;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fillWidth {
|
.fillWidth {
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
top: 15px;
|
top: 15px;
|
||||||
z-index: 100;
|
z-index: 200;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
}
|
}
|
||||||
.icon {
|
.icon {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
"dev:builder": "routify -c dev:vite",
|
"dev:builder": "routify -c dev:vite",
|
||||||
"dev:vite": "vite --host 0.0.0.0",
|
"dev:vite": "vite --host 0.0.0.0",
|
||||||
"rollup": "rollup -c -w",
|
"rollup": "rollup -c -w",
|
||||||
|
"test": "jest",
|
||||||
"cy:setup": "ts-node ./cypress/ts/setup.ts",
|
"cy:setup": "ts-node ./cypress/ts/setup.ts",
|
||||||
"cy:setup:ci": "node ./cypress/setup.js",
|
"cy:setup:ci": "node ./cypress/setup.js",
|
||||||
"cy:open": "cypress open",
|
"cy:open": "cypress open",
|
||||||
|
@ -36,7 +37,8 @@
|
||||||
"components(.*)$": "<rootDir>/src/components$1",
|
"components(.*)$": "<rootDir>/src/components$1",
|
||||||
"builderStore(.*)$": "<rootDir>/src/builderStore$1",
|
"builderStore(.*)$": "<rootDir>/src/builderStore$1",
|
||||||
"stores(.*)$": "<rootDir>/src/stores$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": [
|
"moduleFileExtensions": [
|
||||||
"js",
|
"js",
|
||||||
|
@ -69,10 +71,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "1.3.19-alpha.5",
|
"@budibase/bbui": "1.3.21-alpha.0",
|
||||||
"@budibase/client": "1.3.19-alpha.5",
|
"@budibase/client": "1.3.21-alpha.0",
|
||||||
"@budibase/frontend-core": "1.3.19-alpha.5",
|
"@budibase/frontend-core": "1.3.21-alpha.0",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@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",
|
||||||
|
|
|
@ -9,14 +9,14 @@ import {
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import {
|
import {
|
||||||
queries as queriesStores,
|
queries as queriesStores,
|
||||||
tables as tablesStore,
|
|
||||||
roles as rolesStore,
|
roles as rolesStore,
|
||||||
|
tables as tablesStore,
|
||||||
} from "stores/backend"
|
} from "stores/backend"
|
||||||
import {
|
import {
|
||||||
makePropSafe,
|
|
||||||
isJSBinding,
|
|
||||||
decodeJSBinding,
|
decodeJSBinding,
|
||||||
encodeJSBinding,
|
encodeJSBinding,
|
||||||
|
isJSBinding,
|
||||||
|
makePropSafe,
|
||||||
} from "@budibase/string-templates"
|
} from "@budibase/string-templates"
|
||||||
import { TableNames } from "../constants"
|
import { TableNames } from "../constants"
|
||||||
import { JSONUtils } from "@budibase/frontend-core"
|
import { JSONUtils } from "@budibase/frontend-core"
|
||||||
|
@ -118,8 +118,7 @@ export const readableToRuntimeMap = (bindings, ctx) => {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return Object.keys(ctx).reduce((acc, key) => {
|
return Object.keys(ctx).reduce((acc, key) => {
|
||||||
let parsedQuery = readableToRuntimeBinding(bindings, ctx[key])
|
acc[key] = readableToRuntimeBinding(bindings, ctx[key])
|
||||||
acc[key] = parsedQuery
|
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
@ -132,8 +131,7 @@ export const runtimeToReadableMap = (bindings, ctx) => {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return Object.keys(ctx).reduce((acc, key) => {
|
return Object.keys(ctx).reduce((acc, key) => {
|
||||||
let parsedQuery = runtimeToReadableBinding(bindings, ctx[key])
|
acc[key] = runtimeToReadableBinding(bindings, ctx[key])
|
||||||
acc[key] = parsedQuery
|
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
@ -379,7 +377,7 @@ const getProviderContextBindings = (asset, dataProviders) => {
|
||||||
/**
|
/**
|
||||||
* Gets all bindable properties from the logged in user.
|
* Gets all bindable properties from the logged in user.
|
||||||
*/
|
*/
|
||||||
const getUserBindings = () => {
|
export const getUserBindings = () => {
|
||||||
let bindings = []
|
let bindings = []
|
||||||
const { schema } = getSchemaForTable(TableNames.USERS)
|
const { schema } = getSchemaForTable(TableNames.USERS)
|
||||||
const keys = Object.keys(schema).sort()
|
const keys = Object.keys(schema).sort()
|
||||||
|
|
|
@ -1,31 +1,20 @@
|
||||||
<script>
|
<script>
|
||||||
import { Body, Button, Heading, Icon, Input, Layout } from "@budibase/bbui"
|
import { Body, Button, Heading, Layout } from "@budibase/bbui"
|
||||||
import {
|
import KeyValueBuilder from "components/integration/KeyValueBuilder.svelte"
|
||||||
readableToRuntimeBinding,
|
import { getUserBindings } from "builderStore/dataBinding"
|
||||||
runtimeToReadableBinding,
|
|
||||||
} from "builderStore/dataBinding"
|
|
||||||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
|
||||||
|
|
||||||
export let bindable = true
|
export let bindable = true
|
||||||
export let queryBindings = []
|
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() {
|
function newQueryBinding() {
|
||||||
queryBindings = [...queryBindings, {}]
|
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>
|
</script>
|
||||||
|
|
||||||
<Layout noPadding={bindable} gap="S">
|
<Layout noPadding={bindable} gap="S">
|
||||||
|
@ -46,57 +35,34 @@
|
||||||
{/if}
|
{/if}
|
||||||
</Body>
|
</Body>
|
||||||
<div class="bindings" class:bindable>
|
<div class="bindings" class:bindable>
|
||||||
{#each queryBindings as binding, idx}
|
<KeyValueBuilder
|
||||||
<Input
|
bind:object={internalBindings}
|
||||||
placeholder="Binding Name"
|
tooltip="Set the name of the binding which can be used in Handlebars statements throughout your query"
|
||||||
thin
|
name="binding"
|
||||||
disabled={bindable}
|
headings
|
||||||
bind:value={binding.name}
|
keyPlaceholder="Binding name"
|
||||||
/>
|
valuePlaceholder="Default"
|
||||||
<Input
|
bindings={[...userBindings]}
|
||||||
placeholder="Default"
|
bindingDrawerLeft="260px"
|
||||||
thin
|
on:change={e => {
|
||||||
disabled={bindable}
|
queryBindings = e.detail.map(binding => {
|
||||||
on:change={evt => onBindingChange(binding.name, evt.detail)}
|
return {
|
||||||
bind:value={binding.default}
|
name: binding.name,
|
||||||
/>
|
default: binding.value,
|
||||||
{#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}
|
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.bindings.bindable {
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
.controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bindings {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr 5%;
|
|
||||||
grid-gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.height {
|
.height {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { IntegrationTypes } from "constants/backend"
|
import { IntegrationTypes } from "constants/backend"
|
||||||
|
import { findHBSBlocks } from "@budibase/string-templates"
|
||||||
|
|
||||||
export function schemaToFields(schema) {
|
export function schemaToFields(schema) {
|
||||||
const response = {}
|
const response = {}
|
||||||
|
@ -31,7 +32,7 @@ export function breakQueryString(qs) {
|
||||||
let paramObj = {}
|
let paramObj = {}
|
||||||
for (let param of params) {
|
for (let param of params) {
|
||||||
const split = param.split("=")
|
const split = param.split("=")
|
||||||
paramObj[split[0]] = split.slice(1).join("=")
|
paramObj[split[0]] = decodeURIComponent(split.slice(1).join("="))
|
||||||
}
|
}
|
||||||
return paramObj
|
return paramObj
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,19 @@ export function buildQueryString(obj) {
|
||||||
if (str !== "") {
|
if (str !== "") {
|
||||||
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
|
return str
|
||||||
|
|
|
@ -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)
|
||||||
|
})
|
||||||
|
})
|
|
@ -708,6 +708,7 @@
|
||||||
.url-block {
|
.url-block {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-s);
|
||||||
|
z-index: 200;
|
||||||
}
|
}
|
||||||
.verb {
|
.verb {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import { datasources, integrations, tables, views } from "./"
|
import { datasources, integrations, tables, views } from "./"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { duplicateName } from "../../helpers/duplicate"
|
import { duplicateName } from "helpers/duplicate"
|
||||||
|
|
||||||
const sortQueries = queryList => {
|
const sortQueries = queryList => {
|
||||||
queryList.sort((q1, q2) => {
|
queryList.sort((q1, q2) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { get, writable } from "svelte/store"
|
||||||
import { datasources, queries, views } from "./"
|
import { datasources, queries, views } from "./"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { SWITCHABLE_TYPES } from "../../constants/backend"
|
import { SWITCHABLE_TYPES } from "constants/backend"
|
||||||
|
|
||||||
export function createTablesStore() {
|
export function createTablesStore() {
|
||||||
const store = writable({})
|
const store = writable({})
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { get } from 'svelte/store'
|
import { get } from "svelte/store"
|
||||||
import api from 'builderStore/api'
|
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 { createDatasourcesStore } from "../datasources"
|
||||||
import { queries } from '../queries'
|
import { queries } from '../queries'
|
||||||
|
@ -12,39 +12,39 @@ describe("Datasources Store", () => {
|
||||||
let store = createDatasourcesStore()
|
let store = createDatasourcesStore()
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE]})
|
API.getDatasources.mockReturnValue({ json: () => [SOME_DATASOURCE]})
|
||||||
await store.init()
|
await store.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Initialises correctly", async () => {
|
it("Initialises correctly", async () => {
|
||||||
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE]})
|
API.getDatasources.mockReturnValue({ json: () => [SOME_DATASOURCE]})
|
||||||
|
|
||||||
await store.init()
|
await store.init()
|
||||||
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null})
|
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fetches all the datasources and updates the store", async () => {
|
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()
|
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 () => {
|
it("selects a datasource", async () => {
|
||||||
store.select(SOME_DATASOURCE._id)
|
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 () => {
|
it("resets the queries store when new datasource is selected", async () => {
|
||||||
|
|
||||||
await store.select(SOME_DATASOURCE._id)
|
await store.select(SOME_DATASOURCE._id)
|
||||||
const queriesValue = get(queries)
|
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 () => {
|
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({
|
await store.save({
|
||||||
name: 'CoolDB',
|
name: 'CoolDB',
|
||||||
|
@ -56,13 +56,13 @@ describe("Datasources Store", () => {
|
||||||
expect(get(store).list).toEqual(expect.arrayContaining([SAVE_DATASOURCE.datasource]))
|
expect(get(store).list).toEqual(expect.arrayContaining([SAVE_DATASOURCE.datasource]))
|
||||||
})
|
})
|
||||||
it("deletes a datasource, updates the store and returns status message", async () => {
|
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()
|
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])
|
await store.delete(SOME_DATASOURCE[0])
|
||||||
expect(get(store)).toEqual({ list: [], selected: null})
|
expect(get(store)).toEqual({ list: [], selected: null})
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -1,6 +1,6 @@
|
||||||
import api from 'builderStore/api'
|
import { API } from "api"
|
||||||
|
|
||||||
jest.mock('builderStore/api');
|
jest.mock("api")
|
||||||
|
|
||||||
const PERMISSIONS_FOR_RESOURCE = {
|
const PERMISSIONS_FOR_RESOURCE = {
|
||||||
"write": "BASIC",
|
"write": "BASIC",
|
||||||
|
@ -13,13 +13,12 @@ describe("Permissions Store", () => {
|
||||||
const store = createPermissionStore()
|
const store = createPermissionStore()
|
||||||
|
|
||||||
it("fetches permissions for specific resource", async () => {
|
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 resourceId = "ta_013657543b4043b89dbb17e9d3a4723a"
|
||||||
|
|
||||||
const permissions = await store.forResource(resourceId)
|
const permissions = await store.forResource(resourceId)
|
||||||
|
|
||||||
expect(api.get).toBeCalledWith(`/api/permission/${resourceId}`)
|
|
||||||
expect(permissions).toEqual(PERMISSIONS_FOR_RESOURCE)
|
expect(permissions).toEqual(PERMISSIONS_FOR_RESOURCE)
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -1,9 +1,9 @@
|
||||||
import { get } from 'svelte/store'
|
import { get } from "svelte/store"
|
||||||
import api from 'builderStore/api'
|
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"
|
import { createQueriesStore } from "../queries"
|
||||||
|
|
||||||
|
@ -11,36 +11,36 @@ describe("Queries Store", () => {
|
||||||
let store = createQueriesStore()
|
let store = createQueriesStore()
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
|
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
|
||||||
await store.init()
|
await store.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Initialises correctly", async () => {
|
it("Initialises correctly", async () => {
|
||||||
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
|
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
|
||||||
|
|
||||||
await store.init()
|
await store.init()
|
||||||
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
|
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fetches all the queries", async () => {
|
it("fetches all the queries", async () => {
|
||||||
api.get.mockReturnValue({ json: () => [SOME_QUERY]})
|
API.getQueries.mockReturnValue({ json: () => [SOME_QUERY]})
|
||||||
|
|
||||||
await store.fetch()
|
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 () => {
|
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)
|
await store.select(SOME_QUERY.datasourceId, SOME_QUERY)
|
||||||
|
|
||||||
expect(get(store).list).toEqual(expect.arrayContaining([SOME_QUERY]))
|
expect(get(store).list).toEqual(expect.arrayContaining([SOME_QUERY]))
|
||||||
})
|
})
|
||||||
it("deletes a query, updates the store and returns status message", async () => {
|
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)
|
await store.delete(SOME_QUERY)
|
||||||
expect(get(store)).toEqual({ list: [], selected: null})
|
expect(get(store)).toEqual({ list: [], selected: null})
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -1,10 +1,10 @@
|
||||||
import { get } from 'svelte/store'
|
import { get } from "svelte/store"
|
||||||
import api from 'builderStore/api'
|
import { API } from "api"
|
||||||
|
|
||||||
jest.mock('builderStore/api');
|
jest.mock("api")
|
||||||
|
|
||||||
import { createRolesStore } from "../roles"
|
import { createRolesStore } from "../roles"
|
||||||
import { ROLES } from './fixtures/roles'
|
import { ROLES } from "./fixtures/roles"
|
||||||
|
|
||||||
describe("Roles Store", () => {
|
describe("Roles Store", () => {
|
||||||
let store = createRolesStore()
|
let store = createRolesStore()
|
||||||
|
@ -14,19 +14,18 @@ describe("Roles Store", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fetches roles from backend", async () => {
|
it("fetches roles from backend", async () => {
|
||||||
api.get.mockReturnValue({ json: () => ROLES})
|
API.getRoles.mockReturnValue({ json: () => ROLES})
|
||||||
await store.fetch()
|
await store.fetch()
|
||||||
|
|
||||||
expect(api.get).toBeCalledWith("/api/roles")
|
|
||||||
expect(get(store)).toEqual(ROLES)
|
expect(get(store)).toEqual(ROLES)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes a role", async () => {
|
it("deletes a role", async () => {
|
||||||
api.get.mockReturnValueOnce({ json: () => ROLES})
|
API.getRoles.mockReturnValueOnce({ json: () => ROLES})
|
||||||
await store.fetch()
|
await store.fetch()
|
||||||
|
|
||||||
api.delete.mockReturnValue({status: 200, message: `Role deleted.`})
|
API.deleteRole.mockReturnValue({status: 200, message: `Role deleted.`})
|
||||||
|
|
||||||
const updatedRoles = [...ROLES.slice(1)]
|
const updatedRoles = [...ROLES.slice(1)]
|
||||||
await store.delete(ROLES[0])
|
await store.delete(ROLES[0])
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
import { get } from 'svelte/store'
|
import { get } from "svelte/store"
|
||||||
import api from 'builderStore/api'
|
import { API } from "api"
|
||||||
|
|
||||||
jest.mock('builderStore/api');
|
jest.mock("api")
|
||||||
|
|
||||||
import { SOME_TABLES, SAVE_TABLES_RESPONSE, A_TABLE } from './fixtures/tables'
|
|
||||||
|
|
||||||
|
import { SOME_TABLES, SAVE_TABLES_RESPONSE, A_TABLE } from "./fixtures/tables"
|
||||||
import { createTablesStore } from "../tables"
|
import { createTablesStore } from "../tables"
|
||||||
import { views } from '../views'
|
|
||||||
|
|
||||||
describe("Tables Store", () => {
|
describe("Tables Store", () => {
|
||||||
let store = createTablesStore()
|
let store = createTablesStore()
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
api.get.mockReturnValue({ json: () => SOME_TABLES})
|
API.getTables.mockReturnValue({ json: () => SOME_TABLES})
|
||||||
await store.init()
|
await store.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -21,46 +19,46 @@ describe("Tables Store", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("fetches all the tables", async () => {
|
it("fetches all the tables", async () => {
|
||||||
api.get.mockReturnValue({ json: () => SOME_TABLES})
|
API.getTables.mockReturnValue({ json: () => SOME_TABLES})
|
||||||
|
|
||||||
await store.fetch()
|
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 () => {
|
it("selects a table", async () => {
|
||||||
const tableToSelect = SOME_TABLES[0]
|
const tableToSelect = SOME_TABLES[0]
|
||||||
await store.select(tableToSelect)
|
await store.select(tableToSelect)
|
||||||
|
|
||||||
expect(get(store).selected).toEqual(tableToSelect)
|
expect(get(store).selected).toEqual(tableToSelect)
|
||||||
expect(get(store).draft).toEqual(tableToSelect)
|
expect(get(store).draft).toEqual(tableToSelect)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("selecting without a param resets the selected property", async () => {
|
it("selecting without a param resets the selected property", async () => {
|
||||||
await store.select()
|
await store.select()
|
||||||
|
|
||||||
expect(get(store).draft).toEqual({})
|
expect(get(store).draft).toEqual({})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("saving a table also selects it", async () => {
|
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)
|
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 () => {
|
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)
|
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 () => {
|
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)
|
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
|
// TODO: Write tests for saving and deleting fields
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"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": {
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
"outputPath": "build"
|
"outputPath": "build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "1.3.19-alpha.5",
|
"@budibase/backend-core": "1.3.21-alpha.0",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@budibase/types": "1.3.19-alpha.5",
|
"@budibase/types": "1.3.21-alpha.0",
|
||||||
"axios": "0.21.2",
|
"axios": "0.21.2",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"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.3.19-alpha.5",
|
"@budibase/bbui": "1.3.21-alpha.0",
|
||||||
"@budibase/frontend-core": "1.3.19-alpha.5",
|
"@budibase/frontend-core": "1.3.21-alpha.0",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@spectrum-css/button": "^3.0.3",
|
"@spectrum-css/button": "^3.0.3",
|
||||||
"@spectrum-css/card": "^3.0.3",
|
"@spectrum-css/card": "^3.0.3",
|
||||||
"@spectrum-css/divider": "^1.0.3",
|
"@spectrum-css/divider": "^1.0.3",
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/frontend-core",
|
"name": "@budibase/frontend-core",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"description": "Budibase frontend core libraries used in builder and client",
|
"description": "Budibase frontend core libraries used in builder and client",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "1.3.19-alpha.5",
|
"@budibase/bbui": "1.3.21-alpha.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"svelte": "^3.46.2"
|
"svelte": "^3.46.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -77,11 +77,11 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "10.0.3",
|
"@apidevtools/swagger-parser": "10.0.3",
|
||||||
"@budibase/backend-core": "1.3.19-alpha.5",
|
"@budibase/backend-core": "1.3.21-alpha.0",
|
||||||
"@budibase/client": "1.3.19-alpha.5",
|
"@budibase/client": "1.3.21-alpha.0",
|
||||||
"@budibase/pro": "1.3.19-alpha.5",
|
"@budibase/pro": "1.3.21-alpha.0",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@budibase/types": "1.3.19-alpha.5",
|
"@budibase/types": "1.3.21-alpha.0",
|
||||||
"@bull-board/api": "3.7.0",
|
"@bull-board/api": "3.7.0",
|
||||||
"@bull-board/koa": "3.9.4",
|
"@bull-board/koa": "3.9.4",
|
||||||
"@elastic/elasticsearch": "7.10.0",
|
"@elastic/elasticsearch": "7.10.0",
|
||||||
|
|
|
@ -412,6 +412,7 @@ exports.getDatasourcePlugin = async (name, url, hash) => {
|
||||||
return require(filename)
|
return require(filename)
|
||||||
} else {
|
} else {
|
||||||
console.log(`Updating plugin: ${name}`)
|
console.log(`Updating plugin: ${name}`)
|
||||||
|
delete require.cache[require.resolve(filename)]
|
||||||
fs.unlinkSync(filename)
|
fs.unlinkSync(filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1094,12 +1094,12 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@1.3.19-alpha.5":
|
"@budibase/backend-core@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.19-alpha.5.tgz#c572915f081108999425601b0acccd02839ea331"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.21-alpha.0.tgz#f64dc43f38e1ba8d43ae99fdb67f1f052a0af68e"
|
||||||
integrity sha512-26bYxU13YVj5L9ve0gY6Q+CjuooxF+2MuBsi5heWCt1h50yuvzLHfPJ3WMe285iPqCU74mfLx/ndGeoh2A1Odg==
|
integrity sha512-eVQXs9+ddfjtGYNanXkFCgYYxVwI90To4y1LY3CfUvegcDaJIt26XX9B7uKNwRdWl37XqptwbmaqDfsWlsxIew==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/types" "1.3.19-alpha.5"
|
"@budibase/types" "1.3.21-alpha.0"
|
||||||
"@shopify/jest-koa-mocks" "5.0.1"
|
"@shopify/jest-koa-mocks" "5.0.1"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
|
@ -1180,13 +1180,13 @@
|
||||||
svelte-flatpickr "^3.2.3"
|
svelte-flatpickr "^3.2.3"
|
||||||
svelte-portal "^1.0.0"
|
svelte-portal "^1.0.0"
|
||||||
|
|
||||||
"@budibase/pro@1.3.19-alpha.5":
|
"@budibase/pro@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.19-alpha.5.tgz#a85152c4c162c62e0c449ec10bee96f2c9ef5202"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.21-alpha.0.tgz#e6f3b1b044ff8da0d63fece6b86f10ed076dba6b"
|
||||||
integrity sha512-8MseRJy7QR3fUShvfu5FSd42KSeBqkS80lp7UBZEqJ0dM/Nsw+d3/seE5gv76wEEf7Izu+6sX8mUUHxyHtdIlQ==
|
integrity sha512-NPKZEo9Pz+XFA2/6KUFMhhPIpNzUBZ1AZzQeyeCyjZtXA88ipVA7xdhiJp0OJg1eXwo/QWB1KM/HY7q1kKDkWg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "1.3.19-alpha.5"
|
"@budibase/backend-core" "1.3.21-alpha.0"
|
||||||
"@budibase/types" "1.3.19-alpha.5"
|
"@budibase/types" "1.3.21-alpha.0"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
node-fetch "^2.6.1"
|
node-fetch "^2.6.1"
|
||||||
|
@ -1209,10 +1209,10 @@
|
||||||
svelte-apexcharts "^1.0.2"
|
svelte-apexcharts "^1.0.2"
|
||||||
svelte-flatpickr "^3.1.0"
|
svelte-flatpickr "^3.1.0"
|
||||||
|
|
||||||
"@budibase/types@1.3.19-alpha.5":
|
"@budibase/types@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.19-alpha.5.tgz#2aef86cf1365a00759ef74124e8ebc3fd00d396e"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.21-alpha.0.tgz#665d76bfce66f3bdef064ac9e3bef13e6567da6d"
|
||||||
integrity sha512-kC0x5VaQxYRmwqmcPGKn7u3GX7RWgvSxx5EghrwivpS22LpUQ3ULj54340GS4/Rxn7NjTAzV2jBPhe04PjSXxg==
|
integrity sha512-IkNMFfARkRJRzTSeoRJhqI9hxdkwpq7Wodlj6Mk8++zcMm33RD2Yx4htTBAYEWeeTLYPu67hpvEjQ9OhAZUZNA==
|
||||||
|
|
||||||
"@bull-board/api@3.7.0":
|
"@bull-board/api@3.7.0":
|
||||||
version "3.7.0"
|
version "3.7.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/string-templates",
|
"name": "@budibase/string-templates",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"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",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/types",
|
"name": "@budibase/types",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"description": "Budibase types",
|
"description": "Budibase types",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/worker",
|
"name": "@budibase/worker",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "1.3.19-alpha.5",
|
"version": "1.3.21-alpha.0",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -36,10 +36,10 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "1.3.19-alpha.5",
|
"@budibase/backend-core": "1.3.21-alpha.0",
|
||||||
"@budibase/pro": "1.3.19-alpha.5",
|
"@budibase/pro": "1.3.21-alpha.0",
|
||||||
"@budibase/string-templates": "1.3.19-alpha.5",
|
"@budibase/string-templates": "1.3.21-alpha.0",
|
||||||
"@budibase/types": "1.3.19-alpha.5",
|
"@budibase/types": "1.3.21-alpha.0",
|
||||||
"@koa/router": "8.0.8",
|
"@koa/router": "8.0.8",
|
||||||
"@sentry/node": "6.17.7",
|
"@sentry/node": "6.17.7",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
|
|
|
@ -95,16 +95,15 @@ const addSessionAttributesToUser = ctx => {
|
||||||
ctx.body.csrfToken = ctx.user.csrfToken
|
ctx.body.csrfToken = ctx.user.csrfToken
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const sanitiseUserUpdate = ctx => {
|
||||||
* Remove the attributes that are session based from the current user,
|
const allowed = ["firstName", "lastName", "password", "forceResetPassword"]
|
||||||
* so that stale values are not written to the db
|
const resp = {}
|
||||||
*/
|
for (let [key, value] of Object.entries(ctx.request.body)) {
|
||||||
const removeSessionAttributesFromUser = ctx => {
|
if (allowed.includes(key)) {
|
||||||
delete ctx.request.body.csrfToken
|
resp[key] = value
|
||||||
delete ctx.request.body.account
|
}
|
||||||
delete ctx.request.body.accountPortalAccess
|
}
|
||||||
delete ctx.request.body.budibaseAccess
|
return resp
|
||||||
delete ctx.request.body.license
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getSelf = async ctx => {
|
exports.getSelf = async ctx => {
|
||||||
|
@ -132,10 +131,12 @@ exports.updateSelf = async ctx => {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
const user = await db.get(ctx.user._id)
|
const user = await db.get(ctx.user._id)
|
||||||
let passwordChange = false
|
let passwordChange = false
|
||||||
if (ctx.request.body.password) {
|
|
||||||
|
const userUpdateObj = sanitiseUserUpdate(ctx)
|
||||||
|
if (userUpdateObj.password) {
|
||||||
// changing password
|
// changing password
|
||||||
passwordChange = true
|
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
|
// Log all other sessions out apart from the current one
|
||||||
await platformLogout({
|
await platformLogout({
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -143,14 +144,10 @@ exports.updateSelf = async ctx => {
|
||||||
keepActiveSession: true,
|
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({
|
const response = await db.put({
|
||||||
...user,
|
...user,
|
||||||
...ctx.request.body,
|
...userUpdateObj,
|
||||||
})
|
})
|
||||||
await userCache.invalidateUser(user._id)
|
await userCache.invalidateUser(user._id)
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
errors,
|
errors,
|
||||||
events,
|
events,
|
||||||
tenancy,
|
tenancy,
|
||||||
users as usersCore,
|
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { checkAnyUserExists } from "../../../utilities/users"
|
import { checkAnyUserExists } from "../../../utilities/users"
|
||||||
import { groups as groupUtils } from "@budibase/pro"
|
import { groups as groupUtils } from "@budibase/pro"
|
||||||
|
@ -148,9 +147,7 @@ export const bulkDelete = async (ctx: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await users.bulkDelete(userIds)
|
ctx.body = await users.bulkDelete(userIds)
|
||||||
|
|
||||||
ctx.body = response
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(err)
|
ctx.throw(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,12 +291,12 @@
|
||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@budibase/backend-core@1.3.19-alpha.5":
|
"@budibase/backend-core@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.19-alpha.5.tgz#c572915f081108999425601b0acccd02839ea331"
|
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.21-alpha.0.tgz#f64dc43f38e1ba8d43ae99fdb67f1f052a0af68e"
|
||||||
integrity sha512-26bYxU13YVj5L9ve0gY6Q+CjuooxF+2MuBsi5heWCt1h50yuvzLHfPJ3WMe285iPqCU74mfLx/ndGeoh2A1Odg==
|
integrity sha512-eVQXs9+ddfjtGYNanXkFCgYYxVwI90To4y1LY3CfUvegcDaJIt26XX9B7uKNwRdWl37XqptwbmaqDfsWlsxIew==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/types" "1.3.19-alpha.5"
|
"@budibase/types" "1.3.21-alpha.0"
|
||||||
"@shopify/jest-koa-mocks" "5.0.1"
|
"@shopify/jest-koa-mocks" "5.0.1"
|
||||||
"@techpass/passport-openidconnect" "0.3.2"
|
"@techpass/passport-openidconnect" "0.3.2"
|
||||||
aws-sdk "2.1030.0"
|
aws-sdk "2.1030.0"
|
||||||
|
@ -327,21 +327,21 @@
|
||||||
uuid "8.3.2"
|
uuid "8.3.2"
|
||||||
zlib "1.0.5"
|
zlib "1.0.5"
|
||||||
|
|
||||||
"@budibase/pro@1.3.19-alpha.5":
|
"@budibase/pro@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.19-alpha.5.tgz#a85152c4c162c62e0c449ec10bee96f2c9ef5202"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.21-alpha.0.tgz#e6f3b1b044ff8da0d63fece6b86f10ed076dba6b"
|
||||||
integrity sha512-8MseRJy7QR3fUShvfu5FSd42KSeBqkS80lp7UBZEqJ0dM/Nsw+d3/seE5gv76wEEf7Izu+6sX8mUUHxyHtdIlQ==
|
integrity sha512-NPKZEo9Pz+XFA2/6KUFMhhPIpNzUBZ1AZzQeyeCyjZtXA88ipVA7xdhiJp0OJg1eXwo/QWB1KM/HY7q1kKDkWg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@budibase/backend-core" "1.3.19-alpha.5"
|
"@budibase/backend-core" "1.3.21-alpha.0"
|
||||||
"@budibase/types" "1.3.19-alpha.5"
|
"@budibase/types" "1.3.21-alpha.0"
|
||||||
"@koa/router" "8.0.8"
|
"@koa/router" "8.0.8"
|
||||||
joi "17.6.0"
|
joi "17.6.0"
|
||||||
node-fetch "^2.6.1"
|
node-fetch "^2.6.1"
|
||||||
|
|
||||||
"@budibase/types@1.3.19-alpha.5":
|
"@budibase/types@1.3.21-alpha.0":
|
||||||
version "1.3.19-alpha.5"
|
version "1.3.21-alpha.0"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.19-alpha.5.tgz#2aef86cf1365a00759ef74124e8ebc3fd00d396e"
|
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.21-alpha.0.tgz#665d76bfce66f3bdef064ac9e3bef13e6567da6d"
|
||||||
integrity sha512-kC0x5VaQxYRmwqmcPGKn7u3GX7RWgvSxx5EghrwivpS22LpUQ3ULj54340GS4/Rxn7NjTAzV2jBPhe04PjSXxg==
|
integrity sha512-IkNMFfARkRJRzTSeoRJhqI9hxdkwpq7Wodlj6Mk8++zcMm33RD2Yx4htTBAYEWeeTLYPu67hpvEjQ9OhAZUZNA==
|
||||||
|
|
||||||
"@cspotcode/source-map-consumer@0.8.0":
|
"@cspotcode/source-map-consumer@0.8.0":
|
||||||
version "0.8.0"
|
version "0.8.0"
|
||||||
|
|
38
yarn.lock
38
yarn.lock
|
@ -2700,7 +2700,16 @@ get-caller-file@^1.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
|
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
|
||||||
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
|
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==
|
||||||
|
|
||||||
get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
|
get-intrinsic@^1.0.2:
|
||||||
|
version "1.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.3.tgz#063c84329ad93e83893c7f4f243ef63ffa351385"
|
||||||
|
integrity sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==
|
||||||
|
dependencies:
|
||||||
|
function-bind "^1.1.1"
|
||||||
|
has "^1.0.3"
|
||||||
|
has-symbols "^1.0.3"
|
||||||
|
|
||||||
|
get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.2.tgz#336975123e05ad0b7ba41f152ee4aadbea6cf598"
|
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.2.tgz#336975123e05ad0b7ba41f152ee4aadbea6cf598"
|
||||||
integrity sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==
|
integrity sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==
|
||||||
|
@ -3435,11 +3444,11 @@ is-shared-array-buffer@^1.0.2:
|
||||||
call-bind "^1.0.2"
|
call-bind "^1.0.2"
|
||||||
|
|
||||||
is-ssh@^1.3.0:
|
is-ssh@^1.3.0:
|
||||||
version "1.3.3"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.3.3.tgz#7f133285ccd7f2c2c7fc897b771b53d95a2b2c7e"
|
resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.4.0.tgz#4f8220601d2839d8fa624b3106f8e8884f01b8b2"
|
||||||
integrity sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ==
|
integrity sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
protocols "^1.1.0"
|
protocols "^2.0.1"
|
||||||
|
|
||||||
is-stream@^1.1.0:
|
is-stream@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
|
@ -4680,9 +4689,9 @@ parse-path@^4.0.0:
|
||||||
query-string "^6.13.8"
|
query-string "^6.13.8"
|
||||||
|
|
||||||
parse-url@^6.0.0:
|
parse-url@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-6.0.0.tgz#f5dd262a7de9ec00914939220410b66cff09107d"
|
resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-6.0.5.tgz#4acab8982cef1846a0f8675fa686cef24b2f6f9b"
|
||||||
integrity sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw==
|
integrity sha512-e35AeLTSIlkw/5GFq70IN7po8fmDUjpDPY1rIK+VubRfsUvBonjQ+PBZG+vWMACnQSmNlvl524IucoDmcioMxA==
|
||||||
dependencies:
|
dependencies:
|
||||||
is-ssh "^1.3.0"
|
is-ssh "^1.3.0"
|
||||||
normalize-url "^6.1.0"
|
normalize-url "^6.1.0"
|
||||||
|
@ -4851,11 +4860,16 @@ proto-list@~1.2.1:
|
||||||
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
|
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
|
||||||
integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==
|
integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==
|
||||||
|
|
||||||
protocols@^1.1.0, protocols@^1.4.0:
|
protocols@^1.4.0:
|
||||||
version "1.4.8"
|
version "1.4.8"
|
||||||
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8"
|
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8"
|
||||||
integrity sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==
|
integrity sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==
|
||||||
|
|
||||||
|
protocols@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/protocols/-/protocols-2.0.1.tgz#8f155da3fc0f32644e83c5782c8e8212ccf70a86"
|
||||||
|
integrity sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==
|
||||||
|
|
||||||
protoduck@^5.0.1:
|
protoduck@^5.0.1:
|
||||||
version "5.0.1"
|
version "5.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/protoduck/-/protoduck-5.0.1.tgz#03c3659ca18007b69a50fd82a7ebcc516261151f"
|
resolved "https://registry.yarnpkg.com/protoduck/-/protoduck-5.0.1.tgz#03c3659ca18007b69a50fd82a7ebcc516261151f"
|
||||||
|
@ -4904,9 +4918,9 @@ q@^1.5.1:
|
||||||
integrity sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==
|
integrity sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==
|
||||||
|
|
||||||
qs@^6.9.4:
|
qs@^6.9.4:
|
||||||
version "6.10.5"
|
version "6.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4"
|
resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a"
|
||||||
integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ==
|
integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
side-channel "^1.0.4"
|
side-channel "^1.0.4"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue