@budibase/server 1.0.49-alpha.6 → 1.0.49

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 (376) hide show
  1. package/__mocks__/arangojs.ts +1 -1
  2. package/__mocks__/aws-sdk.ts +4 -4
  3. package/__mocks__/mongodb.ts +5 -4
  4. package/__mocks__/mssql.ts +3 -3
  5. package/__mocks__/node-fetch.ts +1 -2
  6. package/__mocks__/pg.ts +5 -3
  7. package/builder/assets/{index.1b905242.js → index.2c37968e.js} +231 -234
  8. package/builder/assets/index.39e01193.css +1 -0
  9. package/builder/assets/{vendor.d526bfe8.js → vendor.f9faf6ab.js} +12 -12
  10. package/builder/index.html +3 -3
  11. package/coverage/clover.xml +2816 -3119
  12. package/coverage/coverage-final.json +101 -106
  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 +152 -257
  16. package/coverage/lcov-report/api/controllers/auth.js.html +13 -22
  17. package/coverage/lcov-report/api/controllers/automation.js.html +69 -39
  18. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/cloud.js.html +11 -8
  20. package/coverage/lcov-report/api/controllers/component.js.html +16 -13
  21. package/coverage/lcov-report/api/controllers/datasource.js.html +51 -81
  22. package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
  23. package/coverage/lcov-report/{utilities/usageQuota/usageQuoteReset.js.html → api/controllers/hosting.js.html} +48 -36
  24. package/coverage/lcov-report/api/controllers/index.html +76 -76
  25. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
  27. package/coverage/lcov-report/api/controllers/metadata.js.html +21 -6
  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 +35 -38
  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 +10 -7
  34. package/coverage/lcov-report/api/controllers/row/external.js.html +27 -21
  35. package/coverage/lcov-report/api/controllers/row/index.html +34 -49
  36. package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
  37. package/coverage/lcov-report/api/controllers/row/internal.js.html +226 -118
  38. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +34 -52
  39. package/coverage/lcov-report/api/controllers/row/utils.js.html +62 -47
  40. package/coverage/lcov-report/api/controllers/screen.js.html +21 -15
  41. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  42. package/coverage/lcov-report/api/controllers/table/external.js.html +34 -25
  43. package/coverage/lcov-report/api/controllers/table/index.html +43 -58
  44. package/coverage/lcov-report/api/controllers/table/index.js.html +82 -58
  45. package/coverage/lcov-report/api/controllers/table/internal.js.html +66 -81
  46. package/coverage/lcov-report/api/controllers/table/utils.js.html +110 -218
  47. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  48. package/coverage/lcov-report/api/controllers/user.js.html +50 -47
  49. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  50. package/coverage/lcov-report/api/controllers/view/index.html +16 -16
  51. package/coverage/lcov-report/api/controllers/view/index.js.html +33 -27
  52. package/coverage/lcov-report/api/controllers/view/utils.js.html +20 -35
  53. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  54. package/coverage/lcov-report/api/controllers/webhook.js.html +28 -34
  55. package/coverage/lcov-report/api/index.html +1 -1
  56. package/coverage/lcov-report/api/index.js.html +8 -8
  57. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/{migrations.js.html → hosting.js.html} +14 -17
  69. package/coverage/lcov-report/api/routes/index.html +18 -18
  70. package/coverage/lcov-report/api/routes/index.js.html +3 -3
  71. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  80. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  81. package/coverage/lcov-report/api/routes/static.js.html +2 -17
  82. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  83. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  84. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  85. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  86. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  87. package/coverage/lcov-report/automations/actions.js.html +24 -24
  88. package/coverage/lcov-report/automations/automationUtils.js.html +10 -7
  89. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  90. package/coverage/lcov-report/automations/index.html +18 -18
  91. package/coverage/lcov-report/automations/index.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  93. package/coverage/lcov-report/automations/steps/createRow.js.html +22 -13
  94. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  95. package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
  96. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  97. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  98. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  99. package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
  100. package/coverage/lcov-report/automations/steps/index.html +13 -13
  101. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  102. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  103. package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
  104. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  105. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  106. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  107. package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
  108. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  109. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  110. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  111. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  112. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  113. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  114. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  115. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  116. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  117. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  118. package/coverage/lcov-report/automations/triggers.js.html +55 -61
  119. package/coverage/lcov-report/automations/utils.js.html +42 -54
  120. package/coverage/lcov-report/constants/index.html +5 -5
  121. package/coverage/lcov-report/constants/index.js.html +26 -53
  122. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  123. package/coverage/lcov-report/constants/screens.js.html +4 -4
  124. package/coverage/lcov-report/db/client.js.html +18 -18
  125. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  126. package/coverage/lcov-report/db/index.html +15 -15
  127. package/coverage/lcov-report/db/index.js.html +3 -3
  128. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +37 -25
  129. package/coverage/lcov-report/db/linkedRows/index.html +27 -27
  130. package/coverage/lcov-report/db/linkedRows/index.js.html +96 -51
  131. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +42 -42
  132. package/coverage/lcov-report/db/newid.js.html +4 -4
  133. package/coverage/lcov-report/db/utils.js.html +87 -87
  134. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  135. package/coverage/lcov-report/events/index.html +1 -1
  136. package/coverage/lcov-report/events/index.js.html +5 -5
  137. package/coverage/lcov-report/events/utils.js.html +3 -3
  138. package/coverage/lcov-report/index.html +120 -135
  139. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  140. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  141. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  142. package/coverage/lcov-report/middleware/authorized.js.html +65 -173
  143. package/coverage/lcov-report/middleware/builder.js.html +10 -10
  144. package/coverage/lcov-report/middleware/currentapp.js.html +83 -95
  145. package/coverage/lcov-report/middleware/index.html +38 -38
  146. package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
  147. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  148. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  149. package/coverage/lcov-report/middleware/usageQuota.js.html +53 -281
  150. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  151. package/coverage/lcov-report/threads/automation.js.html +24 -30
  152. package/coverage/lcov-report/threads/index.html +26 -26
  153. package/coverage/lcov-report/threads/index.js.html +10 -10
  154. package/coverage/lcov-report/threads/query.js.html +26 -62
  155. package/coverage/lcov-report/threads/utils.js.html +14 -14
  156. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  157. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  158. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  159. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  160. package/coverage/lcov-report/utilities/global.js.html +49 -58
  161. package/coverage/lcov-report/utilities/index.html +37 -37
  162. package/coverage/lcov-report/utilities/index.js.html +73 -43
  163. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
  164. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  165. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  166. package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
  167. package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -27
  168. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +103 -97
  169. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +27 -75
  170. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  171. package/coverage/lcov-report/utilities/security.js.html +8 -8
  172. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  173. package/coverage/lcov-report/utilities/users.js.html +9 -9
  174. package/coverage/lcov-report/utilities/workerRequests.js.html +112 -43
  175. package/coverage/lcov.info +4423 -5022
  176. package/dist/api/controllers/application.js +60 -90
  177. package/dist/api/controllers/auth.js +5 -8
  178. package/dist/api/controllers/automation.js +19 -14
  179. package/dist/api/controllers/cloud.js +3 -2
  180. package/dist/api/controllers/component.js +4 -3
  181. package/dist/api/controllers/datasource.js +10 -20
  182. package/dist/api/controllers/deploy/Deployment.js +6 -3
  183. package/dist/api/controllers/deploy/index.js +13 -12
  184. package/dist/api/controllers/dev.js +5 -5
  185. package/dist/api/controllers/hosting.js +30 -0
  186. package/dist/api/controllers/layout.js +3 -3
  187. package/dist/api/controllers/metadata.js +4 -4
  188. package/dist/api/controllers/permission.js +4 -4
  189. package/dist/api/controllers/query/import/index.js +6 -4
  190. package/dist/api/controllers/query/index.js +10 -11
  191. package/dist/api/controllers/role.js +5 -5
  192. package/dist/api/controllers/routing.js +6 -5
  193. package/dist/api/controllers/row/ExternalRequest.js +63 -76
  194. package/dist/api/controllers/row/external.js +4 -4
  195. package/dist/api/controllers/row/internal.js +93 -55
  196. package/dist/api/controllers/row/internalSearch.js +17 -23
  197. package/dist/api/controllers/row/utils.js +14 -13
  198. package/dist/api/controllers/screen.js +7 -5
  199. package/dist/api/controllers/static/index.js +12 -61
  200. package/dist/api/controllers/table/external.js +10 -7
  201. package/dist/api/controllers/table/index.js +13 -16
  202. package/dist/api/controllers/table/internal.js +16 -22
  203. package/dist/api/controllers/table/utils.js +35 -62
  204. package/dist/api/controllers/user.js +20 -18
  205. package/dist/api/controllers/view/index.js +10 -8
  206. package/dist/api/controllers/view/utils.js +4 -9
  207. package/dist/api/controllers/webhook.js +8 -10
  208. package/dist/api/routes/hosting.js +11 -0
  209. package/dist/api/routes/index.js +2 -2
  210. package/dist/api/routes/static.js +1 -2
  211. package/dist/api/routes/tests/utilities/TestFunctions.js +17 -37
  212. package/dist/app.js +5 -35
  213. package/dist/automations/automationUtils.js +3 -2
  214. package/dist/automations/steps/createRow.js +5 -3
  215. package/dist/automations/steps/deleteRow.js +4 -1
  216. package/dist/automations/steps/updateRow.js +1 -1
  217. package/dist/automations/triggers.js +25 -27
  218. package/dist/automations/utils.js +5 -10
  219. package/dist/constants/index.js +0 -7
  220. package/dist/db/linkedRows/LinkController.js +7 -3
  221. package/dist/db/linkedRows/index.js +27 -16
  222. package/dist/db/linkedRows/linkUtils.js +6 -6
  223. package/dist/db/views/staticViews.js +10 -9
  224. package/dist/definitions/datasource.js +0 -1
  225. package/dist/environment.js +1 -4
  226. package/dist/integrations/base/sql.js +6 -13
  227. package/dist/integrations/index.js +0 -3
  228. package/dist/integrations/utils.js +9 -60
  229. package/dist/middleware/authorized.js +30 -57
  230. package/dist/middleware/builder.js +2 -2
  231. package/dist/middleware/currentapp.js +37 -41
  232. package/dist/middleware/usageQuota.js +15 -82
  233. package/dist/package.json +5 -8
  234. package/dist/tests/utilities/TestConfiguration.js +50 -80
  235. package/dist/threads/automation.js +11 -13
  236. package/dist/threads/query.js +13 -23
  237. package/dist/tsconfig.tsbuildinfo +1 -1
  238. package/dist/utilities/fileSystem/index.js +3 -4
  239. package/dist/utilities/global.js +12 -15
  240. package/dist/utilities/index.js +17 -7
  241. package/dist/utilities/routing/index.js +5 -5
  242. package/dist/utilities/rowProcessor/index.js +17 -23
  243. package/dist/utilities/rowProcessor/utils.js +4 -14
  244. package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -45
  245. package/dist/utilities/users.js +3 -3
  246. package/dist/utilities/workerRequests.js +24 -4
  247. package/nodemon.json +1 -1
  248. package/package.json +6 -9
  249. package/scripts/likeCypress.ts +1 -1
  250. package/src/api/controllers/application.js +50 -85
  251. package/src/api/controllers/auth.js +5 -8
  252. package/src/api/controllers/automation.js +23 -13
  253. package/src/api/controllers/cloud.js +3 -2
  254. package/src/api/controllers/component.js +4 -3
  255. package/src/api/controllers/datasource.js +11 -21
  256. package/src/api/controllers/deploy/Deployment.js +7 -3
  257. package/src/api/controllers/deploy/index.js +13 -20
  258. package/src/api/controllers/dev.js +5 -5
  259. package/src/api/controllers/hosting.js +22 -0
  260. package/src/api/controllers/layout.js +3 -3
  261. package/src/api/controllers/metadata.js +9 -4
  262. package/src/api/controllers/permission.js +4 -4
  263. package/src/api/controllers/query/import/index.ts +6 -4
  264. package/src/api/controllers/query/import/tests/index.spec.js +1 -2
  265. package/src/api/controllers/query/index.js +10 -11
  266. package/src/api/controllers/role.js +5 -5
  267. package/src/api/controllers/routing.js +6 -5
  268. package/src/api/controllers/row/ExternalRequest.ts +42 -53
  269. package/src/api/controllers/row/external.js +6 -4
  270. package/src/api/controllers/row/internal.js +90 -54
  271. package/src/api/controllers/row/internalSearch.js +17 -23
  272. package/src/api/controllers/row/utils.js +18 -13
  273. package/src/api/controllers/screen.js +7 -5
  274. package/src/api/controllers/static/index.js +12 -65
  275. package/src/api/controllers/table/external.js +10 -7
  276. package/src/api/controllers/table/index.js +28 -20
  277. package/src/api/controllers/table/internal.js +19 -24
  278. package/src/api/controllers/table/utils.js +42 -78
  279. package/src/api/controllers/user.js +20 -19
  280. package/src/api/controllers/view/index.js +10 -8
  281. package/src/api/controllers/view/utils.js +4 -9
  282. package/src/api/controllers/webhook.js +8 -10
  283. package/src/api/routes/hosting.js +13 -0
  284. package/src/api/routes/index.js +2 -2
  285. package/src/api/routes/static.js +0 -5
  286. package/src/api/routes/tests/application.spec.js +2 -2
  287. package/src/api/routes/tests/auth.spec.js +2 -1
  288. package/src/api/routes/tests/automation.spec.js +0 -1
  289. package/src/api/routes/tests/hosting.spec.js +36 -0
  290. package/src/api/routes/tests/misc.spec.js +1 -0
  291. package/src/api/routes/tests/routing.spec.js +12 -21
  292. package/src/api/routes/tests/row.spec.js +4 -7
  293. package/src/api/routes/tests/utilities/TestFunctions.js +17 -39
  294. package/src/app.ts +5 -18
  295. package/src/automations/automationUtils.js +3 -2
  296. package/src/automations/steps/createRow.js +5 -2
  297. package/src/automations/steps/deleteRow.js +4 -1
  298. package/src/automations/steps/updateRow.js +1 -1
  299. package/src/automations/triggers.js +31 -33
  300. package/src/automations/utils.js +5 -9
  301. package/src/constants/index.js +0 -9
  302. package/src/db/linkedRows/LinkController.js +7 -3
  303. package/src/db/linkedRows/index.js +31 -16
  304. package/src/db/linkedRows/linkUtils.js +6 -6
  305. package/src/db/tests/linkController.spec.js +1 -0
  306. package/src/db/tests/linkTests.spec.js +6 -5
  307. package/src/db/views/staticViews.js +10 -8
  308. package/src/definitions/common.ts +0 -3
  309. package/src/definitions/datasource.ts +0 -3
  310. package/src/environment.js +1 -4
  311. package/src/integrations/base/sql.ts +7 -14
  312. package/src/integrations/index.ts +0 -3
  313. package/src/integrations/tests/sql.spec.js +0 -16
  314. package/src/integrations/utils.ts +12 -75
  315. package/src/middleware/authorized.js +30 -66
  316. package/src/middleware/builder.js +2 -2
  317. package/src/middleware/currentapp.js +46 -50
  318. package/src/middleware/tests/authorized.spec.js +6 -13
  319. package/src/middleware/tests/currentapp.spec.js +0 -6
  320. package/src/middleware/tests/usageQuota.spec.js +24 -18
  321. package/src/middleware/usageQuota.js +17 -93
  322. package/src/tests/utilities/TestConfiguration.js +55 -82
  323. package/src/threads/automation.js +15 -17
  324. package/src/threads/query.js +14 -26
  325. package/src/utilities/fileSystem/index.js +3 -4
  326. package/src/utilities/global.js +12 -15
  327. package/src/utilities/index.js +17 -7
  328. package/src/utilities/routing/index.js +5 -5
  329. package/src/utilities/rowProcessor/index.js +27 -25
  330. package/src/utilities/rowProcessor/utils.js +7 -23
  331. package/src/utilities/usageQuota.js +73 -0
  332. package/src/utilities/users.js +3 -3
  333. package/src/utilities/workerRequests.js +27 -4
  334. package/builder/assets/index.83c0944f.css +0 -1
  335. package/coverage/lcov-report/api/controllers/migrations.js.html +0 -119
  336. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +0 -548
  337. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +0 -599
  338. package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
  339. package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
  340. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -305
  341. package/dist/api/controllers/migrations.js +0 -21
  342. package/dist/api/controllers/row/staticFormula.js +0 -147
  343. package/dist/api/controllers/table/bulkFormula.js +0 -159
  344. package/dist/api/routes/migrations.js +0 -9
  345. package/dist/integrations/googlesheets.js +0 -340
  346. package/dist/migrations/functions/appUrls.js +0 -46
  347. package/dist/migrations/functions/quotas1.js +0 -50
  348. package/dist/migrations/functions/usageQuotas/index.js +0 -20
  349. package/dist/migrations/functions/usageQuotas/syncApps.js +0 -30
  350. package/dist/migrations/functions/usageQuotas/syncRows.js +0 -33
  351. package/dist/migrations/functions/userEmailViewCasing.js +0 -24
  352. package/dist/migrations/index.js +0 -62
  353. package/dist/utilities/usageQuota/rows.js +0 -78
  354. package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
  355. package/src/api/controllers/migrations.js +0 -13
  356. package/src/api/controllers/row/staticFormula.js +0 -156
  357. package/src/api/controllers/table/bulkFormula.js +0 -173
  358. package/src/api/routes/migrations.js +0 -14
  359. package/src/api/routes/tests/static.spec.js +0 -98
  360. package/src/integrations/googlesheets.ts +0 -353
  361. package/src/migrations/functions/appUrls.ts +0 -34
  362. package/src/migrations/functions/quotas1.ts +0 -20
  363. package/src/migrations/functions/tests/appUrls.spec.js +0 -29
  364. package/src/migrations/functions/tests/quotas1.spec.js +0 -27
  365. package/src/migrations/functions/tests/userEmailViewCasing.spec.js +0 -25
  366. package/src/migrations/functions/usageQuotas/index.ts +0 -8
  367. package/src/migrations/functions/usageQuotas/syncApps.ts +0 -19
  368. package/src/migrations/functions/usageQuotas/syncRows.ts +0 -22
  369. package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -37
  370. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -43
  371. package/src/migrations/functions/userEmailViewCasing.ts +0 -13
  372. package/src/migrations/index.ts +0 -56
  373. package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
  374. package/src/utilities/usageQuota/index.js +0 -93
  375. package/src/utilities/usageQuota/rows.js +0 -75
  376. package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
@@ -19,19 +19,6 @@ import {
19
19
  isRowId,
20
20
  convertRowId,
21
21
  } from "../../../integrations/utils"
22
- import { getDatasourceAndQuery } from "./utils"
23
- import {
24
- DataSourceOperation,
25
- FieldTypes,
26
- RelationshipTypes,
27
- } from "../../../constants"
28
- import { breakExternalTableId, isSQL } from "../../../integrations/utils"
29
- import { processObjectSync } from "@budibase/string-templates"
30
- // @ts-ignore
31
- import { cloneDeep } from "lodash/fp"
32
- import { processFormulas } from "../../../utilities/rowProcessor/utils"
33
- // @ts-ignore
34
- import { getAppDB } from "@budibase/backend-core/context"
35
22
 
36
23
  interface ManyRelationship {
37
24
  tableId?: string
@@ -51,6 +38,18 @@ interface RunConfig {
51
38
  }
52
39
 
53
40
  module External {
41
+ const { getDatasourceAndQuery } = require("./utils")
42
+ const {
43
+ DataSourceOperation,
44
+ FieldTypes,
45
+ RelationshipTypes,
46
+ } = require("../../../constants")
47
+ const { breakExternalTableId, isSQL } = require("../../../integrations/utils")
48
+ const { processObjectSync } = require("@budibase/string-templates")
49
+ const { cloneDeep } = require("lodash/fp")
50
+ const CouchDB = require("../../../db")
51
+ const { processFormulas } = require("../../../utilities/rowProcessor/utils")
52
+
54
53
  function buildFilters(
55
54
  id: string | undefined,
56
55
  filters: SearchFilters,
@@ -211,12 +210,19 @@ module External {
211
210
  }
212
211
 
213
212
  class ExternalRequest {
213
+ private readonly appId: string
214
214
  private operation: Operation
215
215
  private tableId: string
216
216
  private datasource: Datasource
217
217
  private tables: { [key: string]: Table } = {}
218
218
 
219
- constructor(operation: Operation, tableId: string, datasource: Datasource) {
219
+ constructor(
220
+ appId: string,
221
+ operation: Operation,
222
+ tableId: string,
223
+ datasource: Datasource
224
+ ) {
225
+ this.appId = appId
220
226
  this.operation = operation
221
227
  this.tableId = tableId
222
228
  this.datasource = datasource
@@ -225,14 +231,12 @@ module External {
225
231
  }
226
232
  }
227
233
 
228
- getTable(tableId: string | undefined): Table | undefined {
234
+ getTable(tableId: string | undefined): Table {
229
235
  if (!tableId) {
230
236
  throw "Table ID is unknown, cannot find table"
231
237
  }
232
238
  const { tableName } = breakExternalTableId(tableId)
233
- if (tableName) {
234
- return this.tables[tableName]
235
- }
239
+ return this.tables[tableName]
236
240
  }
237
241
 
238
242
  inputProcessing(row: Row | undefined, table: Table) {
@@ -268,11 +272,9 @@ module External {
268
272
  newRow[key] = row[key]
269
273
  continue
270
274
  }
271
- const { tableName: linkTableName } = breakExternalTableId(
272
- field?.tableId
273
- )
275
+ const { tableName: linkTableName } = breakExternalTableId(field.tableId)
274
276
  // table has to exist for many to many
275
- if (!linkTableName || !this.tables[linkTableName]) {
277
+ if (!this.tables[linkTableName]) {
276
278
  continue
277
279
  }
278
280
  const linkTable = this.tables[linkTableName]
@@ -420,7 +422,7 @@ module External {
420
422
  }
421
423
  const { tableName: linkTableName } = breakExternalTableId(field.tableId)
422
424
  // no table to link to, this is not a valid relationships
423
- if (!linkTableName || !this.tables[linkTableName]) {
425
+ if (!this.tables[linkTableName]) {
424
426
  continue
425
427
  }
426
428
  const linkTable = this.tables[linkTableName]
@@ -458,9 +460,6 @@ module External {
458
460
  async lookupRelations(tableId: string, row: Row) {
459
461
  const related: { [key: string]: any } = {}
460
462
  const { tableName } = breakExternalTableId(tableId)
461
- if (!tableName) {
462
- return related
463
- }
464
463
  const table = this.tables[tableName]
465
464
  // @ts-ignore
466
465
  const primaryKey = table.primary[0]
@@ -485,7 +484,7 @@ module External {
485
484
  if (!lookupField || !row[lookupField]) {
486
485
  continue
487
486
  }
488
- const response = await getDatasourceAndQuery({
487
+ const response = await getDatasourceAndQuery(this.appId, {
489
488
  endpoint: getEndpoint(tableId, DataSourceOperation.READ),
490
489
  filters: {
491
490
  equal: {
@@ -516,30 +515,28 @@ module External {
516
515
  row: Row,
517
516
  relationships: ManyRelationship[]
518
517
  ) {
518
+ const { appId } = this
519
519
  // if we're creating (in a through table) need to wipe the existing ones first
520
520
  const promises = []
521
521
  const related = await this.lookupRelations(mainTableId, row)
522
522
  for (let relationship of relationships) {
523
523
  const { key, tableId, isUpdate, id, ...rest } = relationship
524
- const body: { [key: string]: any } = processObjectSync(rest, row, {})
524
+ const body = processObjectSync(rest, row)
525
525
  const linkTable = this.getTable(tableId)
526
526
  // @ts-ignore
527
- const linkPrimary = linkTable?.primary[0]
528
- if (!linkTable || !linkPrimary) {
529
- return
530
- }
531
- const rows = related[key].rows || []
527
+ const linkPrimary = linkTable.primary[0]
528
+ const rows = related[key]?.rows || []
532
529
  const found = rows.find(
533
530
  (row: { [key: string]: any }) =>
534
531
  row[linkPrimary] === relationship.id ||
535
- row[linkPrimary] === body?.[linkPrimary]
532
+ row[linkPrimary] === body[linkPrimary]
536
533
  )
537
534
  const operation = isUpdate
538
535
  ? DataSourceOperation.UPDATE
539
536
  : DataSourceOperation.CREATE
540
537
  if (!found) {
541
538
  promises.push(
542
- getDatasourceAndQuery({
539
+ getDatasourceAndQuery(appId, {
543
540
  endpoint: getEndpoint(tableId, operation),
544
541
  // if we're doing many relationships then we're writing, only one response
545
542
  body,
@@ -555,12 +552,9 @@ module External {
555
552
  for (let [colName, { isMany, rows, tableId }] of Object.entries(
556
553
  related
557
554
  )) {
558
- const table: Table | undefined = this.getTable(tableId)
555
+ const table: Table = this.getTable(tableId)
559
556
  // if its not the foreign key skip it, nothing to do
560
- if (
561
- !table ||
562
- (table.primary && table.primary.indexOf(colName) !== -1)
563
- ) {
557
+ if (table.primary && table.primary.indexOf(colName) !== -1) {
564
558
  continue
565
559
  }
566
560
  for (let row of rows) {
@@ -572,7 +566,7 @@ module External {
572
566
  : DataSourceOperation.UPDATE
573
567
  const body = isMany ? null : { [colName]: null }
574
568
  promises.push(
575
- getDatasourceAndQuery({
569
+ getDatasourceAndQuery(this.appId, {
576
570
  endpoint: getEndpoint(tableId, op),
577
571
  body,
578
572
  filters,
@@ -611,25 +605,20 @@ module External {
611
605
  continue
612
606
  }
613
607
  const { tableName: linkTableName } = breakExternalTableId(field.tableId)
614
- if (linkTableName) {
615
- const linkTable = this.tables[linkTableName]
616
- if (linkTable) {
617
- const linkedFields = extractRealFields(linkTable, fields)
618
- fields = fields.concat(linkedFields)
619
- }
608
+ const linkTable = this.tables[linkTableName]
609
+ if (linkTable) {
610
+ const linkedFields = extractRealFields(linkTable, fields)
611
+ fields = fields.concat(linkedFields)
620
612
  }
621
613
  }
622
614
  return fields
623
615
  }
624
616
 
625
617
  async run(config: RunConfig) {
626
- const { operation, tableId } = this
618
+ const { appId, operation, tableId } = this
627
619
  let { datasourceId, tableName } = breakExternalTableId(tableId)
628
- if (!tableName) {
629
- throw "Unable to run without a table name"
630
- }
631
620
  if (!this.datasource) {
632
- const db = getAppDB()
621
+ const db = new CouchDB(appId)
633
622
  this.datasource = await db.get(datasourceId)
634
623
  if (!this.datasource || !this.datasource.entities) {
635
624
  throw "No tables found, fetch tables before query."
@@ -681,7 +670,7 @@ module External {
681
670
  },
682
671
  }
683
672
  // can't really use response right now
684
- const response = await getDatasourceAndQuery(json)
673
+ const response = await getDatasourceAndQuery(appId, json)
685
674
  // handle many to many relationships now if we know the ID (could be auto increment)
686
675
  if (
687
676
  operation !== DataSourceOperation.READ &&
@@ -9,9 +9,9 @@ const {
9
9
  breakRowIdField,
10
10
  } = require("../../../integrations/utils")
11
11
  const ExternalRequest = require("./ExternalRequest")
12
- const { getAppDB } = require("@budibase/backend-core/context")
12
+ const CouchDB = require("../../../db")
13
13
 
14
- async function handleRequest(operation, tableId, opts = {}) {
14
+ async function handleRequest(appId, operation, tableId, opts = {}) {
15
15
  // make sure the filters are cleaned up, no empty strings for equals, fuzzy or string
16
16
  if (opts && opts.filters) {
17
17
  for (let filterField of NoEmptyFilterStrings) {
@@ -25,7 +25,9 @@ async function handleRequest(operation, tableId, opts = {}) {
25
25
  }
26
26
  }
27
27
  }
28
- return new ExternalRequest(operation, tableId, opts.datasource).run(opts)
28
+ return new ExternalRequest(appId, operation, tableId, opts.datasource).run(
29
+ opts
30
+ )
29
31
  }
30
32
 
31
33
  exports.handleRequest = handleRequest
@@ -179,7 +181,7 @@ exports.fetchEnrichedRow = async ctx => {
179
181
  const id = ctx.params.rowId
180
182
  const tableId = ctx.params.tableId
181
183
  const { datasourceId, tableName } = breakExternalTableId(tableId)
182
- const db = getAppDB()
184
+ const db = new CouchDB(appId)
183
185
  const datasource = await db.get(datasourceId)
184
186
  if (!datasource || !datasource.entities) {
185
187
  ctx.throw(400, "Datasource has not been configured for plus API.")
@@ -1,7 +1,8 @@
1
+ const CouchDB = require("../../../db")
1
2
  const linkRows = require("../../../db/linkedRows")
2
3
  const {
3
- generateRowID,
4
4
  getRowParams,
5
+ generateRowID,
5
6
  DocumentTypes,
6
7
  InternalTables,
7
8
  } = require("../../../db/utils")
@@ -9,9 +10,11 @@ const userController = require("../user")
9
10
  const {
10
11
  inputProcessing,
11
12
  outputProcessing,
13
+ processAutoColumn,
12
14
  cleanupAttachments,
13
15
  } = require("../../../utilities/rowProcessor")
14
16
  const { FieldTypes } = require("../../../constants")
17
+ const { isEqual } = require("lodash")
15
18
  const { validate, findRow } = require("./utils")
16
19
  const { fullSearch, paginatedSearch } = require("./internalSearch")
17
20
  const { getGlobalUsersFromMetadata } = require("../../../utilities/global")
@@ -24,8 +27,6 @@ const {
24
27
  getFromMemoryDoc,
25
28
  } = require("../view/utils")
26
29
  const { cloneDeep } = require("lodash/fp")
27
- const { getAppDB } = require("@budibase/backend-core/context")
28
- const { finaliseRow, updateRelatedFormula } = require("./staticFormula")
29
30
 
30
31
  const CALCULATION_TYPES = {
31
32
  SUM: "sum",
@@ -33,6 +34,51 @@ const CALCULATION_TYPES = {
33
34
  STATS: "stats",
34
35
  }
35
36
 
37
+ async function storeResponse(ctx, db, row, oldTable, table) {
38
+ row.type = "row"
39
+ // don't worry about rev, tables handle rev/lastID updates
40
+ // if another row has been written since processing this will
41
+ // handle the auto ID clash
42
+ if (!isEqual(oldTable, table)) {
43
+ try {
44
+ await db.put(table)
45
+ } catch (err) {
46
+ if (err.status === 409) {
47
+ const updatedTable = await db.get(table._id)
48
+ let response = processAutoColumn(null, updatedTable, row, {
49
+ reprocessing: true,
50
+ })
51
+ await db.put(response.table)
52
+ row = response.row
53
+ } else {
54
+ throw err
55
+ }
56
+ }
57
+ }
58
+ const response = await db.put(row)
59
+ row._rev = response.rev
60
+ // process the row before return, to include relationships
61
+ row = await outputProcessing(ctx, table, row, { squash: false })
62
+ return { row, table }
63
+ }
64
+
65
+ // doesn't do the outputProcessing
66
+ async function getRawTableData(ctx, db, tableId) {
67
+ let rows
68
+ if (tableId === InternalTables.USER_METADATA) {
69
+ await userController.fetchMetadata(ctx)
70
+ rows = ctx.body
71
+ } else {
72
+ const response = await db.allDocs(
73
+ getRowParams(tableId, null, {
74
+ include_docs: true,
75
+ })
76
+ )
77
+ rows = response.rows.map(row => row.doc)
78
+ }
79
+ return rows
80
+ }
81
+
36
82
  async function getView(db, viewName) {
37
83
  let mainGetter = env.SELF_HOSTED ? getFromDesignDoc : getFromMemoryDoc
38
84
  let secondaryGetter = env.SELF_HOSTED ? getFromMemoryDoc : getFromDesignDoc
@@ -59,24 +105,9 @@ async function getView(db, viewName) {
59
105
  return viewInfo
60
106
  }
61
107
 
62
- async function getRawTableData(ctx, db, tableId) {
63
- let rows
64
- if (tableId === InternalTables.USER_METADATA) {
65
- await userController.fetchMetadata(ctx)
66
- rows = ctx.body
67
- } else {
68
- const response = await db.allDocs(
69
- getRowParams(tableId, null, {
70
- include_docs: true,
71
- })
72
- )
73
- rows = response.rows.map(row => row.doc)
74
- }
75
- return rows
76
- }
77
-
78
108
  exports.patch = async ctx => {
79
- const db = getAppDB()
109
+ const appId = ctx.appId
110
+ const db = new CouchDB(appId)
80
111
  const inputs = ctx.request.body
81
112
  const tableId = inputs.tableId
82
113
  const isUserTable = tableId === InternalTables.USER_METADATA
@@ -115,13 +146,14 @@ exports.patch = async ctx => {
115
146
 
116
147
  // returned row is cleaned and prepared for writing to DB
117
148
  row = await linkRows.updateLinks({
149
+ appId,
118
150
  eventType: linkRows.EventType.ROW_UPDATE,
119
151
  row,
120
152
  tableId: row.tableId,
121
153
  table,
122
154
  })
123
155
  // check if any attachments removed
124
- await cleanupAttachments(table, { oldRow, row })
156
+ await cleanupAttachments(appId, table, { oldRow, row })
125
157
 
126
158
  if (isUserTable) {
127
159
  // the row has been updated, need to put it into the ctx
@@ -130,14 +162,12 @@ exports.patch = async ctx => {
130
162
  return { row: ctx.body, table }
131
163
  }
132
164
 
133
- return finaliseRow(table, row, {
134
- oldTable: dbTable,
135
- updateFormula: true,
136
- })
165
+ return storeResponse(ctx, db, row, dbTable, table)
137
166
  }
138
167
 
139
168
  exports.save = async function (ctx) {
140
- const db = getAppDB()
169
+ const appId = ctx.appId
170
+ const db = new CouchDB(appId)
141
171
  let inputs = ctx.request.body
142
172
  inputs.tableId = ctx.params.tableId
143
173
 
@@ -159,19 +189,18 @@ exports.save = async function (ctx) {
159
189
 
160
190
  // make sure link rows are up to date
161
191
  row = await linkRows.updateLinks({
192
+ appId,
162
193
  eventType: linkRows.EventType.ROW_SAVE,
163
194
  row,
164
195
  tableId: row.tableId,
165
196
  table,
166
197
  })
167
198
 
168
- return finaliseRow(table, row, {
169
- oldTable: dbTable,
170
- updateFormula: true,
171
- })
199
+ return storeResponse(ctx, db, row, dbTable, table)
172
200
  }
173
201
 
174
202
  exports.fetchView = async ctx => {
203
+ const appId = ctx.appId
175
204
  const viewName = ctx.params.viewName
176
205
 
177
206
  // if this is a table view being looked for just transfer to that
@@ -180,7 +209,7 @@ exports.fetchView = async ctx => {
180
209
  return exports.fetch(ctx)
181
210
  }
182
211
 
183
- const db = getAppDB()
212
+ const db = new CouchDB(appId)
184
213
  const { calculation, group, field } = ctx.query
185
214
  const viewInfo = await getView(db, viewName)
186
215
  let response
@@ -207,7 +236,7 @@ exports.fetchView = async ctx => {
207
236
  schema: {},
208
237
  }
209
238
  }
210
- rows = await outputProcessing(table, response.rows)
239
+ rows = await outputProcessing(ctx, table, response.rows)
211
240
  }
212
241
 
213
242
  if (calculation === CALCULATION_TYPES.STATS) {
@@ -234,24 +263,27 @@ exports.fetchView = async ctx => {
234
263
  }
235
264
 
236
265
  exports.fetch = async ctx => {
237
- const db = getAppDB()
266
+ const appId = ctx.appId
267
+ const db = new CouchDB(appId)
238
268
 
239
269
  const tableId = ctx.params.tableId
240
270
  let table = await db.get(tableId)
241
271
  let rows = await getRawTableData(ctx, db, tableId)
242
- return outputProcessing(table, rows)
272
+ return outputProcessing(ctx, table, rows)
243
273
  }
244
274
 
245
275
  exports.find = async ctx => {
246
- const db = getAppDB()
276
+ const appId = ctx.appId
277
+ const db = new CouchDB(appId)
247
278
  const table = await db.get(ctx.params.tableId)
248
- let row = await findRow(ctx, ctx.params.tableId, ctx.params.rowId)
249
- row = await outputProcessing(table, row)
279
+ let row = await findRow(ctx, db, ctx.params.tableId, ctx.params.rowId)
280
+ row = await outputProcessing(ctx, table, row)
250
281
  return row
251
282
  }
252
283
 
253
284
  exports.destroy = async function (ctx) {
254
- const db = getAppDB()
285
+ const appId = ctx.appId
286
+ const db = new CouchDB(appId)
255
287
  const { _id, _rev } = ctx.request.body
256
288
  let row = await db.get(_id)
257
289
 
@@ -260,17 +292,16 @@ exports.destroy = async function (ctx) {
260
292
  }
261
293
  const table = await db.get(row.tableId)
262
294
  // update the row to include full relationships before deleting them
263
- row = await outputProcessing(table, row, { squash: false })
295
+ row = await outputProcessing(ctx, table, row, { squash: false })
264
296
  // now remove the relationships
265
297
  await linkRows.updateLinks({
298
+ appId,
266
299
  eventType: linkRows.EventType.ROW_DELETE,
267
300
  row,
268
301
  tableId: row.tableId,
269
302
  })
270
303
  // remove any attachments that were on the row from object storage
271
- await cleanupAttachments(table, { row })
272
- // remove any static formula
273
- await updateRelatedFormula(table, row)
304
+ await cleanupAttachments(appId, table, { row })
274
305
 
275
306
  let response
276
307
  if (ctx.params.tableId === InternalTables.USER_METADATA) {
@@ -286,18 +317,20 @@ exports.destroy = async function (ctx) {
286
317
  }
287
318
 
288
319
  exports.bulkDestroy = async ctx => {
289
- const db = getAppDB()
320
+ const appId = ctx.appId
321
+ const db = new CouchDB(appId)
290
322
  const tableId = ctx.params.tableId
291
323
  const table = await db.get(tableId)
292
324
  let { rows } = ctx.request.body
293
325
 
294
326
  // before carrying out any updates, make sure the rows are ready to be returned
295
327
  // they need to be the full rows (including previous relationships) for automations
296
- rows = await outputProcessing(table, rows, { squash: false })
328
+ rows = await outputProcessing(ctx, table, rows, { squash: false })
297
329
 
298
330
  // remove the relationships first
299
331
  let updates = rows.map(row =>
300
332
  linkRows.updateLinks({
333
+ appId,
301
334
  eventType: linkRows.EventType.ROW_DELETE,
302
335
  row,
303
336
  tableId: row.tableId,
@@ -316,8 +349,7 @@ exports.bulkDestroy = async ctx => {
316
349
  await db.bulkDocs(rows.map(row => ({ ...row, _deleted: true })))
317
350
  }
318
351
  // remove any attachments that were on the rows from object storage
319
- await cleanupAttachments(table, { rows })
320
- await updateRelatedFormula(table, rows)
352
+ await cleanupAttachments(appId, table, { rows })
321
353
  await Promise.all(updates)
322
354
  return { response: { ok: true }, rows }
323
355
  }
@@ -328,27 +360,28 @@ exports.search = async ctx => {
328
360
  return { rows: await exports.fetch(ctx) }
329
361
  }
330
362
 
363
+ const appId = ctx.appId
331
364
  const { tableId } = ctx.params
332
- const db = getAppDB()
365
+ const db = new CouchDB(appId)
333
366
  const { paginate, query, ...params } = ctx.request.body
334
367
  params.version = ctx.version
335
368
  params.tableId = tableId
336
369
 
337
370
  let response
338
371
  if (paginate) {
339
- response = await paginatedSearch(query, params)
372
+ response = await paginatedSearch(appId, query, params)
340
373
  } else {
341
- response = await fullSearch(query, params)
374
+ response = await fullSearch(appId, query, params)
342
375
  }
343
376
 
344
377
  // Enrich search results with relationships
345
378
  if (response.rows && response.rows.length) {
346
379
  // enrich with global users if from users table
347
380
  if (tableId === InternalTables.USER_METADATA) {
348
- response.rows = await getGlobalUsersFromMetadata(response.rows)
381
+ response.rows = await getGlobalUsersFromMetadata(appId, response.rows)
349
382
  }
350
383
  const table = await db.get(tableId)
351
- response.rows = await outputProcessing(table, response.rows)
384
+ response.rows = await outputProcessing(ctx, table, response.rows)
352
385
  }
353
386
 
354
387
  return response
@@ -356,22 +389,25 @@ exports.search = async ctx => {
356
389
 
357
390
  exports.validate = async ctx => {
358
391
  return validate({
392
+ appId: ctx.appId,
359
393
  tableId: ctx.params.tableId,
360
394
  row: ctx.request.body,
361
395
  })
362
396
  }
363
397
 
364
398
  exports.fetchEnrichedRow = async ctx => {
365
- const db = getAppDB()
399
+ const appId = ctx.appId
400
+ const db = new CouchDB(appId)
366
401
  const tableId = ctx.params.tableId
367
402
  const rowId = ctx.params.rowId
368
403
  // need table to work out where links go in row
369
404
  let [table, row] = await Promise.all([
370
405
  db.get(tableId),
371
- findRow(ctx, tableId, rowId),
406
+ findRow(ctx, db, tableId, rowId),
372
407
  ])
373
408
  // get the link docs
374
409
  const linkVals = await linkRows.getLinkDocuments({
410
+ appId,
375
411
  tableId,
376
412
  rowId,
377
413
  })
@@ -398,7 +434,7 @@ exports.fetchEnrichedRow = async ctx => {
398
434
  for (let [tableId, rows] of Object.entries(groups)) {
399
435
  // need to include the IDs in these rows for any links they may have
400
436
  linkedRows = linkedRows.concat(
401
- await outputProcessing(tables[tableId], rows)
437
+ await outputProcessing(ctx, tables[tableId], rows)
402
438
  )
403
439
  }
404
440