Merge branch 'develop' of github.com:Budibase/budibase into cheeks-fixes

This commit is contained in:
Andrew Kingston 2022-08-01 10:29:07 +01:00
commit 04325e1ed4
63 changed files with 951 additions and 504 deletions

View File

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

View File

@ -26,7 +26,7 @@
"build": "lerna run build",
"build:dev": "lerna run prebuild && tsc --build --watch --preserveWatchOutput",
"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:develop": "bash scripts/pro/release.sh develop",
"restore": "yarn run clean && yarn run bootstrap && yarn run build",
@ -85,4 +85,4 @@
"install:pro": "bash scripts/pro/install.sh",
"dep:clean": "yarn clean && yarn bootstrap"
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@ -20,7 +20,7 @@
"test:watch": "jest --watchAll"
},
"dependencies": {
"@budibase/types": "^1.1.29-alpha.1",
"@budibase/types": "1.1.32-alpha.3",
"@techpass/passport-openidconnect": "0.3.2",
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",

View File

@ -50,4 +50,5 @@ exports.getTenantFeatureFlags = tenantId => {
exports.FeatureFlag = {
LICENSING: "LICENSING",
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}`)
}
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) {
console.warn(`bb-warn: ${message}`)
}
export default {
logAlert,
logAlertWithInfo,
logWarn,
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.1.29-alpha.1",
"@budibase/string-templates": "1.1.32-alpha.3",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

@ -115,6 +115,16 @@
class:is-disabled={disabled}
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
{id}
on:click

View File

@ -8,6 +8,7 @@
import Icon from "../../Icon/Icon.svelte"
import StatusLight from "../../StatusLight/StatusLight.svelte"
import Detail from "../../Typography/Detail.svelte"
import Search from "./Search.svelte"
export let primaryLabel = ""
export let primaryValue = null
@ -22,7 +23,6 @@
export let secondaryFieldText = ""
export let secondaryFieldIcon = ""
export let secondaryFieldColour = ""
export let getPrimaryOptionLabel = option => option
export let getPrimaryOptionValue = option => option
export let getPrimaryOptionColour = () => null
export let getPrimaryOptionIcon = () => null
@ -43,17 +43,12 @@
let searchTerm = null
$: groupTitles = Object.keys(primaryOptions)
$: filteredOptions = getFilteredOptions(
primaryOptions,
searchTerm,
getPrimaryOptionLabel
)
let iconData
/*
$: iconData = primaryOptions?.find(x => {
return x.name === primaryFieldText
})
*/
const updateSearch = e => {
dispatch("search", e.detail)
}
const updateValue = newValue => {
if (readonly) {
return
@ -107,16 +102,6 @@
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>
<div
@ -183,6 +168,15 @@
class:auto-width={autoWidth}
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">
{#if placeholderOption}
<li

View File

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

View File

@ -19,9 +19,14 @@ filterTests(["smoke", "all"], () => {
cy.wait(500)
// 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')
cy.get(interact.SPECTRUM_BUTTON).contains("Reset password").click({ force: true })
@ -39,23 +44,14 @@ filterTests(["smoke", "all"], () => {
cy.logoutNoAppGrid()
})
it("should verify Admin Portal", () => {
xit("should verify Admin Portal", () => {
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
// 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')
})
}
// Configure user role
cy.setUserRole("bbuser", "Admin")
bbUserLogin()
// Verify available options for Admin portal
cy.get(".spectrum-SideNav")
cy.get(interact.SPECTRUM_SIDENAV)
.should('contain', 'Apps')
//.and('contain', 'Usage')
.and('contain', 'Users')
@ -72,13 +68,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Development Portal", () => {
// Only Development access should be enabled
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(5).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
cy.setUserRole("bbuser", "Developer")
bbUserLogin()
// Verify available options for Admin portal
@ -99,13 +89,7 @@ filterTests(["smoke", "all"], () => {
it("should verify Standard Portal", () => {
// Development access should be disabled (Admin access is already disabled)
cy.login()
cy.contains("Users").click()
cy.contains("bbuser").click()
cy.wait(500)
cy.get(interact.FIELD).eq(4).within(() => {
cy.get(interact.SPECTRUM_SWITCH_INPUT).click({ force: true })
})
cy.setUserRole("bbuser", "App User")
bbUserLogin()
// Verify Standard Portal

View File

@ -15,25 +15,16 @@ filterTests(["smoke", "all"], () => {
cy.get(interact.SPECTRUM_TABLE).should("contain", "bbuser")
})
it("should confirm basic permission for a New User", () => {
// Basic permission = development & administraton disabled
it("should confirm App User role for a New User", () => {
cy.contains("bbuser").click()
// Confirm development and admin access are disabled
for (let i = 4; i < 6; i++) {
cy.wait(500)
cy.get(interact.FIELD).eq(i).within(() => {
//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")
cy.get(".spectrum-Form-itemField").eq(2).should('contain', 'App User')
// User should not have app access
cy.get(interact.LIST_ITEMS, { timeout: 500 }).should("contain", "No apps")
})
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
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
.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'
cy.get(interact.SPECTRUM_TABLE)
.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
cy.get(interact.FIELD)
.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
cy.get(interact.FIELD)
.eq(4)
@ -175,12 +166,12 @@ filterTests(["smoke", "all"], () => {
it("Should edit user details within user details page", () => {
// 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.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).wait(500).clear().click().type("bb")
})
// 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.get(interact.SPECTRUM_TEXTFIELD_INPUT, { timeout: 1000 }).click().wait(500).clear().type("test")
})
@ -189,16 +180,21 @@ filterTests(["smoke", "all"], () => {
cy.reload()
// 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.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")
})
})
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
cy.get(interact.SPECTRUM_DIALOG_GRID)

View File

@ -19,10 +19,10 @@ filterTests(["smoke", "all"], () => {
cy.contains("Users").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.FIELD).eq(3).within(() => {
cy.get(interact.FIELD).eq(1).within(() => {
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).should('have.value', lname)
})
})

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import filterTests from "../support/filterTests"
const interact = require('../support/interact')
filterTests(["smoke", "all"], () => {
context("Query Level Transformers", () => {
xcontext("Query Level Transformers", () => {
before(() => {
cy.login()
cy.createTestApp()

View File

@ -5,30 +5,31 @@ Cypress.on("uncaught:exception", () => {
// ACCOUNTS & USERS
Cypress.Commands.add("login", (email, password) => {
cy.visit(`${Cypress.config().baseUrl}/builder`, { timeout: 10000 })
cy.wait(2000)
cy.url().then(url => {
if (url.includes("builder/admin")) {
// create admin user
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').first().type("test")
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
cy.contains("Sign in to Budibase").then(() => {
if (email == null) {
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').type("test")
} else {
cy.get("input").first().type(email)
cy.get('input[type="password"]').type(password)
}
cy.get("button").first().click({ force: true })
cy.wait(1000)
})
}
})
cy.url()
.should("include", "/builder/")
.then(url => {
if (url.includes("builder/admin")) {
// create admin user
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').first().type("test")
cy.get('input[type="password"]').eq(1).type("test")
cy.contains("Create super admin user").click({ force: true })
}
if (url.includes("builder/auth") || url.includes("builder/admin")) {
// login
cy.contains("Sign in to Budibase").then(() => {
if (email == null) {
cy.get("input").first().type("test@test.com")
cy.get('input[type="password"]').type("test")
} else {
cy.get("input").first().type(email)
cy.get('input[type="password"]').type(password)
}
cy.get("button").first().click({ force: true })
cy.wait(1000)
})
}
})
})
Cypress.Commands.add("logOut", () => {
@ -50,23 +51,36 @@ Cypress.Commands.add("logoutNoAppGrid", () => {
cy.wait(2000)
})
Cypress.Commands.add("createUser", email => {
// quick hacky recorded way to create a user
Cypress.Commands.add("createUser", (email, permission) => {
cy.contains("Users").click()
cy.get(`[data-cy="add-user"]`).click()
cy.get(".spectrum-Dialog-grid").within(() => {
cy.get(".spectrum-Picker-label").click()
cy.get(
".spectrum-Menu-item:nth-child(2) > .spectrum-Menu-itemLabel"
).click()
// Enter email
cy.get(".spectrum-Textfield-input").clear().click().type(email)
// Onboarding type selector
cy.get(".spectrum-Textfield-input")
.eq(0)
.first()
.type(email, { force: true })
cy.get(".spectrum-Button--cta").click({ force: true })
// Select permission, if applicable
// Default is App User
if (permission != null) {
cy.get(".spectrum-Picker-label").click()
cy.get(".spectrum-Menu").within(() => {
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 => {
@ -74,18 +88,13 @@ Cypress.Commands.add("deleteUser", email => {
cy.contains("Users", { timeout: 2000 }).click()
cy.contains(email).click()
// Click Delete user button
cy.get(".spectrum-Button")
.contains("Delete user")
.click({ force: true })
.then(() => {
// Confirm deletion within modal
cy.get(".spectrum-Dialog-grid", { timeout: 500 }).within(() => {
cy.get(".spectrum-Button")
.contains("Delete user")
.click({ force: true })
})
})
cy.get(".title").within(() => {
cy.get(".spectrum-Icon").click({ force: true })
})
cy.get(".spectrum-Menu").within(() => {
cy.get(".spectrum-Menu-item").contains("Delete").click({ force: true })
})
cy.get(".spectrum-Dialog-grid").contains("Delete user").click({ force: true })
})
Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
@ -120,9 +129,27 @@ Cypress.Commands.add("updateUserInformation", (firstName, lastName) => {
.blur()
}
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
Cypress.Commands.add("createTestApp", () => {
const appName = "Cypress Tests"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,6 +45,7 @@
},
])
}
if (admin) {
menu = menu.concat([
{
@ -52,11 +53,6 @@
href: "/builder/portal/manage/users",
heading: "Manage",
},
{
title: "User Groups",
href: "/builder/portal/manage/groups",
},
{ title: "Auth", href: "/builder/portal/manage/auth" },
{ 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(1, 0, item)
}
if (!$adminStore.cloud) {
menu = menu.concat([
{

View File

@ -41,6 +41,11 @@
let allAppList = []
let user
$: fetchUser(userId)
$: fullName = $userFetch?.data?.firstName
? $userFetch?.data?.firstName + " " + $userFetch?.data?.lastName
: ""
$: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS
)
@ -161,7 +166,7 @@
if (detail === "developer") {
toggleFlags({ admin: { global: false }, builder: { global: true } })
} else if (detail === "admin") {
toggleFlags({ admin: { global: true }, builder: { global: false } })
toggleFlags({ admin: { global: true }, builder: { global: true } })
} else if (detail === "appUser") {
toggleFlags({ admin: { global: false }, builder: { global: false } })
}

View File

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

View File

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

View File

@ -72,19 +72,12 @@
name: {},
email: {},
role: {
noPropagation: true,
sortable: false,
},
...(hasGroupsLicense && {
userGroups: { sortable: false, displayName: "User groups" },
}),
apps: { width: "120px" },
settings: {
sortable: false,
width: "60px",
displayName: "",
align: "Right",
},
apps: {},
}
$: userData = []
@ -323,6 +316,13 @@
</Modal>
<style>
.pagination {
display: flex;
flex-direction: row;
justify-content: flex-end;
margin-top: var(--spacing-xl);
}
.field {
display: flex;
align-items: center;

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
export let app
export let deployments
export let navigateTab
let userCount
const dispatch = createEventDispatcher()
const unpublishApp = () => {
@ -40,7 +40,9 @@
}
onMount(async () => {
await users.search({ page: undefined, appId: "app_" + app.appId })
let resp = await users.getUserCountByApp({ appId: "app_" + app.appId })
userCount = resp.userCount
await users.search({ appId: "app_" + app.appId, limit: 4 })
})
</script>
@ -155,7 +157,8 @@
</div>
<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>
</Layout>
{:else}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.1.29-alpha.1",
"@budibase/frontend-core": "^1.1.29-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.1",
"@budibase/bbui": "1.1.32-alpha.3",
"@budibase/frontend-core": "1.1.32-alpha.3",
"@budibase/string-templates": "1.1.32-alpha.3",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "^1.1.29-alpha.1",
"@budibase/bbui": "1.1.32-alpha.3",
"lodash": "^4.17.21",
"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 { OperatorOptions, SqlNumberTypeRangeMap } from "../constants"
const HBS_REGEX = /{{([^{].*?)}}/g
/**
* Returns the valid operator options for a certain data type
* @param type the data type
@ -98,6 +100,8 @@ export const buildLuceneQuery = filter => {
if (Array.isArray(filter)) {
filter.forEach(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
if (type === "datetime") {
// 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 (operator === "oneOf") {
value = value.split(",").map(item => parseFloat(item))
} else {
} else if (!isHbs) {
value = parseFloat(value)
}
}

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/server",
"email": "hi@budibase.com",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"description": "Budibase Web Server",
"main": "src/index.ts",
"repository": {
@ -77,11 +77,11 @@
"license": "GPL-3.0",
"dependencies": {
"@apidevtools/swagger-parser": "10.0.3",
"@budibase/backend-core": "^1.1.29-alpha.1",
"@budibase/client": "^1.1.29-alpha.1",
"@budibase/pro": "1.1.29-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.1",
"@budibase/types": "^1.1.29-alpha.1",
"@budibase/backend-core": "1.1.32-alpha.3",
"@budibase/client": "1.1.32-alpha.3",
"@budibase/pro": "1.1.32-alpha.3",
"@budibase/string-templates": "1.1.32-alpha.3",
"@budibase/types": "1.1.32-alpha.3",
"@bull-board/api": "3.7.0",
"@bull-board/koa": "3.9.4",
"@elastic/elasticsearch": "7.10.0",

View File

@ -5,7 +5,11 @@ import {
getDevelopmentAppID,
} from "@budibase/backend-core/db"
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 {
getAppId,
@ -80,6 +84,7 @@ async function initDeployedApp(prodAppId: any) {
})
)
).rows.map((row: any) => row.doc)
await clearMetadata()
console.log("You have " + automations.length + " automations")
const promises = []
console.log("Disabling prod crons..")

View File

@ -82,6 +82,27 @@ async function getTable(appId, tableId) {
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 }) {
const { tableId, filters, sortColumn, sortOrder, limit } = inputs
const table = await getTable(appId, tableId)
@ -99,7 +120,7 @@ exports.run = async function ({ inputs, appId }) {
sortType,
limit,
sort: sortColumn,
query: filters || {},
query: typeCoercion(filters || {}, table),
// default to ascending, like data tab
sortOrder: sortOrder || SortOrders.ASCENDING,
},

View File

@ -31,15 +31,21 @@ exports.definition = {
type: "boolean",
description: "Whether the action was successful",
},
message: {
type: "string",
description: "What was output",
},
},
required: ["success"],
required: ["success", "message"],
},
},
}
exports.run = async function ({ inputs, appId }) {
console.log(`App ${appId} - ${inputs.text}`)
const message = `App ${appId} - ${inputs.text}`
console.log(message)
return {
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 () => {
await triggers.externalTrigger(basicAutomation(), { a: 1 })
await wait(100)
expect(thread).toHaveBeenCalled()
expect(thread.execute).toHaveBeenCalled()
})
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)
expect(thread).toHaveBeenCalledWith(makePartial({
expect(thread.execute).toHaveBeenCalledWith(makePartial({
data: {
event: {
fields: {

View File

@ -6,10 +6,16 @@ import newid from "../db/newid"
import { updateEntityMetadata } from "../utilities"
import { MetadataTypes, WebhookType } from "../constants"
import { getProdAppID, doWithDB } from "@budibase/backend-core/db"
import { getAutomationMetadataParams } from "../db/utils"
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 { quotas } from "@budibase/pro"
import { Automation } from "@budibase/types"
const WH_STEP_ID = definitions.WEBHOOK.stepId
const CRON_STEP_ID = definitions.CRON.stepId
@ -82,6 +88,26 @@ export async function disableAllCrons(appId: any) {
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.
* @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) {
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",
}
exports.LoopStepTypes = {
ARRAY: "Array",
STRING: "String",
}
// pass through the list from the auth/core lib
exports.ObjectStoreBuckets = ObjectStoreBuckets
exports.MAX_AUTOMATION_RECURRING_ERRORS = 5

View File

@ -41,6 +41,7 @@ const DocumentTypes = {
METADATA: "metadata",
MEM_VIEW: "view",
USER_FLAG: "flag",
AUTOMATION_METADATA: "meta_au",
}
const InternalTables = {
@ -311,6 +312,21 @@ exports.generateQueryID = datasourceId => {
}${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.
*/

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()
const actions = require("../automations/actions")
const automationUtils = require("../automations/automationUtils")
const AutomationEmitter = require("../events/AutomationEmitter")
const { processObject } = require("@budibase/string-templates")
const { DocumentTypes } = require("../db/utils")
const { definitions: triggerDefs } = require("../automations/triggerInfo")
import { default as threadUtils } from "./utils"
threadUtils.threadSetup()
import { isRecurring, disableCron, isErrorInOutput } from "../automations/utils"
import { default as actions } from "../automations/actions"
import { default as automationUtils } from "../automations/automationUtils"
import { default as AutomationEmitter } from "../events/AutomationEmitter"
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 { AutomationErrors, LoopStepTypes } = require("../constants")
const { storeLog } = require("../automations/logging")
const { logAlertWithInfo, logWarn } = require("@budibase/backend-core/logging")
const { processObject } = require("@budibase/string-templates")
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.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 env = require("../environment")
function typecastForLooping(loopStep, input) {
function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
if (!input || !input.binding) {
return null
}
const isArray = Array.isArray(input.binding),
isString = typeof input.binding === "string"
try {
switch (loopStep.inputs.option) {
case LoopStepTypes.ARRAY:
if (isString) {
if (typeof input.binding === "string") {
return JSON.parse(input.binding)
}
break
case LoopStepTypes.STRING:
if (isArray) {
if (Array.isArray(input.binding)) {
return input.binding.join(",")
}
break
@ -41,7 +52,7 @@ function typecastForLooping(loopStep, input) {
return input.binding
}
function getLoopIterations(loopStep, input) {
function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
const binding = typecastForLooping(loopStep, input)
if (!loopStep || !binding) {
return 1
@ -57,11 +68,24 @@ function getLoopIterations(loopStep, input) {
* inputs and handles any outputs.
*/
class Orchestrator {
constructor(automation, triggerOutput = {}) {
this._metadata = triggerOutput.metadata
this._chainCount = this._metadata ? this._metadata.automationChainCount : 0
this._appId = triggerOutput.appId
this._app = null
_chainCount: number
_appId: string
_automation: Automation
_emitter: any
_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
triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput)
// remove from context
@ -79,14 +103,14 @@ class Orchestrator {
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput)
}
cleanupTriggerOutputs(stepId, triggerOutput) {
cleanupTriggerOutputs(stepId: string, triggerOutput: TriggerOutput) {
if (stepId === CRON_STEP_ID) {
triggerOutput.timestamp = Date.now()
}
return triggerOutput
}
async getStepFunctionality(stepId) {
async getStepFunctionality(stepId: string) {
let step = await actions.getAction(stepId)
if (step == null) {
throw `Cannot find automation step by name ${stepId}`
@ -94,25 +118,107 @@ class Orchestrator {
return step
}
async getApp() {
if (this._app) {
return this._app
}
async getMetadata(): Promise<AutomationMetadata> {
const metadataId = generateAutomationMetadataID(this._automation._id)
const db = getAppDB()
this._app = await db.get(DocumentTypes.APP_METADATA)
return this._app
let metadata: AutomationMetadata
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 }
// 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)
if (this.executionOutput.steps.length === 0) {
if (
this.executionOutput.steps.length === 0 ||
this.executionOutput.trigger.id === id
) {
this.executionOutput.trigger = 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, {
id: step.id,
stepId: step.stepId,
@ -133,11 +239,22 @@ class Orchestrator {
async execute() {
let automation = this._automation
let stopped = false
let loopStep = null
let loopStep: AutomationStep | undefined = undefined
let stepCount = 0
let loopStepNumber = null
let loopSteps = []
let loopStepNumber: any = undefined
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) {
stepCount++
let input,
@ -151,7 +268,7 @@ class Orchestrator {
if (loopStep) {
input = await processObject(loopStep.inputs, this._context)
iterations = getLoopIterations(loopStep, input)
iterations = getLoopIterations(loopStep as LoopStep, input)
}
for (let index = 0; index < iterations; index++) {
@ -166,14 +283,17 @@ class Orchestrator {
let tempOutput = { items: loopSteps, iterations: iterationCount }
try {
newInput.binding = typecastForLooping(loopStep, newInput)
newInput.binding = typecastForLooping(
loopStep as LoopStep,
newInput
)
} catch (err) {
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
status: AutomationErrors.INCORRECT_TYPE,
success: false,
})
loopSteps = null
loopStep = null
loopSteps = undefined
loopStep = undefined
break
}
@ -223,8 +343,8 @@ class Orchestrator {
status: AutomationErrors.MAX_ITERATIONS,
success: true,
})
loopSteps = null
loopStep = null
loopSteps = undefined
loopStep = undefined
break
}
@ -232,7 +352,7 @@ class Orchestrator {
const currentItem = this._context.steps[loopStepNumber]?.currentItem
if (currentItem && typeof currentItem === "object") {
isFailure = Object.keys(currentItem).some(value => {
return currentItem[value] === loopStep.inputs.failure
return currentItem[value] === loopStep?.inputs.failure
})
} else {
isFailure = currentItem && currentItem === loopStep.inputs.failure
@ -243,8 +363,8 @@ class Orchestrator {
status: AutomationErrors.FAILURE_CONDITION,
success: false,
})
loopSteps = null
loopStep = null
loopSteps = undefined
loopStep = undefined
break
}
}
@ -295,7 +415,7 @@ class Orchestrator {
if (loopStep) {
iterationCount++
if (index === iterations - 1) {
loopStep = null
loopStep = undefined
this._context.steps.splice(loopStepNumber, 1)
break
}
@ -316,22 +436,26 @@ class Orchestrator {
})
this._context.steps.splice(loopStepNumber, 0, tempOutput)
loopSteps = null
loopSteps = undefined
}
}
// store the logs for the automation run
await storeLog(this._automation, this.executionOutput)
if (isProdAppID(this._appId) && isRecurring(automation) && metadata) {
await this.updateMetadata(metadata)
}
return this.executionOutput
}
}
module.exports = (input, callback) => {
export function execute(input: AutomationEvent, callback: WorkerCallback) {
const appId = input.data.event.appId
doInAppContext(appId, async () => {
const automationOrchestrator = new Orchestrator(
input.data.automation,
input.data.event
input.data.event,
input.opts
)
try {
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:
throw "Unknown thread type"
}
// have to use require here, to make it work with worker-farm
return require.resolve(filename)
}
export class Thread {
type: any
count: any
disableThreading: any
workers: any
timeoutMs: any
disableThreading: boolean
static workerRefs: any[] = []
constructor(type: any, opts: any = { timeoutMs: null, count: 1 }) {
this.type = type
this.count = opts.count ? opts.count : 1
this.disableThreading =
env.isTest() ||
env.DISABLE_THREADING ||
this.count === 0 ||
env.isInThread()
this.disableThreading = this.shouldDisableThreading()
if (!this.disableThreading) {
const workerOpts: any = {
autoStart: true,
@ -47,33 +44,44 @@ export class Thread {
this.timeoutMs = opts.timeoutMs
workerOpts.maxCallTime = opts.timeoutMs
}
this.workers = workerFarm(workerOpts, typeToFile(type))
this.workers = workerFarm(workerOpts, typeToFile(type), ["execute"])
Thread.workerRefs.push(this.workers)
}
}
shouldDisableThreading(): boolean {
return !!(
env.isTest() ||
env.DISABLE_THREADING ||
this.count === 0 ||
env.isInThread()
)
}
run(data: any) {
const timeout = this.timeoutMs
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 (this.disableThreading) {
fncToCall = require(typeToFile(this.type))
import(typeToFile(this.type)).then((thread: any) => {
fire(thread)
})
} 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()
import { WorkerCallback, QueryEvent, QueryVariable } from "./definitions"
const ScriptRunner = require("../utilities/scriptRunner")
const { integrations } = require("../integrations")
const { processStringSync } = require("@budibase/string-templates")
@ -19,7 +20,22 @@ const {
} = require("../integrations/queries/sql")
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.queryVerb = input.queryVerb
this.fields = input.fields
@ -37,9 +53,10 @@ class QueryRunner {
this.queryResponse = {}
this.hasRerun = false
this.hasRefreshedOAuth = false
this.hasDynamicVariables = false
}
async execute() {
async execute(): Promise<any> {
let { datasource, fields, queryVerb, transformer } = this
let datasourceClone = cloneDeep(datasource)
@ -52,7 +69,7 @@ class QueryRunner {
if (datasourceClone.config.authConfigs) {
datasourceClone.config.authConfigs =
datasourceClone.config.authConfigs.map(config => {
datasourceClone.config.authConfigs.map((config: any) => {
return enrichQueryFields(config, this.ctx)
})
}
@ -138,8 +155,8 @@ class QueryRunner {
}
// map into JSON if just raw primitive here
if (rows.find(row => typeof row !== "object")) {
rows = rows.map(value => ({ value }))
if (rows.find((row: any) => typeof row !== "object")) {
rows = rows.map((value: any) => ({ value }))
}
// get all the potential fields in the schema
@ -152,7 +169,7 @@ class QueryRunner {
return { rows, keys, info, extra, pagination }
}
async runAnotherQuery(queryId, parameters) {
async runAnotherQuery(queryId: string, parameters: any) {
const db = getAppDB()
const query = await db.get(queryId)
const datasource = await db.get(query.datasourceId)
@ -163,12 +180,13 @@ class QueryRunner {
fields: query.fields,
parameters,
transformer: query.transformer,
queryId,
},
{ noRecursiveQuery: true }
).execute()
}
async refreshOAuth2(ctx) {
async refreshOAuth2(ctx: any) {
const { oauth2, providerType, _id } = ctx.user
const { configId } = ctx.auth
@ -200,7 +218,7 @@ class QueryRunner {
return resp
}
async getDynamicVariable(variable) {
async getDynamicVariable(variable: QueryVariable) {
let { parameters } = this
const queryId = variable.queryId,
name = variable.name
@ -233,7 +251,7 @@ class QueryRunner {
if (!this.noRecursiveQuery) {
// need to see if this uses any variables
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)
if (variable.queryId === this.queryId) {
return false
@ -242,7 +260,9 @@ class QueryRunner {
const regex = new RegExp(`{{[ ]*${variable.name}[ ]*}}`)
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)
for (let i = 0; i < foundVars.length; 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 () => {
const Runner = new QueryRunner(input)
try {

View File

@ -1,10 +1,11 @@
import { QueryVariable } from "./definitions"
const env = require("../environment")
const db = require("../db")
const redis = require("@budibase/backend-core/redis")
const { SEPARATOR } = require("@budibase/backend-core/db")
const VARIABLE_TTL_SECONDS = 3600
let client
let client: any
async function getClient() {
if (!client) {
@ -14,10 +15,16 @@ async function getClient() {
}
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
if (env.isTest() || env.DISABLE_THREADING) {
return
@ -27,16 +34,15 @@ exports.threadSetup = () => {
db.init()
}
function makeVariableKey(queryId, variable) {
return `${queryId}${SEPARATOR}${variable}`
}
exports.checkCacheForDynamicVariable = async (queryId, variable) => {
export async function checkCacheForDynamicVariable(
queryId: string,
variable: string
) {
const cache = await getClient()
return cache.get(makeVariableKey(queryId, variable))
}
exports.invalidateDynamicVariables = async cachedVars => {
export async function invalidateDynamicVariables(cachedVars: QueryVariable[]) {
const cache = await getClient()
let promises = []
for (let variable of cachedVars) {
@ -47,7 +53,11 @@ exports.invalidateDynamicVariables = async cachedVars => {
await Promise.all(promises)
}
exports.storeDynamicVariable = async (queryId, variable, value) => {
export async function storeDynamicVariable(
queryId: string,
variable: string,
value: any
) {
const cache = await getClient()
await cache.store(
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") {
try {
resp = JSON.parse(resp)
@ -67,7 +77,7 @@ exports.formatResponse = resp => {
return resp
}
exports.hasExtraData = response => {
export function hasExtraData(response: any) {
return (
typeof response === "object" &&
!Array.isArray(response) &&
@ -76,3 +86,12 @@ exports.hasExtraData = response => {
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 (!user.roleId && user.builder && user.builder.global) {
user.roleId = BUILTIN_ROLE_IDS.ADMIN
} else if (!user.roleId) {
} else if (!user.roleId && !user?.userGroups?.length) {
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
} else if (user?.userGroups?.length) {
user.roleId = null
}
delete user.roles
@ -41,10 +43,8 @@ exports.updateAppRole = (user, { appId } = {}) => {
}
async function checkGroupRoles(user, { appId } = {}) {
if (!user.roleId) {
let roleId = await groups.getGroupRoleId(user, appId)
user.roleId = roleId
}
let roleId = await groups.getGroupRoleId(user, appId)
user.roleId = roleId
return user
}
@ -54,7 +54,7 @@ async function processUser(user, { appId } = {}) {
delete user.password
}
user = await exports.updateAppRole(user, { appId })
if (user?.userGroups?.length) {
if (!user.roleId && user?.userGroups?.length) {
user = await checkGroupRoles(user, { appId })
}

View File

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

View File

@ -156,9 +156,9 @@
adal-node "^0.2.2"
"@azure/storage-blob@^12.5.0":
version "12.11.0"
resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.11.0.tgz#2e27902ab293715411ab1f7c8fae422ad0b4b827"
integrity sha512-na+FisoARuaOWaHWpmdtk3FeuTWf2VWamdJ9/TJJzj5ZdXPLC3juoDgFs6XVuJIoK30yuBpyFBEDXVRK4pB7Tg==
version "12.10.0"
resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.10.0.tgz#b92269f45a1765700a900b41ca81a474a6e36ea4"
integrity sha512-FBEPKGnvtQJS8V8Tg1P9obgmVD9AodrIfwtwhBpsjenClhFyugMp3HPJY0tF7rInUB/CivKBCbnQKrUnKxqxzw==
dependencies:
"@azure/abort-controller" "^1.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"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.29-alpha.1.tgz#0940fa58c7d41d254a4f048854f4600ba684ea27"
integrity sha512-pJbg1wWFWBsMZwHDSyykr/9QagoK9wycgviTZjzJDwdGsQn/HpQYM1Brz3MhTKoMbnP3C39DwhUORMMrT9ch5Q==
"@budibase/backend-core@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.32-alpha.3.tgz#ac4bb5d3b45619d9fc7ada6ebbf68ac4d1f91593"
integrity sha512-utNS+tvvPIrMxIn8X2aetDEtrcdVjza/5gnSJVGWYJKQPlzxjKnQ7v0j+ZZ36x2+2DZWwYa/7THfqOR9kQY7AQ==
dependencies:
"@budibase/types" "^1.1.29-alpha.1"
"@budibase/types" "1.1.32-alpha.3"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1177,13 +1177,13 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.29-alpha.1.tgz#df07cd31cac8439a924c1308f9a4fe22495e96b5"
integrity sha512-xBTnHvZV57AnekseGMjUMf3vq1TUd8o/iCQsnKNgYwj1Ie7alvJ1CscHnjylDULP6uqeOwvtoTJ4FyoaExx9fw==
"@budibase/pro@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.32-alpha.3.tgz#e40be7020d100349e7889e09f072e31332b9c43a"
integrity sha512-+4C1DWCmlIC5VCvymhbwHEgkTxghEo+iVdhH0Cc+HOxdDMfd4HSTTstqKEeGG1VxenbeWiSwIY2pUNab26QA7w==
dependencies:
"@budibase/backend-core" "1.1.29-alpha.1"
"@budibase/types" "1.1.29-alpha.1"
"@budibase/backend-core" "1.1.32-alpha.3"
"@budibase/types" "1.1.32-alpha.3"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
@ -1206,10 +1206,10 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@1.1.29-alpha.1", "@budibase/types@^1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.29-alpha.1.tgz#8141a6d44176b3dfd53d216640ab7f460fd96e75"
integrity sha512-e/6Pd1NA80y9vszYADy2NBTl3QMNpcpOoe5+CBfSomnR2GL0FPyJp9jBj9Nr0G88wDiXe5tvwMZsgY+hkLdvJQ==
"@budibase/types@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.32-alpha.3.tgz#f31e01311b99c33b1993fa0adcfbfbcc29c03a35"
integrity sha512-Alm1gtbWmvSu8DR+CHwbDq0KDpiXCR+COvsmBOjQ/H5r8Afgk+qkDiiEd9cjJ/TRJYBU1K+mt3mv5ZmNpzi5yg==
"@bull-board/api@3.7.0":
version "3.7.0"
@ -1959,24 +1959,29 @@
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/gen-mapping@^0.3.0":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz#cf92a983c83466b8c0ce9124fadeaf09f7c66ea9"
integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg==
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==
dependencies:
"@jridgewell/set-array" "^1.0.0"
"@jridgewell/set-array" "^1.0.1"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/resolve-uri@^3.0.3":
version "3.0.7"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz#30cd49820a962aff48c8fffc5cd760151fca61fe"
integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA==
version "3.1.0"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==
"@jridgewell/set-array@^1.0.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea"
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":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb"
@ -1986,11 +1991,11 @@
"@jridgewell/trace-mapping" "^0.3.9"
"@jridgewell/sourcemap-codec@^1.4.10":
version "1.4.13"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c"
integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==
version "1.4.14"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
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"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea"
integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w==
@ -1998,6 +2003,14 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@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":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@jsdevtools/ono/-/ono-7.1.3.tgz#9df03bbd7c696a5c58885c34aa06da41c8543796"
@ -2842,7 +2855,7 @@
"@types/bson" "*"
"@types/node" "*"
"@types/node-fetch@2.6.1":
"@types/node-fetch@2.6.1", "@types/node-fetch@^2.5.0":
version "2.6.1"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.1.tgz#8f127c50481db65886800ef496f20bbf15518975"
integrity sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==
@ -2850,14 +2863,6 @@
"@types/node" "*"
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":
version "17.0.41"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.41.tgz#1607b2fd3da014ae5d4d1b31bc792a39348dfb9b"
@ -3726,11 +3731,6 @@ atomic-sleep@^1.0.0:
resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b"
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:
version "2.1030.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1030.0.tgz#24a856af3d2b8b37c14a8f59974993661c66fd82"
@ -3747,9 +3747,9 @@ aws-sdk@2.1030.0:
xml2js "0.4.19"
aws-sdk@^2.878.0:
version "2.1174.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1174.0.tgz#3e2acb1ee29229cc5d97015b2d1a18c41e967979"
integrity sha512-t/Cwbdunmoj3WAI+u+hw/kr6mla1sYCn+VncxxIjkACStA47+ZTsfd7cQfpoVMit5KubkHaJ3SHX4/qvmt0Jfg==
version "2.1152.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1152.0.tgz#73e4fb81b3a9c289234b5d6848bcdb854f169bdf"
integrity sha512-Lqwk0bDhm3vzpYb3AAM9VgGHeDpbB8+o7UJnP9R+CO23kJfi/XRpKihAcbyKDD/AUQ+O1LJaUVpvaJYLS9Am7w==
dependencies:
buffer "4.9.2"
events "1.1.1"
@ -3758,7 +3758,6 @@ aws-sdk@^2.878.0:
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
util "^0.12.4"
uuid "8.0.0"
xml2js "0.4.19"
@ -5499,7 +5498,7 @@ error-inject@^1.0.0:
resolved "https://registry.yarnpkg.com/error-inject/-/error-inject-1.0.0.tgz#e2b3d91b54aed672f309d950d154850fa11d4f37"
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"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.1.tgz#027292cd6ef44bd12b1913b828116f54787d1814"
integrity sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==
@ -7449,14 +7448,6 @@ is-accessor-descriptor@^1.0.0:
dependencies:
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:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@ -7763,17 +7754,6 @@ is-type-of@^1.0.0:
is-class-hotfix "~0.0.6"
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:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
@ -9969,16 +9949,11 @@ moment-timezone@^0.5.15, moment-timezone@^0.5.31:
dependencies:
moment ">= 2.9.0"
"moment@>= 2.9.0":
"moment@>= 2.9.0", moment@^2.29.3:
version "2.29.3"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
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:
version "3.6.3"
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.3.tgz#eddaed0cc3598474d7a15f0f2a5b04848489fd05"
@ -12312,7 +12287,7 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
simple-lru-cache@^0.0.2:
version "0.0.2"
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:
version "0.2.2"
@ -12383,9 +12358,9 @@ snowflake-promise@^4.5.0:
snowflake-sdk "^1.6.0"
snowflake-sdk@^1.6.0:
version "1.6.11"
resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.11.tgz#2797c816d0d2af6d56180949e1364e53df8a9c13"
integrity sha512-w4oCXjNQ1peAJjhnrwihr+epYw1pSxbe5/+PdxexYb2rzowyOn0RA5PFbir90q/dx0jzM2gvPiHDjnSBEZ1/zA==
version "1.6.10"
resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.10.tgz#c6c4f267edbc50d3c1ef6fcc2651188bb8545dce"
integrity sha512-kguQQSGhmNqZfmN/yZNDaIaMMktTcrTYBjtyx+szJzV69b5F+5b77btpYp+bCFqao69otVM+IPUtb3sugvCVnQ==
dependencies:
"@azure/storage-blob" "^12.5.0"
"@techteamer/ocsp" "1.0.0"
@ -13129,9 +13104,9 @@ terser-webpack-plugin@^5.1.3:
terser "^5.7.2"
terser@^5.7.2:
version "5.14.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.0.tgz#eefeec9af5153f55798180ee2617f390bdd285e2"
integrity sha512-JC6qfIEkPBd9j1SMO3Pfn+A6w2kQV54tv+ABQLgZr7dA3k/DL/OBoYSWxzVpZev3J+bUHXfr55L8Mox7AaNo6g==
version "5.14.2"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10"
integrity sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==
dependencies:
"@jridgewell/source-map" "^0.3.2"
acorn "^8.5.0"
@ -13771,18 +13746,6 @@ util.promisify@^1.0.0, util.promisify@^1.0.1:
has-symbols "^1.0.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:
version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
@ -14066,18 +14029,6 @@ which-module@^2.0.0:
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
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:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
@ -14120,23 +14071,7 @@ winston-transport@^4.5.0:
readable-stream "^3.6.0"
triple-beam "^1.3.0"
winston@^3.1.0:
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:
winston@^3.1.0, winston@^3.3.3:
version "3.7.2"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.7.2.tgz#95b4eeddbec902b3db1424932ac634f887c400b1"
integrity sha512-QziIqtojHBoyzUOdQvQiar1DH0Xp9nF1A1y7NVy2DGEsz82SBDtOalS0ulTRGVT14xPX3WRWkCsdcJKqNflKng==

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/types",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"description": "Budibase types",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

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

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.1.29-alpha.1",
"version": "1.1.32-alpha.3",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -35,10 +35,10 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.1.29-alpha.1",
"@budibase/pro": "1.1.29-alpha.1",
"@budibase/string-templates": "^1.1.29-alpha.1",
"@budibase/types": "^1.1.29-alpha.1",
"@budibase/backend-core": "1.1.32-alpha.3",
"@budibase/pro": "1.1.32-alpha.3",
"@budibase/string-templates": "1.1.32-alpha.3",
"@budibase/types": "1.1.32-alpha.3",
"@koa/router": "8.0.8",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "0.3.2",

View File

@ -3,7 +3,7 @@ import { checkInviteCode } from "../../../utilities/redis"
import { sendEmail } from "../../../utilities/email"
import { users } from "../../../sdk"
import env from "../../../environment"
import { User, CloudAccount, UserGroup } from "@budibase/types"
import { User, CloudAccount } from "@budibase/types"
import {
events,
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) => {
const id = ctx.params.id

View File

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

View File

@ -20,7 +20,7 @@ import { groups as groupUtils } from "@budibase/pro"
const PAGE_LIMIT = 8
export const allUsers = async (newDb?: any) => {
export const allUsers = async () => {
const db = tenancy.getGlobalDB()
const response = await db.allDocs(
dbUtils.getGlobalUserParams(null, {
@ -30,6 +30,13 @@ export const allUsers = async (newDb?: any) => {
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 ({
page,
email,

View File

@ -291,12 +291,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.29-alpha.1.tgz#0940fa58c7d41d254a4f048854f4600ba684ea27"
integrity sha512-pJbg1wWFWBsMZwHDSyykr/9QagoK9wycgviTZjzJDwdGsQn/HpQYM1Brz3MhTKoMbnP3C39DwhUORMMrT9ch5Q==
"@budibase/backend-core@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.32-alpha.3.tgz#ac4bb5d3b45619d9fc7ada6ebbf68ac4d1f91593"
integrity sha512-utNS+tvvPIrMxIn8X2aetDEtrcdVjza/5gnSJVGWYJKQPlzxjKnQ7v0j+ZZ36x2+2DZWwYa/7THfqOR9kQY7AQ==
dependencies:
"@budibase/types" "^1.1.29-alpha.1"
"@budibase/types" "1.1.32-alpha.3"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -324,21 +324,21 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.29-alpha.1.tgz#df07cd31cac8439a924c1308f9a4fe22495e96b5"
integrity sha512-xBTnHvZV57AnekseGMjUMf3vq1TUd8o/iCQsnKNgYwj1Ie7alvJ1CscHnjylDULP6uqeOwvtoTJ4FyoaExx9fw==
"@budibase/pro@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.32-alpha.3.tgz#e40be7020d100349e7889e09f072e31332b9c43a"
integrity sha512-+4C1DWCmlIC5VCvymhbwHEgkTxghEo+iVdhH0Cc+HOxdDMfd4HSTTstqKEeGG1VxenbeWiSwIY2pUNab26QA7w==
dependencies:
"@budibase/backend-core" "1.1.29-alpha.1"
"@budibase/types" "1.1.29-alpha.1"
"@budibase/backend-core" "1.1.32-alpha.3"
"@budibase/types" "1.1.32-alpha.3"
"@koa/router" "8.0.8"
joi "17.6.0"
node-fetch "^2.6.1"
"@budibase/types@1.1.29-alpha.1", "@budibase/types@^1.1.29-alpha.1":
version "1.1.29-alpha.1"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.29-alpha.1.tgz#8141a6d44176b3dfd53d216640ab7f460fd96e75"
integrity sha512-e/6Pd1NA80y9vszYADy2NBTl3QMNpcpOoe5+CBfSomnR2GL0FPyJp9jBj9Nr0G88wDiXe5tvwMZsgY+hkLdvJQ==
"@budibase/types@1.1.32-alpha.3":
version "1.1.32-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.32-alpha.3.tgz#f31e01311b99c33b1993fa0adcfbfbcc29c03a35"
integrity sha512-Alm1gtbWmvSu8DR+CHwbDq0KDpiXCR+COvsmBOjQ/H5r8Afgk+qkDiiEd9cjJ/TRJYBU1K+mt3mv5ZmNpzi5yg==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"