diff --git a/lerna.json b/lerna.json
index cae3496514..7d62e9b7a6 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "version": "1.1.29-alpha.1",
+ "version": "1.1.32-alpha.3",
"npmClient": "yarn",
"packages": [
"packages/*"
diff --git a/package.json b/package.json
index 0c7d3989a2..4c24e0025b 100644
--- a/package.json
+++ b/package.json
@@ -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"
}
-}
+}
\ No newline at end of file
diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json
index a2f005d646..e54e0859b0 100644
--- a/packages/backend-core/package.json
+++ b/packages/backend-core/package.json
@@ -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",
diff --git a/packages/backend-core/src/featureFlags/index.js b/packages/backend-core/src/featureFlags/index.js
index c050cbdfef..103ac4df59 100644
--- a/packages/backend-core/src/featureFlags/index.js
+++ b/packages/backend-core/src/featureFlags/index.js
@@ -50,4 +50,5 @@ exports.getTenantFeatureFlags = tenantId => {
exports.FeatureFlag = {
LICENSING: "LICENSING",
GOOGLE_SHEETS: "GOOGLE_SHEETS",
+ USER_GROUPS: "USER_GROUPS",
}
diff --git a/packages/backend-core/src/logging.ts b/packages/backend-core/src/logging.ts
index 8eda15ac79..3fc79a5fe7 100644
--- a/packages/backend-core/src/logging.ts
+++ b/packages/backend-core/src/logging.ts
@@ -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,
}
diff --git a/packages/bbui/package.json b/packages/bbui/package.json
index 527d823617..ef878d74c6 100644
--- a/packages/bbui/package.json
+++ b/packages/bbui/package.json
@@ -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",
diff --git a/packages/bbui/src/Form/Core/InputDropdown.svelte b/packages/bbui/src/Form/Core/InputDropdown.svelte
index 723b8ba9b1..8865ee3ddc 100644
--- a/packages/bbui/src/Form/Core/InputDropdown.svelte
+++ b/packages/bbui/src/Form/Core/InputDropdown.svelte
@@ -115,6 +115,16 @@
class:is-disabled={disabled}
class:is-focused={focus}
>
+ {#if error}
+
+ {/if}
+
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
- }
+ {#if autocomplete}
+ updateSearch(event)}
+ {disabled}
+ placeholder="Search"
+ />
+ {/if}
+
diff --git a/packages/builder/src/pages/builder/portal/manage/users/index.svelte b/packages/builder/src/pages/builder/portal/manage/users/index.svelte
index 952acaf324..5a6c58aed1 100644
--- a/packages/builder/src/pages/builder/portal/manage/users/index.svelte
+++ b/packages/builder/src/pages/builder/portal/manage/users/index.svelte
@@ -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 @@
diff --git a/packages/builder/src/pages/builder/portal/overview/_components/AssignmentModal.svelte b/packages/builder/src/pages/builder/portal/overview/_components/AssignmentModal.svelte
index d1efcb3ad8..9de1ce98a0 100644
--- a/packages/builder/src/pages/builder/portal/overview/_components/AssignmentModal.svelte
+++ b/packages/builder/src/pages/builder/portal/overview/_components/AssignmentModal.svelte
@@ -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}
>
-
- {#each appData as input, index}
- 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}
-
+ {#each appData as input, index}
+ 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}
diff --git a/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte
index 6693c285ff..3e8e15fb2c 100644
--- a/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte
+++ b/packages/builder/src/pages/builder/portal/overview/_components/OverviewTab.svelte
@@ -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 })
})
@@ -155,7 +157,8 @@
- {$users?.data.length} users have access to this app
+ {userCount}
+ {userCount > 1 ? `users have` : `user has`} access to this app
{:else}
diff --git a/packages/builder/src/stores/portal/users.js b/packages/builder/src/stores/portal/users.js
index 94fdf806e6..490d1bc9f6 100644
--- a/packages/builder/src/stores/portal/users.js
+++ b/packages/builder/src/stores/portal/users.js
@@ -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,
}
}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 3df5fa60bd..76fb84134d 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -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",
diff --git a/packages/client/package.json b/packages/client/package.json
index 75f77334db..ca29a444c1 100644
--- a/packages/client/package.json
+++ b/packages/client/package.json
@@ -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",
diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json
index abf70cc494..f78b8e8992 100644
--- a/packages/frontend-core/package.json
+++ b/packages/frontend-core/package.json
@@ -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"
}
diff --git a/packages/frontend-core/src/api/user.js b/packages/frontend-core/src/api/user.js
index b2ecafdb35..17223a80e6 100644
--- a/packages/frontend-core/src/api/user.js
+++ b/packages/frontend-core/src/api/user.js
@@ -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}`,
+ })
+ },
})
diff --git a/packages/frontend-core/src/utils/lucene.js b/packages/frontend-core/src/utils/lucene.js
index b27296af37..b6699628d1 100644
--- a/packages/frontend-core/src/utils/lucene.js
+++ b/packages/frontend-core/src/utils/lucene.js
@@ -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)
}
}
diff --git a/packages/server/package.json b/packages/server/package.json
index 9275cc55d9..4b239fd7df 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -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",
diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts
index 7c1a093398..e2b66fc936 100644
--- a/packages/server/src/api/controllers/deploy/index.ts
+++ b/packages/server/src/api/controllers/deploy/index.ts
@@ -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..")
diff --git a/packages/server/src/automations/steps/queryRows.js b/packages/server/src/automations/steps/queryRows.js
index b6d1938995..58e7313dd2 100644
--- a/packages/server/src/automations/steps/queryRows.js
+++ b/packages/server/src/automations/steps/queryRows.js
@@ -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,
},
diff --git a/packages/server/src/automations/steps/serverLog.js b/packages/server/src/automations/steps/serverLog.js
index b88a731d56..19bbc36abf 100644
--- a/packages/server/src/automations/steps/serverLog.js
+++ b/packages/server/src/automations/steps/serverLog.js
@@ -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,
}
}
diff --git a/packages/server/src/automations/tests/automation.spec.js b/packages/server/src/automations/tests/automation.spec.js
index e7496fa4b3..168819daa3 100644
--- a/packages/server/src/automations/tests/automation.spec.js
+++ b/packages/server/src/automations/tests/automation.spec.js
@@ -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: {
diff --git a/packages/server/src/automations/utils.ts b/packages/server/src/automations/utils.ts
index 906923b2e9..1799b4d74d 100644
--- a/packages/server/src/automations/utils.ts
+++ b/packages/server/src/automations/utils.ts
@@ -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
+}
diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js
index 3aa5b2fb7b..c002c10f7b 100644
--- a/packages/server/src/constants/index.js
+++ b/packages/server/src/constants/index.js
@@ -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
diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js
index 152b0e9d33..8372040723 100644
--- a/packages/server/src/db/utils.js
+++ b/packages/server/src/db/utils.js
@@ -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.
*/
diff --git a/packages/server/src/definitions/automations.ts b/packages/server/src/definitions/automations.ts
new file mode 100644
index 0000000000..e1ac690bf1
--- /dev/null
+++ b/packages/server/src/definitions/automations.ts
@@ -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
+}
diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.ts
similarity index 61%
rename from packages/server/src/threads/automation.js
rename to packages/server/src/threads/automation.ts
index 8880f0cbcb..0b8d2e89bd 100644
--- a/packages/server/src/threads/automation.js
+++ b/packages/server/src/threads/automation.ts
@@ -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 {
+ 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 {
+ 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()
diff --git a/packages/server/src/threads/definitions.ts b/packages/server/src/threads/definitions.ts
new file mode 100644
index 0000000000..3da69d3640
--- /dev/null
+++ b/packages/server/src/threads/definitions.ts
@@ -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
+}
diff --git a/packages/server/src/threads/index.ts b/packages/server/src/threads/index.ts
index b39224cbb5..f112fdca5e 100644
--- a/packages/server/src/threads/index.ts
+++ b/packages/server/src/threads/index.ts
@@ -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)
- }
- })
})
}
diff --git a/packages/server/src/threads/query.js b/packages/server/src/threads/query.ts
similarity index 87%
rename from packages/server/src/threads/query.js
rename to packages/server/src/threads/query.ts
index 757fdc040b..6b93a00200 100644
--- a/packages/server/src/threads/query.js
+++ b/packages/server/src/threads/query.ts
@@ -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 {
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 {
diff --git a/packages/server/src/threads/utils.js b/packages/server/src/threads/utils.ts
similarity index 65%
rename from packages/server/src/threads/utils.js
rename to packages/server/src/threads/utils.ts
index 77824eba96..a51c861b00 100644
--- a/packages/server/src/threads/utils.js
+++ b/packages/server/src/threads/utils.ts
@@ -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,
+}
diff --git a/packages/server/src/utilities/global.js b/packages/server/src/utilities/global.js
index b277b1aad9..462ef6ba5d 100644
--- a/packages/server/src/utilities/global.js
+++ b/packages/server/src/utilities/global.js
@@ -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 })
}
diff --git a/packages/server/src/utilities/queue/inMemoryQueue.js b/packages/server/src/utilities/queue/inMemoryQueue.js
index 375092609e..620b65cf38 100644
--- a/packages/server/src/utilities/queue/inMemoryQueue.js
+++ b/packages/server/src/utilities/queue/inMemoryQueue.js
@@ -109,6 +109,10 @@ class InMemoryQueue {
async clean() {
return []
}
+
+ async getJob() {
+ return {}
+ }
}
module.exports = InMemoryQueue
diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock
index 7719a48753..c501ced884 100644
--- a/packages/server/yarn.lock
+++ b/packages/server/yarn.lock
@@ -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==
diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json
index 467a6143a2..4d22db4596 100644
--- a/packages/string-templates/package.json
+++ b/packages/string-templates/package.json
@@ -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",
diff --git a/packages/types/package.json b/packages/types/package.json
index f2dbd4ce14..0b7835518e 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -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",
diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts
index 97248ff173..50562461e4 100644
--- a/packages/types/src/documents/app/automation.ts
+++ b/packages/types/src/documents/app/automation.ts
@@ -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
diff --git a/packages/worker/package.json b/packages/worker/package.json
index 8ed7707eb5..9c34f04a75 100644
--- a/packages/worker/package.json
+++ b/packages/worker/package.json
@@ -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",
diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts
index ff630efae8..17e655edb3 100644
--- a/packages/worker/src/api/controllers/global/users.ts
+++ b/packages/worker/src/api/controllers/global/users.ts
@@ -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
diff --git a/packages/worker/src/api/routes/global/users.js b/packages/worker/src/api/routes/global/users.js
index a1aa9fca7f..e62e996443 100644
--- a/packages/worker/src/api/routes/global/users.js
+++ b/packages/worker/src/api/routes/global/users.js
@@ -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",
diff --git a/packages/worker/src/sdk/users/users.ts b/packages/worker/src/sdk/users/users.ts
index 48e4f0db02..ea7f2517e0 100644
--- a/packages/worker/src/sdk/users/users.ts
+++ b/packages/worker/src/sdk/users/users.ts
@@ -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,
diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock
index ae3d3ad90f..b65f68e86b 100644
--- a/packages/worker/yarn.lock
+++ b/packages/worker/yarn.lock
@@ -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"