Merge branch 'feature/audit-logs' of github.com:Budibase/budibase into feature/audit-logs

This commit is contained in:
Peter Clement 2023-02-13 11:47:29 +00:00
commit 00388c4b04
31 changed files with 217 additions and 135 deletions

View File

@ -55,7 +55,7 @@ http {
set $csp_style "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com"; set $csp_style "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com";
set $csp_object "object-src 'none'"; set $csp_object "object-src 'none'";
set $csp_base_uri "base-uri 'self'"; set $csp_base_uri "base-uri 'self'";
set $csp_connect "connect-src 'self' https://*.budibase.net https://api-iam.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com https://*.s3.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.cn-north-1.amazonaws.com https://*.s3.cn-northwest-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com"; set $csp_connect "connect-src 'self' https://*.budibase.net https://api-iam.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com https://*.s3.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.cn-north-1.amazonaws.com https://*.s3.cn-northwest-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com https://api.github.com";
set $csp_font "font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com https://js.intercomcdn.com https://fonts.intercomcdn.com"; set $csp_font "font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com https://js.intercomcdn.com https://fonts.intercomcdn.com";
set $csp_frame "frame-src 'self' https:"; set $csp_frame "frame-src 'self' https:";
set $csp_img "img-src http: https: data: blob:"; set $csp_img "img-src http: https: data: blob:";

View File

@ -1,5 +1,5 @@
{ {
"version": "2.3.2-alpha.3", "version": "2.3.11-alpha.0",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/backend-core", "name": "@budibase/backend-core",
"version": "2.3.2-alpha.3", "version": "2.3.11-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",
@ -24,7 +24,7 @@
"dependencies": { "dependencies": {
"@budibase/nano": "10.1.1", "@budibase/nano": "10.1.1",
"@budibase/pouchdb-replication-stream": "1.2.10", "@budibase/pouchdb-replication-stream": "1.2.10",
"@budibase/types": "2.3.2-alpha.3", "@budibase/types": "2.3.11-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-cloudfront-sign": "2.2.0", "aws-cloudfront-sign": "2.2.0",

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": "2.3.2-alpha.3", "version": "2.3.11-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": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-alpha.0",
"@spectrum-css/accordion": "3.0.24", "@spectrum-css/accordion": "3.0.24",
"@spectrum-css/actionbutton": "1.0.1", "@spectrum-css/actionbutton": "1.0.1",
"@spectrum-css/actiongroup": "1.0.1", "@spectrum-css/actiongroup": "1.0.1",

View File

@ -1,5 +1,5 @@
<script> <script>
import { createEventDispatcher } from "svelte" import { createEventDispatcher, onMount } from "svelte"
import FancyField from "./FancyField.svelte" import FancyField from "./FancyField.svelte"
import FancyFieldLabel from "./FancyFieldLabel.svelte" import FancyFieldLabel from "./FancyFieldLabel.svelte"
import { fade } from "svelte/transition" import { fade } from "svelte/transition"
@ -14,8 +14,11 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let ref
let focused = false let focused = false
$: placeholder = !focused && !value let autofilled = false
$: placeholder = !autofilled && !focused && !value
const onChange = e => { const onChange = e => {
const newValue = e.target.value const newValue = e.target.value
@ -25,6 +28,27 @@
error = validate(newValue) error = validate(newValue)
} }
} }
onMount(() => {
// Start watching for autofill every 100ms
const interval = setInterval(() => {
autofilled = ref?.matches(":-webkit-autofill")
if (autofilled) {
clearInterval(interval)
}
}, 100)
// Give up after 2 seconds and assume autofill has not been used
const timeout = setTimeout(() => {
clearInterval(interval)
}, 2000)
// Cleanup
return () => {
clearInterval(interval)
clearTimeout(timeout)
}
})
</script> </script>
<FancyField {error} {value} {validate} {disabled} {focused}> <FancyField {error} {value} {validate} {disabled} {focused}>
@ -39,6 +63,7 @@
on:focus={() => (focused = true)} on:focus={() => (focused = true)}
on:blur={() => (focused = false)} on:blur={() => (focused = false)}
class:placeholder class:placeholder
bind:this={ref}
/> />
{#if suffix && !placeholder} {#if suffix && !placeholder}
<div in:fade|local={{ duration: 130 }} class="suffix">{suffix}</div> <div in:fade|local={{ duration: 130 }} class="suffix">{suffix}</div>
@ -74,4 +99,11 @@
line-height: 17px; line-height: 17px;
font-family: var(--font-sans); font-family: var(--font-sans);
} }
input:-webkit-autofill {
border-radius: 2px;
-webkit-box-shadow: 0 0 0 100px var(--spectrum-global-color-gray-300) inset;
-webkit-text-fill-color: var(--spectrum-global-color-gray-900);
transition: -webkit-box-shadow 130ms 200ms, background-color 0s 86400s;
padding: 3px 8px 4px 8px;
}
</style> </style>

View File

@ -13,6 +13,7 @@
export let quiet = false export let quiet = false
export let align export let align
export let autofocus = false export let autofocus = false
export let autocomplete = null
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -103,6 +104,7 @@
class="spectrum-Textfield-input" class="spectrum-Textfield-input"
style={align ? `text-align: ${align};` : ""} style={align ? `text-align: ${align};` : ""}
inputmode={type === "number" ? "decimal" : "text"} inputmode={type === "number" ? "decimal" : "text"}
{autocomplete}
/> />
</div> </div>

View File

@ -14,6 +14,7 @@
export let updateOnChange = true export let updateOnChange = true
export let quiet = false export let quiet = false
export let autofocus export let autofocus
export let autocomplete
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const onChange = e => { const onChange = e => {
@ -33,6 +34,7 @@
{type} {type}
{quiet} {quiet}
{autofocus} {autofocus}
{autocomplete}
on:change={onChange} on:change={onChange}
on:click on:click
on:input on:input

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "2.3.2-alpha.3", "version": "2.3.11-alpha.0",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -58,10 +58,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "2.3.2-alpha.3", "@budibase/bbui": "2.3.11-alpha.0",
"@budibase/client": "2.3.2-alpha.3", "@budibase/client": "2.3.11-alpha.0",
"@budibase/frontend-core": "2.3.2-alpha.3", "@budibase/frontend-core": "2.3.11-alpha.0",
"@budibase/string-templates": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-alpha.0",
"@fortawesome/fontawesome-svg-core": "^6.2.1", "@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1", "@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1", "@fortawesome/free-solid-svg-icons": "^6.2.1",

View File

@ -75,7 +75,8 @@
editableColumn.constraints.presence = { allowEmpty: false } editableColumn.constraints.presence = { allowEmpty: false }
} }
$: if (field && !savingColumn) { const initialiseField = (field, savingColumn) => {
if (field && !savingColumn) {
editableColumn = cloneDeep(field) editableColumn = cloneDeep(field)
originalName = editableColumn.name ? editableColumn.name + "" : null originalName = editableColumn.name ? editableColumn.name + "" : null
linkEditDisabled = originalName != null linkEditDisabled = originalName != null
@ -84,6 +85,9 @@
$tables.selected.primaryDisplay == null || $tables.selected.primaryDisplay == null ||
$tables.selected.primaryDisplay === editableColumn.name $tables.selected.primaryDisplay === editableColumn.name
} }
}
$: initialiseField(field, savingColumn)
$: checkConstraints(editableColumn) $: checkConstraints(editableColumn)
$: required = !!editableColumn?.constraints?.presence || primaryDisplay $: required = !!editableColumn?.constraints?.presence || primaryDisplay
@ -583,7 +587,12 @@
title="Formula" title="Formula"
label="Formula" label="Formula"
value={editableColumn.formula} value={editableColumn.formula}
on:change={e => (editableColumn.formula = e.detail)} on:change={e => {
editableColumn = {
...editableColumn,
formula: e.detail,
}
}}
bindings={getBindings({ table })} bindings={getBindings({ table })}
allowJS allowJS
/> />

View File

@ -71,6 +71,7 @@
} }
}} }}
value={productionValue} value={productionValue}
autocomplete="new-password"
/> />
</div> </div>
<div> <div>
@ -83,6 +84,7 @@
disabled={useProductionValue} disabled={useProductionValue}
label="Value" label="Value"
value={useProductionValue ? productionValue : developmentValue} value={useProductionValue ? productionValue : developmentValue}
autocomplete="new-password"
/> />
<Checkbox bind:value={useProductionValue} text="Use production value" /> <Checkbox bind:value={useProductionValue} text="Use production value" />
</div> </div>

View File

@ -62,6 +62,7 @@ const getTours = () => {
id: TOUR_STEP_KEYS.BUILDER_APP_PUBLISH, id: TOUR_STEP_KEYS.BUILDER_APP_PUBLISH,
title: "Publish", title: "Publish",
layout: OnboardingPublish, layout: OnboardingPublish,
route: "/builder/app/:application/design",
query: ".toprightnav #builder-app-publish-button", query: ".toprightnav #builder-app-publish-button",
onLoad: () => { onLoad: () => {
tourEvent(TOUR_STEP_KEYS.BUILDER_APP_PUBLISH) tourEvent(TOUR_STEP_KEYS.BUILDER_APP_PUBLISH)

View File

@ -147,8 +147,8 @@
options: setting.options || [], options: setting.options || [],
// Number fields // Number fields
min: setting.min || null, min: setting.min ?? null,
max: setting.max || null, max: setting.max ?? null,
}} }}
{bindings} {bindings}
{componentBindings} {componentBindings}

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "2.3.2-alpha.3", "version": "2.3.11-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": "2.3.2-alpha.3", "@budibase/backend-core": "2.3.11-alpha.0",
"@budibase/string-templates": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-alpha.0",
"@budibase/types": "2.3.2-alpha.3", "@budibase/types": "2.3.11-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",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/client", "name": "@budibase/client",
"version": "2.3.2-alpha.3", "version": "2.3.11-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": "2.3.2-alpha.3", "@budibase/bbui": "2.3.11-alpha.0",
"@budibase/frontend-core": "2.3.2-alpha.3", "@budibase/frontend-core": "2.3.11-alpha.0",
"@budibase/string-templates": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-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",

View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/sdk", "name": "@budibase/sdk",
"version": "2.3.2-alpha.3", "version": "2.3.11-alpha.0",
"description": "Budibase Public API SDK", "description": "Budibase Public API SDK",
"author": "Budibase", "author": "Budibase",
"license": "MPL-2.0", "license": "MPL-2.0",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "2.3.2-alpha.3", "version": "2.3.11-alpha.0",
"description": "Budibase Web Server", "description": "Budibase Web Server",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -43,11 +43,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": "2.3.2-alpha.3", "@budibase/backend-core": "2.3.11-alpha.0",
"@budibase/client": "2.3.2-alpha.3", "@budibase/client": "2.3.11-alpha.0",
"@budibase/pro": "2.3.2-alpha.3", "@budibase/pro": "2.3.11-alpha.0",
"@budibase/string-templates": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-alpha.0",
"@budibase/types": "2.3.2-alpha.3", "@budibase/types": "2.3.11-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",

View File

@ -191,7 +191,7 @@ export async function validate(ctx: BBContext) {
} }
export async function exportRows(ctx: BBContext) { export async function exportRows(ctx: BBContext) {
const { datasourceId } = breakExternalTableId(ctx.params.tableId) const { datasourceId, tableName } = breakExternalTableId(ctx.params.tableId)
const format = ctx.query.format const format = ctx.query.format
const { columns } = ctx.request.body const { columns } = ctx.request.body
const datasource = await sdk.datasources.get(datasourceId!) const datasource = await sdk.datasources.get(datasourceId!)
@ -227,7 +227,9 @@ export async function exportRows(ctx: BBContext) {
rows = result.rows rows = result.rows
} }
// @ts-ignore if (!tableName) {
ctx.throw(400, "Could not find table name.")
}
let schema = datasource.entities[tableName].schema let schema = datasource.entities[tableName].schema
let exportRows = cleanExportRows(rows, schema, format, columns) let exportRows = cleanExportRows(rows, schema, format, columns)

View File

@ -104,7 +104,6 @@ export function importToRows(data: any, table: any, user: any = {}) {
const processed: any = inputProcessing(user, table, row, { const processed: any = inputProcessing(user, table, row, {
noAutoRelationships: true, noAutoRelationships: true,
}) })
table = processed.table
row = processed.row row = processed.row
let fieldName: any let fieldName: any
@ -113,6 +112,7 @@ export function importToRows(data: any, table: any, user: any = {}) {
// check whether the options need to be updated for inclusion as part of the data import // check whether the options need to be updated for inclusion as part of the data import
if ( if (
schema.type === FieldTypes.OPTIONS && schema.type === FieldTypes.OPTIONS &&
row[fieldName] &&
(!schema.constraints.inclusion || (!schema.constraints.inclusion ||
schema.constraints.inclusion.indexOf(row[fieldName]) === -1) schema.constraints.inclusion.indexOf(row[fieldName]) === -1)
) { ) {
@ -120,6 +120,7 @@ export function importToRows(data: any, table: any, user: any = {}) {
...schema.constraints.inclusion, ...schema.constraints.inclusion,
row[fieldName], row[fieldName],
] ]
schema.constraints.inclusion.sort()
} }
} }

View File

@ -1,4 +1,4 @@
const { roles } = require("@budibase/backend-core") const { roles, utils } = require("@budibase/backend-core")
const { checkPermissionsEndpoint } = require("./utilities/TestFunctions") const { checkPermissionsEndpoint } = require("./utilities/TestFunctions")
const setup = require("./utilities") const setup = require("./utilities")
const { BUILTIN_ROLE_IDS } = roles const { BUILTIN_ROLE_IDS } = roles
@ -28,8 +28,8 @@ describe("/users", () => {
describe("fetch", () => { describe("fetch", () => {
it("returns a list of users from an instance db", async () => { it("returns a list of users from an instance db", async () => {
await config.createUser("uuidx") await config.createUser({ id: "uuidx" })
await config.createUser("uuidy") await config.createUser({ id: "uuidy" })
const res = await request const res = await request
.get(`/api/users/metadata`) .get(`/api/users/metadata`)
.set(config.defaultHeaders()) .set(config.defaultHeaders())
@ -56,7 +56,7 @@ describe("/users", () => {
describe("update", () => { describe("update", () => {
it("should be able to update the user", async () => { it("should be able to update the user", async () => {
const user = await config.createUser() const user = await config.createUser({ id: `us_update${Math.random()}` })
user.roleId = BUILTIN_ROLE_IDS.BASIC user.roleId = BUILTIN_ROLE_IDS.BASIC
const res = await request const res = await request
.put(`/api/users/metadata`) .put(`/api/users/metadata`)
@ -180,14 +180,11 @@ describe("/users", () => {
const app1 = await config.createApp('App 1') const app1 = await config.createApp('App 1')
const app2 = await config.createApp('App 2') const app2 = await config.createApp('App 2')
let user = await config.createUser( let user = await config.createUser({
undefined, builder: false,
undefined, admin: true,
undefined, roles: { [app1.appId]: 'ADMIN' }
undefined, })
false,
true,
{ [app1.appId]: 'ADMIN' })
let res = await request let res = await request
.post(`/api/users/metadata/sync/${user._id}`) .post(`/api/users/metadata/sync/${user._id}`)
.set(config.defaultHeaders()) .set(config.defaultHeaders())

View File

@ -67,6 +67,15 @@ if (
INTEGRATIONS[SourceName.ORACLE] = oracle.integration INTEGRATIONS[SourceName.ORACLE] = oracle.integration
} }
export async function getDefinition(source: SourceName): Promise<Integration> {
// check if its integrated, faster
if (DEFINITIONS[source]) {
return DEFINITIONS[source]
}
const allDefinitions = await getDefinitions()
return allDefinitions[source]
}
export async function getDefinitions() { export async function getDefinitions() {
const pluginSchemas: { [key: string]: Integration } = {} const pluginSchemas: { [key: string]: Integration } = {}
if (env.SELF_HOSTED) { if (env.SELF_HOSTED) {

View File

@ -26,7 +26,7 @@ interface MSSQLConfig {
user: string user: string
password: string password: string
server: string server: string
port: number port: number | string
database: string database: string
schema: string schema: string
encrypt?: boolean encrypt?: boolean

View File

@ -93,24 +93,16 @@ describe("migrations", () => {
await clearMigrations() await clearMigrations()
const appId = config.prodAppId const appId = config.prodAppId
const roles = { [appId]: "role_12345" } const roles = { [appId]: "role_12345" }
await config.createUser( await config.createUser({
undefined, builder: false,
undefined, admin: true,
undefined, roles,
undefined, }) // admin only
false, await config.createUser({
true, builder: false,
roles admin: false,
) // admin only roles,
await config.createUser( }) // non admin non builder
undefined,
undefined,
undefined,
undefined,
false,
false,
roles
) // non admin non builder
await config.createTable() await config.createTable()
await config.createRow() await config.createRow()
await config.createRow() await config.createRow()

View File

@ -3,6 +3,7 @@ import { findHBSBlocks, processObjectSync } from "@budibase/string-templates"
import { import {
Datasource, Datasource,
DatasourceFieldType, DatasourceFieldType,
Integration,
PASSWORD_REPLACEMENT, PASSWORD_REPLACEMENT,
RestAuthConfig, RestAuthConfig,
RestAuthType, RestAuthType,
@ -11,16 +12,38 @@ import {
} from "@budibase/types" } from "@budibase/types"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { getEnvironmentVariables } from "../../utils" import { getEnvironmentVariables } from "../../utils"
import { getDefinitions } from "../../../integrations" import { getDefinitions, getDefinition } from "../../../integrations"
const ENV_VAR_PREFIX = "env." const ENV_VAR_PREFIX = "env."
export function checkDatasourceTypes(schema: Integration, config: any) {
for (let key of Object.keys(config)) {
if (!schema.datasource[key]) {
continue
}
const type = schema.datasource[key].type
if (
type === DatasourceFieldType.NUMBER &&
typeof config[key] === "string"
) {
config[key] = parseFloat(config[key])
}
}
return config
}
async function enrichDatasourceWithValues(datasource: Datasource) { async function enrichDatasourceWithValues(datasource: Datasource) {
const cloned = cloneDeep(datasource) const cloned = cloneDeep(datasource)
const env = await getEnvironmentVariables() const env = await getEnvironmentVariables()
const processed = processObjectSync(cloned, { env }, { onlyFound: true }) const processed = processObjectSync(
cloned,
{ env },
{ onlyFound: true }
) as Datasource
const definition = await getDefinition(processed.source)
processed.config = checkDatasourceTypes(definition, processed.config)
return { return {
datasource: processed as Datasource, datasource: processed,
envVars: env as Record<string, string>, envVars: env as Record<string, string>,
} }
} }

View File

@ -275,14 +275,24 @@ class TestConfiguration {
} }
async createUser( async createUser(
id = null, user: {
firstName = this.defaultUserValues.firstName, id?: string
lastName = this.defaultUserValues.lastName, firstName?: string
email = this.defaultUserValues.email, lastName?: string
builder = true, email?: string
admin = false, builder?: boolean
roles = {} admin?: boolean
roles?: any
} = {}
) { ) {
let { id, firstName, lastName, email, builder, admin, roles } = user
firstName = firstName || this.defaultUserValues.firstName
lastName = lastName || this.defaultUserValues.lastName
email = email || this.defaultUserValues.email
roles = roles || {}
if (builder == null) {
builder = true
}
const globalId = !id ? `us_${Math.random()}` : `us_${id}` const globalId = !id ? `us_${Math.random()}` : `us_${id}`
const resp = await this.globalUser({ const resp = await this.globalUser({
id: globalId, id: globalId,

View File

@ -464,6 +464,9 @@ export function execute(job: Job, callback: WorkerCallback) {
throw new Error("Unable to execute, event doesn't contain app ID.") throw new Error("Unable to execute, event doesn't contain app ID.")
} }
return context.doInAppContext(appId, async () => { return context.doInAppContext(appId, async () => {
const envVars = await sdkUtils.getEnvironmentVariables()
// put into automation thread for whole context
await context.doInEnvironmentContext(envVars, async () => {
const automationOrchestrator = new Orchestrator(job) const automationOrchestrator = new Orchestrator(job)
try { try {
const response = await automationOrchestrator.execute() const response = await automationOrchestrator.execute()
@ -472,6 +475,7 @@ export function execute(job: Job, callback: WorkerCallback) {
callback(err) callback(err)
} }
}) })
})
} }
export const removeStalled = async (job: Job) => { export const removeStalled = async (job: Job) => {
@ -480,11 +484,7 @@ export const removeStalled = async (job: Job) => {
throw new Error("Unable to execute, event doesn't contain app ID.") throw new Error("Unable to execute, event doesn't contain app ID.")
} }
await context.doInAppContext(appId, async () => { await context.doInAppContext(appId, async () => {
const envVars = await sdkUtils.getEnvironmentVariables()
// put into automation thread for whole context
await context.doInEnvironmentContext(envVars, async () => {
const automationOrchestrator = new Orchestrator(job) const automationOrchestrator = new Orchestrator(job)
await automationOrchestrator.stopCron("stalled") await automationOrchestrator.stopCron("stalled")
}) })
})
} }

View File

@ -1278,14 +1278,14 @@
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@2.3.2-alpha.3": "@budibase/backend-core@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.3.2-alpha.3.tgz#798782018e5e4e1076d56bfc50cec01f48d73f5c" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.3.11-alpha.0.tgz#361e30139a1a26d023902c6bdb4fdcac2610b69f"
integrity sha512-S5yXD8YWSrxGv89Z4y3dYnbRTUZFlNVXuE6rtin4JesORi6TmverZ0DmerxD6+bTm57WraaQ+UBIKXgug3fZ+g== integrity sha512-hlaeTkYsSJJYIwwqL3LJ7Pxzq0tOgSjQ38+nFiBPIzjkDSaV0UPwi0rZAZq/kPvaT7AKdTEcf8tn1wiui/VkYA==
dependencies: dependencies:
"@budibase/nano" "10.1.1" "@budibase/nano" "10.1.1"
"@budibase/pouchdb-replication-stream" "1.2.10" "@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.3.2-alpha.3" "@budibase/types" "2.3.11-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-cloudfront-sign "2.2.0" aws-cloudfront-sign "2.2.0"
@ -1392,13 +1392,13 @@
pouchdb-promise "^6.0.4" pouchdb-promise "^6.0.4"
through2 "^2.0.0" through2 "^2.0.0"
"@budibase/pro@2.3.2-alpha.3": "@budibase/pro@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.3.2-alpha.3.tgz#e16d60721aab59f226fcbc69d749a52875357345" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.3.11-alpha.0.tgz#b59edba2c04e2a490f3d9246cd328d8dd3213295"
integrity sha512-/AyS3WtzTyXYAxuzSkRHS8PWSH9Ug/e3iXN4TcawZXOnYYh6UatLQBvds13IZNtCppqx/Gicaq21Jo9939oGcQ== integrity sha512-z7tLgRKYKm1psNZGdRErQT8tV+vSj9hXJkD/H/uFxsJ3IQkjWbcFP5FUBPads5RnvCtqOfYu8OpRHCJfNNBoCA==
dependencies: dependencies:
"@budibase/backend-core" "2.3.2-alpha.3" "@budibase/backend-core" "2.3.11-alpha.0"
"@budibase/types" "2.3.2-alpha.3" "@budibase/types" "2.3.11-alpha.0"
"@koa/router" "8.0.8" "@koa/router" "8.0.8"
bull "4.10.1" bull "4.10.1"
joi "17.6.0" joi "17.6.0"
@ -1424,10 +1424,10 @@
svelte-apexcharts "^1.0.2" svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0" svelte-flatpickr "^3.1.0"
"@budibase/types@2.3.2-alpha.3": "@budibase/types@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.3.2-alpha.3.tgz#619c31f355786bdccc1553bcacd6274518ab9435" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.3.11-alpha.0.tgz#55cdcef6fb30c79e9d7d90ae8789e4f0cc6a2b63"
integrity sha512-eA0NdLEpE/2QwMPoP16bpyN7mqw85YxRzNYmjoqsiSNrQmuFc3uA1XuDoxRYB2f6WCEh0VaOXzYaOQvGctzDvw== integrity sha512-SFW9vManFRJ45bgMW7wkDiNxiQQfAME8HOmSqCHKDC0OPzsDydygIl7BNeF/domFvCXxDD3NPu7HC2JXMlV6cw==
"@bull-board/api@3.7.0": "@bull-board/api@3.7.0":
version "3.7.0" version "3.7.0"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "2.3.2-alpha.3", "version": "2.3.11-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",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/types", "name": "@budibase/types",
"version": "2.3.2-alpha.3", "version": "2.3.11-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",

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "2.3.2-alpha.3", "version": "2.3.11-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": "2.3.2-alpha.3", "@budibase/backend-core": "2.3.11-alpha.0",
"@budibase/pro": "2.3.2-alpha.3", "@budibase/pro": "2.3.11-alpha.0",
"@budibase/string-templates": "2.3.2-alpha.3", "@budibase/string-templates": "2.3.11-alpha.0",
"@budibase/types": "2.3.2-alpha.3", "@budibase/types": "2.3.11-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",

View File

@ -475,14 +475,14 @@
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@2.3.2-alpha.3": "@budibase/backend-core@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.3.2-alpha.3.tgz#798782018e5e4e1076d56bfc50cec01f48d73f5c" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-2.3.11-alpha.0.tgz#361e30139a1a26d023902c6bdb4fdcac2610b69f"
integrity sha512-S5yXD8YWSrxGv89Z4y3dYnbRTUZFlNVXuE6rtin4JesORi6TmverZ0DmerxD6+bTm57WraaQ+UBIKXgug3fZ+g== integrity sha512-hlaeTkYsSJJYIwwqL3LJ7Pxzq0tOgSjQ38+nFiBPIzjkDSaV0UPwi0rZAZq/kPvaT7AKdTEcf8tn1wiui/VkYA==
dependencies: dependencies:
"@budibase/nano" "10.1.1" "@budibase/nano" "10.1.1"
"@budibase/pouchdb-replication-stream" "1.2.10" "@budibase/pouchdb-replication-stream" "1.2.10"
"@budibase/types" "2.3.2-alpha.3" "@budibase/types" "2.3.11-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-cloudfront-sign "2.2.0" aws-cloudfront-sign "2.2.0"
@ -539,13 +539,13 @@
pouchdb-promise "^6.0.4" pouchdb-promise "^6.0.4"
through2 "^2.0.0" through2 "^2.0.0"
"@budibase/pro@2.3.2-alpha.3": "@budibase/pro@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.3.2-alpha.3.tgz#e16d60721aab59f226fcbc69d749a52875357345" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.3.11-alpha.0.tgz#b59edba2c04e2a490f3d9246cd328d8dd3213295"
integrity sha512-/AyS3WtzTyXYAxuzSkRHS8PWSH9Ug/e3iXN4TcawZXOnYYh6UatLQBvds13IZNtCppqx/Gicaq21Jo9939oGcQ== integrity sha512-z7tLgRKYKm1psNZGdRErQT8tV+vSj9hXJkD/H/uFxsJ3IQkjWbcFP5FUBPads5RnvCtqOfYu8OpRHCJfNNBoCA==
dependencies: dependencies:
"@budibase/backend-core" "2.3.2-alpha.3" "@budibase/backend-core" "2.3.11-alpha.0"
"@budibase/types" "2.3.2-alpha.3" "@budibase/types" "2.3.11-alpha.0"
"@koa/router" "8.0.8" "@koa/router" "8.0.8"
bull "4.10.1" bull "4.10.1"
joi "17.6.0" joi "17.6.0"
@ -553,10 +553,10 @@
lru-cache "^7.14.1" lru-cache "^7.14.1"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/types@2.3.2-alpha.3": "@budibase/types@2.3.11-alpha.0":
version "2.3.2-alpha.3" version "2.3.11-alpha.0"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.3.2-alpha.3.tgz#619c31f355786bdccc1553bcacd6274518ab9435" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.3.11-alpha.0.tgz#55cdcef6fb30c79e9d7d90ae8789e4f0cc6a2b63"
integrity sha512-eA0NdLEpE/2QwMPoP16bpyN7mqw85YxRzNYmjoqsiSNrQmuFc3uA1XuDoxRYB2f6WCEh0VaOXzYaOQvGctzDvw== integrity sha512-SFW9vManFRJ45bgMW7wkDiNxiQQfAME8HOmSqCHKDC0OPzsDydygIl7BNeF/domFvCXxDD3NPu7HC2JXMlV6cw==
"@cspotcode/source-map-support@^0.8.0": "@cspotcode/source-map-support@^0.8.0":
version "0.8.1" version "0.8.1"