@budibase/server 1.4.16 → 1.4.18-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 (250) hide show
  1. package/Dockerfile +2 -0
  2. package/builder/assets/{index.de734399.js → index.95d0ae95.js} +296 -292
  3. package/builder/assets/index.ffaba7b0.css +6 -0
  4. package/builder/index.html +2 -2
  5. package/coverage/clover.xml +141 -179
  6. package/coverage/coverage-final.json +33 -35
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/index.html +9 -24
  14. package/coverage/lcov-report/api/controllers/integration.js.html +2 -2
  15. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  42. package/coverage/lcov-report/api/index.html +1 -1
  43. package/coverage/lcov-report/api/index.js.html +1 -1
  44. package/coverage/lcov-report/api/routes/analytics.js.html +2 -2
  45. package/coverage/lcov-report/api/routes/apikeys.js.html +2 -2
  46. package/coverage/lcov-report/api/routes/automation.js.html +2 -2
  47. package/coverage/lcov-report/api/routes/backup.js.html +2 -2
  48. package/coverage/lcov-report/api/routes/cloud.js.html +2 -2
  49. package/coverage/lcov-report/api/routes/component.js.html +2 -2
  50. package/coverage/lcov-report/api/routes/datasource.js.html +2 -2
  51. package/coverage/lcov-report/api/routes/deploy.js.html +2 -2
  52. package/coverage/lcov-report/api/routes/dev.js.html +2 -2
  53. package/coverage/lcov-report/api/routes/index.html +5 -20
  54. package/coverage/lcov-report/api/routes/integration.js.html +2 -2
  55. package/coverage/lcov-report/api/routes/layout.js.html +2 -2
  56. package/coverage/lcov-report/api/routes/metadata.js.html +2 -2
  57. package/coverage/lcov-report/api/routes/migrations.js.html +2 -2
  58. package/coverage/lcov-report/api/routes/permission.js.html +2 -2
  59. package/coverage/lcov-report/api/routes/query.js.html +2 -2
  60. package/coverage/lcov-report/api/routes/role.js.html +2 -2
  61. package/coverage/lcov-report/api/routes/routing.js.html +2 -2
  62. package/coverage/lcov-report/api/routes/screen.js.html +2 -2
  63. package/coverage/lcov-report/api/routes/script.js.html +2 -2
  64. package/coverage/lcov-report/api/routes/table.js.html +2 -2
  65. package/coverage/lcov-report/api/routes/templates.js.html +2 -2
  66. package/coverage/lcov-report/api/routes/user.js.html +2 -2
  67. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  68. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/view.js.html +2 -2
  70. package/coverage/lcov-report/api/routes/webhook.js.html +2 -2
  71. package/coverage/lcov-report/automations/actions.js.html +1 -1
  72. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  73. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  74. package/coverage/lcov-report/automations/index.html +1 -1
  75. package/coverage/lcov-report/automations/index.js.html +1 -1
  76. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  77. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/index.html +1 -1
  83. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +52 -4
  88. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  93. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  94. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  102. package/coverage/lcov-report/constants/index.html +1 -1
  103. package/coverage/lcov-report/constants/index.js.html +1 -1
  104. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  105. package/coverage/lcov-report/constants/screens.js.html +1 -1
  106. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  107. package/coverage/lcov-report/db/index.html +5 -5
  108. package/coverage/lcov-report/db/index.js.html +4 -4
  109. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  110. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  111. package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
  112. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +7 -7
  113. package/coverage/lcov-report/db/newid.js.html +1 -1
  114. package/coverage/lcov-report/db/utils.js.html +1 -1
  115. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  116. package/coverage/lcov-report/events/index.html +1 -1
  117. package/coverage/lcov-report/events/index.js.html +1 -1
  118. package/coverage/lcov-report/events/utils.js.html +1 -1
  119. package/coverage/lcov-report/index.html +32 -32
  120. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  121. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  122. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  123. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  124. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  125. package/coverage/lcov-report/middleware/index.html +1 -1
  126. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  127. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  128. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  129. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  130. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  131. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  132. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  133. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  134. package/coverage/lcov-report/utilities/global.js.html +19 -13
  135. package/coverage/lcov-report/utilities/index.html +24 -24
  136. package/coverage/lcov-report/utilities/index.js.html +1 -1
  137. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  138. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  139. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  140. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  141. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  142. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +12 -12
  143. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +8 -8
  144. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  145. package/coverage/lcov-report/utilities/security.js.html +1 -1
  146. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  147. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  148. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  149. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  150. package/coverage/lcov-report/utilities/users.js.html +21 -12
  151. package/coverage/lcov-report/utilities/workerRequests.js.html +33 -3
  152. package/coverage/lcov.info +216 -272
  153. package/dist/api/controllers/application.js +5 -3
  154. package/dist/api/controllers/auth.js +58 -49
  155. package/dist/api/controllers/integration.js +1 -1
  156. package/dist/api/routes/analytics.js +1 -1
  157. package/dist/api/routes/apikeys.js +1 -1
  158. package/dist/api/routes/auth.js +31 -4
  159. package/dist/api/routes/automation.js +1 -1
  160. package/dist/api/routes/backup.js +1 -1
  161. package/dist/api/routes/cloud.js +1 -1
  162. package/dist/api/routes/component.js +1 -1
  163. package/dist/api/routes/datasource.js +1 -1
  164. package/dist/api/routes/deploy.js +1 -1
  165. package/dist/api/routes/dev.js +1 -1
  166. package/dist/api/routes/integration.js +1 -1
  167. package/dist/api/routes/layout.js +1 -1
  168. package/dist/api/routes/metadata.js +1 -1
  169. package/dist/api/routes/migrations.js +1 -1
  170. package/dist/api/routes/permission.js +1 -1
  171. package/dist/api/routes/public/applications.js +5 -0
  172. package/dist/api/routes/public/queries.js +2 -0
  173. package/dist/api/routes/public/rows.js +5 -0
  174. package/dist/api/routes/public/tables.js +5 -0
  175. package/dist/api/routes/public/users.js +5 -0
  176. package/dist/api/routes/query.js +1 -1
  177. package/dist/api/routes/role.js +1 -1
  178. package/dist/api/routes/routing.js +1 -1
  179. package/dist/api/routes/screen.js +1 -1
  180. package/dist/api/routes/script.js +1 -1
  181. package/dist/api/routes/table.js +1 -1
  182. package/dist/api/routes/templates.js +1 -1
  183. package/dist/api/routes/user.js +1 -1
  184. package/dist/api/routes/view.js +1 -1
  185. package/dist/api/routes/webhook.js +1 -1
  186. package/dist/automations/steps/sendSmtpEmail.js +10 -2
  187. package/dist/db/index.js +1 -1
  188. package/dist/integrations/mysql.js +1 -1
  189. package/dist/middleware/authorized.js +2 -2
  190. package/dist/migrations/functions/usageQuotas/syncApps.js +2 -1
  191. package/dist/migrations/functions/usageQuotas/syncRows.js +2 -1
  192. package/dist/package.json +6 -6
  193. package/dist/tsconfig.build.tsbuildinfo +1 -1
  194. package/dist/utilities/global.js +6 -3
  195. package/dist/utilities/users.js +4 -2
  196. package/dist/utilities/workerRequests.js +3 -1
  197. package/package.json +7 -7
  198. package/scripts/dev/manage.js +1 -0
  199. package/specs/openapi.json +22 -0
  200. package/specs/openapi.yaml +22 -0
  201. package/src/api/controllers/application.ts +6 -10
  202. package/src/api/controllers/{auth.js → auth.ts} +20 -18
  203. package/src/api/controllers/integration.js +1 -1
  204. package/src/api/routes/analytics.js +1 -1
  205. package/src/api/routes/apikeys.js +1 -1
  206. package/src/api/routes/auth.ts +8 -0
  207. package/src/api/routes/automation.js +1 -1
  208. package/src/api/routes/backup.js +1 -1
  209. package/src/api/routes/cloud.js +1 -1
  210. package/src/api/routes/component.js +1 -1
  211. package/src/api/routes/datasource.js +1 -1
  212. package/src/api/routes/deploy.js +1 -1
  213. package/src/api/routes/dev.js +1 -1
  214. package/src/api/routes/integration.js +1 -1
  215. package/src/api/routes/layout.js +1 -1
  216. package/src/api/routes/metadata.js +1 -1
  217. package/src/api/routes/migrations.js +1 -1
  218. package/src/api/routes/permission.js +1 -1
  219. package/src/api/routes/public/applications.ts +5 -0
  220. package/src/api/routes/public/queries.ts +2 -0
  221. package/src/api/routes/public/rows.ts +5 -0
  222. package/src/api/routes/public/tables.ts +5 -0
  223. package/src/api/routes/public/users.ts +5 -0
  224. package/src/api/routes/query.js +1 -1
  225. package/src/api/routes/role.js +1 -1
  226. package/src/api/routes/routing.js +1 -1
  227. package/src/api/routes/screen.js +1 -1
  228. package/src/api/routes/script.js +1 -1
  229. package/src/api/routes/table.js +1 -1
  230. package/src/api/routes/templates.js +1 -1
  231. package/src/api/routes/tests/row.spec.js +3 -1
  232. package/src/api/routes/user.js +1 -1
  233. package/src/api/routes/view.js +1 -1
  234. package/src/api/routes/webhook.js +1 -1
  235. package/src/automations/steps/sendSmtpEmail.js +18 -2
  236. package/src/db/index.js +1 -1
  237. package/src/definitions/openapi.ts +134 -447
  238. package/src/integrations/mysql.ts +2 -0
  239. package/src/middleware/authorized.ts +2 -2
  240. package/src/migrations/functions/usageQuotas/syncApps.ts +2 -1
  241. package/src/migrations/functions/usageQuotas/syncRows.ts +2 -1
  242. package/src/migrations/functions/usageQuotas/tests/syncApps.spec.ts +2 -1
  243. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -1
  244. package/src/utilities/global.js +6 -4
  245. package/src/utilities/users.js +5 -2
  246. package/src/utilities/workerRequests.js +11 -1
  247. package/builder/assets/index.91c8117f.css +0 -6
  248. package/coverage/lcov-report/api/controllers/auth.js.html +0 -292
  249. package/coverage/lcov-report/api/routes/auth.js.html +0 -109
  250. package/src/api/routes/auth.js +0 -8
@@ -43,9 +43,10 @@ exports.updateAppRole = (user, { appId } = {}) => {
43
43
  }
44
44
 
45
45
  async function checkGroupRoles(user, { appId } = {}) {
46
- let roleId = await groups.getGroupRoleId(user, appId)
47
- user.roleId = roleId
48
-
46
+ if (user.roleId && user.roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
47
+ return user
48
+ }
49
+ user.roleId = await groups.getGroupRoleId(user, appId)
49
50
  return user
50
51
  }
51
52
 
@@ -74,8 +75,9 @@ exports.getRawGlobalUser = async userId => {
74
75
  }
75
76
 
76
77
  exports.getGlobalUser = async userId => {
78
+ const appId = getAppId()
77
79
  let user = await exports.getRawGlobalUser(userId)
78
- return processUser(user)
80
+ return processUser(user, { appId })
79
81
  }
80
82
 
81
83
  exports.getGlobalUsers = async (users = null) => {
@@ -2,10 +2,11 @@ const { InternalTables } = require("../db/utils")
2
2
  const { getGlobalUser } = require("../utilities/global")
3
3
  const { getAppDB } = require("@budibase/backend-core/context")
4
4
  const { getProdAppID } = require("@budibase/backend-core/db")
5
+ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
5
6
 
6
7
  exports.getFullUser = async (ctx, userId) => {
7
8
  const global = await getGlobalUser(userId)
8
- let metadata
9
+ let metadata = {}
9
10
  try {
10
11
  // this will throw an error if the db doesn't exist, or there is no appId
11
12
  const db = getAppDB()
@@ -15,9 +16,11 @@ exports.getFullUser = async (ctx, userId) => {
15
16
  delete global._id
16
17
  delete global._rev
17
18
  }
19
+ delete metadata.csrfToken
18
20
  return {
19
- ...global,
20
21
  ...metadata,
22
+ ...global,
23
+ roleId: global.roleId || BUILTIN_ROLE_IDS.PUBLIC,
21
24
  tableId: InternalTables.USER_METADATA,
22
25
  // make sure the ID is always a local ID, not a global one
23
26
  _id: userId,
@@ -54,7 +54,15 @@ async function checkResponse(response, errorMsg, { ctx } = {}) {
54
54
  exports.request = request
55
55
 
56
56
  // have to pass in the tenant ID as this could be coming from an automation
57
- exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
57
+ exports.sendSmtpEmail = async (
58
+ to,
59
+ from,
60
+ subject,
61
+ contents,
62
+ cc,
63
+ bcc,
64
+ automation
65
+ ) => {
58
66
  // tenant ID will be set in header
59
67
  const response = await fetch(
60
68
  checkSlashesInUrl(env.WORKER_URL + `/api/global/email/send`),
@@ -65,6 +73,8 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
65
73
  from,
66
74
  contents,
67
75
  subject,
76
+ cc,
77
+ bcc,
68
78
  purpose: "custom",
69
79
  automation,
70
80
  },