@budibase/server 1.0.49-alpha.0 → 1.0.49-alpha.12

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 (357) hide show
  1. package/__mocks__/arangojs.ts +1 -1
  2. package/__mocks__/aws-sdk.ts +4 -4
  3. package/__mocks__/mongodb.ts +4 -5
  4. package/__mocks__/mssql.ts +3 -3
  5. package/__mocks__/node-fetch.ts +2 -1
  6. package/__mocks__/pg.ts +3 -5
  7. package/builder/assets/{index.8184eed9.js → index.0bdf1cad.js} +195 -194
  8. package/builder/assets/{index.dd9e386f.css → index.83c0944f.css} +1 -1
  9. package/builder/assets/{vendor.3bd2f661.js → vendor.d526bfe8.js} +1 -1
  10. package/builder/index.html +3 -3
  11. package/coverage/clover.xml +2927 -2819
  12. package/coverage/coverage-final.json +104 -103
  13. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/application.js.html +157 -136
  16. package/coverage/lcov-report/api/controllers/auth.js.html +11 -14
  17. package/coverage/lcov-report/api/controllers/automation.js.html +39 -69
  18. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/cloud.js.html +8 -11
  20. package/coverage/lcov-report/api/controllers/component.js.html +10 -13
  21. package/coverage/lcov-report/api/controllers/datasource.js.html +31 -37
  22. package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
  23. package/coverage/lcov-report/api/controllers/index.html +69 -54
  24. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
  26. package/coverage/lcov-report/api/controllers/metadata.js.html +6 -21
  27. package/coverage/lcov-report/{migrations/usageQuotas/syncApps.js.html → api/controllers/migrations.js.html} +30 -45
  28. package/coverage/lcov-report/api/controllers/permission.js.html +19 -19
  29. package/coverage/lcov-report/api/controllers/query/index.html +10 -10
  30. package/coverage/lcov-report/api/controllers/query/index.js.html +38 -35
  31. package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
  32. package/coverage/lcov-report/api/controllers/role.js.html +16 -16
  33. package/coverage/lcov-report/api/controllers/routing.js.html +7 -10
  34. package/coverage/lcov-report/api/controllers/row/external.js.html +48 -141
  35. package/coverage/lcov-report/api/controllers/row/index.html +52 -37
  36. package/coverage/lcov-report/api/controllers/row/index.js.html +13 -13
  37. package/coverage/lcov-report/api/controllers/row/internal.js.html +108 -216
  38. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +52 -34
  39. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +548 -0
  40. package/coverage/lcov-report/api/controllers/row/utils.js.html +27 -24
  41. package/coverage/lcov-report/api/controllers/screen.js.html +15 -21
  42. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  43. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +599 -0
  44. package/coverage/lcov-report/api/controllers/table/external.js.html +25 -34
  45. package/coverage/lcov-report/api/controllers/table/index.html +57 -42
  46. package/coverage/lcov-report/api/controllers/table/index.js.html +28 -70
  47. package/coverage/lcov-report/api/controllers/table/internal.js.html +56 -47
  48. package/coverage/lcov-report/api/controllers/table/utils.js.html +169 -85
  49. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  50. package/coverage/lcov-report/api/controllers/user.js.html +43 -52
  51. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  52. package/coverage/lcov-report/api/controllers/view/index.html +16 -16
  53. package/coverage/lcov-report/api/controllers/view/index.js.html +27 -33
  54. package/coverage/lcov-report/api/controllers/view/utils.js.html +35 -20
  55. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  56. package/coverage/lcov-report/api/controllers/webhook.js.html +34 -28
  57. package/coverage/lcov-report/api/index.html +1 -1
  58. package/coverage/lcov-report/api/index.js.html +3 -3
  59. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/index.html +22 -7
  71. package/coverage/lcov-report/api/routes/index.js.html +10 -4
  72. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  75. package/coverage/lcov-report/{migrations/usageQuotas/index.js.html → api/routes/migrations.js.html} +25 -55
  76. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  80. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  81. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  82. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  83. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  84. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  85. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  86. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  87. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  88. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  89. package/coverage/lcov-report/automations/actions.js.html +24 -24
  90. package/coverage/lcov-report/automations/automationUtils.js.html +7 -10
  91. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  92. package/coverage/lcov-report/automations/index.html +18 -18
  93. package/coverage/lcov-report/automations/index.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  95. package/coverage/lcov-report/automations/steps/createRow.js.html +7 -10
  96. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  97. package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
  98. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  99. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  100. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  101. package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
  102. package/coverage/lcov-report/automations/steps/index.html +1 -1
  103. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  104. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  105. package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
  106. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  107. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  108. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  109. package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
  110. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  111. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  112. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  113. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  115. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  116. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  117. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  118. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  119. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  120. package/coverage/lcov-report/automations/triggers.js.html +61 -55
  121. package/coverage/lcov-report/automations/utils.js.html +54 -42
  122. package/coverage/lcov-report/constants/index.html +5 -5
  123. package/coverage/lcov-report/constants/index.js.html +42 -27
  124. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  125. package/coverage/lcov-report/constants/screens.js.html +4 -4
  126. package/coverage/lcov-report/db/client.js.html +18 -18
  127. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  128. package/coverage/lcov-report/db/index.html +1 -1
  129. package/coverage/lcov-report/db/index.js.html +3 -3
  130. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +15 -27
  131. package/coverage/lcov-report/db/linkedRows/index.html +27 -27
  132. package/coverage/lcov-report/db/linkedRows/index.js.html +40 -85
  133. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +40 -40
  134. package/coverage/lcov-report/db/newid.js.html +4 -4
  135. package/coverage/lcov-report/db/utils.js.html +75 -75
  136. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  137. package/coverage/lcov-report/events/index.html +1 -1
  138. package/coverage/lcov-report/events/index.js.html +5 -5
  139. package/coverage/lcov-report/events/utils.js.html +3 -3
  140. package/coverage/lcov-report/index.html +107 -122
  141. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  142. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  143. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  144. package/coverage/lcov-report/middleware/authorized.js.html +21 -15
  145. package/coverage/lcov-report/middleware/builder.js.html +3 -3
  146. package/coverage/lcov-report/middleware/currentapp.js.html +72 -60
  147. package/coverage/lcov-report/middleware/index.html +28 -28
  148. package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
  149. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  150. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  151. package/coverage/lcov-report/middleware/usageQuota.js.html +29 -35
  152. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  153. package/coverage/lcov-report/threads/automation.js.html +30 -24
  154. package/coverage/lcov-report/threads/index.html +25 -25
  155. package/coverage/lcov-report/threads/index.js.html +10 -10
  156. package/coverage/lcov-report/threads/query.js.html +26 -47
  157. package/coverage/lcov-report/threads/utils.js.html +14 -14
  158. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  159. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  160. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  161. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  162. package/coverage/lcov-report/utilities/global.js.html +57 -48
  163. package/coverage/lcov-report/utilities/index.html +27 -27
  164. package/coverage/lcov-report/utilities/index.js.html +42 -72
  165. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
  166. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  167. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  168. package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
  169. package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
  170. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +65 -71
  171. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +75 -27
  172. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  173. package/coverage/lcov-report/utilities/security.js.html +8 -8
  174. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  175. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  176. package/coverage/lcov-report/utilities/usageQuota/index.js.html +13 -10
  177. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +5 -2
  178. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  179. package/coverage/lcov-report/utilities/users.js.html +9 -9
  180. package/coverage/lcov-report/utilities/workerRequests.js.html +16 -16
  181. package/coverage/lcov.info +4620 -4358
  182. package/dist/api/controllers/application.js +49 -48
  183. package/dist/api/controllers/auth.js +4 -5
  184. package/dist/api/controllers/automation.js +14 -19
  185. package/dist/api/controllers/cloud.js +2 -3
  186. package/dist/api/controllers/component.js +3 -4
  187. package/dist/api/controllers/datasource.js +9 -10
  188. package/dist/api/controllers/deploy/Deployment.js +3 -6
  189. package/dist/api/controllers/deploy/index.js +12 -13
  190. package/dist/api/controllers/dev.js +5 -5
  191. package/dist/api/controllers/layout.js +3 -3
  192. package/dist/api/controllers/metadata.js +4 -4
  193. package/dist/api/controllers/migrations.js +21 -0
  194. package/dist/api/controllers/permission.js +4 -4
  195. package/dist/api/controllers/query/import/index.js +4 -6
  196. package/dist/api/controllers/query/index.js +11 -10
  197. package/dist/api/controllers/role.js +5 -5
  198. package/dist/api/controllers/routing.js +5 -6
  199. package/dist/api/controllers/row/ExternalRequest.js +90 -67
  200. package/dist/api/controllers/row/external.js +14 -22
  201. package/dist/api/controllers/row/internal.js +55 -93
  202. package/dist/api/controllers/row/internalSearch.js +23 -17
  203. package/dist/api/controllers/row/staticFormula.js +147 -0
  204. package/dist/api/controllers/row/utils.js +7 -6
  205. package/dist/api/controllers/screen.js +5 -7
  206. package/dist/api/controllers/static/index.js +4 -4
  207. package/dist/api/controllers/table/bulkFormula.js +159 -0
  208. package/dist/api/controllers/table/external.js +7 -10
  209. package/dist/api/controllers/table/index.js +7 -10
  210. package/dist/api/controllers/table/internal.js +20 -16
  211. package/dist/api/controllers/table/utils.js +54 -34
  212. package/dist/api/controllers/user.js +16 -20
  213. package/dist/api/controllers/view/index.js +8 -10
  214. package/dist/api/controllers/view/utils.js +9 -4
  215. package/dist/api/controllers/webhook.js +10 -8
  216. package/dist/api/routes/index.js +2 -0
  217. package/dist/api/routes/migrations.js +9 -0
  218. package/dist/api/routes/tests/utilities/TestFunctions.js +37 -17
  219. package/dist/app.js +35 -5
  220. package/dist/automations/automationUtils.js +2 -3
  221. package/dist/automations/steps/createRow.js +1 -1
  222. package/dist/automations/steps/updateRow.js +1 -1
  223. package/dist/automations/triggers.js +27 -25
  224. package/dist/automations/utils.js +10 -5
  225. package/dist/constants/index.js +4 -0
  226. package/dist/db/linkedRows/LinkController.js +3 -7
  227. package/dist/db/linkedRows/index.js +16 -27
  228. package/dist/db/linkedRows/linkUtils.js +6 -6
  229. package/dist/db/views/staticViews.js +9 -10
  230. package/dist/environment.js +3 -1
  231. package/dist/integrations/base/sql.js +43 -8
  232. package/dist/integrations/utils.js +3 -0
  233. package/dist/middleware/authorized.js +5 -3
  234. package/dist/middleware/builder.js +2 -2
  235. package/dist/middleware/currentapp.js +41 -37
  236. package/dist/middleware/usageQuota.js +2 -4
  237. package/dist/migrations/functions/appUrls.js +46 -0
  238. package/dist/migrations/functions/quotas1.js +50 -0
  239. package/dist/migrations/{usageQuotas → functions/usageQuotas}/index.js +6 -10
  240. package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncApps.js +12 -9
  241. package/dist/migrations/{usageQuotas → functions/usageQuotas}/syncRows.js +16 -12
  242. package/dist/migrations/functions/userEmailViewCasing.js +24 -0
  243. package/dist/migrations/index.js +62 -0
  244. package/dist/package.json +4 -4
  245. package/dist/tests/utilities/TestConfiguration.js +70 -44
  246. package/dist/threads/automation.js +13 -11
  247. package/dist/threads/query.js +13 -19
  248. package/dist/tsconfig.tsbuildinfo +1 -1
  249. package/dist/utilities/fileSystem/index.js +4 -3
  250. package/dist/utilities/global.js +15 -12
  251. package/dist/utilities/index.js +7 -17
  252. package/dist/utilities/routing/index.js +5 -5
  253. package/dist/utilities/rowProcessor/index.js +23 -17
  254. package/dist/utilities/rowProcessor/utils.js +14 -4
  255. package/dist/utilities/usageQuota/index.js +1 -0
  256. package/dist/utilities/usageQuota/rows.js +1 -0
  257. package/dist/utilities/users.js +3 -3
  258. package/dist/utilities/workerRequests.js +4 -4
  259. package/package.json +5 -5
  260. package/scripts/integrations/postgres/init.sql +11 -6
  261. package/scripts/likeCypress.ts +1 -1
  262. package/src/api/controllers/application.js +38 -31
  263. package/src/api/controllers/auth.js +4 -5
  264. package/src/api/controllers/automation.js +13 -23
  265. package/src/api/controllers/cloud.js +2 -3
  266. package/src/api/controllers/component.js +3 -4
  267. package/src/api/controllers/datasource.js +9 -11
  268. package/src/api/controllers/deploy/Deployment.js +3 -7
  269. package/src/api/controllers/deploy/index.js +20 -13
  270. package/src/api/controllers/dev.js +5 -5
  271. package/src/api/controllers/layout.js +3 -3
  272. package/src/api/controllers/metadata.js +4 -9
  273. package/src/api/controllers/migrations.js +13 -0
  274. package/src/api/controllers/permission.js +4 -4
  275. package/src/api/controllers/query/import/index.ts +4 -6
  276. package/src/api/controllers/query/import/tests/index.spec.js +2 -1
  277. package/src/api/controllers/query/index.js +11 -10
  278. package/src/api/controllers/role.js +5 -5
  279. package/src/api/controllers/routing.js +5 -6
  280. package/src/api/controllers/row/ExternalRequest.ts +67 -43
  281. package/src/api/controllers/row/external.js +27 -58
  282. package/src/api/controllers/row/internal.js +54 -90
  283. package/src/api/controllers/row/internalSearch.js +23 -17
  284. package/src/api/controllers/row/staticFormula.js +156 -0
  285. package/src/api/controllers/row/utils.js +7 -6
  286. package/src/api/controllers/screen.js +5 -7
  287. package/src/api/controllers/static/index.js +4 -4
  288. package/src/api/controllers/table/bulkFormula.js +173 -0
  289. package/src/api/controllers/table/external.js +7 -10
  290. package/src/api/controllers/table/index.js +7 -21
  291. package/src/api/controllers/table/internal.js +22 -19
  292. package/src/api/controllers/table/utils.js +70 -42
  293. package/src/api/controllers/user.js +17 -20
  294. package/src/api/controllers/view/index.js +8 -10
  295. package/src/api/controllers/view/utils.js +9 -4
  296. package/src/api/controllers/webhook.js +10 -8
  297. package/src/api/routes/index.js +2 -0
  298. package/src/api/routes/migrations.js +14 -0
  299. package/src/api/routes/tests/automation.spec.js +1 -0
  300. package/src/api/routes/tests/misc.spec.js +0 -1
  301. package/src/api/routes/tests/routing.spec.js +21 -12
  302. package/src/api/routes/tests/row.spec.js +7 -4
  303. package/src/api/routes/tests/utilities/TestFunctions.js +39 -17
  304. package/src/app.ts +18 -5
  305. package/src/automations/automationUtils.js +2 -3
  306. package/src/automations/steps/createRow.js +0 -1
  307. package/src/automations/steps/updateRow.js +1 -1
  308. package/src/automations/triggers.js +33 -31
  309. package/src/automations/utils.js +9 -5
  310. package/src/constants/index.js +5 -0
  311. package/src/db/linkedRows/LinkController.js +3 -7
  312. package/src/db/linkedRows/index.js +16 -31
  313. package/src/db/linkedRows/linkUtils.js +6 -6
  314. package/src/db/tests/linkController.spec.js +0 -1
  315. package/src/db/tests/linkTests.spec.js +5 -6
  316. package/src/db/views/staticViews.js +8 -10
  317. package/src/definitions/common.ts +3 -0
  318. package/src/environment.js +3 -1
  319. package/src/integrations/base/sql.ts +55 -14
  320. package/src/integrations/utils.ts +4 -1
  321. package/src/middleware/authorized.js +5 -3
  322. package/src/middleware/builder.js +2 -2
  323. package/src/middleware/currentapp.js +50 -46
  324. package/src/middleware/tests/authorized.spec.js +7 -2
  325. package/src/middleware/tests/currentapp.spec.js +6 -0
  326. package/src/middleware/usageQuota.js +2 -4
  327. package/src/migrations/functions/appUrls.ts +34 -0
  328. package/src/migrations/functions/quotas1.ts +20 -0
  329. package/src/migrations/functions/tests/appUrls.spec.js +29 -0
  330. package/src/migrations/{tests/usageQuotas/index.spec.js → functions/tests/quotas1.spec.js} +5 -5
  331. package/src/migrations/functions/tests/userEmailViewCasing.spec.js +25 -0
  332. package/src/migrations/functions/usageQuotas/index.ts +8 -0
  333. package/src/migrations/{usageQuotas/syncApps.js → functions/usageQuotas/syncApps.ts} +6 -6
  334. package/src/migrations/functions/usageQuotas/syncRows.ts +22 -0
  335. package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncApps.spec.js +4 -4
  336. package/src/migrations/{tests/usageQuotas → functions/usageQuotas/tests}/syncRows.spec.js +4 -4
  337. package/src/migrations/functions/userEmailViewCasing.ts +13 -0
  338. package/src/migrations/index.ts +56 -0
  339. package/src/module.d.ts +3 -0
  340. package/src/tests/utilities/TestConfiguration.js +73 -50
  341. package/src/threads/automation.js +17 -15
  342. package/src/threads/query.js +14 -21
  343. package/src/utilities/fileSystem/index.js +4 -3
  344. package/src/utilities/global.js +15 -12
  345. package/src/utilities/index.js +7 -17
  346. package/src/utilities/routing/index.js +5 -5
  347. package/src/utilities/rowProcessor/index.js +25 -27
  348. package/src/utilities/rowProcessor/utils.js +23 -7
  349. package/src/utilities/usageQuota/index.js +1 -0
  350. package/src/utilities/usageQuota/rows.js +1 -0
  351. package/src/utilities/users.js +3 -3
  352. package/src/utilities/workerRequests.js +4 -4
  353. package/tsconfig.json +2 -1
  354. package/coverage/lcov-report/migrations/usageQuotas/index.html +0 -141
  355. package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +0 -143
  356. package/src/migrations/usageQuotas/index.js +0 -24
  357. package/src/migrations/usageQuotas/syncRows.js +0 -21
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const { budibaseTempDir } = require("../budibaseDir");
12
- const { isDev } = require("../index");
13
12
  const fs = require("fs");
14
13
  const { join } = require("path");
15
14
  const uuid = require("uuid/v4");
@@ -20,6 +19,7 @@ const { updateClientLibrary } = require("./clientLibrary");
20
19
  const env = require("../../environment");
21
20
  const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, } = require("../../db/utils");
22
21
  const MemoryStream = require("memorystream");
22
+ const { getAppId } = require("@budibase/backend-core/context");
23
23
  const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..");
24
24
  const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules");
25
25
  /**
@@ -47,7 +47,7 @@ exports.init = () => {
47
47
  * everything required to function is ready.
48
48
  */
49
49
  exports.checkDevelopmentEnvironment = () => {
50
- if (!isDev()) {
50
+ if (!env.isDev() || env.isTest()) {
51
51
  return;
52
52
  }
53
53
  if (!fs.existsSync(budibaseTempDir())) {
@@ -218,7 +218,8 @@ exports.downloadTemplate = (type, name) => __awaiter(void 0, void 0, void 0, fun
218
218
  /**
219
219
  * Retrieves component libraries from object store (or tmp symlink if in local)
220
220
  */
221
- exports.getComponentLibraryManifest = (appId, library) => __awaiter(void 0, void 0, void 0, function* () {
221
+ exports.getComponentLibraryManifest = (library) => __awaiter(void 0, void 0, void 0, function* () {
222
+ const appId = getAppId();
222
223
  const filename = "manifest.json";
223
224
  /* istanbul ignore next */
224
225
  // when testing in cypress and so on we need to get the package
@@ -10,12 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  const { getMultiIDParams, getGlobalIDFromUserMetadataID, } = require("../db/utils");
12
12
  const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
13
- const { getDeployedAppID } = require("@budibase/backend-core/db");
13
+ const { getProdAppID } = require("@budibase/backend-core/db");
14
14
  const { getGlobalUserParams } = require("@budibase/backend-core/db");
15
15
  const { user: userCache } = require("@budibase/backend-core/cache");
16
16
  const { getGlobalDB, isUserInAppTenant, } = require("@budibase/backend-core/tenancy");
17
17
  const env = require("../environment");
18
- exports.updateAppRole = (appId, user) => {
18
+ const { getAppId } = require("@budibase/backend-core/context");
19
+ exports.updateAppRole = (user, { appId } = {}) => {
20
+ appId = appId || getAppId();
19
21
  if (!user || !user.roles) {
20
22
  return user;
21
23
  }
@@ -27,7 +29,7 @@ exports.updateAppRole = (appId, user) => {
27
29
  return user;
28
30
  }
29
31
  // always use the deployed app
30
- user.roleId = user.roles[getDeployedAppID(appId)];
32
+ user.roleId = user.roles[getProdAppID(appId)];
31
33
  // if a role wasn't found then either set as admin (builder) or public (everyone else)
32
34
  if (!user.roleId && user.builder && user.builder.global) {
33
35
  user.roleId = BUILTIN_ROLE_IDS.ADMIN;
@@ -38,27 +40,28 @@ exports.updateAppRole = (appId, user) => {
38
40
  delete user.roles;
39
41
  return user;
40
42
  };
41
- function processUser(appId, user) {
43
+ function processUser(user, { appId } = {}) {
42
44
  if (user) {
43
45
  delete user.password;
44
46
  }
45
- return exports.updateAppRole(appId, user);
47
+ return exports.updateAppRole(user, { appId });
46
48
  }
47
49
  exports.getCachedSelf = (ctx, appId) => __awaiter(void 0, void 0, void 0, function* () {
48
50
  // this has to be tenant aware, can't depend on the context to find it out
49
51
  // running some middlewares before the tenancy causes context to break
50
52
  const user = yield userCache.getUser(ctx.user._id);
51
- return processUser(appId, user);
53
+ return processUser(user, { appId });
52
54
  });
53
55
  exports.getRawGlobalUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
54
56
  const db = getGlobalDB();
55
57
  return db.get(getGlobalIDFromUserMetadataID(userId));
56
58
  });
57
- exports.getGlobalUser = (appId, userId) => __awaiter(void 0, void 0, void 0, function* () {
59
+ exports.getGlobalUser = (userId) => __awaiter(void 0, void 0, void 0, function* () {
58
60
  let user = yield exports.getRawGlobalUser(userId);
59
- return processUser(appId, user);
61
+ return processUser(user);
60
62
  });
61
- exports.getGlobalUsers = (appId = null, users = null) => __awaiter(void 0, void 0, void 0, function* () {
63
+ exports.getGlobalUsers = (users = null) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const appId = getAppId();
62
65
  const db = getGlobalDB();
63
66
  let globalUsers;
64
67
  if (users) {
@@ -80,10 +83,10 @@ exports.getGlobalUsers = (appId = null, users = null) => __awaiter(void 0, void
80
83
  if (!appId) {
81
84
  return globalUsers;
82
85
  }
83
- return globalUsers.map(user => exports.updateAppRole(appId, user));
86
+ return globalUsers.map(user => exports.updateAppRole(user));
84
87
  });
85
- exports.getGlobalUsersFromMetadata = (appId, users) => __awaiter(void 0, void 0, void 0, function* () {
86
- const globalUsers = yield exports.getGlobalUsers(appId, users);
88
+ exports.getGlobalUsersFromMetadata = (users) => __awaiter(void 0, void 0, void 0, function* () {
89
+ const globalUsers = yield exports.getGlobalUsers(users);
87
90
  return users.map(user => {
88
91
  const globalUser = globalUsers.find(globalUser => globalUser && user._id.includes(globalUser._id));
89
92
  return Object.assign(Object.assign({}, globalUser), user);
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  const env = require("../environment");
12
12
  const { OBJ_STORE_DIRECTORY } = require("../constants");
13
13
  const { sanitizeKey } = require("@budibase/backend-core/objectStore");
14
- const CouchDB = require("../db");
15
14
  const { generateMetadataID } = require("../db/utils");
16
15
  const Readable = require("stream").Readable;
16
+ const { getAppDB } = require("@budibase/backend-core/context");
17
17
  const BB_CDN = "https://cdn.budi.live";
18
18
  exports.wait = ms => new Promise(resolve => setTimeout(resolve, ms));
19
19
  exports.isDev = env.isDev;
@@ -72,8 +72,8 @@ exports.clientLibraryPath = (appId, version) => {
72
72
  exports.attachmentsRelativeURL = attachmentKey => {
73
73
  return exports.checkSlashesInUrl(`${exports.objectStoreUrl()}/${attachmentKey}`);
74
74
  };
75
- exports.updateEntityMetadata = (appId, type, entityId, updateFn) => __awaiter(void 0, void 0, void 0, function* () {
76
- const db = new CouchDB(appId);
75
+ exports.updateEntityMetadata = (type, entityId, updateFn) => __awaiter(void 0, void 0, void 0, function* () {
76
+ const db = getAppDB();
77
77
  const id = generateMetadataID(type, entityId);
78
78
  // read it to see if it exists, we'll overwrite it no matter what
79
79
  let rev, metadata = {};
@@ -93,13 +93,13 @@ exports.updateEntityMetadata = (appId, type, entityId, updateFn) => __awaiter(vo
93
93
  const response = yield db.put(metadata);
94
94
  return Object.assign(Object.assign({}, metadata), { _id: id, _rev: response.rev });
95
95
  });
96
- exports.saveEntityMetadata = (appId, type, entityId, metadata) => __awaiter(void 0, void 0, void 0, function* () {
97
- return exports.updateEntityMetadata(appId, type, entityId, () => {
96
+ exports.saveEntityMetadata = (type, entityId, metadata) => __awaiter(void 0, void 0, void 0, function* () {
97
+ return exports.updateEntityMetadata(type, entityId, () => {
98
98
  return metadata;
99
99
  });
100
100
  });
101
- exports.deleteEntityMetadata = (appId, type, entityId) => __awaiter(void 0, void 0, void 0, function* () {
102
- const db = new CouchDB(appId);
101
+ exports.deleteEntityMetadata = (type, entityId) => __awaiter(void 0, void 0, void 0, function* () {
102
+ const db = getAppDB();
103
103
  const id = generateMetadataID(type, entityId);
104
104
  let rev;
105
105
  try {
@@ -132,16 +132,6 @@ exports.stringToReadStream = string => {
132
132
  },
133
133
  });
134
134
  };
135
- exports.doesDatabaseExist = (dbName) => __awaiter(void 0, void 0, void 0, function* () {
136
- try {
137
- const db = new CouchDB(dbName, { skip_setup: true });
138
- const info = yield db.info();
139
- return info && !info.error;
140
- }
141
- catch (err) {
142
- return false;
143
- }
144
- });
145
135
  exports.formatBytes = bytes => {
146
136
  const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
147
137
  const byteIncrements = 1024;
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const CouchDB = require("../../db");
12
11
  const { createRoutingView } = require("../../db/views/staticViews");
13
12
  const { ViewNames, getQueryIndex, UNICODE_MAX } = require("../../db/utils");
14
- exports.getRoutingInfo = (appId) => __awaiter(void 0, void 0, void 0, function* () {
15
- const db = new CouchDB(appId);
13
+ const { getAppDB } = require("@budibase/backend-core/context");
14
+ exports.getRoutingInfo = () => __awaiter(void 0, void 0, void 0, function* () {
15
+ const db = getAppDB();
16
16
  try {
17
17
  const allRouting = yield db.query(getQueryIndex(ViewNames.ROUTING), {
18
18
  startKey: "",
@@ -24,8 +24,8 @@ exports.getRoutingInfo = (appId) => __awaiter(void 0, void 0, void 0, function*
24
24
  // check if the view doesn't exist, it should for all new instances
25
25
  /* istanbul ignore next */
26
26
  if (err != null && err.name === "not_found") {
27
- yield createRoutingView(appId);
28
- return exports.getRoutingInfo(appId);
27
+ yield createRoutingView();
28
+ return exports.getRoutingInfo();
29
29
  }
30
30
  else {
31
31
  throw err;
@@ -15,8 +15,8 @@ const { attachmentsRelativeURL } = require("../index");
15
15
  const { processFormulas } = require("./utils");
16
16
  const { deleteFiles } = require("../../utilities/fileSystem/utilities");
17
17
  const { ObjectStoreBuckets } = require("../../constants");
18
- const { isProdAppID, getDeployedAppID, dbExists, } = require("@budibase/backend-core/db");
19
- const CouchDB = require("../../db");
18
+ const { isProdAppID, getProdAppID, dbExists, } = require("@budibase/backend-core/db");
19
+ const { getAppId } = require("@budibase/backend-core/context");
20
20
  const BASE_AUTO_ID = 1;
21
21
  /**
22
22
  * A map of how we convert various properties in rows to each other based on the row type.
@@ -175,6 +175,7 @@ function processAutoColumn(user, table, row, opts = { reprocessing: false, noAut
175
175
  return { table, row };
176
176
  }
177
177
  exports.processAutoColumn = processAutoColumn;
178
+ exports.processFormulas = processFormulas;
178
179
  /**
179
180
  * This will coerce a value to the correct types based on the type transform map
180
181
  * @param {object} row The value to coerce
@@ -218,11 +219,11 @@ exports.inputProcessing = (user = {}, table, row, opts = { noAutoRelationships:
218
219
  }
219
220
  continue;
220
221
  }
221
- // specific case to delete formula values if they get saved
222
- // type coercion cannot completely remove the field, so have to do it here
222
+ // remove any formula values, they are to be generated
223
223
  if (field.type === FieldTypes.FORMULA) {
224
224
  delete clonedRow[key];
225
225
  }
226
+ // otherwise coerce what is there to correct types
226
227
  else {
227
228
  clonedRow[key] = exports.coerce(value, field.type);
228
229
  }
@@ -237,24 +238,22 @@ exports.inputProcessing = (user = {}, table, row, opts = { noAutoRelationships:
237
238
  /**
238
239
  * This function enriches the input rows with anything they are supposed to contain, for example
239
240
  * link records or attachment links.
240
- * @param {object} ctx the request which is looking for enriched rows.
241
241
  * @param {object} table the table from which these rows came from originally, this is used to determine
242
242
  * the schema of the rows and then enrich.
243
243
  * @param {object[]|object} rows the rows which are to be enriched.
244
244
  * @param {object} opts used to set some options for the output, such as disabling relationship squashing.
245
245
  * @returns {object[]|object} the enriched rows will be returned.
246
246
  */
247
- exports.outputProcessing = (ctx, table, rows, opts = { squash: true }) => __awaiter(void 0, void 0, void 0, function* () {
248
- const appId = ctx.appId;
247
+ exports.outputProcessing = (table, rows, opts = { squash: true }) => __awaiter(void 0, void 0, void 0, function* () {
249
248
  let wasArray = true;
250
249
  if (!(rows instanceof Array)) {
251
250
  rows = [rows];
252
251
  wasArray = false;
253
252
  }
254
253
  // attach any linked row information
255
- let enriched = yield linkRows.attachFullLinkedDocs(ctx, table, rows);
254
+ let enriched = yield linkRows.attachFullLinkedDocs(table, rows);
256
255
  // process formulas
257
- enriched = processFormulas(table, enriched);
256
+ enriched = processFormulas(table, enriched, { dynamic: true });
258
257
  // update the attachments URL depending on hosting
259
258
  for (let [property, column] of Object.entries(table.schema)) {
260
259
  if (column.type === FieldTypes.ATTACHMENT) {
@@ -269,24 +268,26 @@ exports.outputProcessing = (ctx, table, rows, opts = { squash: true }) => __awai
269
268
  }
270
269
  }
271
270
  if (opts.squash) {
272
- enriched = yield linkRows.squashLinksToPrimaryDisplay(appId, table, enriched);
271
+ enriched = yield linkRows.squashLinksToPrimaryDisplay(table, enriched);
273
272
  }
274
273
  return wasArray ? enriched : enriched[0];
275
274
  });
276
275
  /**
277
276
  * Clean up any attachments that were attached to a row.
278
- * @param {string} appId The ID of the app from which a row is being deleted.
279
277
  * @param {object} table The table from which a row is being removed.
280
278
  * @param {any} row optional - the row being removed.
281
279
  * @param {any} rows optional - if multiple rows being deleted can do this in bulk.
282
280
  * @param {any} oldRow optional - if updating a row this will determine the difference.
281
+ * @param {any} oldTable optional - if updating a table, can supply the old table to look for
282
+ * deleted attachment columns.
283
283
  * @return {Promise<void>} When all attachments have been removed this will return.
284
284
  */
285
- exports.cleanupAttachments = (appId, table, { row, rows, oldRow }) => __awaiter(void 0, void 0, void 0, function* () {
285
+ exports.cleanupAttachments = (table, { row, rows, oldRow, oldTable }) => __awaiter(void 0, void 0, void 0, function* () {
286
+ const appId = getAppId();
286
287
  if (!isProdAppID(appId)) {
287
- const prodAppId = getDeployedAppID(appId);
288
+ const prodAppId = getProdAppID(appId);
288
289
  // if prod exists, then don't allow deleting
289
- const exists = yield dbExists(CouchDB, prodAppId);
290
+ const exists = yield dbExists(prodAppId);
290
291
  if (exists) {
291
292
  return;
292
293
  }
@@ -297,12 +298,17 @@ exports.cleanupAttachments = (appId, table, { row, rows, oldRow }) => __awaiter(
297
298
  files = files.concat(row[key].map(attachment => attachment.key));
298
299
  }
299
300
  }
300
- for (let [key, schema] of Object.entries(table.schema)) {
301
+ const schemaToUse = oldTable ? oldTable.schema : table.schema;
302
+ for (let [key, schema] of Object.entries(schemaToUse)) {
301
303
  if (schema.type !== FieldTypes.ATTACHMENT) {
302
304
  continue;
303
305
  }
304
- // if updating, need to manage the differences
305
- if (oldRow && row) {
306
+ // old table had this column, new table doesn't - delete it
307
+ if (oldTable && !table.schema[key]) {
308
+ rows.forEach(row => addFiles(row, key));
309
+ }
310
+ else if (oldRow && row) {
311
+ // if updating, need to manage the differences
306
312
  files = files.concat(getRemovedAttachmentKeys(oldRow, row, key));
307
313
  }
308
314
  else if (row) {
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
- const { FieldTypes } = require("../../constants");
2
+ const { FieldTypes, FormulaTypes } = require("../../constants");
3
3
  const { processStringSync } = require("@budibase/string-templates");
4
4
  /**
5
5
  * Looks through the rows provided and finds formulas - which it then processes.
6
6
  */
7
- exports.processFormulas = (table, rows) => {
7
+ exports.processFormulas = (table, rows, { dynamic, contextRows } = { dynamic: true }) => {
8
8
  const single = !Array.isArray(rows);
9
9
  if (single) {
10
10
  rows = [rows];
11
+ contextRows = contextRows ? [contextRows] : contextRows;
11
12
  }
12
13
  for (let [column, schema] of Object.entries(table.schema)) {
13
- if (schema.type !== FieldTypes.FORMULA) {
14
+ const isStatic = schema.formulaType === FormulaTypes.STATIC;
15
+ if (schema.type !== FieldTypes.FORMULA ||
16
+ (dynamic && isStatic) ||
17
+ (!dynamic && !isStatic)) {
14
18
  continue;
15
19
  }
16
20
  // iterate through rows and process formula
17
- rows = rows.map(row => (Object.assign(Object.assign({}, row), { [column]: processStringSync(schema.formula, row) })));
21
+ for (let i = 0; i < rows.length; i++) {
22
+ if (schema.formula) {
23
+ let row = rows[i];
24
+ let context = contextRows ? contextRows[i] : row;
25
+ rows[i] = Object.assign(Object.assign({}, row), { [column]: processStringSync(schema.formula, context) });
26
+ }
27
+ }
18
28
  }
19
29
  return single ? rows[0] : rows;
20
30
  };
@@ -52,6 +52,7 @@ exports.getUsageQuotaDoc = (db) => __awaiter(void 0, void 0, void 0, function* (
52
52
  * Given a specified tenantId this will add to the usage object for the specified property.
53
53
  * @param {string} property The property which is to be added to (within the nested usageQuota object).
54
54
  * @param {number} usage The amount (this can be negative) to adjust the number by.
55
+ * @param {object} opts optional - options such as dryRun, to check what update will do.
55
56
  * @returns {Promise<void>} When this completes the API key will now be up to date - the quota period may have
56
57
  * also been reset after this call.
57
58
  */
@@ -31,6 +31,7 @@ const getAppPairs = appIds => {
31
31
  return pairs;
32
32
  };
33
33
  const getAppRows = (appId) => __awaiter(void 0, void 0, void 0, function* () {
34
+ // need to specify the app ID, as this is used for different apps in one call
34
35
  const appDb = new CouchDB(appId);
35
36
  const response = yield appDb.allDocs(getRowParams(null, null, {
36
37
  include_docs: false,
@@ -8,15 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const CouchDB = require("../db");
12
11
  const { InternalTables } = require("../db/utils");
13
12
  const { getGlobalUser } = require("../utilities/global");
13
+ const { getAppDB } = require("@budibase/backend-core/context");
14
14
  exports.getFullUser = (ctx, userId) => __awaiter(void 0, void 0, void 0, function* () {
15
- const global = yield getGlobalUser(ctx.appId, userId);
15
+ const global = yield getGlobalUser(userId);
16
16
  let metadata;
17
17
  try {
18
18
  // this will throw an error if the db doesn't exist, or there is no appId
19
- const db = new CouchDB(ctx.appId);
19
+ const db = getAppDB();
20
20
  metadata = yield db.get(userId);
21
21
  }
22
22
  catch (err) {
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  const fetch = require("node-fetch");
12
12
  const env = require("../environment");
13
13
  const { checkSlashesInUrl } = require("./index");
14
- const { getDeployedAppID } = require("@budibase/backend-core/db");
14
+ const { getProdAppID } = require("@budibase/backend-core/db");
15
15
  const { updateAppRole } = require("./global");
16
16
  const { Headers } = require("@budibase/backend-core/constants");
17
17
  const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy");
@@ -71,13 +71,13 @@ exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0,
71
71
  }
72
72
  let json = yield response.json();
73
73
  if (appId) {
74
- json = updateAppRole(appId, json);
74
+ json = updateAppRole(json);
75
75
  }
76
76
  return json;
77
77
  });
78
78
  exports.removeAppFromUserRoles = (ctx, appId) => __awaiter(void 0, void 0, void 0, function* () {
79
- const deployedAppId = getDeployedAppID(appId);
80
- const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${deployedAppId}`), request(ctx, {
79
+ const prodAppId = getProdAppID(appId);
80
+ const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`), request(ctx, {
81
81
  method: "DELETE",
82
82
  }));
83
83
  if (response.status !== 200) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.49-alpha.0",
4
+ "version": "1.0.49-alpha.12",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -70,9 +70,9 @@
70
70
  "license": "GPL-3.0",
71
71
  "dependencies": {
72
72
  "@apidevtools/swagger-parser": "^10.0.3",
73
- "@budibase/backend-core": "^1.0.49-alpha.0",
74
- "@budibase/client": "^1.0.49-alpha.0",
75
- "@budibase/string-templates": "^1.0.49-alpha.0",
73
+ "@budibase/backend-core": "^1.0.49-alpha.12",
74
+ "@budibase/client": "^1.0.49-alpha.12",
75
+ "@budibase/string-templates": "^1.0.49-alpha.12",
76
76
  "@bull-board/api": "^3.7.0",
77
77
  "@bull-board/koa": "^3.7.0",
78
78
  "@elastic/elasticsearch": "7.10.0",
@@ -168,5 +168,5 @@
168
168
  "optionalDependencies": {
169
169
  "oracledb": "^5.3.0"
170
170
  },
171
- "gitHead": "27d295ae310158a0a240fe62c45362ad03f82115"
171
+ "gitHead": "77f938b85661b5da74e6f676afed584370ac48e1"
172
172
  }
@@ -9,12 +9,16 @@ CREATE TABLE Persons (
9
9
  );
10
10
  CREATE TABLE Tasks (
11
11
  TaskID SERIAL PRIMARY KEY,
12
- PersonID INT,
12
+ ExecutorID INT,
13
+ QaID INT,
13
14
  Completed BOOLEAN,
14
15
  TaskName varchar(255),
15
- CONSTRAINT fkPersons
16
- FOREIGN KEY(PersonID)
17
- REFERENCES Persons(PersonID)
16
+ CONSTRAINT fkexecutor
17
+ FOREIGN KEY(ExecutorID)
18
+ REFERENCES Persons(PersonID),
19
+ CONSTRAINT fkqa
20
+ FOREIGN KEY(QaID)
21
+ REFERENCES Persons(PersonID)
18
22
  );
19
23
  CREATE TABLE Products (
20
24
  ProductID SERIAL PRIMARY KEY,
@@ -32,8 +36,9 @@ CREATE TABLE Products_Tasks (
32
36
  PRIMARY KEY (ProductID, TaskID)
33
37
  );
34
38
  INSERT INTO Persons (FirstName, LastName, Address, City) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast');
35
- INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'assembling', TRUE);
36
- INSERT INTO Tasks (PersonID, TaskName, Completed) VALUES (1, 'processing', FALSE);
39
+ INSERT INTO Persons (FirstName, LastName, Address, City) Values ('John', 'Smith', '64 Updown Road', 'Dublin');
40
+ INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (1, 2, 'assembling', TRUE);
41
+ INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (2, 1, 'processing', FALSE);
37
42
  INSERT INTO Products (ProductName) VALUES ('Computers');
38
43
  INSERT INTO Products (ProductName) VALUES ('Laptops');
39
44
  INSERT INTO Products (ProductName) VALUES ('Chairs');
@@ -30,4 +30,4 @@ process.env.ALLOW_DEV_AUTOMATIONS = "1"
30
30
  const server = require("../src/app")
31
31
  process.env.PORT = WORKER_PORT
32
32
  const worker = require("../../worker/src/index")
33
- process.env.PORT = MAIN_PORT
33
+ process.env.PORT = MAIN_PORT