Merge branch 'develop' of github.com:Budibase/budibase into cheeks-lab-day-keyboard-shortcuts-develop

This commit is contained in:
Andrew Kingston 2022-08-01 19:08:30 +01:00
commit 7b7075b276
71 changed files with 1311 additions and 777 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -26,7 +26,7 @@
"build": "lerna run build", "build": "lerna run build",
"build:dev": "lerna run prebuild && tsc --build --watch --preserveWatchOutput", "build:dev": "lerna run prebuild && tsc --build --watch --preserveWatchOutput",
"release": "lerna publish ${RELEASE_VERSION_TYPE:-patch} --yes --force-publish && yarn release:pro", "release": "lerna publish ${RELEASE_VERSION_TYPE:-patch} --yes --force-publish && yarn release:pro",
"release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop && yarn release:pro:develop", "release:develop": "lerna publish prerelease --yes --force-publish --dist-tag develop --exact && yarn release:pro:develop",
"release:pro": "bash scripts/pro/release.sh", "release:pro": "bash scripts/pro/release.sh",
"release:pro:develop": "bash scripts/pro/release.sh develop", "release:pro:develop": "bash scripts/pro/release.sh develop",
"restore": "yarn run clean && yarn run bootstrap && yarn run build", "restore": "yarn run clean && yarn run bootstrap && yarn run build",
@ -85,4 +85,4 @@
"install:pro": "bash scripts/pro/install.sh", "install:pro": "bash scripts/pro/install.sh",
"dep:clean": "yarn clean && yarn bootstrap" "dep:clean": "yarn clean && yarn bootstrap"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/backend-core", "name": "@budibase/backend-core",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"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.1.29-alpha.2", "@budibase/types": "1.1.33-alpha.1",
"@techpass/passport-openidconnect": "0.3.2", "@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0", "aws-sdk": "2.1030.0",
"bcrypt": "5.0.1", "bcrypt": "5.0.1",

View File

@ -50,4 +50,5 @@ exports.getTenantFeatureFlags = tenantId => {
exports.FeatureFlag = { exports.FeatureFlag = {
LICENSING: "LICENSING", LICENSING: "LICENSING",
GOOGLE_SHEETS: "GOOGLE_SHEETS", GOOGLE_SHEETS: "GOOGLE_SHEETS",
USER_GROUPS: "USER_GROUPS",
} }

View File

@ -15,11 +15,22 @@ export function logAlert(message: string, e?: any) {
console.error(`bb-alert: ${message} ${errorJson}`) console.error(`bb-alert: ${message} ${errorJson}`)
} }
export function logAlertWithInfo(
message: string,
db: string,
id: string,
error: any
) {
message = `${message} - db: ${db} - doc: ${id} - error: `
logAlert(message, error)
}
export function logWarn(message: string) { export function logWarn(message: string) {
console.warn(`bb-warn: ${message}`) console.warn(`bb-warn: ${message}`)
} }
export default { export default {
logAlert, logAlert,
logAlertWithInfo,
logWarn, logWarn,
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/bbui", "name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.", "description": "A UI solution used in the different Budibase projects.",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"license": "MPL-2.0", "license": "MPL-2.0",
"svelte": "src/index.js", "svelte": "src/index.js",
"module": "dist/bbui.es.js", "module": "dist/bbui.es.js",
@ -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.1.29-alpha.2", "@budibase/string-templates": "1.1.33-alpha.1",
"@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",

View File

@ -115,6 +115,16 @@
class:is-disabled={disabled} class:is-disabled={disabled}
class:is-focused={focus} class:is-focused={focus}
> >
{#if error}
<svg
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
focusable="false"
aria-hidden="true"
>
<use xlink:href="#spectrum-icon-18-Alert" />
</svg>
{/if}
<input <input
{id} {id}
on:click on:click

View File

@ -8,6 +8,7 @@
import Icon from "../../Icon/Icon.svelte" import Icon from "../../Icon/Icon.svelte"
import StatusLight from "../../StatusLight/StatusLight.svelte" import StatusLight from "../../StatusLight/StatusLight.svelte"
import Detail from "../../Typography/Detail.svelte" import Detail from "../../Typography/Detail.svelte"
import Search from "./Search.svelte"
export let primaryLabel = "" export let primaryLabel = ""
export let primaryValue = null export let primaryValue = null
@ -22,7 +23,6 @@
export let secondaryFieldText = "" export let secondaryFieldText = ""
export let secondaryFieldIcon = "" export let secondaryFieldIcon = ""
export let secondaryFieldColour = "" export let secondaryFieldColour = ""
export let getPrimaryOptionLabel = option => option
export let getPrimaryOptionValue = option => option export let getPrimaryOptionValue = option => option
export let getPrimaryOptionColour = () => null export let getPrimaryOptionColour = () => null
export let getPrimaryOptionIcon = () => null export let getPrimaryOptionIcon = () => null
@ -43,17 +43,12 @@
let searchTerm = null let searchTerm = null
$: groupTitles = Object.keys(primaryOptions) $: groupTitles = Object.keys(primaryOptions)
$: filteredOptions = getFilteredOptions(
primaryOptions,
searchTerm,
getPrimaryOptionLabel
)
let iconData let iconData
/*
$: iconData = primaryOptions?.find(x => { const updateSearch = e => {
return x.name === primaryFieldText dispatch("search", e.detail)
}) }
*/
const updateValue = newValue => { const updateValue = newValue => {
if (readonly) { if (readonly) {
return return
@ -107,16 +102,6 @@
updateValue(event.target.value) updateValue(event.target.value)
} }
} }
const getFilteredOptions = (options, term, getLabel) => {
if (autocomplete && term) {
const lowerCaseTerm = term.toLowerCase()
return options.filter(option => {
return `${getLabel(option)}`.toLowerCase().includes(lowerCaseTerm)
})
}
return options
}
</script> </script>
<div <div
@ -183,6 +168,15 @@
class:auto-width={autoWidth} class:auto-width={autoWidth}
class:is-full-width={!secondaryOptions.length} class:is-full-width={!secondaryOptions.length}
> >
{#if autocomplete}
<Search
value={searchTerm}
on:change={event => updateSearch(event)}
{disabled}
placeholder="Search"
/>
{/if}
<ul class="spectrum-Menu" role="listbox"> <ul class="spectrum-Menu" role="listbox">
{#if placeholderOption} {#if placeholderOption}
<li <li
@ -239,7 +233,10 @@
</div> </div>
{:else if getPrimaryOptionColour(option, idx)} {:else if getPrimaryOptionColour(option, idx)}
<span class="option-left"> <span class="option-left">
<StatusLight color={getPrimaryOptionColour(option, idx)} /> <StatusLight
square
color={getPrimaryOptionColour(option, idx)}
/>
</span> </span>
{/if} {/if}
<span class="spectrum-Menu-itemLabel"> <span class="spectrum-Menu-itemLabel">
@ -259,6 +256,7 @@
{#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)} {#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)}
<span class="option-right"> <span class="option-right">
<StatusLight <StatusLight
square
color={getPrimaryOptionColour(option, idx)} color={getPrimaryOptionColour(option, idx)}
/> />
</span> </span>
@ -287,7 +285,7 @@
</span> </span>
{:else if secondaryFieldColour} {:else if secondaryFieldColour}
<span class="option-left"> <span class="option-left">
<StatusLight color={secondaryFieldColour} /> <StatusLight square color={secondaryFieldColour} />
</span> </span>
{/if} {/if}
@ -325,6 +323,7 @@
{#if getSecondaryOptionColour(option, idx)} {#if getSecondaryOptionColour(option, idx)}
<span class="option-left"> <span class="option-left">
<StatusLight <StatusLight
square
color={getSecondaryOptionColour(option, idx)} color={getSecondaryOptionColour(option, idx)}
/> />
</span> </span>
@ -357,6 +356,13 @@
min-width: 0; min-width: 0;
width: 100%; width: 100%;
} }
.spectrum-InputGroup :global(.spectrum-Search-input) {
border: none;
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.override-borders { .override-borders {
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;

View File

@ -26,6 +26,7 @@
export let autofocus export let autofocus
export let primaryOptions = [] export let primaryOptions = []
export let secondaryOptions = [] export let secondaryOptions = []
export let searchTerm
let primaryLabel let primaryLabel
let secondaryLabel let secondaryLabel
@ -87,10 +88,15 @@
} }
return value return value
} }
const updateSearchTerm = e => {
searchTerm = e.detail
}
</script> </script>
<Field {label} {labelPosition} {error}> <Field {label} {labelPosition} {error}>
<PickerDropdown <PickerDropdown
{searchTerm}
{autocomplete} {autocomplete}
{dataCy} {dataCy}
{updateOnChange} {updateOnChange}
@ -116,6 +122,7 @@
{secondaryLabel} {secondaryLabel}
on:pickprimary={onPickPrimary} on:pickprimary={onPickPrimary}
on:picksecondary={onPickSecondary} on:picksecondary={onPickSecondary}
on:search={updateSearchTerm}
on:click on:click
on:input on:input
on:blur on:blur

View File

@ -19,9 +19,14 @@ filterTests(["smoke", "all"], () => {
cy.wait(500) cy.wait(500)
// Reset password // Reset password
cy.get(".spectrum-ActionButton-label", { timeout: 2000 }).contains("Force password reset").click({ force: true }) cy.get(".title").within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
cy.get(interact.SPECTRUM_MENU).within(() => {
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Force Password Reset").click({ force: true })
})
cy.get(".spectrum-Dialog-grid") cy.get(interact.SPECTRUM_DIALOG_GRID)
.find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd') .find(interact.SPECTRUM_TEXTFIELD_INPUT).invoke('val').as('pwd')
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true }) cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
@ -39,23 +44,14 @@ filterTests(["smoke", "all"], () => {
cy.logoutNoAppGrid() cy.logoutNoAppGrid()
}) })
it("should verify Admin Portal", () => { xit("should verify Admin Portal", () => {
cy.login() cy.login()
cy.contains("Users").click() // Configure user role
cy.contains("bbuser").click() cy.setUserRole("bbuser", "Admin")
// Enable Development & Administration access
cy.wait(500)
for (let i = 4; i < 6; i++) {
cy.get(interact.FIELD).eq(i).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
cy.get(interact.SPECTRUM_SWITCH_INPUT).should('be.enabled')
})
}
bbUserLogin() bbUserLogin()
// Verify available options for Admin portal // Verify available options for Admin portal
cy.get(".spectrum-SideNav") cy.get(interact.SPECTRUM_SIDENAV)
.should('contain', 'Apps') .should('contain', 'Apps')
//.and('contain', 'Usage') //.and('contain', 'Usage')
.and('contain', 'Users') .and('contain', 'Users')
@ -72,13 +68,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Development Portal", () => { it("should verify Development Portal", () => {
// Only Development access should be enabled // Only Development access should be enabled
cy.login() cy.login()
cy.contains("Users").click() cy.setUserRole("bbuser", "Developer")
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(5).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
bbUserLogin() bbUserLogin()
// Verify available options for Admin portal // Verify available options for Admin portal
@ -99,13 +89,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Standard Portal", () => { it("should verify Standard Portal", () => {
// Development access should be disabled (Admin access is already disabled) // Development access should be disabled (Admin access is already disabled)
cy.login() cy.login()
cy.contains("Users").click() cy.setUserRole("bbuser", "App User")
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(4).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
bbUserLogin() bbUserLogin()
// Verify Standard Portal // Verify Standard Portal

View File

@ -15,25 +15,16 @@ filterTests(["smoke", "all"], () => {
cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser") cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser")
}) })
it("should confirm basic permission for a New User", () => { it("should confirm App User role for a New User", () => {
// Basic permission = development & administraton disabled
cy.contains("bbuser").click() cy.contains("bbuser").click()
// Confirm development and admin access are disabled cy.get(".spectrum-Form-itemField").eq(2).should('contain', 'App User')
for (let i = 4; i < 6; i++) {
cy.wait(500) // User should not have app access
cy.get(interact.FIELD).eq(i).within(() => { cy.get(interact.LIST_ITEMS, { timeout: 500 }).should("contain", "No apps")
//cy.get(interact.SPECTRUM_SWITCH_INPUT).should('be.disabled')
cy.get(".spectrum-Switch-switch").should('not.be.checked')
})
}
// Existing apps appear within the No Access table
cy.get(interact.SPECTRUM_TABLE, { timeout: 500 }).eq(1).should("not.contain", "No rows found")
// Configure roles table should not contain apps
cy.get(interact.SPECTRUM_TABLE).eq(0).contains("No rows found")
}) })
if (Cypress.env("TEST_ENV")) { if (Cypress.env("TEST_ENV")) {
it("should assign role types", () => { xit("should assign role types", () => {
// 3 apps minimum required - to assign an app to each role type // 3 apps minimum required - to assign an app to each role type
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.its("body") .its("body")
@ -96,7 +87,7 @@ filterTests(["smoke", "all"], () => {
}) })
}) })
it("should unassign role types", () => { xit("should unassign role types", () => {
// Set each app within Configure roles table to 'No Access' // Set each app within Configure roles table to 'No Access'
cy.get(interact.SPECTRUM_TABLE) cy.get(interact.SPECTRUM_TABLE)
.eq(0) .eq(0)
@ -125,7 +116,7 @@ filterTests(["smoke", "all"], () => {
}) })
} }
it("should enable Developer access and verify application access", () => { xit("should enable Developer access and verify application access", () => {
// Enable Developer access // Enable Developer access
cy.get(interact.FIELD) cy.get(interact.FIELD)
.eq(4) .eq(4)
@ -157,7 +148,7 @@ filterTests(["smoke", "all"], () => {
}) })
}) })
it("should disable Developer access and verify application access", () => { xit("should disable Developer access and verify application access", () => {
// Disable Developer access // Disable Developer access
cy.get(interact.FIELD) cy.get(interact.FIELD)
.eq(4) .eq(4)
@ -175,12 +166,12 @@ filterTests(["smoke", "all"], () => {
it("Should edit user details within user details page", () => { it("Should edit user details within user details page", () => {
// Add First name // Add First name
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.wait(500) cy.wait(500)
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb")
}) })
// Add Last name // Add Last name
cy.get(interact.FIELD, { timeout: 1000 }).eq(3).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.wait(500) cy.wait(500)
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test")
}) })
@ -189,16 +180,21 @@ filterTests(["smoke", "all"], () => {
cy.reload() cy.reload()
// Confirm details have been saved // Confirm details have been saved
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', "bb")
}) })
cy.get(interact.FIELD, { timeout: 1000 }).eq(3).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).should('have.value', "test") cy.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).should('have.value', "test")
}) })
}) })
it("should reset the users password", () => { it("should reset the users password", () => {
cy.get(interact.REGENERATE, { timeout: 500 }).contains("Force password reset").click({ force: true }) cy.get(".title").within(() => {
cy.get(interact.SPECTRUM_ICON).click({ force: true })
})
cy.get(interact.SPECTRUM_MENU).within(() => {
cy.get(interact.SPECTRUM_MENU_ITEM).contains("Force Password Reset").click({ force: true })
})
// Reset password modal // Reset password modal
cy.get(interact.SPECTRUM_DIALOG_GRID) cy.get(interact.SPECTRUM_DIALOG_GRID)

View File

@ -19,10 +19,10 @@ filterTests(["smoke", "all"], () => {
cy.contains("Users").click() cy.contains("Users").click()
cy.contains("test@test.com").click() cy.contains("test@test.com").click()
cy.get(interact.FIELD, { timeout: 1000 }).eq(2).within(() => { cy.get(interact.FIELD, { timeout: 1000 }).eq(0).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname) cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', fname)
}) })
cy.get(interact.FIELD).eq(3).within(() => { cy.get(interact.FIELD).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname) cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname)
}) })
}) })

View File

@ -10,10 +10,8 @@ filterTests(['smoke', 'all'], () => {
it("should disable the autogenerated screen options if no sources are available", () => { it("should disable the autogenerated screen options if no sources are available", () => {
cy.createApp("First Test App", false) cy.createApp("First Test App", false)
cy.closeModal(); cy.closeModal();
cy.contains("Design").click()
cy.navigateToAutogeneratedModal() cy.navigateToAutogeneratedModal()
cy.get(interact.CONFIRM_WRAP_SPE_BUTTON).should('be.disabled') cy.get(interact.CONFIRM_WRAP_SPE_BUTTON).should('be.disabled')

View File

@ -199,15 +199,16 @@ filterTests(["all"], () => {
.within(() => { .within(() => {
cy.get("input").clear().type(queryRename) cy.get("input").clear().type(queryRename)
}) })
// Save query // Click on a nav item
cy.get(".spectrum-Button").contains("Save Query").click({ force: true }) cy.get(".nav-item").first().click()
// Confirm name change
cy.get(".nav-item").should("contain", queryRename) cy.get(".nav-item").should("contain", queryRename)
}) })
it("should delete a query", () => { it("should delete a query", () => {
// Get query nav item - QueryName // Get query nav item - QueryName
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryRename)
.parent() .parent()
.within(() => { .within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true }) cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -218,7 +219,7 @@ filterTests(["all"], () => {
.contains("Delete Query") .contains("Delete Query")
.click({ force: true }) .click({ force: true })
// Confirm deletion // Confirm deletion
cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryName) cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryRename)
}) })
} }
}) })

View File

@ -220,7 +220,8 @@ filterTests(["all"], () => {
it("should edit a query name", () => { it("should edit a query name", () => {
// Access query // Access query
cy.get(".hierarchy-items-container", { timeout: 2000 }) cy.get(".hierarchy-items-container", { timeout: 2000 })
.contains(queryName + " (1)") //.contains(queryName + " (1)")
.contains(queryName)
.click({ force: true }) .click({ force: true })
// Rename query // Rename query
@ -231,18 +232,16 @@ filterTests(["all"], () => {
cy.get("input").clear().type(queryRename) cy.get("input").clear().type(queryRename)
}) })
// Run and Save query // Click on a nav item and confirm name change
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Run Query").click({ force: true }) cy.get(".nav-item").first().click()
cy.wait(1000) // Confirm name change
cy.get(".spectrum-Button", { timeout: 2000 }).contains("Save Query").click({ force: true }) cy.get(".nav-item").should("contain", queryRename)
cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 2000 }).should("contain", queryRename)
}) })
it("should delete a query", () => { it("should delete a query", () => {
// Get query nav item - QueryName // Get query nav item - QueryName
cy.get(".nav-item") cy.get(".nav-item")
.contains(queryName) .contains(queryRename)
.parent() .parent()
.within(() => { .within(() => {
cy.get(".spectrum-Icon").eq(1).click({ force: true }) cy.get(".spectrum-Icon").eq(1).click({ force: true })
@ -254,7 +253,7 @@ filterTests(["all"], () => {
.click({ force: true }) .click({ force: true })
// Confirm deletion // Confirm deletion
cy.reload({ timeout: 5000 }) cy.reload({ timeout: 5000 })
cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryName) cy.get(".nav-item", { timeout: 1000 }).should("not.contain", queryRename)
}) })
const switchSchema = schema => { const switchSchema = schema => {

View File

@ -5,30 +5,31 @@ Cypress.on("uncaught:exception", () => {
// ACCOUNTS & USERS // ACCOUNTS & USERS
Cypress.Commands.add("login", (email, password) => { Cypress.Commands.add("login", (email, password) => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 }) cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
cy.wait(2000) cy.url()
cy.url().then(url => { .should("include", "/builder/")
if (url.includes("builder/admin")) { .then(url => {
// create admin user if (url.includes("builder/admin")) {
cy.get("input").first().type("test@test.com") // create admin user
cy.get('input[type="password"]').first().type("test") cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').eq(1).type("test") cy.get('input[type="password"]').first().type("test")
cy.contains("Create super admin user").click({ force: true }) cy.get('input[type="password"]').eq(1).type("test")
} cy.contains("Create super admin user").click({ force: true })
if (url.includes("builder/auth/login") || url.includes("builder/admin")) { }
// login if (url.includes("builder/auth") || url.includes("builder/admin")) {
cy.contains("Sign in to Budibase").then(() => { // login
if (email == null) { cy.contains("Sign in to Budibase").then(() => {
cy.get("input").first().type("test@test.com") if (email == null) {
cy.get('input[type="password"]').type("test") cy.get("input").first().type("test@test.com")
} else { cy.get('input[type="password"]').type("test")
cy.get("input").first().type(email) } else {
cy.get('input[type="password"]').type(password) cy.get("input").first().type(email)
} cy.get('input[type="password"]').type(password)
cy.get("button").first().click({ force: true }) }
cy.wait(1000) cy.get("button").first().click({ force: true })
}) cy.wait(1000)
} })
}) }
})
}) })
Cypress.Commands.add("logOut", () => { Cypress.Commands.add("logOut", () => {
@ -50,23 +51,36 @@ Cypress.Commands.add("logoutNoAppGrid", () => {
cy.wait(2000) cy.wait(2000)
}) })
Cypress.Commands.add("createUser", email => { Cypress.Commands.add("createUser", (email, permission) => {
// quick hacky recorded way to create a user
cy.contains("Users").click() cy.contains("Users").click()
cy.get(`[data-cy="add-user"]`).click() cy.get(`[data-cy="add-user"]`).click()
cy.get(".spectrum-Dialog-grid").within(() => { cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Picker-label").click() // Enter email
cy.get( cy.get(".spectrum-Textfield-input").clear().click().type(email)
".spectrum-Menu-item:nth-child(2) > .spectrum-Menu-itemLabel"
).click()
// Onboarding type selector // Select permission, if applicable
cy.get(".spectrum-Textfield-input") // Default is App User
.eq(0) if (permission != null) {
.first() cy.get(".spectrum-Picker-label").click()
.type(email, { force: true }) cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Button--cta").click({ force: true }) cy.get(".spectrum-Menu-item")
.contains(permission)
.click({ force: true })
})
}
// Add user and wait for modal to change
cy.get(".spectrum-Button").contains("Add user").click({ force: true })
cy.get(".spectrum-ActionButton").contains("Add email").should("not.exist")
}) })
// Onboarding modal
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".onboarding-type").eq(1).click()
cy.get(".spectrum-Button").contains("Done").click({ force: true })
cy.get(".spectrum-Button").contains("Cancel").should("not.exist")
})
// Accounts created modal - Click Done button
cy.get(".spectrum-Button").contains("Done").click({ force: true })
}) })
Cypress.Commands.add("deleteUser", email => { Cypress.Commands.add("deleteUser", email => {
@ -74,18 +88,13 @@ Cypress.Commands.add("deleteUser", email => {
cy.contains("Users", { timeout: 2000 }).click() cy.contains("Users", { timeout: 2000 }).click()
cy.contains(email).click() cy.contains(email).click()
// Click Delete user button cy.get(".title").within(() => {
cy.get(".spectrum-Button") cy.get(".spectrum-Icon").click({ force: true })
.contains("Delete user") })
.click({ force: true }) cy.get(".spectrum-Menu").within(() => {
.then(() => { cy.get(".spectrum-Menu-item").contains("Delete").click({ force: true })
// Confirm deletion within modal })
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => { cy.get(".spectrum-Dialog-grid").contains("Delete user").click({ force: true })
cy.get(".spectrum-Button")
.contains("Delete user")
.click({ force: true })
})
})
}) })
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => { Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
@ -120,9 +129,27 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.blur() .blur()
} }
cy.get("button").contains("Update information").click({ force: true }) cy.get("button").contains("Update information").click({ force: true })
cy.get(".spectrum-Dialog-grid").should("not.exist")
}) })
}) })
Cypress.Commands.add("setUserRole", (user, role) => {
cy.contains("Users").click()
cy.contains(user).click()
// Set Role
cy.wait(500)
cy.get(".spectrum-Form-itemField")
.eq(2)
.within(() => {
cy.get(".spectrum-Picker-label").click({ force: true })
})
cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Menu-itemLabel").contains(role).click({ force: true })
})
cy.get(".spectrum-Form-itemField").eq(2).should("contain", role)
})
// APPLICATIONS // APPLICATIONS
Cypress.Commands.add("createTestApp", () => { Cypress.Commands.add("createTestApp", () => {
const appName = "Cypress Tests" const appName = "Cypress Tests"
@ -516,15 +543,22 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
// DESIGN SECTION // DESIGN SECTION
Cypress.Commands.add("searchAndAddComponent", component => { Cypress.Commands.add("searchAndAddComponent", component => {
// Open component menu // Open component menu
cy.get(".spectrum-Button").contains("Component").click({ force: true }) cy.get(".icon-side-nav").within(() => {
cy.get(".icon-side-nav-item").eq(1).click()
})
cy.get(".add-component > .spectrum-Button")
.contains("Add component")
.click({ force: true })
cy.get(".container", { timeout: 1000 }).within(() => {
cy.get(".title").should("contain", "Add component")
// Search and add component // Search and add component
cy.wait(500) cy.get(".spectrum-Textfield-input").clear().type(component)
cy.get(".spectrum-Textfield-input").clear().type(component) cy.get(".body").within(() => {
cy.get(".body").within(() => { cy.get(".component")
cy.get(".component") .contains(new RegExp("^" + component + "$"), { timeout: 3000 })
.contains(new RegExp("^" + component + "$"), { timeout: 3000 }) .click({ force: true })
.click({ force: true }) })
}) })
cy.wait(1000) cy.wait(1000)
cy.location().then(loc => { cy.location().then(loc => {
@ -570,7 +604,7 @@ Cypress.Commands.add("getComponent", componentId => {
Cypress.Commands.add("createScreen", (route, accessLevelLabel) => { Cypress.Commands.add("createScreen", (route, accessLevelLabel) => {
// Blank Screen // Blank Screen
cy.contains("Design").click() cy.contains("Design").click()
cy.get(".header > .add-button").click() cy.get(".spectrum-Button").contains("Add screen").click({ force: true })
cy.get(".spectrum-Modal").within(() => { cy.get(".spectrum-Modal").within(() => {
cy.get("[data-cy='blank-screen']").click() cy.get("[data-cy='blank-screen']").click()
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) cy.get(".spectrum-Button").contains("Continue").click({ force: true })
@ -595,7 +629,7 @@ Cypress.Commands.add(
"createDatasourceScreen", "createDatasourceScreen",
(datasourceNames, accessLevelLabel) => { (datasourceNames, accessLevelLabel) => {
cy.contains("Design").click() cy.contains("Design").click()
cy.get(".header > .add-button").click() cy.get(".spectrum-Button").contains("Add screen").click({ force: true })
cy.get(".spectrum-Modal").within(() => { cy.get(".spectrum-Modal").within(() => {
cy.get(".item").contains("Autogenerated screens").click() cy.get(".item").contains("Autogenerated screens").click()
cy.get(".spectrum-Button").contains("Continue").click({ force: true }) cy.get(".spectrum-Button").contains("Continue").click({ force: true })
@ -715,7 +749,7 @@ Cypress.Commands.add("navigateToDataSection", () => {
Cypress.Commands.add("navigateToAutogeneratedModal", () => { Cypress.Commands.add("navigateToAutogeneratedModal", () => {
// Screen name must already exist within data source // Screen name must already exist within data source
cy.contains("Design").click() cy.contains("Design").click()
cy.get(".header > .add-button").click() cy.get(".spectrum-Button").contains("Add screen").click({ force: true })
cy.get(".spectrum-Modal").within(() => { cy.get(".spectrum-Modal").within(() => {
cy.get(".item", { timeout: 2000 }) cy.get(".item", { timeout: 2000 })
.contains("Autogenerated screens") .contains("Autogenerated screens")

View File

@ -109,6 +109,8 @@ export const REGENERATE = ".regenerate"
export const SPECTRUM_DIALOG_CONTENT = ".spectrum-Dialog-content" export const SPECTRUM_DIALOG_CONTENT = ".spectrum-Dialog-content"
export const SPECTRUM_ICON = ".spectrum-Icon" export const SPECTRUM_ICON = ".spectrum-Icon"
export const SPECTRUM_HEADING = ".spectrum-Heading" export const SPECTRUM_HEADING = ".spectrum-Heading"
export const SPECTRUM_FORM_ITEMFIELD = ".spectrum-Form-itemField"
export const LIST_ITEMS = ".list-items"
//createView //createView
export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel" export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel"

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/builder", "name": "@budibase/builder",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"license": "GPL-3.0", "license": "GPL-3.0",
"private": true, "private": true,
"scripts": { "scripts": {
@ -69,10 +69,10 @@
} }
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.1.29-alpha.2", "@budibase/bbui": "1.1.33-alpha.1",
"@budibase/client": "^1.1.29-alpha.2", "@budibase/client": "1.1.33-alpha.1",
"@budibase/frontend-core": "^1.1.29-alpha.2", "@budibase/frontend-core": "1.1.33-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.2", "@budibase/string-templates": "1.1.33-alpha.1",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1", "@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1", "@spectrum-css/vars": "^3.0.1",

View File

@ -32,7 +32,8 @@
if (!results) { if (!results) {
return {} return {}
} }
if (results.outputs?.status?.toLowerCase() === "stopped") { const lcStatus = results.outputs?.status?.toLowerCase()
if (lcStatus === "stopped" || lcStatus === "stopped_error") {
return { yellow: true, message: "Stopped" } return { yellow: true, message: "Stopped" }
} else if (results.outputs?.success || isTrigger) { } else if (results.outputs?.success || isTrigger) {
return { positive: true, message: "Success" } return { positive: true, message: "Success" }

View File

@ -1,5 +1,5 @@
<script> <script>
import { Layout, Icon, ActionButton } from "@budibase/bbui" import { Layout, Icon, ActionButton, InlineAlert } from "@budibase/bbui"
import StatusRenderer from "./StatusRenderer.svelte" import StatusRenderer from "./StatusRenderer.svelte"
import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte" import DateTimeRenderer from "components/common/renderers/DateTimeRenderer.svelte"
import TestDisplay from "components/automation/AutomationBuilder/TestDisplay.svelte" import TestDisplay from "components/automation/AutomationBuilder/TestDisplay.svelte"
@ -9,6 +9,7 @@
export let history export let history
export let appId export let appId
export let close export let close
const STOPPED_ERROR = "stopped_error"
$: exists = $automationStore.automations?.find( $: exists = $automationStore.automations?.find(
auto => auto._id === history?.automationId auto => auto._id === history?.automationId
@ -32,6 +33,15 @@
<Icon name="JourneyVoyager" /> <Icon name="JourneyVoyager" />
<div>{history.automationName}</div> <div>{history.automationName}</div>
</div> </div>
{#if history.status === STOPPED_ERROR}
<div class="cron-error">
<InlineAlert
type="error"
header="CRON automation disabled"
message="Fix the error and re-publish your app to re-activate."
/>
</div>
{/if}
<div> <div>
{#if exists} {#if exists}
<ActionButton <ActionButton
@ -87,4 +97,10 @@
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
gap: var(--spacing-s); gap: var(--spacing-s);
} }
.cron-error {
display: flex;
width: 100%;
justify-content: center;
}
</style> </style>

View File

@ -3,7 +3,8 @@
export let value export let value
$: isError = !value || value.toLowerCase() === "error" $: isError = !value || value.toLowerCase() === "error"
$: isStopped = value?.toLowerCase() === "stopped" $: isStoppedError = value?.toLowerCase() === "stopped_error"
$: isStopped = value?.toLowerCase() === "stopped" || isStoppedError
$: status = getStatus(isError, isStopped) $: status = getStatus(isError, isStopped)
function getStatus(error, stopped) { function getStatus(error, stopped) {

View File

@ -3,6 +3,7 @@ import { get } from "svelte/store"
export const FEATURE_FLAGS = { export const FEATURE_FLAGS = {
LICENSING: "LICENSING", LICENSING: "LICENSING",
USER_GROUPS: "USER_GROUPS",
} }
export const isEnabled = featureFlag => { export const isEnabled = featureFlag => {

View File

@ -190,7 +190,7 @@
$goto("./navigation") $goto("./navigation")
} }
} else if (type === "request-add-component") { } else if (type === "request-add-component") {
$goto("./components/new") $goto(`./components/${$selectedComponent?._id}/new`)
} else if (type === "highlight-setting") { } else if (type === "highlight-setting") {
store.actions.settings.highlight(data.setting) store.actions.settings.highlight(data.setting)

View File

@ -184,6 +184,7 @@
<div class="category-label">{category.name}</div> <div class="category-label">{category.name}</div>
{#each category.children as component} {#each category.children as component}
<div <div
data-cy={`component-${component.name}`}
class="component" class="component"
class:selected={selectedIndex === class:selected={selectedIndex ===
orderMap[component.component]} orderMap[component.component]}

View File

@ -46,23 +46,25 @@
$: { $: {
if (!Object.keys($auth.user?.roles).length && $auth.user?.userGroups) { if (!Object.keys($auth.user?.roles).length && $auth.user?.userGroups) {
userApps = $auth.user?.builder?.global userApps =
? publishedApps $auth.user?.builder?.global || $auth.user?.admin?.global
: publishedApps.filter(app => { ? publishedApps
return userGroups.find(group => { : publishedApps.filter(app => {
return Object.keys(group.roles) return userGroups.find(group => {
.map(role => apps.extractAppId(role)) return Object.keys(group.roles)
.includes(app.appId) .map(role => apps.extractAppId(role))
.includes(app.appId)
})
}) })
})
} else { } else {
userApps = $auth.user?.builder?.global userApps =
? publishedApps $auth.user?.builder?.global || $auth.user?.admin?.global
: publishedApps.filter(app => ? publishedApps
Object.keys($auth.user?.roles) : publishedApps.filter(app =>
.map(x => apps.extractAppId(x)) Object.keys($auth.user?.roles)
.includes(app.appId) .map(x => apps.extractAppId(x))
) .includes(app.appId)
)
} }
} }

View File

@ -45,6 +45,7 @@
}, },
]) ])
} }
if (admin) { if (admin) {
menu = menu.concat([ menu = menu.concat([
{ {
@ -52,11 +53,6 @@
href: "/builder/portal/manage/users", href: "/builder/portal/manage/users",
heading: "Manage", heading: "Manage",
}, },
{
title: "User Groups",
href: "/builder/portal/manage/groups",
},
{ title: "Auth", href: "/builder/portal/manage/auth" }, { title: "Auth", href: "/builder/portal/manage/auth" },
{ title: "Email", href: "/builder/portal/manage/email" }, { title: "Email", href: "/builder/portal/manage/email" },
{ {
@ -70,6 +66,15 @@
}, },
]) ])
if (isEnabled(FEATURE_FLAGS.USER_GROUPS)) {
let item = {
title: "User Groups",
href: "/builder/portal/manage/groups",
}
menu.splice(2, 0, item)
}
if (!$adminStore.cloud) { if (!$adminStore.cloud) {
menu = menu.concat([ menu = menu.concat([
{ {

View File

@ -18,23 +18,44 @@
import { users, apps, groups } from "stores/portal" import { users, apps, groups } from "stores/portal"
import { onMount } from "svelte" import { onMount } from "svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
import { roles } from "stores/backend"
export let groupId export let groupId
let popoverAnchor let popoverAnchor
let popover let popover
let searchTerm = "" let searchTerm = ""
let selectedUsers = [] let selectedUsers = []
let prevSearch = undefined, let prevSearch = undefined
search = undefined
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let loaded = false
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchUsers(page, search) $: fetchUsers(page, searchTerm)
$: group = $groups.find(x => x._id === groupId) $: group = $groups.find(x => x._id === groupId)
async function addAll() { async function addAll() {
group.users = selectedUsers selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)]
let reducedUserObjects = filtered.map(u => {
return {
_id: u._id,
email: u.email,
}
})
group.users = [...reducedUserObjects, ...group.users]
await groups.actions.save(group) await groups.actions.save(group)
$users.data.forEach(async user => {
let userToEdit = await users.get(user._id)
let userGroups = userToEdit.userGroups || []
userGroups.push(groupId)
await users.save({
...userToEdit,
userGroups,
})
})
} }
async function selectUser(id) { async function selectUser(id) {
@ -97,106 +118,119 @@
prevSearch = search prevSearch = search
try { try {
pageInfo.loading() pageInfo.loading()
await users.search({ page, search }) await users.search({ page, email: search })
pageInfo.fetched($users.hasNextPage, $users.nextPage) pageInfo.fetched($users.hasNextPage, $users.nextPage)
} catch (error) { } catch (error) {
notifications.error("Error getting user list") notifications.error("Error getting user list")
} }
} }
const getRoleLabel = appId => {
const roleId = group?.roles?.[`app_${appId}`]
const role = $roles.find(x => x._id === roleId)
return role?.name || "Custom role"
}
onMount(async () => { onMount(async () => {
try { try {
await groups.actions.init() await Promise.all([groups.actions.init(), apps.load(), roles.fetch()])
await apps.load() loaded = true
} catch (error) { } catch (error) {
notifications.error("Error fetching User Group data") notifications.error("Error fetching user group data")
} }
}) })
</script> </script>
<Layout noPadding> {#if loaded}
<div> <Layout noPadding>
<ActionButton on:click={() => $goto("../groups")} size="S" icon="ArrowLeft"> <div>
Back <ActionButton
</ActionButton> on:click={() => $goto("../groups")}
</div> size="S"
<div class="header"> icon="ArrowLeft"
<div class="title"> >
<div style="background: {group?.color};" class="circle"> Back
<div> </ActionButton>
<Icon size="M" name={group?.icon} /> </div>
<div class="header">
<div class="title">
<div style="background: {group?.color};" class="circle">
<div>
<Icon size="M" name={group?.icon} />
</div>
</div>
<div class="text-padding">
<Heading>{group?.name}</Heading>
</div> </div>
</div> </div>
<div class="text-padding"> <div bind:this={popoverAnchor}>
<Heading>{group?.name}</Heading> <Button on:click={popover.show()} icon="UserAdd" cta>Add user</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"email"}
title={"User"}
bind:searchTerm
bind:selected={selectedUsers}
bind:filtered
{addAll}
select={selectUser}
/>
</Popover>
</div>
<List>
{#if group?.users.length}
{#each group.users as user}
<ListItem title={user?.email} avatar
><Icon
on:click={() => removeUser(user?._id)}
hoverable
size="L"
name="Close"
/></ListItem
>
{/each}
{:else}
<ListItem icon="UserGroup" title="You have no users in this team" />
{/if}
</List>
<div
style="flex-direction: column; margin-top: var(--spacing-m)"
class="title"
>
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S"
>Manage apps that this User group has been assigned to</Body
>
</div> </div>
</div> </div>
<div bind:this={popoverAnchor}>
<Button on:click={popover.show()} icon="UserAdd" cta>Add User</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"email"}
title={"User"}
bind:searchTerm
bind:selected={selectedUsers}
bind:filtered
{addAll}
select={selectUser}
/>
</Popover>
</div>
<List> <List>
{#if group?.users.length} {#if groupApps.length}
{#each group.users as user} {#each groupApps as app}
<ListItem title={user?.email} avatar <ListItem
><Icon title={app.name}
on:click={() => removeUser(user?._id)} icon={app?.icon?.name || "Apps"}
hoverable iconBackground={app?.icon?.color || ""}
size="L" >
name="Close" <div class="title ">
/></ListItem <StatusLight
> square
{/each} color={RoleUtils.getRoleColour(group.roles[`app_${app.appId}`])}
{:else} >
<ListItem icon="UserGroup" title="You have no users in this team" /> {getRoleLabel(app.appId)}
{/if} </StatusLight>
</List>
<div
style="flex-direction: column; margin-top: var(--spacing-m)"
class="title"
>
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this User group has been assigned to</Body
>
</div>
</div>
<List>
{#if groupApps.length}
{#each groupApps as app}
<ListItem
title={app.name}
icon={app?.icon?.name || "Apps"}
iconBackground={app?.icon?.color || ""}
>
<div class="title ">
<StatusLight
color={RoleUtils.getRoleColour(group.roles[app.appId])}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS">{group.roles[app.appId]}</Body>
</div> </div>
</div> </ListItem>
</ListItem> {/each}
{/each} {:else}
{:else} <ListItem icon="UserGroup" title="No apps" />
<ListItem icon="UserGroup" title="No apps" /> {/if}
{/if} </List>
</List> </Layout>
</Layout> {/if}
<style> <style>
.text-padding { .text-padding {

View File

@ -14,13 +14,9 @@
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte" import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
import UserGroupsRow from "./_components/UserGroupsRow.svelte" import UserGroupsRow from "./_components/UserGroupsRow.svelte"
import { cloneDeep } from "lodash/fp"
$: hasGroupsLicense = $auth.user?.license.features.includes( const DefaultGroup = {
Constants.Features.USER_GROUPS
)
let modal
let group = {
name: "", name: "",
icon: "UserGroup", icon: "UserGroup",
color: "var(--spectrum-global-color-blue-600)", color: "var(--spectrum-global-color-blue-600)",
@ -28,6 +24,12 @@
apps: [], apps: [],
roles: {}, roles: {},
} }
let modal
let group = cloneDeep(DefaultGroup)
$: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS
)
async function deleteGroup(group) { async function deleteGroup(group) {
try { try {
@ -45,6 +47,11 @@
} }
} }
const showCreateGroupModal = () => {
group = cloneDeep(DefaultGroup)
modal?.show()
}
onMount(async () => { onMount(async () => {
try { try {
if (hasGroupsLicense) { if (hasGroupsLicense) {
@ -78,10 +85,11 @@
icon={hasGroupsLicense ? "UserGroup" : ""} icon={hasGroupsLicense ? "UserGroup" : ""}
cta={hasGroupsLicense} cta={hasGroupsLicense}
on:click={hasGroupsLicense on:click={hasGroupsLicense
? () => modal.show() ? showCreateGroupModal
: window.open("https://budibase.com/pricing/", "_blank")} : window.open("https://budibase.com/pricing/", "_blank")}
>{hasGroupsLicense ? "Create user group" : "Upgrade Account"}</Button
> >
{hasGroupsLicense ? "Create user group" : "Upgrade Account"}
</Button>
{#if !hasGroupsLicense} {#if !hasGroupsLicense}
<Button <Button
newStyles newStyles
@ -130,7 +138,7 @@
.groupTable :global(> div) { .groupTable :global(> div) {
background: var(--bg-color); background: var(--bg-color);
height: 70px; height: 55px;
display: grid; display: grid;
align-items: center; align-items: center;
grid-gap: var(--spacing-xl); grid-gap: var(--spacing-xl);

View File

@ -21,9 +21,9 @@
StatusLight, StatusLight,
} from "@budibase/bbui" } from "@budibase/bbui"
import { onMount } from "svelte" import { onMount } from "svelte"
import { fetchData } from "helpers" import { fetchData } from "helpers"
import { users, auth, groups, apps } from "stores/portal" import { users, auth, groups, apps } from "stores/portal"
import { roles } from "stores/backend"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte" import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
@ -40,10 +40,18 @@
let selectedGroups = [] let selectedGroups = []
let allAppList = [] let allAppList = []
let user let user
let loaded = false
$: fetchUser(userId) $: fetchUser(userId)
$: fullName = $userFetch?.data?.firstName
? $userFetch?.data?.firstName + " " + $userFetch?.data?.lastName
: ""
$: hasGroupsLicense = $auth.user?.license.features.includes( $: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS Constants.Features.USER_GROUPS
) )
$: nameLabel = getNameLabel($userFetch)
$: initials = getInitials(nameLabel)
$: allAppList = $apps $: allAppList = $apps
.filter(x => { .filter(x => {
@ -86,6 +94,39 @@
const userFetch = fetchData(`/api/global/users/${userId}`) const userFetch = fetchData(`/api/global/users/${userId}`)
const getNameLabel = userFetch => {
const { firstName, lastName, email } = userFetch?.data || {}
if (!firstName && !lastName) {
return email || ""
}
let label
if (firstName) {
label = firstName
if (lastName) {
label += ` ${lastName}`
}
} else {
label = lastName
}
return label
}
const getInitials = nameLabel => {
if (!nameLabel) {
return "?"
}
return nameLabel
.split(" ")
.slice(0, 2)
.map(x => x[0])
.join("")
}
const getRoleLabel = roleId => {
const role = $roles.find(x => x._id === roleId)
return role?.name || "Custom role"
}
function getHighestRole(roles) { function getHighestRole(roles) {
let highestRole let highestRole
let highestRoleNumber = 0 let highestRoleNumber = 0
@ -127,7 +168,7 @@
if (detail === "developer") { if (detail === "developer") {
toggleFlags({ admin: { global: false }, builder: { global: true } }) toggleFlags({ admin: { global: false }, builder: { global: true } })
} else if (detail === "admin") { } else if (detail === "admin") {
toggleFlags({ admin: { global: true }, builder: { global: false } }) toggleFlags({ admin: { global: true }, builder: { global: true } })
} else if (detail === "appUser") { } else if (detail === "appUser") {
toggleFlags({ admin: { global: false }, builder: { global: false } }) toggleFlags({ admin: { global: false }, builder: { global: false } })
} }
@ -166,166 +207,168 @@
function addAll() {} function addAll() {}
onMount(async () => { onMount(async () => {
try { try {
await groups.actions.init() await Promise.all([groups.actions.init(), apps.load(), roles.fetch()])
await apps.load() loaded = true
} catch (error) { } catch (error) {
notifications.error("Error getting User groups") notifications.error("Error getting user groups")
} }
}) })
</script> </script>
<Layout gap="L" noPadding> {#if loaded}
<Layout gap="XS" noPadding> <Layout gap="L" noPadding>
<div> <Layout gap="XS" noPadding>
<ActionButton on:click={() => $goto("./")} size="S" icon="ArrowLeft">
Back
</ActionButton>
</div>
</Layout>
<Layout gap="XS" noPadding>
<div class="title">
<div> <div>
<div style="display: flex;"> <ActionButton on:click={() => $goto("./")} size="S" icon="ArrowLeft">
<Avatar size="XXL" initials="PC" /> Back
<div class="subtitle"> </ActionButton>
<Heading size="S" </div>
>{$userFetch?.data?.firstName + </Layout>
" " + <Layout gap="XS" noPadding>
$userFetch?.data?.lastName}</Heading <div class="title">
> <div>
<Body size="XS">{$userFetch?.data?.email}</Body> <div style="display: flex;">
<Avatar size="XXL" {initials} />
<div class="subtitle">
<Heading size="S">{nameLabel}</Heading>
{#if nameLabel !== $userFetch?.data?.email}
<Body size="XS">{$userFetch?.data?.email}</Body>
{/if}
</div>
</div> </div>
</div> </div>
</div>
<div>
<ActionMenu align="right">
<span slot="control">
<Icon hoverable name="More" />
</span>
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
>Force Password Reset</MenuItem
>
<MenuItem on:click={deleteModal.show} icon="Delete">Delete</MenuItem>
</ActionMenu>
</div>
</div>
</Layout>
<Layout gap="S" noPadding>
<div class="fields">
<div class="field">
<Label size="L">First name</Label>
<Input
thin
value={$userFetch?.data?.firstName}
on:blur={updateUserFirstName}
/>
</div>
<div class="field">
<Label size="L">Last name</Label>
<Input
thin
value={$userFetch?.data?.lastName}
on:blur={updateUserLastName}
/>
</div>
<!-- don't let a user remove the privileges that let them be here -->
{#if userId !== $auth.user._id}
<div class="field">
<Label size="L">Role</Label>
<Select
value={globalRole}
options={Constants.BbRoles}
on:change={updateUserRole}
/>
</div>
{/if}
</div>
</Layout>
{#if hasGroupsLicense}
<!-- User groups -->
<Layout gap="XS" noPadding>
<div class="tableTitle">
<div> <div>
<Heading size="XS">User groups</Heading> <ActionMenu align="right">
<Body size="S">Add or remove this user from user groups</Body> <span slot="control">
<Icon hoverable name="More" />
</span>
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
>Force Password Reset</MenuItem
>
<MenuItem on:click={deleteModal.show} icon="Delete">Delete</MenuItem
>
</ActionMenu>
</div> </div>
<div bind:this={popoverAnchor}> </div>
<Button on:click={popover.show()} icon="UserGroup" cta </Layout>
>Add User Group</Button <Layout gap="S" noPadding>
> <div class="fields">
</div> <div class="field">
<Popover align="right" bind:this={popover} anchor={popoverAnchor}> <Label size="L">First name</Label>
<UserGroupPicker <Input
key={"name"} thin
title={"Group"} value={$userFetch?.data?.firstName}
bind:searchTerm on:blur={updateUserFirstName}
bind:selected={selectedGroups}
bind:filtered={filteredGroups}
{addAll}
select={addGroup}
/> />
</Popover> </div>
<div class="field">
<Label size="L">Last name</Label>
<Input
thin
value={$userFetch?.data?.lastName}
on:blur={updateUserLastName}
/>
</div>
<!-- don't let a user remove the privileges that let them be here -->
{#if userId !== $auth.user._id}
<div class="field">
<Label size="L">Role</Label>
<Select
value={globalRole}
options={Constants.BbRoles}
on:change={updateUserRole}
/>
</div>
{/if}
</div>
</Layout>
{#if hasGroupsLicense}
<!-- User groups -->
<Layout gap="XS" noPadding>
<div class="tableTitle">
<div>
<Heading size="XS">User groups</Heading>
<Body size="S">Add or remove this user from user groups</Body>
</div>
<div bind:this={popoverAnchor}>
<Button on:click={popover.show()} icon="UserGroup" cta>
Add user group
</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"name"}
title={"Group"}
bind:searchTerm
bind:selected={selectedGroups}
bind:filtered={filteredGroups}
{addAll}
select={addGroup}
/>
</Popover>
</div>
<List>
{#if userGroups.length}
{#each userGroups as group}
<ListItem
title={group.name}
icon={group.icon}
iconBackground={group.color}
><Icon
on:click={removeGroup(group._id)}
hoverable
size="L"
name="Close"
/></ListItem
>
{/each}
{:else}
<ListItem icon="UserGroup" title="No groups" />
{/if}
</List>
</Layout>
{/if}
<!-- User Apps -->
<Layout gap="S" noPadding>
<div class="appsTitle">
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this user has been assigned to</Body>
</div>
</div> </div>
<List> <List>
{#if userGroups.length} {#if allAppList.length}
{#each userGroups as group} {#each allAppList as app}
<ListItem <div
title={group.name} class="pointer"
icon={group.icon} on:click={$goto(`../../overview/${app.devId}`)}
iconBackground={group.color}
><Icon
on:click={removeGroup(group._id)}
hoverable
size="L"
name="Close"
/></ListItem
> >
<ListItem
title={app.name}
iconBackground={app?.icon?.color || ""}
icon={app?.icon?.name || "Apps"}
>
<div class="title ">
<StatusLight
square
color={RoleUtils.getRoleColour(getHighestRole(app.roles))}
>
{getRoleLabel(getHighestRole(app.roles))}
</StatusLight>
</div>
</ListItem>
</div>
{/each} {/each}
{:else} {:else}
<ListItem icon="UserGroup" title="No groups" /> <ListItem icon="Apps" title="No apps" />
{/if} {/if}
</List> </List>
</Layout> </Layout>
{/if}
<!-- User Apps -->
<Layout gap="S" noPadding>
<div class="appsTitle">
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this user has been assigned to</Body>
</div>
</div>
<List>
{#if allAppList.length}
{#each allAppList as app}
<div class="pointer" on:click={$goto(`../../overview/${app.devId}`)}>
<ListItem
title={app.name}
iconBackground={app?.icon?.color || ""}
icon={app?.icon?.name || "Apps"}
>
<div class="title ">
<StatusLight
color={RoleUtils.getRoleColour(getHighestRole(app.roles))}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS"
>{Constants.Roles[getHighestRole(app.roles)]}</Body
>
</div>
</div>
</ListItem>
</div>
{/each}
{:else}
<ListItem icon="Apps" title="No apps" />
{/if}
</List>
</Layout> </Layout>
</Layout> {/if}
<Modal bind:this={deleteModal}> <Modal bind:this={deleteModal}>
<DeleteUserModal user={$userFetch.data} /> <DeleteUserModal user={$userFetch.data} />
@ -365,7 +408,10 @@
.subtitle { .subtitle {
padding: 0 0 0 var(--spacing-m); padding: 0 0 0 var(--spacing-m);
display: inline-block; display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
} }
.appsTitle { .appsTitle {

View File

@ -6,15 +6,17 @@
Multiselect, Multiselect,
InputDropdown, InputDropdown,
Layout, Layout,
Icon,
} from "@budibase/bbui" } from "@budibase/bbui"
import { groups, auth } from "stores/portal" import { groups, auth } from "stores/portal"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import { emailValidator } from "helpers/validation"
export let showOnboardingTypeModal export let showOnboardingTypeModal
const password = Math.random().toString(36).substring(2, 22) const password = Math.random().toString(36).substring(2, 22)
let disabled let disabled
let userGroups = [] let userGroups = []
$: errors = []
$: hasGroupsLicense = $auth.user?.license.features.includes( $: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS Constants.Features.USER_GROUPS
) )
@ -27,6 +29,10 @@
forceResetPassword: true, forceResetPassword: true,
}, },
] ]
function removeInput(idx) {
userData = userData.filter((e, i) => i !== idx)
}
function addNewInput() { function addNewInput() {
userData = [ userData = [
...userData, ...userData,
@ -38,6 +44,18 @@
}, },
] ]
} }
function validateInput(email, index) {
if (email) {
if (emailValidator(email) === true) {
errors[index] = true
return null
} else {
errors[index] = false
return emailValidator(email)
}
}
}
</script> </script>
<ModalContent <ModalContent
@ -49,18 +67,40 @@
confirmDisabled={disabled} confirmDisabled={disabled}
cancelText="Cancel" cancelText="Cancel"
showCloseIcon={false} showCloseIcon={false}
disabled={errors.some(x => x === false) ||
userData.some(x => x.email === "" || x.email === null)}
> >
<Layout noPadding gap="XS"> <Layout noPadding gap="XS">
<Label>Email Address</Label> <Label>Email Address</Label>
{#each userData as input, index} {#each userData as input, index}
<InputDropdown <div
inputType="email" style="display: flex;
bind:inputValue={input.email} align-items: center;
bind:dropdownValue={input.role} flex-direction: row;"
options={Constants.BbRoles} >
error={input.error} <div style="width: 90%">
/> <InputDropdown
inputType="email"
bind:inputValue={input.email}
bind:dropdownValue={input.role}
options={Constants.BbRoles}
error={validateInput(input.email, index)}
/>
</div>
<div
class:fix-height={errors.length && !errors[index]}
class:normal-height={errors.length && !!errors[index]}
style="width: 10% "
>
<Icon
name="Close"
hoverable
size="S"
on:click={() => removeInput(index)}
/>
</div>
</div>
{/each} {/each}
<div> <div>
<ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton> <ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton>
@ -80,7 +120,10 @@
</ModalContent> </ModalContent>
<style> <style>
:global(.spectrum-Picker) { .fix-height {
border-top-left-radius: 0px; margin-bottom: 5%;
}
.normal-height {
margin-bottom: 0%;
} }
</style> </style>

View File

@ -108,10 +108,6 @@
</ModalContent> </ModalContent>
<style> <style>
:global(.spectrum-Picker) {
border-top-left-radius: 0px;
}
.dropzone { .dropzone {
text-align: center; text-align: center;
display: flex; display: flex;

View File

@ -17,7 +17,7 @@
</div> </div>
{value} {value}
{:else} {:else}
<div class="text">Not Available</div> <div class="text">-</div>
{/if} {/if}
</div> </div>

View File

@ -79,10 +79,6 @@
display: flex; display: flex;
} }
:global(.spectrum-Picker) {
border-top-left-radius: 0px;
}
.container { .container {
width: 100%; width: 100%;
height: var(--spectrum-alias-item-height-l); height: var(--spectrum-alias-item-height-l);

View File

@ -72,19 +72,12 @@
name: {}, name: {},
email: {}, email: {},
role: { role: {
noPropagation: true,
sortable: false, sortable: false,
}, },
...(hasGroupsLicense && { ...(hasGroupsLicense && {
userGroups: { sortable: false, displayName: "User groups" }, userGroups: { sortable: false, displayName: "User groups" },
}), }),
apps: { width: "120px" }, apps: {},
settings: {
sortable: false,
width: "60px",
displayName: "",
align: "Right",
},
} }
$: userData = [] $: userData = []
@ -256,10 +249,10 @@
dataCy="add-user" dataCy="add-user"
on:click={createUserModal.show} on:click={createUserModal.show}
icon="UserAdd" icon="UserAdd"
cta>Add Users</Button cta>Add users</Button
> >
<Button on:click={importUsersModal.show} icon="Import" primary <Button on:click={importUsersModal.show} icon="Import" primary
>Import Users</Button >Import users</Button
> >
<div class="field"> <div class="field">
@ -323,6 +316,13 @@
</Modal> </Modal>
<style> <style>
.pagination {
display: flex;
flex-direction: row;
justify-content: flex-end;
margin-top: var(--spacing-xl);
}
.field { .field {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -66,7 +66,7 @@
selectedApp?.status === AppStatus.DEPLOYED && latestDeployments?.length > 0 selectedApp?.status === AppStatus.DEPLOYED && latestDeployments?.length > 0
$: appUrl = `${window.origin}/app${selectedApp?.url}` $: appUrl = `${window.origin}/app${selectedApp?.url}`
$: tabs = ["Overview", "Automation History", "Backups", "Settings"] $: tabs = ["Overview", "Automation History", "Backups", "Settings", "Access"]
$: selectedTab = "Overview" $: selectedTab = "Overview"
const backToAppList = () => { const backToAppList = () => {

View File

@ -29,7 +29,6 @@
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let fixedAppId let fixedAppId
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchUsers(page, search)
$: hasGroupsLicense = $auth.user?.license.features.includes( $: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS Constants.Features.USER_GROUPS
@ -37,12 +36,6 @@
$: fixedAppId = apps.getProdAppID(app.devId) $: fixedAppId = apps.getProdAppID(app.devId)
$: appUsers =
$users.data?.filter(x => {
return Object.keys(x.roles).find(y => {
return y === fixedAppId
})
}) || []
$: appGroups = $groups.filter(x => { $: appGroups = $groups.filter(x => {
return x.apps.includes(app.appId) return x.apps.includes(app.appId)
}) })
@ -130,6 +123,12 @@
pageInfo.loading() pageInfo.loading()
await users.search({ page, appId: fixedAppId }) await users.search({ page, appId: fixedAppId })
pageInfo.fetched($users.hasNextPage, $users.nextPage) pageInfo.fetched($users.hasNextPage, $users.nextPage)
appUsers =
$users.data?.filter(x => {
return Object.keys(x.roles).find(y => {
return y === fixedAppId
})
}) || []
} catch (error) { } catch (error) {
notifications.error("Error getting user list") notifications.error("Error getting user list")
} }
@ -137,6 +136,8 @@
onMount(async () => { onMount(async () => {
try { try {
await fetchUsers(page, search)
await groups.actions.init() await groups.actions.init()
await apps.load() await apps.load()
await roles.fetch() await roles.fetch()
@ -212,8 +213,14 @@
page={$pageInfo.pageNumber} page={$pageInfo.pageNumber}
hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage} hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage}
hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage} hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage}
goToPrevPage={pageInfo.prevPage} goToPrevPage={async () => {
goToNextPage={pageInfo.nextPage} await pageInfo.prevPage()
fetchUsers(page, search)
}}
goToNextPage={async () => {
await pageInfo.nextPage()
fetchUsers(page, search)
}}
/> />
</div> </div>
{/if} {/if}
@ -264,4 +271,11 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.pagination {
display: flex;
flex-direction: row;
justify-content: flex-end;
margin-top: var(--spacing-xl);
}
</style> </style>

View File

@ -3,6 +3,7 @@
ModalContent, ModalContent,
PickerDropdown, PickerDropdown,
ActionButton, ActionButton,
Layout,
notifications, notifications,
} from "@budibase/bbui" } from "@budibase/bbui"
import { roles } from "stores/backend" import { roles } from "stores/backend"
@ -13,7 +14,6 @@
export let app export let app
export let addData export let addData
export let appUsers = [] export let appUsers = []
let prevSearch = undefined, let prevSearch = undefined,
search = undefined search = undefined
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
@ -32,16 +32,16 @@
prevSearch = search prevSearch = search
try { try {
pageInfo.loading() pageInfo.loading()
await users.search({ page, search }) await users.search({ page, email: search })
pageInfo.fetched($users.hasNextPage, $users.nextPage) pageInfo.fetched($users.hasNextPage, $users.nextPage)
} catch (error) { } catch (error) {
notifications.error("Error getting user list") notifications.error("Error getting user list")
} }
} }
$: filteredGroups = $groups.filter(element => { $: filteredGroups = $groups.filter(group => {
return !element.apps.find(y => { return !group.apps.find(appId => {
return y.appId === app.appId return appId === app.appId
}) })
}) })
@ -79,24 +79,26 @@
onConfirm={() => addData(appData)} onConfirm={() => addData(appData)}
showCloseIcon={false} showCloseIcon={false}
> >
{#each appData as input, index} <Layout noPadding gap="XS">
<PickerDropdown {#each appData as input, index}
autocomplete <PickerDropdown
primaryOptions={optionSections} autocomplete
placeholder={"Search Users"} primaryOptions={optionSections}
secondaryOptions={$roles} secondaryOptions={$roles}
bind:primaryValue={input.id} secondaryPlaceholder="Access"
bind:secondaryValue={input.role} bind:primaryValue={input.id}
getPrimaryOptionLabel={group => group.name} bind:secondaryValue={input.role}
getPrimaryOptionValue={group => group.name} bind:searchTerm={search}
getPrimaryOptionIcon={group => group.icon} getPrimaryOptionLabel={group => group.name}
getPrimaryOptionColour={group => group.colour} getPrimaryOptionValue={group => group.name}
getSecondaryOptionLabel={role => role.name} getPrimaryOptionIcon={group => group.icon}
getSecondaryOptionValue={role => role._id} getPrimaryOptionColour={group => group.colour}
getSecondaryOptionColour={role => RoleUtils.getRoleColour(role._id)} getSecondaryOptionLabel={role => role.name}
/> getSecondaryOptionValue={role => role._id}
{/each} getSecondaryOptionColour={role => RoleUtils.getRoleColour(role._id)}
/>
{/each}
</Layout>
<div> <div>
<ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton> <ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton>
</div> </div>

View File

@ -5,13 +5,13 @@
import { store } from "builderStore" import { store } from "builderStore"
import clientPackage from "@budibase/client/package.json" import clientPackage from "@budibase/client/package.json"
import { processStringSync } from "@budibase/string-templates" import { processStringSync } from "@budibase/string-templates"
import { users, auth } from "stores/portal" import { users, auth, apps } from "stores/portal"
import { createEventDispatcher, onMount } from "svelte" import { createEventDispatcher, onMount } from "svelte"
export let app export let app
export let deployments export let deployments
export let navigateTab export let navigateTab
let userCount
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const unpublishApp = () => { const unpublishApp = () => {
@ -40,7 +40,11 @@
} }
onMount(async () => { onMount(async () => {
await users.search({ page: undefined, appId: "app_" + app.appId }) let resp = await users.getUserCountByApp({
appId: apps.getProdAppID(app.devId),
})
userCount = resp.userCount
await users.search({ appId: apps.getProdAppID(app.devId), limit: 4 })
}) })
</script> </script>
@ -155,7 +159,8 @@
</div> </div>
<div class="users-text"> <div class="users-text">
{$users?.data.length} users have access to this app {userCount}
{userCount > 1 ? `users have` : `user has`} access to this app
</div> </div>
</Layout> </Layout>
{:else} {:else}

View File

@ -61,6 +61,7 @@ export function createUsersStore() {
break break
case "admin": case "admin":
body.admin = { global: true } body.admin = { global: true }
body.builder = { global: true }
break break
} }
@ -77,6 +78,10 @@ export function createUsersStore() {
update(users => users.filter(user => user._id !== id)) update(users => users.filter(user => user._id !== id))
} }
async function getUserCountByApp({ appId }) {
return await API.getUserCountByApp({ appId })
}
async function bulkDelete(userIds) { async function bulkDelete(userIds) {
await API.deleteUsers(userIds) await API.deleteUsers(userIds)
} }
@ -99,6 +104,7 @@ export function createUsersStore() {
create, create,
save, save,
bulkDelete, bulkDelete,
getUserCountByApp,
delete: del, delete: del,
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/cli", "name": "@budibase/cli",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"description": "Budibase CLI, for developers, self hosting and migrations.", "description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js", "main": "src/index.js",
"bin": { "bin": {
@ -26,7 +26,7 @@
"outputPath": "build" "outputPath": "build"
}, },
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.1.29-alpha.2", "@budibase/backend-core": "1.1.32-alpha.6",
"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": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"license": "MPL-2.0", "license": "MPL-2.0",
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"main": "dist/budibase-client.js", "main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw" "dev:builder": "rollup -cw"
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^1.1.29-alpha.2", "@budibase/bbui": "1.1.33-alpha.1",
"@budibase/frontend-core": "^1.1.29-alpha.2", "@budibase/frontend-core": "1.1.33-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.2", "@budibase/string-templates": "1.1.33-alpha.1",
"@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

@ -72,6 +72,7 @@
// Sanity limit of 100 active indicators // Sanity limit of 100 active indicators
const children = Array.from(parents) const children = Array.from(parents)
.map(parent => parent?.children?.[0]) .map(parent => parent?.children?.[0])
.filter(x => x != null)
.slice(0, 100) .slice(0, 100)
// If there aren't any nodes then reset // If there aren't any nodes then reset

View File

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

View File

@ -172,4 +172,15 @@ export const buildUserEndpoints = API => ({
}, },
}) })
}, },
/**
* Accepts an invite to join the platform and creates a user.
* @param inviteCode the invite code sent in the email
* @param password the password for the newly created user
*/
getUserCountByApp: async ({ appId }) => {
return await API.get({
url: `/api/global/users/count/${appId}`,
})
},
}) })

View File

@ -1,6 +1,8 @@
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { OperatorOptions, SqlNumberTypeRangeMap } from "../constants" import { OperatorOptions, SqlNumberTypeRangeMap } from "../constants"
const HBS_REGEX = /{{([^{].*?)}}/g
/** /**
* Returns the valid operator options for a certain data type * Returns the valid operator options for a certain data type
* @param type the data type * @param type the data type
@ -98,6 +100,8 @@ export const buildLuceneQuery = filter => {
if (Array.isArray(filter)) { if (Array.isArray(filter)) {
filter.forEach(expression => { filter.forEach(expression => {
let { operator, field, type, value, externalType } = expression let { operator, field, type, value, externalType } = expression
const isHbs =
typeof value === "string" && value.match(HBS_REGEX)?.length > 0
// Parse all values into correct types // Parse all values into correct types
if (type === "datetime") { if (type === "datetime") {
// Ensure date value is a valid date and parse into correct format // Ensure date value is a valid date and parse into correct format
@ -113,7 +117,7 @@ export const buildLuceneQuery = filter => {
if (type === "number" && !Array.isArray(value)) { if (type === "number" && !Array.isArray(value)) {
if (operator === "oneOf") { if (operator === "oneOf") {
value = value.split(",").map(item => parseFloat(item)) value = value.split(",").map(item => parseFloat(item))
} else { } else if (!isHbs) {
value = parseFloat(value) value = parseFloat(value)
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/server", "name": "@budibase/server",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"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.1.29-alpha.2", "@budibase/backend-core": "1.1.33-alpha.1",
"@budibase/client": "^1.1.29-alpha.2", "@budibase/client": "1.1.33-alpha.1",
"@budibase/pro": "1.1.29-alpha.2", "@budibase/pro": "1.1.33-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.2", "@budibase/string-templates": "1.1.33-alpha.1",
"@budibase/types": "^1.1.29-alpha.2", "@budibase/types": "1.1.33-alpha.1",
"@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

@ -5,7 +5,11 @@ import {
getDevelopmentAppID, getDevelopmentAppID,
} from "@budibase/backend-core/db" } from "@budibase/backend-core/db"
import { DocumentTypes, getAutomationParams } from "../../../db/utils" import { DocumentTypes, getAutomationParams } from "../../../db/utils"
import { disableAllCrons, enableCronTrigger } from "../../../automations/utils" import {
disableAllCrons,
enableCronTrigger,
clearMetadata,
} from "../../../automations/utils"
import { app as appCache } from "@budibase/backend-core/cache" import { app as appCache } from "@budibase/backend-core/cache"
import { import {
getAppId, getAppId,
@ -80,6 +84,7 @@ async function initDeployedApp(prodAppId: any) {
}) })
) )
).rows.map((row: any) => row.doc) ).rows.map((row: any) => row.doc)
await clearMetadata()
console.log("You have " + automations.length + " automations") console.log("You have " + automations.length + " automations")
const promises = [] const promises = []
console.log("Disabling prod crons..") console.log("Disabling prod crons..")

View File

@ -22,7 +22,7 @@ exports.queryValidation = () => {
schema: Joi.object({}).required().unknown(true), schema: Joi.object({}).required().unknown(true),
transformer: OPTIONAL_STRING, transformer: OPTIONAL_STRING,
flags: Joi.object().optional(), flags: Joi.object().optional(),
}) }).unknown(true)
} }
exports.generateQueryValidation = () => { exports.generateQueryValidation = () => {
@ -46,5 +46,5 @@ exports.generateQueryPreviewValidation = () => {
transformer: OPTIONAL_STRING, transformer: OPTIONAL_STRING,
parameters: Joi.object({}).required().unknown(true), parameters: Joi.object({}).required().unknown(true),
queryId: OPTIONAL_STRING, queryId: OPTIONAL_STRING,
})) }).unknown(true))
} }

View File

@ -82,6 +82,27 @@ async function getTable(appId, tableId) {
return ctx.body return ctx.body
} }
function typeCoercion(filters, table) {
if (!filters || !table) {
return filters
}
for (let key of Object.keys(filters)) {
if (typeof filters[key] === "object") {
for (let [property, value] of Object.entries(filters[key])) {
const column = table.schema[property]
// convert string inputs
if (!column || typeof value !== "string") {
continue
}
if (column.type === FieldTypes.NUMBER) {
filters[key][property] = parseFloat(value)
}
}
}
}
return filters
}
exports.run = async function ({ inputs, appId }) { exports.run = async function ({ inputs, appId }) {
const { tableId, filters, sortColumn, sortOrder, limit } = inputs const { tableId, filters, sortColumn, sortOrder, limit } = inputs
const table = await getTable(appId, tableId) const table = await getTable(appId, tableId)
@ -99,7 +120,7 @@ exports.run = async function ({ inputs, appId }) {
sortType, sortType,
limit, limit,
sort: sortColumn, sort: sortColumn,
query: filters || {}, query: typeCoercion(filters || {}, table),
// default to ascending, like data tab // default to ascending, like data tab
sortOrder: sortOrder || SortOrders.ASCENDING, sortOrder: sortOrder || SortOrders.ASCENDING,
}, },

View File

@ -31,15 +31,21 @@ exports.definition = {
type: "boolean", type: "boolean",
description: "Whether the action was successful", description: "Whether the action was successful",
}, },
message: {
type: "string",
description: "What was output",
},
}, },
required: ["success"], required: ["success", "message"],
}, },
}, },
} }
exports.run = async function ({ inputs, appId }) { exports.run = async function ({ inputs, appId }) {
console.log(`App ${appId} - ${inputs.text}`) const message = `App ${appId} - ${inputs.text}`
console.log(message)
return { return {
success: true, success: true,
message,
} }
} }

View File

@ -31,7 +31,7 @@ describe("Run through some parts of the automations system", () => {
it("should be able to init in builder", async () => { it("should be able to init in builder", async () => {
await triggers.externalTrigger(basicAutomation(), { a: 1 }) await triggers.externalTrigger(basicAutomation(), { a: 1 })
await wait(100) await wait(100)
expect(thread).toHaveBeenCalled() expect(thread.execute).toHaveBeenCalled()
}) })
it("should be able to init in prod", async () => { it("should be able to init in prod", async () => {
@ -52,7 +52,7 @@ describe("Run through some parts of the automations system", () => {
} }
}) })
await wait(100) await wait(100)
expect(thread).toHaveBeenCalledWith(makePartial({ expect(thread.execute).toHaveBeenCalledWith(makePartial({
data: { data: {
event: { event: {
fields: { fields: {

View File

@ -6,10 +6,16 @@ import newid from "../db/newid"
import { updateEntityMetadata } from "../utilities" import { updateEntityMetadata } from "../utilities"
import { MetadataTypes, WebhookType } from "../constants" import { MetadataTypes, WebhookType } from "../constants"
import { getProdAppID, doWithDB } from "@budibase/backend-core/db" import { getProdAppID, doWithDB } from "@budibase/backend-core/db"
import { getAutomationMetadataParams } from "../db/utils"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { getAppDB, getAppId } from "@budibase/backend-core/context" import {
getAppDB,
getAppId,
getProdAppDB,
} from "@budibase/backend-core/context"
import { tenancy } from "@budibase/backend-core" import { tenancy } from "@budibase/backend-core"
import { quotas } from "@budibase/pro" import { quotas } from "@budibase/pro"
import { Automation } from "@budibase/types"
const WH_STEP_ID = definitions.WEBHOOK.stepId const WH_STEP_ID = definitions.WEBHOOK.stepId
const CRON_STEP_ID = definitions.CRON.stepId const CRON_STEP_ID = definitions.CRON.stepId
@ -82,6 +88,26 @@ export async function disableAllCrons(appId: any) {
return Promise.all(promises) return Promise.all(promises)
} }
export async function disableCron(jobId: string, jobKey: string) {
await queue.removeRepeatableByKey(jobKey)
await queue.removeJobs(jobId)
}
export async function clearMetadata() {
const db = getProdAppDB()
const automationMetadata = (
await db.allDocs(
getAutomationMetadataParams({
include_docs: true,
})
)
).rows.map((row: any) => row.doc)
for (let metadata of automationMetadata) {
metadata._deleted = true
}
await db.bulkDocs(automationMetadata)
}
/** /**
* This function handles checking of any cron jobs that need to be enabled/updated. * This function handles checking of any cron jobs that need to be enabled/updated.
* @param {string} appId The ID of the app in which we are checking for webhooks * @param {string} appId The ID of the app in which we are checking for webhooks
@ -204,3 +230,30 @@ export async function checkForWebhooks({ oldAuto, newAuto }: any) {
export async function cleanupAutomations(appId: any) { export async function cleanupAutomations(appId: any) {
await disableAllCrons(appId) await disableAllCrons(appId)
} }
/**
* Checks if the supplied automation is of a recurring type.
* @param automation The automation to check.
* @return {boolean} if it is recurring (cron).
*/
export function isRecurring(automation: Automation) {
return automation.definition.trigger.stepId === definitions.CRON.stepId
}
export function isErrorInOutput(output: {
steps: { outputs?: { success: boolean } }[]
}) {
let first = true,
error = false
for (let step of output.steps) {
// skip the trigger, its always successful if automation ran
if (first) {
first = false
continue
}
if (!step.outputs?.success) {
error = true
}
}
return error
}

View File

@ -208,10 +208,7 @@ exports.AutomationErrors = {
FAILURE_CONDITION: "FAILURE_CONDITION_MET", FAILURE_CONDITION: "FAILURE_CONDITION_MET",
} }
exports.LoopStepTypes = {
ARRAY: "Array",
STRING: "String",
}
// pass through the list from the auth/core lib // pass through the list from the auth/core lib
exports.ObjectStoreBuckets = ObjectStoreBuckets exports.ObjectStoreBuckets = ObjectStoreBuckets
exports.MAX_AUTOMATION_RECURRING_ERRORS = 5

View File

@ -41,6 +41,7 @@ const DocumentTypes = {
METADATA: "metadata", METADATA: "metadata",
MEM_VIEW: "view", MEM_VIEW: "view",
USER_FLAG: "flag", USER_FLAG: "flag",
AUTOMATION_METADATA: "meta_au",
} }
const InternalTables = { const InternalTables = {
@ -311,6 +312,21 @@ exports.generateQueryID = datasourceId => {
}${SEPARATOR}${datasourceId}${SEPARATOR}${newid()}` }${SEPARATOR}${datasourceId}${SEPARATOR}${newid()}`
} }
/**
* Generates a metadata ID for automations, used to track errors in recurring
* automations etc.
*/
exports.generateAutomationMetadataID = automationId => {
return `${DocumentTypes.AUTOMATION_METADATA}${SEPARATOR}${automationId}`
}
/**
* Retrieve all automation metadata in an app database.
*/
exports.getAutomationMetadataParams = (otherProps = {}) => {
return getDocParams(DocumentTypes.AUTOMATION_METADATA, null, otherProps)
}
/** /**
* Gets parameters for retrieving a query, this is a utility function for the getDocParams function. * Gets parameters for retrieving a query, this is a utility function for the getDocParams function.
*/ */

View File

@ -0,0 +1,49 @@
import {
Automation,
AutomationResults,
AutomationStep,
Document,
} from "@budibase/types"
export enum LoopStepTypes {
ARRAY = "Array",
STRING = "String",
}
export interface LoopStep extends AutomationStep {
inputs: {
option: LoopStepTypes
[key: string]: any
}
}
export interface LoopInput {
binding: string[] | string
}
export interface TriggerOutput {
metadata?: any
appId?: string
timestamp?: number
}
export interface AutomationEvent {
data: {
automation: Automation
event: any
}
opts?: {
repeat?: {
jobId: string
}
}
}
export interface AutomationContext extends AutomationResults {
steps: any[]
trigger: any
}
export interface AutomationMetadata extends Document {
errorCount?: number
}

View File

@ -1,36 +1,47 @@
require("./utils").threadSetup() import { default as threadUtils } from "./utils"
const actions = require("../automations/actions") threadUtils.threadSetup()
const automationUtils = require("../automations/automationUtils") import { isRecurring, disableCron, isErrorInOutput } from "../automations/utils"
const AutomationEmitter = require("../events/AutomationEmitter") import { default as actions } from "../automations/actions"
const { processObject } = require("@budibase/string-templates") import { default as automationUtils } from "../automations/automationUtils"
const { DocumentTypes } = require("../db/utils") import { default as AutomationEmitter } from "../events/AutomationEmitter"
const { definitions: triggerDefs } = require("../automations/triggerInfo") import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
import { definitions as triggerDefs } from "../automations/triggerInfo"
import { AutomationErrors, MAX_AUTOMATION_RECURRING_ERRORS } from "../constants"
import { storeLog } from "../automations/logging"
import { Automation, AutomationStep, AutomationStatus } from "@budibase/types"
import {
LoopStep,
LoopStepTypes,
LoopInput,
AutomationEvent,
TriggerOutput,
AutomationContext,
AutomationMetadata,
} from "../definitions/automations"
import { WorkerCallback } from "./definitions"
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context") const { doInAppContext, getAppDB } = require("@budibase/backend-core/context")
const { AutomationErrors, LoopStepTypes } = require("../constants") const { logAlertWithInfo, logWarn } = require("@budibase/backend-core/logging")
const { storeLog } = require("../automations/logging") const { processObject } = require("@budibase/string-templates")
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
const CRON_STEP_ID = triggerDefs.CRON.stepId const CRON_STEP_ID = triggerDefs.CRON.stepId
const STOPPED_STATUS = { success: true, status: "STOPPED" } const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
const { cloneDeep } = require("lodash/fp") const { cloneDeep } = require("lodash/fp")
const env = require("../environment") const env = require("../environment")
function typecastForLooping(loopStep, input) { function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
if (!input || !input.binding) { if (!input || !input.binding) {
return null return null
} }
const isArray = Array.isArray(input.binding),
isString = typeof input.binding === "string"
try { try {
switch (loopStep.inputs.option) { switch (loopStep.inputs.option) {
case LoopStepTypes.ARRAY: case LoopStepTypes.ARRAY:
if (isString) { if (typeof input.binding === "string") {
return JSON.parse(input.binding) return JSON.parse(input.binding)
} }
break break
case LoopStepTypes.STRING: case LoopStepTypes.STRING:
if (isArray) { if (Array.isArray(input.binding)) {
return input.binding.join(",") return input.binding.join(",")
} }
break break
@ -41,7 +52,7 @@ function typecastForLooping(loopStep, input) {
return input.binding return input.binding
} }
function getLoopIterations(loopStep, input) { function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
const binding = typecastForLooping(loopStep, input) const binding = typecastForLooping(loopStep, input)
if (!loopStep || !binding) { if (!loopStep || !binding) {
return 1 return 1
@ -57,11 +68,24 @@ function getLoopIterations(loopStep, input) {
* inputs and handles any outputs. * inputs and handles any outputs.
*/ */
class Orchestrator { class Orchestrator {
constructor(automation, triggerOutput = {}) { _chainCount: number
this._metadata = triggerOutput.metadata _appId: string
this._chainCount = this._metadata ? this._metadata.automationChainCount : 0 _automation: Automation
this._appId = triggerOutput.appId _emitter: any
this._app = null _context: AutomationContext
_repeat?: { jobId: string; jobKey: string }
executionOutput: AutomationContext
constructor(automation: Automation, triggerOutput: TriggerOutput, opts: any) {
const metadata = triggerOutput.metadata
this._chainCount = metadata ? metadata.automationChainCount : 0
this._appId = triggerOutput.appId as string
if (opts?.repeat) {
this._repeat = {
jobId: opts.repeat.jobId,
jobKey: opts.repeat.key,
}
}
const triggerStepId = automation.definition.trigger.stepId const triggerStepId = automation.definition.trigger.stepId
triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput) triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput)
// remove from context // remove from context
@ -79,14 +103,14 @@ class Orchestrator {
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput) this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput)
} }
cleanupTriggerOutputs(stepId, triggerOutput) { cleanupTriggerOutputs(stepId: string, triggerOutput: TriggerOutput) {
if (stepId === CRON_STEP_ID) { if (stepId === CRON_STEP_ID) {
triggerOutput.timestamp = Date.now() triggerOutput.timestamp = Date.now()
} }
return triggerOutput return triggerOutput
} }
async getStepFunctionality(stepId) { async getStepFunctionality(stepId: string) {
let step = await actions.getAction(stepId) let step = await actions.getAction(stepId)
if (step == null) { if (step == null) {
throw `Cannot find automation step by name ${stepId}` throw `Cannot find automation step by name ${stepId}`
@ -94,25 +118,107 @@ class Orchestrator {
return step return step
} }
async getApp() { async getMetadata(): Promise<AutomationMetadata> {
if (this._app) { const metadataId = generateAutomationMetadataID(this._automation._id)
return this._app
}
const db = getAppDB() const db = getAppDB()
this._app = await db.get(DocumentTypes.APP_METADATA) let metadata: AutomationMetadata
return this._app try {
metadata = await db.get(metadataId)
} catch (err) {
metadata = {
_id: metadataId,
errorCount: 0,
}
}
return metadata
} }
updateExecutionOutput(id, stepId, inputs, outputs) { async checkIfShouldStop(metadata: AutomationMetadata): Promise<boolean> {
if (!metadata.errorCount || !this._repeat) {
return false
}
const automation = this._automation
const trigger = automation.definition.trigger
if (metadata.errorCount >= MAX_AUTOMATION_RECURRING_ERRORS) {
logWarn(
`CRON disabled due to errors - ${this._appId}/${this._automation._id}`
)
await disableCron(this._repeat?.jobId, this._repeat?.jobKey)
this.updateExecutionOutput(
trigger.id,
trigger.stepId,
{},
{
status: AutomationStatus.STOPPED_ERROR,
success: false,
}
)
await storeLog(automation, this.executionOutput)
return true
}
return false
}
async updateMetadata(metadata: AutomationMetadata) {
const output = this.executionOutput,
automation = this._automation
if (!output || !isRecurring(automation)) {
return
}
const count = metadata.errorCount
const isError = isErrorInOutput(output)
// nothing to do in this scenario, escape
if (!count && !isError) {
return
}
if (isError) {
metadata.errorCount = count ? count + 1 : 1
} else {
metadata.errorCount = 0
}
const db = getAppDB()
try {
await db.put(metadata)
} catch (err) {
logAlertWithInfo(
"Failed to write automation metadata",
db.name,
automation._id,
err
)
}
}
updateExecutionOutput(id: string, stepId: string, inputs: any, outputs: any) {
const stepObj = { id, stepId, inputs, outputs } const stepObj = { id, stepId, inputs, outputs }
// replacing trigger when disabling CRON
if (
stepId === CRON_STEP_ID &&
outputs.status === AutomationStatus.STOPPED_ERROR
) {
this.executionOutput.trigger = stepObj
this.executionOutput.steps = [stepObj]
return
}
// first entry is always the trigger (constructor) // first entry is always the trigger (constructor)
if (this.executionOutput.steps.length === 0) { if (
this.executionOutput.steps.length === 0 ||
this.executionOutput.trigger.id === id
) {
this.executionOutput.trigger = stepObj this.executionOutput.trigger = stepObj
} }
this.executionOutput.steps.push(stepObj) this.executionOutput.steps.push(stepObj)
} }
updateContextAndOutput(loopStepNumber, step, output, result) { updateContextAndOutput(
loopStepNumber: number | undefined,
step: AutomationStep,
output: any,
result: { success: boolean; status: string }
) {
if (!loopStepNumber) {
throw new Error("No loop step number provided.")
}
this.executionOutput.steps.splice(loopStepNumber, 0, { this.executionOutput.steps.splice(loopStepNumber, 0, {
id: step.id, id: step.id,
stepId: step.stepId, stepId: step.stepId,
@ -133,11 +239,22 @@ class Orchestrator {
async execute() { async execute() {
let automation = this._automation let automation = this._automation
let stopped = false let stopped = false
let loopStep = null let loopStep: AutomationStep | undefined = undefined
let stepCount = 0 let stepCount = 0
let loopStepNumber = null let loopStepNumber: any = undefined
let loopSteps = [] let loopSteps: LoopStep[] | undefined = []
let metadata
// check if this is a recurring automation,
if (isProdAppID(this._appId) && isRecurring(automation)) {
metadata = await this.getMetadata()
const shouldStop = await this.checkIfShouldStop(metadata)
if (shouldStop) {
return
}
}
for (let step of automation.definition.steps) { for (let step of automation.definition.steps) {
stepCount++ stepCount++
let input, let input,
@ -151,7 +268,7 @@ class Orchestrator {
if (loopStep) { if (loopStep) {
input = await processObject(loopStep.inputs, this._context) input = await processObject(loopStep.inputs, this._context)
iterations = getLoopIterations(loopStep, input) iterations = getLoopIterations(loopStep as LoopStep, input)
} }
for (let index = 0; index < iterations; index++) { for (let index = 0; index < iterations; index++) {
@ -166,14 +283,17 @@ class Orchestrator {
let tempOutput = { items: loopSteps, iterations: iterationCount } let tempOutput = { items: loopSteps, iterations: iterationCount }
try { try {
newInput.binding = typecastForLooping(loopStep, newInput) newInput.binding = typecastForLooping(
loopStep as LoopStep,
newInput
)
} catch (err) { } catch (err) {
this.updateContextAndOutput(loopStepNumber, step, tempOutput, { this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
status: AutomationErrors.INCORRECT_TYPE, status: AutomationErrors.INCORRECT_TYPE,
success: false, success: false,
}) })
loopSteps = null loopSteps = undefined
loopStep = null loopStep = undefined
break break
} }
@ -223,8 +343,8 @@ class Orchestrator {
status: AutomationErrors.MAX_ITERATIONS, status: AutomationErrors.MAX_ITERATIONS,
success: true, success: true,
}) })
loopSteps = null loopSteps = undefined
loopStep = null loopStep = undefined
break break
} }
@ -232,7 +352,7 @@ class Orchestrator {
const currentItem = this._context.steps[loopStepNumber]?.currentItem const currentItem = this._context.steps[loopStepNumber]?.currentItem
if (currentItem && typeof currentItem === "object") { if (currentItem && typeof currentItem === "object") {
isFailure = Object.keys(currentItem).some(value => { isFailure = Object.keys(currentItem).some(value => {
return currentItem[value] === loopStep.inputs.failure return currentItem[value] === loopStep?.inputs.failure
}) })
} else { } else {
isFailure = currentItem && currentItem === loopStep.inputs.failure isFailure = currentItem && currentItem === loopStep.inputs.failure
@ -243,8 +363,8 @@ class Orchestrator {
status: AutomationErrors.FAILURE_CONDITION, status: AutomationErrors.FAILURE_CONDITION,
success: false, success: false,
}) })
loopSteps = null loopSteps = undefined
loopStep = null loopStep = undefined
break break
} }
} }
@ -295,7 +415,7 @@ class Orchestrator {
if (loopStep) { if (loopStep) {
iterationCount++ iterationCount++
if (index === iterations - 1) { if (index === iterations - 1) {
loopStep = null loopStep = undefined
this._context.steps.splice(loopStepNumber, 1) this._context.steps.splice(loopStepNumber, 1)
break break
} }
@ -316,22 +436,26 @@ class Orchestrator {
}) })
this._context.steps.splice(loopStepNumber, 0, tempOutput) this._context.steps.splice(loopStepNumber, 0, tempOutput)
loopSteps = null loopSteps = undefined
} }
} }
// store the logs for the automation run // store the logs for the automation run
await storeLog(this._automation, this.executionOutput) await storeLog(this._automation, this.executionOutput)
if (isProdAppID(this._appId) && isRecurring(automation) && metadata) {
await this.updateMetadata(metadata)
}
return this.executionOutput return this.executionOutput
} }
} }
module.exports = (input, callback) => { export function execute(input: AutomationEvent, callback: WorkerCallback) {
const appId = input.data.event.appId const appId = input.data.event.appId
doInAppContext(appId, async () => { doInAppContext(appId, async () => {
const automationOrchestrator = new Orchestrator( const automationOrchestrator = new Orchestrator(
input.data.automation, input.data.automation,
input.data.event input.data.event,
input.opts
) )
try { try {
const response = await automationOrchestrator.execute() const response = await automationOrchestrator.execute()

View File

@ -0,0 +1,18 @@
export type WorkerCallback = (error: any, response?: any) => void
export interface QueryEvent {
appId?: string
datasource: any
queryVerb: string
fields: { [key: string]: any }
parameters: { [key: string]: any }
pagination?: any
transformer: any
queryId: string
ctx?: any
}
export interface QueryVariable {
queryId: string
name: string
}

View File

@ -18,26 +18,23 @@ function typeToFile(type: any) {
default: default:
throw "Unknown thread type" throw "Unknown thread type"
} }
// have to use require here, to make it work with worker-farm
return require.resolve(filename) return require.resolve(filename)
} }
export class Thread { export class Thread {
type: any type: any
count: any count: any
disableThreading: any
workers: any workers: any
timeoutMs: any timeoutMs: any
disableThreading: boolean
static workerRefs: any[] = [] static workerRefs: any[] = []
constructor(type: any, opts: any = { timeoutMs: null, count: 1 }) { constructor(type: any, opts: any = { timeoutMs: null, count: 1 }) {
this.type = type this.type = type
this.count = opts.count ? opts.count : 1 this.count = opts.count ? opts.count : 1
this.disableThreading = this.disableThreading = this.shouldDisableThreading()
env.isTest() ||
env.DISABLE_THREADING ||
this.count === 0 ||
env.isInThread()
if (!this.disableThreading) { if (!this.disableThreading) {
const workerOpts: any = { const workerOpts: any = {
autoStart: true, autoStart: true,
@ -47,33 +44,44 @@ export class Thread {
this.timeoutMs = opts.timeoutMs this.timeoutMs = opts.timeoutMs
workerOpts.maxCallTime = opts.timeoutMs workerOpts.maxCallTime = opts.timeoutMs
} }
this.workers = workerFarm(workerOpts, typeToFile(type)) this.workers = workerFarm(workerOpts, typeToFile(type), ["execute"])
Thread.workerRefs.push(this.workers) Thread.workerRefs.push(this.workers)
} }
} }
shouldDisableThreading(): boolean {
return !!(
env.isTest() ||
env.DISABLE_THREADING ||
this.count === 0 ||
env.isInThread()
)
}
run(data: any) { run(data: any) {
const timeout = this.timeoutMs
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let fncToCall function fire(worker: any) {
worker.execute(data, (err: any, response: any) => {
if (err && err.type === "TimeoutError") {
reject(
new Error(`Query response time exceeded ${timeout}ms timeout.`)
)
} else if (err) {
reject(err)
} else {
resolve(response)
}
})
}
// if in test then don't use threading // if in test then don't use threading
if (this.disableThreading) { if (this.disableThreading) {
fncToCall = require(typeToFile(this.type)) import(typeToFile(this.type)).then((thread: any) => {
fire(thread)
})
} else { } else {
fncToCall = this.workers fire(this.workers)
} }
fncToCall(data, (err: any, response: any) => {
if (err && err.type === "TimeoutError") {
reject(
new Error(
`Query response time exceeded ${this.timeoutMs}ms timeout.`
)
)
} else if (err) {
reject(err)
} else {
resolve(response)
}
})
}) })
} }

View File

@ -1,5 +1,6 @@
const threadUtils = require("./utils") import { default as threadUtils } from "./utils"
threadUtils.threadSetup() threadUtils.threadSetup()
import { WorkerCallback, QueryEvent, QueryVariable } from "./definitions"
const ScriptRunner = require("../utilities/scriptRunner") const ScriptRunner = require("../utilities/scriptRunner")
const { integrations } = require("../integrations") const { integrations } = require("../integrations")
const { processStringSync } = require("@budibase/string-templates") const { processStringSync } = require("@budibase/string-templates")
@ -19,7 +20,22 @@ const {
} = require("../integrations/queries/sql") } = require("../integrations/queries/sql")
class QueryRunner { class QueryRunner {
constructor(input, flags = { noRecursiveQuery: false }) { datasource: any
queryVerb: string
queryId: string
fields: any
parameters: any
pagination: any
transformer: any
cachedVariables: any[]
ctx: any
queryResponse: any
noRecursiveQuery: boolean
hasRerun: boolean
hasRefreshedOAuth: boolean
hasDynamicVariables: boolean
constructor(input: QueryEvent, flags = { noRecursiveQuery: false }) {
this.datasource = input.datasource this.datasource = input.datasource
this.queryVerb = input.queryVerb this.queryVerb = input.queryVerb
this.fields = input.fields this.fields = input.fields
@ -37,9 +53,10 @@ class QueryRunner {
this.queryResponse = {} this.queryResponse = {}
this.hasRerun = false this.hasRerun = false
this.hasRefreshedOAuth = false this.hasRefreshedOAuth = false
this.hasDynamicVariables = false
} }
async execute() { async execute(): Promise<any> {
let { datasource, fields, queryVerb, transformer } = this let { datasource, fields, queryVerb, transformer } = this
let datasourceClone = cloneDeep(datasource) let datasourceClone = cloneDeep(datasource)
@ -52,7 +69,7 @@ class QueryRunner {
if (datasourceClone.config.authConfigs) { if (datasourceClone.config.authConfigs) {
datasourceClone.config.authConfigs = datasourceClone.config.authConfigs =
datasourceClone.config.authConfigs.map(config => { datasourceClone.config.authConfigs.map((config: any) => {
return enrichQueryFields(config, this.ctx) return enrichQueryFields(config, this.ctx)
}) })
} }
@ -138,8 +155,8 @@ class QueryRunner {
} }
// map into JSON if just raw primitive here // map into JSON if just raw primitive here
if (rows.find(row => typeof row !== "object")) { if (rows.find((row: any) => typeof row !== "object")) {
rows = rows.map(value => ({ value })) rows = rows.map((value: any) => ({ value }))
} }
// get all the potential fields in the schema // get all the potential fields in the schema
@ -152,7 +169,7 @@ class QueryRunner {
return { rows, keys, info, extra, pagination } return { rows, keys, info, extra, pagination }
} }
async runAnotherQuery(queryId, parameters) { async runAnotherQuery(queryId: string, parameters: any) {
const db = getAppDB() const db = getAppDB()
const query = await db.get(queryId) const query = await db.get(queryId)
const datasource = await db.get(query.datasourceId) const datasource = await db.get(query.datasourceId)
@ -163,12 +180,13 @@ class QueryRunner {
fields: query.fields, fields: query.fields,
parameters, parameters,
transformer: query.transformer, transformer: query.transformer,
queryId,
}, },
{ noRecursiveQuery: true } { noRecursiveQuery: true }
).execute() ).execute()
} }
async refreshOAuth2(ctx) { async refreshOAuth2(ctx: any) {
const { oauth2, providerType, _id } = ctx.user const { oauth2, providerType, _id } = ctx.user
const { configId } = ctx.auth const { configId } = ctx.auth
@ -200,7 +218,7 @@ class QueryRunner {
return resp return resp
} }
async getDynamicVariable(variable) { async getDynamicVariable(variable: QueryVariable) {
let { parameters } = this let { parameters } = this
const queryId = variable.queryId, const queryId = variable.queryId,
name = variable.name name = variable.name
@ -233,7 +251,7 @@ class QueryRunner {
if (!this.noRecursiveQuery) { if (!this.noRecursiveQuery) {
// need to see if this uses any variables // need to see if this uses any variables
const stringFields = JSON.stringify(fields) const stringFields = JSON.stringify(fields)
const foundVars = dynamicVars.filter(variable => { const foundVars = dynamicVars.filter((variable: QueryVariable) => {
// don't allow a query to use its own dynamic variable (loop) // don't allow a query to use its own dynamic variable (loop)
if (variable.queryId === this.queryId) { if (variable.queryId === this.queryId) {
return false return false
@ -242,7 +260,9 @@ class QueryRunner {
const regex = new RegExp(`{{[ ]*${variable.name}[ ]*}}`) const regex = new RegExp(`{{[ ]*${variable.name}[ ]*}}`)
return regex.test(stringFields) return regex.test(stringFields)
}) })
const dynamics = foundVars.map(dynVar => this.getDynamicVariable(dynVar)) const dynamics = foundVars.map((dynVar: QueryVariable) =>
this.getDynamicVariable(dynVar)
)
const responses = await Promise.all(dynamics) const responses = await Promise.all(dynamics)
for (let i = 0; i < foundVars.length; i++) { for (let i = 0; i < foundVars.length; i++) {
const variable = foundVars[i] const variable = foundVars[i]
@ -264,7 +284,7 @@ class QueryRunner {
} }
} }
module.exports = (input, callback) => { export function execute(input: QueryEvent, callback: WorkerCallback) {
doInAppContext(input.appId, async () => { doInAppContext(input.appId, async () => {
const Runner = new QueryRunner(input) const Runner = new QueryRunner(input)
try { try {

View File

@ -1,10 +1,11 @@
import { QueryVariable } from "./definitions"
const env = require("../environment") const env = require("../environment")
const db = require("../db") const db = require("../db")
const redis = require("@budibase/backend-core/redis") const redis = require("@budibase/backend-core/redis")
const { SEPARATOR } = require("@budibase/backend-core/db") const { SEPARATOR } = require("@budibase/backend-core/db")
const VARIABLE_TTL_SECONDS = 3600 const VARIABLE_TTL_SECONDS = 3600
let client let client: any
async function getClient() { async function getClient() {
if (!client) { if (!client) {
@ -14,10 +15,16 @@ async function getClient() {
} }
process.on("exit", async () => { process.on("exit", async () => {
if (client) await client.finish() if (client) {
await client.finish()
}
}) })
exports.threadSetup = () => { function makeVariableKey(queryId: string, variable: string) {
return `${queryId}${SEPARATOR}${variable}`
}
export function threadSetup() {
// don't run this if not threading // don't run this if not threading
if (env.isTest() || env.DISABLE_THREADING) { if (env.isTest() || env.DISABLE_THREADING) {
return return
@ -27,16 +34,15 @@ exports.threadSetup = () => {
db.init() db.init()
} }
function makeVariableKey(queryId, variable) { export async function checkCacheForDynamicVariable(
return `${queryId}${SEPARATOR}${variable}` queryId: string,
} variable: string
) {
exports.checkCacheForDynamicVariable = async (queryId, variable) => {
const cache = await getClient() const cache = await getClient()
return cache.get(makeVariableKey(queryId, variable)) return cache.get(makeVariableKey(queryId, variable))
} }
exports.invalidateDynamicVariables = async cachedVars => { export async function invalidateDynamicVariables(cachedVars: QueryVariable[]) {
const cache = await getClient() const cache = await getClient()
let promises = [] let promises = []
for (let variable of cachedVars) { for (let variable of cachedVars) {
@ -47,7 +53,11 @@ exports.invalidateDynamicVariables = async cachedVars => {
await Promise.all(promises) await Promise.all(promises)
} }
exports.storeDynamicVariable = async (queryId, variable, value) => { export async function storeDynamicVariable(
queryId: string,
variable: string,
value: any
) {
const cache = await getClient() const cache = await getClient()
await cache.store( await cache.store(
makeVariableKey(queryId, variable), makeVariableKey(queryId, variable),
@ -56,7 +66,7 @@ exports.storeDynamicVariable = async (queryId, variable, value) => {
) )
} }
exports.formatResponse = resp => { export function formatResponse(resp: any) {
if (typeof resp === "string") { if (typeof resp === "string") {
try { try {
resp = JSON.parse(resp) resp = JSON.parse(resp)
@ -67,7 +77,7 @@ exports.formatResponse = resp => {
return resp return resp
} }
exports.hasExtraData = response => { export function hasExtraData(response: any) {
return ( return (
typeof response === "object" && typeof response === "object" &&
!Array.isArray(response) && !Array.isArray(response) &&
@ -76,3 +86,12 @@ exports.hasExtraData = response => {
response.info != null response.info != null
) )
} }
export default {
hasExtraData,
formatResponse,
storeDynamicVariable,
invalidateDynamicVariables,
checkCacheForDynamicVariable,
threadSetup,
}

View File

@ -32,8 +32,10 @@ exports.updateAppRole = (user, { appId } = {}) => {
// if a role wasn't found then either set as admin (builder) or public (everyone else) // if a role wasn't found then either set as admin (builder) or public (everyone else)
if (!user.roleId && user.builder && user.builder.global) { if (!user.roleId && user.builder && user.builder.global) {
user.roleId = BUILTIN_ROLE_IDS.ADMIN user.roleId = BUILTIN_ROLE_IDS.ADMIN
} else if (!user.roleId) { } else if (!user.roleId && !user?.userGroups?.length) {
user.roleId = BUILTIN_ROLE_IDS.PUBLIC user.roleId = BUILTIN_ROLE_IDS.PUBLIC
} else if (user?.userGroups?.length) {
user.roleId = null
} }
delete user.roles delete user.roles
@ -41,10 +43,8 @@ exports.updateAppRole = (user, { appId } = {}) => {
} }
async function checkGroupRoles(user, { appId } = {}) { async function checkGroupRoles(user, { appId } = {}) {
if (!user.roleId) { let roleId = await groups.getGroupRoleId(user, appId)
let roleId = await groups.getGroupRoleId(user, appId) user.roleId = roleId
user.roleId = roleId
}
return user return user
} }
@ -54,7 +54,7 @@ async function processUser(user, { appId } = {}) {
delete user.password delete user.password
} }
user = await exports.updateAppRole(user, { appId }) user = await exports.updateAppRole(user, { appId })
if (user?.userGroups?.length) { if (!user.roleId && user?.userGroups?.length) {
user = await checkGroupRoles(user, { appId }) user = await checkGroupRoles(user, { appId })
} }

View File

@ -109,6 +109,10 @@ class InMemoryQueue {
async clean() { async clean() {
return [] return []
} }
async getJob() {
return {}
}
} }
module.exports = InMemoryQueue module.exports = InMemoryQueue

View File

@ -156,9 +156,9 @@
adal-node "^0.2.2" adal-node "^0.2.2"
"@azure/storage-blob@^12.5.0": "@azure/storage-blob@^12.5.0":
version "12.11.0" version "12.10.0"
resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.11.0.tgz#2e27902ab293715411ab1f7c8fae422ad0b4b827" resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.10.0.tgz#b92269f45a1765700a900b41ca81a474a6e36ea4"
integrity sha512-na+FisoARuaOWaHWpmdtk3FeuTWf2VWamdJ9/TJJzj5ZdXPLC3juoDgFs6XVuJIoK30yuBpyFBEDXVRK4pB7Tg== integrity sha512-FBEPKGnvtQJS8V8Tg1P9obgmVD9AodrIfwtwhBpsjenClhFyugMp3HPJY0tF7rInUB/CivKBCbnQKrUnKxqxzw==
dependencies: dependencies:
"@azure/abort-controller" "^1.0.0" "@azure/abort-controller" "^1.0.0"
"@azure/core-http" "^2.0.0" "@azure/core-http" "^2.0.0"
@ -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.1.29-alpha.2": "@budibase/backend-core@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.29-alpha.2.tgz#56c115be486fc264348ee2a06fc5387c202051ec" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.33-alpha.1.tgz#2c483f71c99f0dfd07e78dfc162be979e97a5a37"
integrity sha512-q2yIKrvFj8kQVOekNp17FOkclLlYSPy2gjKicfnsHg1Oeq+iGhgUHQYJ+QTBUlU61Xjd6E9Kkp5pQXOZ09Bf5g== integrity sha512-1oY1GPWQ4ym4m75QJxnCBOmEGc+yuXRGafKpBGXXqpyA7qMP5TSYpEGrrpX3uKrIsLIRsiaqw3oPr0T8aL2LQw==
dependencies: dependencies:
"@budibase/types" "^1.1.29-alpha.2" "@budibase/types" "1.1.33-alpha.1"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -1177,13 +1177,13 @@
svelte-flatpickr "^3.2.3" svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0" svelte-portal "^1.0.0"
"@budibase/pro@1.1.29-alpha.2": "@budibase/pro@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.29-alpha.2.tgz#cafeb466acb9ff552dcb37710f84e3b2192d39f1" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.33-alpha.1.tgz#2778f4895b5dec982ef8245d0c36247c6242cd73"
integrity sha512-rD11gx5MvmSN0VS6ie2bjbeOnPj/0sbzzsoEqogOcki9ovdMdiXtlIHkYYcVZbgodY47Fw+jrJVSspJ9vr5SFg== integrity sha512-M0gust58aTyPtpp2CKhFqsmzVYu1ZttW1l6p9tePClhfp4FvkYTy/UsHLV7Pg3NbCLDo3qpCzTpPTYnePtf/vg==
dependencies: dependencies:
"@budibase/backend-core" "1.1.29-alpha.2" "@budibase/backend-core" "1.1.33-alpha.1"
"@budibase/types" "1.1.29-alpha.2" "@budibase/types" "1.1.33-alpha.1"
"@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"
@ -1206,15 +1206,10 @@
svelte-apexcharts "^1.0.2" svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0" svelte-flatpickr "^3.1.0"
"@budibase/types@1.1.29-alpha.2": "@budibase/types@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.29-alpha.2.tgz#d824f8045ba362c4ac91798b70239064a3aca98c" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.33-alpha.1.tgz#8a1253208a618b439d85977c3879b0184b6487e8"
integrity sha512-XYWfMmxcIHn4xVeub86+9MKrid/EzsvMazoC32kTmkH2DppPTjihqWXyGWhhLzDme7GpZ3/bzXPjbd3rkebFGQ== integrity sha512-BEIJqb9WjAck16rkgtGHlnxANhkK8OXbJLBxu+eB4x7F6tSmMI+T6zsBkGE0ehHmqa6YNzY7OldKLc967mAaLA==
"@budibase/types@^1.1.29-alpha.2":
version "1.1.30"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.30.tgz#89bb0aeea747a890ddd299f68e178d686c9cafdc"
integrity sha512-Gh5zGQ4TWI6HFiJM7684bTgPot2JqHBnR0ReHcBOguIj/U/euUBPInxaa7xTZrLYs++Rbe4gffrqnYmZfEy2sg==
"@bull-board/api@3.7.0": "@bull-board/api@3.7.0":
version "3.7.0" version "3.7.0"
@ -1964,24 +1959,29 @@
"@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/gen-mapping@^0.3.0": "@jridgewell/gen-mapping@^0.3.0":
version "0.3.1" version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz#cf92a983c83466b8c0ce9124fadeaf09f7c66ea9" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg== integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==
dependencies: dependencies:
"@jridgewell/set-array" "^1.0.0" "@jridgewell/set-array" "^1.0.1"
"@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9" "@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/resolve-uri@^3.0.3": "@jridgewell/resolve-uri@^3.0.3":
version "3.0.7" version "3.1.0"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz#30cd49820a962aff48c8fffc5cd760151fca61fe" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
"@jridgewell/set-array@^1.0.0": "@jridgewell/set-array@^1.0.0":
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea" resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea"
integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ==
"@jridgewell/set-array@^1.0.1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
"@jridgewell/source-map@^0.3.2": "@jridgewell/source-map@^0.3.2":
version "0.3.2" version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb"
@ -1991,11 +1991,11 @@
"@jridgewell/trace-mapping" "^0.3.9" "@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/sourcemap-codec@^1.4.10": "@jridgewell/sourcemap-codec@^1.4.10":
version "1.4.13" version "1.4.14"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
"@jridgewell/trace-mapping@^0.3.7", "@jridgewell/trace-mapping@^0.3.9": "@jridgewell/trace-mapping@^0.3.7":
version "0.3.13" version "0.3.13"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea"
integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w== integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==
@ -2003,6 +2003,14 @@
"@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping@^0.3.9":
version "0.3.14"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed"
integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==
dependencies:
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jsdevtools/ono@^7.1.3": "@jsdevtools/ono@^7.1.3":
version "7.1.3" version "7.1.3"
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796" resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"
@ -2847,7 +2855,7 @@
"@types/bson" "*" "@types/bson" "*"
"@types/node" "*" "@types/node" "*"
"@types/node-fetch@2.6.1": "@types/node-fetch@2.6.1", "@types/node-fetch@^2.5.0":
version "2.6.1" version "2.6.1"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.1.tgz#8f127c50481db65886800ef496f20bbf15518975" resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.1.tgz#8f127c50481db65886800ef496f20bbf15518975"
integrity sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA== integrity sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==
@ -2855,14 +2863,6 @@
"@types/node" "*" "@types/node" "*"
form-data "^3.0.0" form-data "^3.0.0"
"@types/node-fetch@^2.5.0":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==
dependencies:
"@types/node" "*"
form-data "^3.0.0"
"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.13.4", "@types/node@>=13.7.0": "@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.13.4", "@types/node@>=13.7.0":
version "17.0.41" version "17.0.41"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.41.tgz#1607b2fd3da014ae5d4d1b31bc792a39348dfb9b" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.41.tgz#1607b2fd3da014ae5d4d1b31bc792a39348dfb9b"
@ -3731,11 +3731,6 @@ atomic-sleep@^1.0.0:
resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b"
integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==
available-typed-arrays@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==
aws-sdk@2.1030.0: aws-sdk@2.1030.0:
version "2.1030.0" version "2.1030.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1030.0.tgz#24a856af3d2b8b37c14a8f59974993661c66fd82" resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1030.0.tgz#24a856af3d2b8b37c14a8f59974993661c66fd82"
@ -3752,9 +3747,9 @@ aws-sdk@2.1030.0:
xml2js "0.4.19" xml2js "0.4.19"
aws-sdk@^2.878.0: aws-sdk@^2.878.0:
version "2.1174.0" version "2.1152.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1174.0.tgz#3e2acb1ee29229cc5d97015b2d1a18c41e967979" resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1152.0.tgz#73e4fb81b3a9c289234b5d6848bcdb854f169bdf"
integrity sha512-t/Cwbdunmoj3WAI+u+hw/kr6mla1sYCn+VncxxIjkACStA47+ZTsfd7cQfpoVMit5KubkHaJ3SHX4/qvmt0Jfg== integrity sha512-Lqwk0bDhm3vzpYb3AAM9VgGHeDpbB8+o7UJnP9R+CO23kJfi/XRpKihAcbyKDD/AUQ+O1LJaUVpvaJYLS9Am7w==
dependencies: dependencies:
buffer "4.9.2" buffer "4.9.2"
events "1.1.1" events "1.1.1"
@ -3763,7 +3758,6 @@ aws-sdk@^2.878.0:
querystring "0.2.0" querystring "0.2.0"
sax "1.2.1" sax "1.2.1"
url "0.10.3" url "0.10.3"
util "^0.12.4"
uuid "8.0.0" uuid "8.0.0"
xml2js "0.4.19" xml2js "0.4.19"
@ -5504,7 +5498,7 @@ error-inject@^1.0.0:
resolved "https://registry.yarnpkg.com/error-inject/-/error-inject-1.0.0.tgz#e2b3d91b54aed672f309d950d154850fa11d4f37" resolved "https://registry.yarnpkg.com/error-inject/-/error-inject-1.0.0.tgz#e2b3d91b54aed672f309d950d154850fa11d4f37"
integrity sha512-JM8N6PytDbmIYm1IhPWlo8vr3NtfjhDY/1MhD/a5b/aad/USE8a0+NsqE9d5n+GVGmuNkPQWm4bFQWv18d8tMg== integrity sha512-JM8N6PytDbmIYm1IhPWlo8vr3NtfjhDY/1MhD/a5b/aad/USE8a0+NsqE9d5n+GVGmuNkPQWm4bFQWv18d8tMg==
es-abstract@^1.17.5, es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.2, es-abstract@^1.19.5, es-abstract@^1.20.0, es-abstract@^1.20.1: es-abstract@^1.17.5, es-abstract@^1.19.0, es-abstract@^1.19.1, es-abstract@^1.19.2, es-abstract@^1.19.5, es-abstract@^1.20.1:
version "1.20.1" version "1.20.1"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814"
integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA== integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==
@ -7454,14 +7448,6 @@ is-accessor-descriptor@^1.0.0:
dependencies: dependencies:
kind-of "^6.0.0" kind-of "^6.0.0"
is-arguments@^1.0.4:
version "1.1.1"
resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b"
integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==
dependencies:
call-bind "^1.0.2"
has-tostringtag "^1.0.0"
is-arrayish@^0.2.1: is-arrayish@^0.2.1:
version "0.2.1" version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@ -7768,17 +7754,6 @@ is-type-of@^1.0.0:
is-class-hotfix "~0.0.6" is-class-hotfix "~0.0.6"
isstream "~0.1.2" isstream "~0.1.2"
is-typed-array@^1.1.3, is-typed-array@^1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.9.tgz#246d77d2871e7d9f5aeb1d54b9f52c71329ece67"
integrity sha512-kfrlnTTn8pZkfpJMUgYD7YZ3qzeJgWUn8XfVYBARc4wnmNOmLbmuuaAs3q5fvB0UJOn6yHAKaGTPM7d6ezoD/A==
dependencies:
available-typed-arrays "^1.0.5"
call-bind "^1.0.2"
es-abstract "^1.20.0"
for-each "^0.3.3"
has-tostringtag "^1.0.0"
is-typedarray@^1.0.0, is-typedarray@~1.0.0: is-typedarray@^1.0.0, is-typedarray@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
@ -9974,16 +9949,11 @@ moment-timezone@^0.5.15, moment-timezone@^0.5.31:
dependencies: dependencies:
moment ">= 2.9.0" moment ">= 2.9.0"
"moment@>= 2.9.0": "moment@>= 2.9.0", moment@^2.29.3:
version "2.29.3" version "2.29.3"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3" resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw== integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==
moment@^2.29.3:
version "2.29.4"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
mongodb@3.6.3: mongodb@3.6.3:
version "3.6.3" version "3.6.3"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.3.tgz#eddaed0cc3598474d7a15f0f2a5b04848489fd05" resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.3.tgz#eddaed0cc3598474d7a15f0f2a5b04848489fd05"
@ -12317,7 +12287,7 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
simple-lru-cache@^0.0.2: simple-lru-cache@^0.0.2:
version "0.0.2" version "0.0.2"
resolved "https://registry.yarnpkg.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd" resolved "https://registry.yarnpkg.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd"
integrity sha512-uEv/AFO0ADI7d99OHDmh1QfYzQk/izT1vCmu/riQfh7qjBVUUgRT87E5s5h7CxWCA/+YoZerykpEthzVrW3LIw== integrity sha1-1ZzDoZPBpdAyD4Tucy9uRxPlEd0=
simple-swizzle@^0.2.2: simple-swizzle@^0.2.2:
version "0.2.2" version "0.2.2"
@ -12388,9 +12358,9 @@ snowflake-promise@^4.5.0:
snowflake-sdk "^1.6.0" snowflake-sdk "^1.6.0"
snowflake-sdk@^1.6.0: snowflake-sdk@^1.6.0:
version "1.6.11" version "1.6.10"
resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.11.tgz#2797c816d0d2af6d56180949e1364e53df8a9c13" resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.10.tgz#c6c4f267edbc50d3c1ef6fcc2651188bb8545dce"
integrity sha512-w4oCXjNQ1peAJjhnrwihr+epYw1pSxbe5/+PdxexYb2rzowyOn0RA5PFbir90q/dx0jzM2gvPiHDjnSBEZ1/zA== integrity sha512-kguQQSGhmNqZfmN/yZNDaIaMMktTcrTYBjtyx+szJzV69b5F+5b77btpYp+bCFqao69otVM+IPUtb3sugvCVnQ==
dependencies: dependencies:
"@azure/storage-blob" "^12.5.0" "@azure/storage-blob" "^12.5.0"
"@techteamer/ocsp" "1.0.0" "@techteamer/ocsp" "1.0.0"
@ -13134,9 +13104,9 @@ terser-webpack-plugin@^5.1.3:
terser "^5.7.2" terser "^5.7.2"
terser@^5.7.2: terser@^5.7.2:
version "5.14.0" version "5.14.2"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.0.tgz#eefeec9af5153f55798180ee2617f390bdd285e2" resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10"
integrity sha512-JC6qfIEkPBd9j1SMO3Pfn+A6w2kQV54tv+ABQLgZr7dA3k/DL/OBoYSWxzVpZev3J+bUHXfr55L8Mox7AaNo6g== integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==
dependencies: dependencies:
"@jridgewell/source-map" "^0.3.2" "@jridgewell/source-map" "^0.3.2"
acorn "^8.5.0" acorn "^8.5.0"
@ -13776,18 +13746,6 @@ util.promisify@^1.0.0, util.promisify@^1.0.1:
has-symbols "^1.0.1" has-symbols "^1.0.1"
object.getownpropertydescriptors "^2.1.1" object.getownpropertydescriptors "^2.1.1"
util@^0.12.4:
version "0.12.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.12.4.tgz#66121a31420df8f01ca0c464be15dfa1d1850253"
integrity sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw==
dependencies:
inherits "^2.0.3"
is-arguments "^1.0.4"
is-generator-function "^1.0.7"
is-typed-array "^1.1.3"
safe-buffer "^5.1.2"
which-typed-array "^1.1.2"
utils-merge@1.x.x: utils-merge@1.x.x:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
@ -14071,18 +14029,6 @@ which-module@^2.0.0:
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
which-typed-array@^1.1.2:
version "1.1.8"
resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.8.tgz#0cfd53401a6f334d90ed1125754a42ed663eb01f"
integrity sha512-Jn4e5PItbcAHyLoRDwvPj1ypu27DJbtdYXUa5zsinrUx77Uvfb0cXwwnGMTn7cjUfhhqgVQnVJCwF+7cgU7tpw==
dependencies:
available-typed-arrays "^1.0.5"
call-bind "^1.0.2"
es-abstract "^1.20.0"
for-each "^0.3.3"
has-tostringtag "^1.0.0"
is-typed-array "^1.1.9"
which@^1.2.9: which@^1.2.9:
version "1.3.1" version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
@ -14125,23 +14071,7 @@ winston-transport@^4.5.0:
readable-stream "^3.6.0" readable-stream "^3.6.0"
triple-beam "^1.3.0" triple-beam "^1.3.0"
winston@^3.1.0: winston@^3.1.0, winston@^3.3.3:
version "3.8.1"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.8.1.tgz#76f15b3478cde170b780234e0c4cf805c5a7fb57"
integrity sha512-r+6YAiCR4uI3N8eQNOg8k3P3PqwAm20cLKlzVD9E66Ch39+LZC+VH1UKf9JemQj2B3QoUHfKD7Poewn0Pr3Y1w==
dependencies:
"@dabh/diagnostics" "^2.0.2"
async "^3.2.3"
is-stream "^2.0.0"
logform "^2.4.0"
one-time "^1.0.0"
readable-stream "^3.4.0"
safe-stable-stringify "^2.3.1"
stack-trace "0.0.x"
triple-beam "^1.3.0"
winston-transport "^4.5.0"
winston@^3.3.3:
version "3.7.2" version "3.7.2"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.7.2.tgz#95b4eeddbec902b3db1424932ac634f887c400b1" resolved "https://registry.yarnpkg.com/winston/-/winston-3.7.2.tgz#95b4eeddbec902b3db1424932ac634f887c400b1"
integrity sha512-QziIqtojHBoyzUOdQvQiar1DH0Xp9nF1A1y7NVy2DGEsz82SBDtOalS0ulTRGVT14xPX3WRWkCsdcJKqNflKng== integrity sha512-QziIqtojHBoyzUOdQvQiar1DH0Xp9nF1A1y7NVy2DGEsz82SBDtOalS0ulTRGVT14xPX3WRWkCsdcJKqNflKng==

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.cjs",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",

View File

@ -1,6 +1,6 @@
{ {
"name": "@budibase/types", "name": "@budibase/types",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"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

@ -12,6 +12,14 @@ export interface Automation extends Document {
export interface AutomationStep { export interface AutomationStep {
id: string id: string
stepId: string stepId: string
inputs: {
[key: string]: any
}
schema: {
inputs: {
[key: string]: any
}
}
} }
export interface AutomationTrigger { export interface AutomationTrigger {
@ -23,11 +31,12 @@ export enum AutomationStatus {
SUCCESS = "success", SUCCESS = "success",
ERROR = "error", ERROR = "error",
STOPPED = "stopped", STOPPED = "stopped",
STOPPED_ERROR = "stopped_error",
} }
export interface AutomationResults { export interface AutomationResults {
automationId: string automationId?: string
status: string status?: AutomationStatus
trigger?: any trigger?: any
steps: { steps: {
stepId: string stepId: string

View File

@ -1,7 +1,7 @@
{ {
"name": "@budibase/worker", "name": "@budibase/worker",
"email": "hi@budibase.com", "email": "hi@budibase.com",
"version": "1.1.29-alpha.2", "version": "1.1.33-alpha.1",
"description": "Budibase background service", "description": "Budibase background service",
"main": "src/index.ts", "main": "src/index.ts",
"repository": { "repository": {
@ -35,10 +35,10 @@
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@budibase/backend-core": "^1.1.29-alpha.2", "@budibase/backend-core": "1.1.33-alpha.1",
"@budibase/pro": "1.1.29-alpha.2", "@budibase/pro": "1.1.33-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.2", "@budibase/string-templates": "1.1.33-alpha.1",
"@budibase/types": "^1.1.29-alpha.2", "@budibase/types": "1.1.33-alpha.1",
"@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

@ -3,7 +3,7 @@ import { checkInviteCode } from "../../../utilities/redis"
import { sendEmail } from "../../../utilities/email" import { sendEmail } from "../../../utilities/email"
import { users } from "../../../sdk" import { users } from "../../../sdk"
import env from "../../../environment" import env from "../../../environment"
import { User, CloudAccount, UserGroup } from "@budibase/types" import { User, CloudAccount } from "@budibase/types"
import { import {
events, events,
errors, errors,
@ -114,6 +114,16 @@ export const adminUser = async (ctx: any) => {
}) })
} }
export const countByApp = async (ctx: any) => {
const appId = ctx.params.appId
try {
const response = await users.countUsersByApp(appId)
ctx.body = response
} catch (err: any) {
ctx.throw(err.status || 400, err)
}
}
export const destroy = async (ctx: any) => { export const destroy = async (ctx: any) => {
const id = ctx.params.id const id = ctx.params.id

View File

@ -64,6 +64,7 @@ router
.post("/api/global/users/search", builderOrAdmin, controller.search) .post("/api/global/users/search", builderOrAdmin, controller.search)
.delete("/api/global/users/:id", adminOnly, controller.destroy) .delete("/api/global/users/:id", adminOnly, controller.destroy)
.post("/api/global/users/bulkDelete", adminOnly, controller.bulkDelete) .post("/api/global/users/bulkDelete", adminOnly, controller.bulkDelete)
.get("/api/global/users/count/:appId", adminOnly, controller.countByApp)
.get("/api/global/roles/:appId") .get("/api/global/roles/:appId")
.post( .post(
"/api/global/users/invite", "/api/global/users/invite",

View File

@ -20,7 +20,7 @@ import { groups as groupUtils } from "@budibase/pro"
const PAGE_LIMIT = 8 const PAGE_LIMIT = 8
export const allUsers = async (newDb?: any) => { export const allUsers = async () => {
const db = tenancy.getGlobalDB() const db = tenancy.getGlobalDB()
const response = await db.allDocs( const response = await db.allDocs(
dbUtils.getGlobalUserParams(null, { dbUtils.getGlobalUserParams(null, {
@ -30,6 +30,13 @@ export const allUsers = async (newDb?: any) => {
return response.rows.map((row: any) => row.doc) return response.rows.map((row: any) => row.doc)
} }
export const countUsersByApp = async (appId: string) => {
let response: any = await usersCore.searchGlobalUsersByApp(appId, {})
return {
userCount: response.length,
}
}
export const paginatedUsers = async ({ export const paginatedUsers = async ({
page, page,
email, email,

View File

@ -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.1.29-alpha.2": "@budibase/backend-core@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.29-alpha.2.tgz#56c115be486fc264348ee2a06fc5387c202051ec" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.33-alpha.1.tgz#2c483f71c99f0dfd07e78dfc162be979e97a5a37"
integrity sha512-q2yIKrvFj8kQVOekNp17FOkclLlYSPy2gjKicfnsHg1Oeq+iGhgUHQYJ+QTBUlU61Xjd6E9Kkp5pQXOZ09Bf5g== integrity sha512-1oY1GPWQ4ym4m75QJxnCBOmEGc+yuXRGafKpBGXXqpyA7qMP5TSYpEGrrpX3uKrIsLIRsiaqw3oPr0T8aL2LQw==
dependencies: dependencies:
"@budibase/types" "^1.1.29-alpha.2" "@budibase/types" "1.1.33-alpha.1"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -324,26 +324,21 @@
uuid "8.3.2" uuid "8.3.2"
zlib "1.0.5" zlib "1.0.5"
"@budibase/pro@1.1.29-alpha.2": "@budibase/pro@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.29-alpha.2.tgz#cafeb466acb9ff552dcb37710f84e3b2192d39f1" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.33-alpha.1.tgz#2778f4895b5dec982ef8245d0c36247c6242cd73"
integrity sha512-rD11gx5MvmSN0VS6ie2bjbeOnPj/0sbzzsoEqogOcki9ovdMdiXtlIHkYYcVZbgodY47Fw+jrJVSspJ9vr5SFg== integrity sha512-M0gust58aTyPtpp2CKhFqsmzVYu1ZttW1l6p9tePClhfp4FvkYTy/UsHLV7Pg3NbCLDo3qpCzTpPTYnePtf/vg==
dependencies: dependencies:
"@budibase/backend-core" "1.1.29-alpha.2" "@budibase/backend-core" "1.1.33-alpha.1"
"@budibase/types" "1.1.29-alpha.2" "@budibase/types" "1.1.33-alpha.1"
"@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.1.29-alpha.2": "@budibase/types@1.1.33-alpha.1":
version "1.1.29-alpha.2" version "1.1.33-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.29-alpha.2.tgz#d824f8045ba362c4ac91798b70239064a3aca98c" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.33-alpha.1.tgz#8a1253208a618b439d85977c3879b0184b6487e8"
integrity sha512-XYWfMmxcIHn4xVeub86+9MKrid/EzsvMazoC32kTmkH2DppPTjihqWXyGWhhLzDme7GpZ3/bzXPjbd3rkebFGQ== integrity sha512-BEIJqb9WjAck16rkgtGHlnxANhkK8OXbJLBxu+eB4x7F6tSmMI+T6zsBkGE0ehHmqa6YNzY7OldKLc967mAaLA==
"@budibase/types@^1.1.29-alpha.2":
version "1.1.30"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.30.tgz#89bb0aeea747a890ddd299f68e178d686c9cafdc"
integrity sha512-Gh5zGQ4TWI6HFiJM7684bTgPot2JqHBnR0ReHcBOguIj/U/euUBPInxaa7xTZrLYs++Rbe4gffrqnYmZfEy2sg==
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":
version "0.8.0" version "0.8.0"