@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.
Files changed (208) hide show
  1. package/builder/assets/index.55714cd6.js +977 -0
  2. package/builder/assets/{index.2b959037.css → index.aa03d5f4.css} +2 -2
  3. package/builder/assets/{vendor.162098da.js → vendor.6bcafa60.js} +1 -1
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +407 -711
  6. package/coverage/coverage-final.json +15 -18
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +1 -1
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/validation.js.html +2 -2
  23. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/index.html +18 -18
  27. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +94 -49
  29. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
  45. package/coverage/lcov-report/api/index.html +1 -1
  46. package/coverage/lcov-report/api/index.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/index.html +1 -1
  58. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/validators.js.html +2 -2
  73. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  75. package/coverage/lcov-report/automations/actions.js.html +1 -1
  76. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  77. package/coverage/lcov-report/automations/bullboard.js.html +17 -17
  78. package/coverage/lcov-report/automations/index.html +1 -1
  79. package/coverage/lcov-report/automations/index.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/executeQuery.js.html +5 -2
  84. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/index.html +25 -25
  87. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/queryRows.js.html +73 -10
  91. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/serverLog.js.html +27 -9
  93. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggers.js.html +18 -18
  106. package/coverage/lcov-report/constants/index.html +1 -1
  107. package/coverage/lcov-report/constants/index.js.html +5 -14
  108. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  109. package/coverage/lcov-report/constants/screens.js.html +1 -1
  110. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  111. package/coverage/lcov-report/db/index.html +19 -19
  112. package/coverage/lcov-report/db/index.js.html +1 -1
  113. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  116. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  117. package/coverage/lcov-report/db/newid.js.html +1 -1
  118. package/coverage/lcov-report/db/utils.js.html +61 -13
  119. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  120. package/coverage/lcov-report/events/index.html +1 -1
  121. package/coverage/lcov-report/events/index.js.html +1 -1
  122. package/coverage/lcov-report/events/utils.js.html +1 -1
  123. package/coverage/lcov-report/index.html +66 -81
  124. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  125. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  126. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  127. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  128. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  129. package/coverage/lcov-report/middleware/index.html +21 -21
  130. package/coverage/lcov-report/middleware/joi-validator.js.html +43 -43
  131. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  132. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  133. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  134. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  135. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  136. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  137. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  138. package/coverage/lcov-report/utilities/global.js.html +67 -13
  139. package/coverage/lcov-report/utilities/index.html +20 -20
  140. package/coverage/lcov-report/utilities/index.js.html +1 -1
  141. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +26 -14
  142. package/coverage/lcov-report/utilities/queue/index.html +17 -17
  143. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  144. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  145. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  146. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  147. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  148. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  149. package/coverage/lcov-report/utilities/security.js.html +2 -2
  150. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  151. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  152. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  153. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  154. package/coverage/lcov-report/utilities/users.js.html +1 -1
  155. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  156. package/coverage/lcov.info +747 -1245
  157. package/dist/api/controllers/deploy/index.js +1 -0
  158. package/dist/api/controllers/query/index.js +1 -1
  159. package/dist/api/controllers/query/validation.js +1 -1
  160. package/dist/api/controllers/row/internalSearch.js +30 -16
  161. package/dist/api/routes/utils/validators.js +1 -1
  162. package/dist/automations/steps/queryRows.js +21 -1
  163. package/dist/automations/steps/serverLog.js +8 -2
  164. package/dist/automations/utils.js +47 -1
  165. package/dist/constants/index.js +1 -4
  166. package/dist/db/utils.js +14 -1
  167. package/dist/definitions/automations.js +8 -0
  168. package/dist/integrations/base/sql.js +43 -14
  169. package/dist/package.json +8 -8
  170. package/dist/threads/automation.js +147 -54
  171. package/dist/threads/definitions.js +2 -0
  172. package/dist/threads/index.js +27 -20
  173. package/dist/threads/query.js +23 -15
  174. package/dist/threads/utils.js +47 -24
  175. package/dist/tsconfig.build.tsbuildinfo +1 -1
  176. package/dist/utilities/global.js +21 -4
  177. package/dist/utilities/queue/inMemoryQueue.js +5 -0
  178. package/package.json +9 -9
  179. package/src/api/controllers/deploy/index.ts +6 -1
  180. package/src/api/controllers/query/index.ts +1 -1
  181. package/src/api/controllers/query/validation.js +1 -1
  182. package/src/api/controllers/row/internalSearch.js +35 -20
  183. package/src/api/routes/tests/user.spec.js +2 -0
  184. package/src/api/routes/utils/validators.js +1 -1
  185. package/src/automations/steps/executeQuery.js +1 -0
  186. package/src/automations/steps/queryRows.js +22 -1
  187. package/src/automations/steps/serverLog.js +8 -2
  188. package/src/automations/tests/automation.spec.js +2 -2
  189. package/src/automations/utils.ts +54 -1
  190. package/src/constants/index.js +2 -5
  191. package/src/db/utils.js +16 -0
  192. package/src/definitions/automations.ts +49 -0
  193. package/src/definitions/datasource.ts +3 -0
  194. package/src/integrations/base/sql.ts +44 -13
  195. package/src/integrations/tests/sql.spec.js +50 -4
  196. package/src/middleware/tests/currentapp.spec.js +11 -0
  197. package/src/threads/{automation.js → automation.ts} +172 -48
  198. package/src/threads/definitions.ts +18 -0
  199. package/src/threads/index.ts +31 -23
  200. package/src/threads/{query.js → query.ts} +32 -12
  201. package/src/threads/{utils.js → utils.ts} +31 -12
  202. package/src/utilities/global.js +20 -2
  203. package/src/utilities/queue/inMemoryQueue.js +4 -0
  204. package/builder/assets/index.f116ac7f.js +0 -978
  205. package/coverage/lcov-report/threads/automation.js.html +0 -1114
  206. package/coverage/lcov-report/threads/index.html +0 -146
  207. package/coverage/lcov-report/threads/query.js.html +0 -916
  208. 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) await client.finish()
18
+ if (client) {
19
+ await client.finish()
20
+ }
18
21
  })
19
22
 
20
- exports.threadSetup = () => {
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 makeVariableKey(queryId, variable) {
31
- return `${queryId}${SEPARATOR}${variable}`
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
- exports.invalidateDynamicVariables = async cachedVars => {
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
- exports.storeDynamicVariable = async (queryId, variable, value) => {
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
- exports.formatResponse = resp => {
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
- exports.hasExtraData = response => {
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
+ }
@@ -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 processUser(user, { appId } = {}) {
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
- return exports.updateAppRole(user, { appId })
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
 
@@ -109,6 +109,10 @@ class InMemoryQueue {
109
109
  async clean() {
110
110
  return []
111
111
  }
112
+
113
+ async getJob() {
114
+ return {}
115
+ }
112
116
  }
113
117
 
114
118
  module.exports = InMemoryQueue