@budibase/server 1.1.29 → 1.1.32-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/index.55714cd6.js +977 -0
- package/builder/assets/{index.2b959037.css → index.aa03d5f4.css} +2 -2
- package/builder/assets/{vendor.162098da.js → vendor.6bcafa60.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +407 -711
- package/coverage/coverage-final.json +15 -18
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +2 -2
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +18 -18
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +94 -49
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +2 -2
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +17 -17
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +5 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +25 -25
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +73 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +27 -9
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +5 -14
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +61 -13
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +66 -81
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +21 -21
- package/coverage/lcov-report/middleware/joi-validator.js.html +43 -43
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +67 -13
- package/coverage/lcov-report/utilities/index.html +20 -20
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +26 -14
- package/coverage/lcov-report/utilities/queue/index.html +17 -17
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +747 -1245
- package/dist/api/controllers/deploy/index.js +1 -0
- package/dist/api/controllers/query/index.js +1 -1
- package/dist/api/controllers/query/validation.js +1 -1
- package/dist/api/controllers/row/internalSearch.js +30 -16
- package/dist/api/routes/utils/validators.js +1 -1
- package/dist/automations/steps/queryRows.js +21 -1
- package/dist/automations/steps/serverLog.js +8 -2
- package/dist/automations/utils.js +47 -1
- package/dist/constants/index.js +1 -4
- package/dist/db/utils.js +14 -1
- package/dist/definitions/automations.js +8 -0
- package/dist/integrations/base/sql.js +43 -14
- package/dist/package.json +8 -8
- package/dist/threads/automation.js +147 -54
- package/dist/threads/definitions.js +2 -0
- package/dist/threads/index.js +27 -20
- package/dist/threads/query.js +23 -15
- package/dist/threads/utils.js +47 -24
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/global.js +21 -4
- package/dist/utilities/queue/inMemoryQueue.js +5 -0
- package/package.json +9 -9
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/query/index.ts +1 -1
- package/src/api/controllers/query/validation.js +1 -1
- package/src/api/controllers/row/internalSearch.js +35 -20
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +1 -1
- package/src/automations/steps/executeQuery.js +1 -0
- package/src/automations/steps/queryRows.js +22 -1
- package/src/automations/steps/serverLog.js +8 -2
- package/src/automations/tests/automation.spec.js +2 -2
- package/src/automations/utils.ts +54 -1
- package/src/constants/index.js +2 -5
- package/src/db/utils.js +16 -0
- package/src/definitions/automations.ts +49 -0
- package/src/definitions/datasource.ts +3 -0
- package/src/integrations/base/sql.ts +44 -13
- package/src/integrations/tests/sql.spec.js +50 -4
- package/src/middleware/tests/currentapp.spec.js +11 -0
- package/src/threads/{automation.js → automation.ts} +172 -48
- package/src/threads/definitions.ts +18 -0
- package/src/threads/index.ts +31 -23
- package/src/threads/{query.js → query.ts} +32 -12
- package/src/threads/{utils.js → utils.ts} +31 -12
- package/src/utilities/global.js +20 -2
- package/src/utilities/queue/inMemoryQueue.js +4 -0
- package/builder/assets/index.f116ac7f.js +0 -978
- package/coverage/lcov-report/threads/automation.js.html +0 -1114
- package/coverage/lcov-report/threads/index.html +0 -146
- package/coverage/lcov-report/threads/query.js.html +0 -916
- package/coverage/lcov-report/threads/utils.js.html +0 -319
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { QueryVariable } from "./definitions"
|
|
1
2
|
const env = require("../environment")
|
|
2
3
|
const db = require("../db")
|
|
3
4
|
const redis = require("@budibase/backend-core/redis")
|
|
4
5
|
const { SEPARATOR } = require("@budibase/backend-core/db")
|
|
5
6
|
|
|
6
7
|
const VARIABLE_TTL_SECONDS = 3600
|
|
7
|
-
let client
|
|
8
|
+
let client: any
|
|
8
9
|
|
|
9
10
|
async function getClient() {
|
|
10
11
|
if (!client) {
|
|
@@ -14,10 +15,16 @@ async function getClient() {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
process.on("exit", async () => {
|
|
17
|
-
if (client)
|
|
18
|
+
if (client) {
|
|
19
|
+
await client.finish()
|
|
20
|
+
}
|
|
18
21
|
})
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
function makeVariableKey(queryId: string, variable: string) {
|
|
24
|
+
return `${queryId}${SEPARATOR}${variable}`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function threadSetup() {
|
|
21
28
|
// don't run this if not threading
|
|
22
29
|
if (env.isTest() || env.DISABLE_THREADING) {
|
|
23
30
|
return
|
|
@@ -27,16 +34,15 @@ exports.threadSetup = () => {
|
|
|
27
34
|
db.init()
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports.checkCacheForDynamicVariable = async (queryId, variable) => {
|
|
37
|
+
export async function checkCacheForDynamicVariable(
|
|
38
|
+
queryId: string,
|
|
39
|
+
variable: string
|
|
40
|
+
) {
|
|
35
41
|
const cache = await getClient()
|
|
36
42
|
return cache.get(makeVariableKey(queryId, variable))
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
export async function invalidateDynamicVariables(cachedVars: QueryVariable[]) {
|
|
40
46
|
const cache = await getClient()
|
|
41
47
|
let promises = []
|
|
42
48
|
for (let variable of cachedVars) {
|
|
@@ -47,7 +53,11 @@ exports.invalidateDynamicVariables = async cachedVars => {
|
|
|
47
53
|
await Promise.all(promises)
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
export async function storeDynamicVariable(
|
|
57
|
+
queryId: string,
|
|
58
|
+
variable: string,
|
|
59
|
+
value: any
|
|
60
|
+
) {
|
|
51
61
|
const cache = await getClient()
|
|
52
62
|
await cache.store(
|
|
53
63
|
makeVariableKey(queryId, variable),
|
|
@@ -56,7 +66,7 @@ exports.storeDynamicVariable = async (queryId, variable, value) => {
|
|
|
56
66
|
)
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
|
|
69
|
+
export function formatResponse(resp: any) {
|
|
60
70
|
if (typeof resp === "string") {
|
|
61
71
|
try {
|
|
62
72
|
resp = JSON.parse(resp)
|
|
@@ -67,7 +77,7 @@ exports.formatResponse = resp => {
|
|
|
67
77
|
return resp
|
|
68
78
|
}
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
export function hasExtraData(response: any) {
|
|
71
81
|
return (
|
|
72
82
|
typeof response === "object" &&
|
|
73
83
|
!Array.isArray(response) &&
|
|
@@ -76,3 +86,12 @@ exports.hasExtraData = response => {
|
|
|
76
86
|
response.info != null
|
|
77
87
|
)
|
|
78
88
|
}
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
hasExtraData,
|
|
92
|
+
formatResponse,
|
|
93
|
+
storeDynamicVariable,
|
|
94
|
+
invalidateDynamicVariables,
|
|
95
|
+
checkCacheForDynamicVariable,
|
|
96
|
+
threadSetup,
|
|
97
|
+
}
|
package/src/utilities/global.js
CHANGED
|
@@ -12,9 +12,11 @@ const {
|
|
|
12
12
|
} = require("@budibase/backend-core/tenancy")
|
|
13
13
|
const env = require("../environment")
|
|
14
14
|
const { getAppId } = require("@budibase/backend-core/context")
|
|
15
|
+
const { groups } = require("@budibase/pro")
|
|
15
16
|
|
|
16
17
|
exports.updateAppRole = (user, { appId } = {}) => {
|
|
17
18
|
appId = appId || getAppId()
|
|
19
|
+
|
|
18
20
|
if (!user || !user.roles) {
|
|
19
21
|
return user
|
|
20
22
|
}
|
|
@@ -33,15 +35,30 @@ exports.updateAppRole = (user, { appId } = {}) => {
|
|
|
33
35
|
} else if (!user.roleId) {
|
|
34
36
|
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
delete user.roles
|
|
37
40
|
return user
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
function
|
|
43
|
+
async function checkGroupRoles(user, { appId } = {}) {
|
|
44
|
+
if (!user.roleId) {
|
|
45
|
+
let roleId = await groups.getGroupRoleId(user, appId)
|
|
46
|
+
user.roleId = roleId
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return user
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function processUser(user, { appId } = {}) {
|
|
41
53
|
if (user) {
|
|
42
54
|
delete user.password
|
|
43
55
|
}
|
|
44
|
-
|
|
56
|
+
user = await exports.updateAppRole(user, { appId })
|
|
57
|
+
if (user?.userGroups?.length) {
|
|
58
|
+
user = await checkGroupRoles(user, { appId })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return user
|
|
45
62
|
}
|
|
46
63
|
|
|
47
64
|
exports.getCachedSelf = async (ctx, appId) => {
|
|
@@ -89,6 +106,7 @@ exports.getGlobalUsers = async (users = null) => {
|
|
|
89
106
|
if (!appId) {
|
|
90
107
|
return globalUsers
|
|
91
108
|
}
|
|
109
|
+
|
|
92
110
|
return globalUsers.map(user => exports.updateAppRole(user))
|
|
93
111
|
}
|
|
94
112
|
|