@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,9 +9,9 @@ const {
9
9
  breakRowIdField,
10
10
  } = require("../../../integrations/utils")
11
11
  const ExternalRequest = require("./ExternalRequest")
12
- const CouchDB = require("../../../db")
12
+ const { getAppDB } = require("@budibase/backend-core/context")
13
13
 
14
- async function handleRequest(appId, operation, tableId, opts = {}) {
14
+ async function handleRequest(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,31 +25,27 @@ async function handleRequest(appId, operation, tableId, opts = {}) {
25
25
  }
26
26
  }
27
27
  }
28
- return new ExternalRequest(appId, operation, tableId, opts.datasource).run(
29
- opts
30
- )
28
+ return new ExternalRequest(operation, tableId, opts.datasource).run(opts)
31
29
  }
32
30
 
33
31
  exports.handleRequest = handleRequest
34
32
 
35
33
  exports.patch = async ctx => {
36
- const appId = ctx.appId
37
34
  const inputs = ctx.request.body
38
35
  const tableId = ctx.params.tableId
39
36
  const id = breakRowIdField(inputs._id)
40
37
  // don't save the ID to db
41
38
  delete inputs._id
42
- return handleRequest(appId, DataSourceOperation.UPDATE, tableId, {
39
+ return handleRequest(DataSourceOperation.UPDATE, tableId, {
43
40
  id,
44
41
  row: inputs,
45
42
  })
46
43
  }
47
44
 
48
45
  exports.save = async ctx => {
49
- const appId = ctx.appId
50
46
  const inputs = ctx.request.body
51
47
  const tableId = ctx.params.tableId
52
- return handleRequest(appId, DataSourceOperation.CREATE, tableId, {
48
+ return handleRequest(DataSourceOperation.CREATE, tableId, {
53
49
  row: inputs,
54
50
  })
55
51
  }
@@ -63,49 +59,35 @@ exports.fetchView = async ctx => {
63
59
  }
64
60
 
65
61
  exports.fetch = async ctx => {
66
- const appId = ctx.appId
67
62
  const tableId = ctx.params.tableId
68
- return handleRequest(appId, DataSourceOperation.READ, tableId)
63
+ return handleRequest(DataSourceOperation.READ, tableId)
69
64
  }
70
65
 
71
66
  exports.find = async ctx => {
72
- const appId = ctx.appId
73
67
  const id = ctx.params.rowId
74
68
  const tableId = ctx.params.tableId
75
- const response = await handleRequest(
76
- appId,
77
- DataSourceOperation.READ,
78
- tableId,
79
- {
80
- id,
81
- }
82
- )
69
+ const response = await handleRequest(DataSourceOperation.READ, tableId, {
70
+ id,
71
+ })
83
72
  return response ? response[0] : response
84
73
  }
85
74
 
86
75
  exports.destroy = async ctx => {
87
- const appId = ctx.appId
88
76
  const tableId = ctx.params.tableId
89
77
  const id = ctx.request.body._id
90
- const { row } = await handleRequest(
91
- appId,
92
- DataSourceOperation.DELETE,
93
- tableId,
94
- {
95
- id,
96
- }
97
- )
78
+ const { row } = await handleRequest(DataSourceOperation.DELETE, tableId, {
79
+ id,
80
+ })
98
81
  return { response: { ok: true }, row }
99
82
  }
100
83
 
101
84
  exports.bulkDestroy = async ctx => {
102
- const appId = ctx.appId
103
85
  const { rows } = ctx.request.body
104
86
  const tableId = ctx.params.tableId
105
87
  let promises = []
106
88
  for (let row of rows) {
107
89
  promises.push(
108
- handleRequest(appId, DataSourceOperation.DELETE, tableId, {
90
+ handleRequest(DataSourceOperation.DELETE, tableId, {
109
91
  id: breakRowIdField(row._id),
110
92
  })
111
93
  )
@@ -115,7 +97,6 @@ exports.bulkDestroy = async ctx => {
115
97
  }
116
98
 
117
99
  exports.search = async ctx => {
118
- const appId = ctx.appId
119
100
  const tableId = ctx.params.tableId
120
101
  const { paginate, query, ...params } = ctx.request.body
121
102
  let { bookmark, limit } = params
@@ -145,26 +126,21 @@ exports.search = async ctx => {
145
126
  [params.sort]: direction,
146
127
  }
147
128
  }
148
- const rows = await handleRequest(appId, DataSourceOperation.READ, tableId, {
129
+ const rows = await handleRequest(DataSourceOperation.READ, tableId, {
149
130
  filters: query,
150
131
  sort,
151
132
  paginate: paginateObj,
152
133
  })
153
134
  let hasNextPage = false
154
135
  if (paginate && rows.length === limit) {
155
- const nextRows = await handleRequest(
156
- appId,
157
- DataSourceOperation.READ,
158
- tableId,
159
- {
160
- filters: query,
161
- sort,
162
- paginate: {
163
- limit: 1,
164
- page: bookmark * limit + 1,
165
- },
166
- }
167
- )
136
+ const nextRows = await handleRequest(DataSourceOperation.READ, tableId, {
137
+ filters: query,
138
+ sort,
139
+ paginate: {
140
+ limit: 1,
141
+ page: bookmark * limit + 1,
142
+ },
143
+ })
168
144
  hasNextPage = nextRows.length > 0
169
145
  }
170
146
  // need wrapper object for bookmarks etc when paginating
@@ -177,25 +153,19 @@ exports.validate = async () => {
177
153
  }
178
154
 
179
155
  exports.fetchEnrichedRow = async ctx => {
180
- const appId = ctx.appId
181
156
  const id = ctx.params.rowId
182
157
  const tableId = ctx.params.tableId
183
158
  const { datasourceId, tableName } = breakExternalTableId(tableId)
184
- const db = new CouchDB(appId)
159
+ const db = getAppDB()
185
160
  const datasource = await db.get(datasourceId)
186
161
  if (!datasource || !datasource.entities) {
187
162
  ctx.throw(400, "Datasource has not been configured for plus API.")
188
163
  }
189
164
  const tables = datasource.entities
190
- const response = await handleRequest(
191
- appId,
192
- DataSourceOperation.READ,
193
- tableId,
194
- {
195
- id,
196
- datasource,
197
- }
198
- )
165
+ const response = await handleRequest(DataSourceOperation.READ, tableId, {
166
+ id,
167
+ datasource,
168
+ })
199
169
  const table = tables[tableName]
200
170
  const row = response[0]
201
171
  // this seems like a lot of work, but basically we need to dig deeper for the enrich
@@ -214,7 +184,6 @@ exports.fetchEnrichedRow = async ctx => {
214
184
  // don't support composite keys right now
215
185
  const linkedIds = links.map(link => breakRowIdField(link._id)[0])
216
186
  row[fieldName] = await handleRequest(
217
- appId,
218
187
  DataSourceOperation.READ,
219
188
  linkedTableId,
220
189
  {
@@ -1,8 +1,7 @@
1
- const CouchDB = require("../../../db")
2
1
  const linkRows = require("../../../db/linkedRows")
3
2
  const {
4
- getRowParams,
5
3
  generateRowID,
4
+ getRowParams,
6
5
  DocumentTypes,
7
6
  InternalTables,
8
7
  } = require("../../../db/utils")
@@ -10,11 +9,9 @@ const userController = require("../user")
10
9
  const {
11
10
  inputProcessing,
12
11
  outputProcessing,
13
- processAutoColumn,
14
12
  cleanupAttachments,
15
13
  } = require("../../../utilities/rowProcessor")
16
14
  const { FieldTypes } = require("../../../constants")
17
- const { isEqual } = require("lodash")
18
15
  const { validate, findRow } = require("./utils")
19
16
  const { fullSearch, paginatedSearch } = require("./internalSearch")
20
17
  const { getGlobalUsersFromMetadata } = require("../../../utilities/global")
@@ -27,6 +24,8 @@ const {
27
24
  getFromMemoryDoc,
28
25
  } = require("../view/utils")
29
26
  const { cloneDeep } = require("lodash/fp")
27
+ const { getAppDB } = require("@budibase/backend-core/context")
28
+ const { finaliseRow, updateRelatedFormula } = require("./staticFormula")
30
29
 
31
30
  const CALCULATION_TYPES = {
32
31
  SUM: "sum",
@@ -34,51 +33,6 @@ const CALCULATION_TYPES = {
34
33
  STATS: "stats",
35
34
  }
36
35
 
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
-
82
36
  async function getView(db, viewName) {
83
37
  let mainGetter = env.SELF_HOSTED ? getFromDesignDoc : getFromMemoryDoc
84
38
  let secondaryGetter = env.SELF_HOSTED ? getFromMemoryDoc : getFromDesignDoc
@@ -105,9 +59,24 @@ async function getView(db, viewName) {
105
59
  return viewInfo
106
60
  }
107
61
 
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
+
108
78
  exports.patch = async ctx => {
109
- const appId = ctx.appId
110
- const db = new CouchDB(appId)
79
+ const db = getAppDB()
111
80
  const inputs = ctx.request.body
112
81
  const tableId = inputs.tableId
113
82
  const isUserTable = tableId === InternalTables.USER_METADATA
@@ -146,14 +115,13 @@ exports.patch = async ctx => {
146
115
 
147
116
  // returned row is cleaned and prepared for writing to DB
148
117
  row = await linkRows.updateLinks({
149
- appId,
150
118
  eventType: linkRows.EventType.ROW_UPDATE,
151
119
  row,
152
120
  tableId: row.tableId,
153
121
  table,
154
122
  })
155
123
  // check if any attachments removed
156
- await cleanupAttachments(appId, table, { oldRow, row })
124
+ await cleanupAttachments(table, { oldRow, row })
157
125
 
158
126
  if (isUserTable) {
159
127
  // the row has been updated, need to put it into the ctx
@@ -162,12 +130,14 @@ exports.patch = async ctx => {
162
130
  return { row: ctx.body, table }
163
131
  }
164
132
 
165
- return storeResponse(ctx, db, row, dbTable, table)
133
+ return finaliseRow(table, row, {
134
+ oldTable: dbTable,
135
+ updateFormula: true,
136
+ })
166
137
  }
167
138
 
168
139
  exports.save = async function (ctx) {
169
- const appId = ctx.appId
170
- const db = new CouchDB(appId)
140
+ const db = getAppDB()
171
141
  let inputs = ctx.request.body
172
142
  inputs.tableId = ctx.params.tableId
173
143
 
@@ -189,18 +159,19 @@ exports.save = async function (ctx) {
189
159
 
190
160
  // make sure link rows are up to date
191
161
  row = await linkRows.updateLinks({
192
- appId,
193
162
  eventType: linkRows.EventType.ROW_SAVE,
194
163
  row,
195
164
  tableId: row.tableId,
196
165
  table,
197
166
  })
198
167
 
199
- return storeResponse(ctx, db, row, dbTable, table)
168
+ return finaliseRow(table, row, {
169
+ oldTable: dbTable,
170
+ updateFormula: true,
171
+ })
200
172
  }
201
173
 
202
174
  exports.fetchView = async ctx => {
203
- const appId = ctx.appId
204
175
  const viewName = ctx.params.viewName
205
176
 
206
177
  // if this is a table view being looked for just transfer to that
@@ -209,7 +180,7 @@ exports.fetchView = async ctx => {
209
180
  return exports.fetch(ctx)
210
181
  }
211
182
 
212
- const db = new CouchDB(appId)
183
+ const db = getAppDB()
213
184
  const { calculation, group, field } = ctx.query
214
185
  const viewInfo = await getView(db, viewName)
215
186
  let response
@@ -236,7 +207,7 @@ exports.fetchView = async ctx => {
236
207
  schema: {},
237
208
  }
238
209
  }
239
- rows = await outputProcessing(ctx, table, response.rows)
210
+ rows = await outputProcessing(table, response.rows)
240
211
  }
241
212
 
242
213
  if (calculation === CALCULATION_TYPES.STATS) {
@@ -263,27 +234,24 @@ exports.fetchView = async ctx => {
263
234
  }
264
235
 
265
236
  exports.fetch = async ctx => {
266
- const appId = ctx.appId
267
- const db = new CouchDB(appId)
237
+ const db = getAppDB()
268
238
 
269
239
  const tableId = ctx.params.tableId
270
240
  let table = await db.get(tableId)
271
241
  let rows = await getRawTableData(ctx, db, tableId)
272
- return outputProcessing(ctx, table, rows)
242
+ return outputProcessing(table, rows)
273
243
  }
274
244
 
275
245
  exports.find = async ctx => {
276
- const appId = ctx.appId
277
- const db = new CouchDB(appId)
246
+ const db = getAppDB()
278
247
  const table = await db.get(ctx.params.tableId)
279
- let row = await findRow(ctx, db, ctx.params.tableId, ctx.params.rowId)
280
- row = await outputProcessing(ctx, table, row)
248
+ let row = await findRow(ctx, ctx.params.tableId, ctx.params.rowId)
249
+ row = await outputProcessing(table, row)
281
250
  return row
282
251
  }
283
252
 
284
253
  exports.destroy = async function (ctx) {
285
- const appId = ctx.appId
286
- const db = new CouchDB(appId)
254
+ const db = getAppDB()
287
255
  const { _id, _rev } = ctx.request.body
288
256
  let row = await db.get(_id)
289
257
 
@@ -292,16 +260,17 @@ exports.destroy = async function (ctx) {
292
260
  }
293
261
  const table = await db.get(row.tableId)
294
262
  // update the row to include full relationships before deleting them
295
- row = await outputProcessing(ctx, table, row, { squash: false })
263
+ row = await outputProcessing(table, row, { squash: false })
296
264
  // now remove the relationships
297
265
  await linkRows.updateLinks({
298
- appId,
299
266
  eventType: linkRows.EventType.ROW_DELETE,
300
267
  row,
301
268
  tableId: row.tableId,
302
269
  })
303
270
  // remove any attachments that were on the row from object storage
304
- await cleanupAttachments(appId, table, { row })
271
+ await cleanupAttachments(table, { row })
272
+ // remove any static formula
273
+ await updateRelatedFormula(table, row)
305
274
 
306
275
  let response
307
276
  if (ctx.params.tableId === InternalTables.USER_METADATA) {
@@ -317,20 +286,18 @@ exports.destroy = async function (ctx) {
317
286
  }
318
287
 
319
288
  exports.bulkDestroy = async ctx => {
320
- const appId = ctx.appId
321
- const db = new CouchDB(appId)
289
+ const db = getAppDB()
322
290
  const tableId = ctx.params.tableId
323
291
  const table = await db.get(tableId)
324
292
  let { rows } = ctx.request.body
325
293
 
326
294
  // before carrying out any updates, make sure the rows are ready to be returned
327
295
  // they need to be the full rows (including previous relationships) for automations
328
- rows = await outputProcessing(ctx, table, rows, { squash: false })
296
+ rows = await outputProcessing(table, rows, { squash: false })
329
297
 
330
298
  // remove the relationships first
331
299
  let updates = rows.map(row =>
332
300
  linkRows.updateLinks({
333
- appId,
334
301
  eventType: linkRows.EventType.ROW_DELETE,
335
302
  row,
336
303
  tableId: row.tableId,
@@ -349,7 +316,8 @@ exports.bulkDestroy = async ctx => {
349
316
  await db.bulkDocs(rows.map(row => ({ ...row, _deleted: true })))
350
317
  }
351
318
  // remove any attachments that were on the rows from object storage
352
- await cleanupAttachments(appId, table, { rows })
319
+ await cleanupAttachments(table, { rows })
320
+ await updateRelatedFormula(table, rows)
353
321
  await Promise.all(updates)
354
322
  return { response: { ok: true }, rows }
355
323
  }
@@ -360,28 +328,27 @@ exports.search = async ctx => {
360
328
  return { rows: await exports.fetch(ctx) }
361
329
  }
362
330
 
363
- const appId = ctx.appId
364
331
  const { tableId } = ctx.params
365
- const db = new CouchDB(appId)
332
+ const db = getAppDB()
366
333
  const { paginate, query, ...params } = ctx.request.body
367
334
  params.version = ctx.version
368
335
  params.tableId = tableId
369
336
 
370
337
  let response
371
338
  if (paginate) {
372
- response = await paginatedSearch(appId, query, params)
339
+ response = await paginatedSearch(query, params)
373
340
  } else {
374
- response = await fullSearch(appId, query, params)
341
+ response = await fullSearch(query, params)
375
342
  }
376
343
 
377
344
  // Enrich search results with relationships
378
345
  if (response.rows && response.rows.length) {
379
346
  // enrich with global users if from users table
380
347
  if (tableId === InternalTables.USER_METADATA) {
381
- response.rows = await getGlobalUsersFromMetadata(appId, response.rows)
348
+ response.rows = await getGlobalUsersFromMetadata(response.rows)
382
349
  }
383
350
  const table = await db.get(tableId)
384
- response.rows = await outputProcessing(ctx, table, response.rows)
351
+ response.rows = await outputProcessing(table, response.rows)
385
352
  }
386
353
 
387
354
  return response
@@ -389,25 +356,22 @@ exports.search = async ctx => {
389
356
 
390
357
  exports.validate = async ctx => {
391
358
  return validate({
392
- appId: ctx.appId,
393
359
  tableId: ctx.params.tableId,
394
360
  row: ctx.request.body,
395
361
  })
396
362
  }
397
363
 
398
364
  exports.fetchEnrichedRow = async ctx => {
399
- const appId = ctx.appId
400
- const db = new CouchDB(appId)
365
+ const db = getAppDB()
401
366
  const tableId = ctx.params.tableId
402
367
  const rowId = ctx.params.rowId
403
368
  // need table to work out where links go in row
404
369
  let [table, row] = await Promise.all([
405
370
  db.get(tableId),
406
- findRow(ctx, db, tableId, rowId),
371
+ findRow(ctx, tableId, rowId),
407
372
  ])
408
373
  // get the link docs
409
374
  const linkVals = await linkRows.getLinkDocuments({
410
- appId,
411
375
  tableId,
412
376
  rowId,
413
377
  })
@@ -434,7 +398,7 @@ exports.fetchEnrichedRow = async ctx => {
434
398
  for (let [tableId, rows] of Object.entries(groups)) {
435
399
  // need to include the IDs in these rows for any links they may have
436
400
  linkedRows = linkedRows.concat(
437
- await outputProcessing(ctx, tables[tableId], rows)
401
+ await outputProcessing(tables[tableId], rows)
438
402
  )
439
403
  }
440
404
 
@@ -1,14 +1,14 @@
1
1
  const { SearchIndexes } = require("../../../db/utils")
2
2
  const fetch = require("node-fetch")
3
3
  const { getCouchUrl } = require("@budibase/backend-core/db")
4
+ const { getAppId } = require("@budibase/backend-core/context")
4
5
 
5
6
  /**
6
7
  * Class to build lucene query URLs.
7
8
  * Optionally takes a base lucene query object.
8
9
  */
9
10
  class QueryBuilder {
10
- constructor(appId, base) {
11
- this.appId = appId
11
+ constructor(base) {
12
12
  this.query = {
13
13
  string: {},
14
14
  fuzzy: {},
@@ -37,22 +37,30 @@ class QueryBuilder {
37
37
  }
38
38
 
39
39
  setLimit(limit) {
40
- this.limit = limit
40
+ if (limit != null) {
41
+ this.limit = limit
42
+ }
41
43
  return this
42
44
  }
43
45
 
44
46
  setSort(sort) {
45
- this.sort = sort
47
+ if (sort != null) {
48
+ this.sort = sort
49
+ }
46
50
  return this
47
51
  }
48
52
 
49
53
  setSortOrder(sortOrder) {
50
- this.sortOrder = sortOrder
54
+ if (sortOrder != null) {
55
+ this.sortOrder = sortOrder
56
+ }
51
57
  return this
52
58
  }
53
59
 
54
60
  setSortType(sortType) {
55
- this.sortType = sortType
61
+ if (sortType != null) {
62
+ this.sortType = sortType
63
+ }
56
64
  return this
57
65
  }
58
66
 
@@ -233,7 +241,8 @@ class QueryBuilder {
233
241
  }
234
242
 
235
243
  async run() {
236
- const url = `${getCouchUrl()}/${this.appId}/_design/database/_search/${
244
+ const appId = getAppId()
245
+ const url = `${getCouchUrl()}/${appId}/_design/database/_search/${
237
246
  SearchIndexes.ROWS
238
247
  }`
239
248
  const body = this.buildSearchBody()
@@ -270,7 +279,6 @@ const runQuery = async (url, body) => {
270
279
  * Gets round the fixed limit of 200 results from a query by fetching as many
271
280
  * pages as required and concatenating the results. This recursively operates
272
281
  * until enough results have been found.
273
- * @param appId {string} The app ID to search
274
282
  * @param query {object} The JSON query structure
275
283
  * @param params {object} The search params including:
276
284
  * tableId {string} The table ID to search
@@ -283,7 +291,7 @@ const runQuery = async (url, body) => {
283
291
  * rows {array|null} Current results in the recursive search
284
292
  * @returns {Promise<*[]|*>}
285
293
  */
286
- const recursiveSearch = async (appId, query, params) => {
294
+ const recursiveSearch = async (query, params) => {
287
295
  const bookmark = params.bookmark
288
296
  const rows = params.rows || []
289
297
  if (rows.length >= params.limit) {
@@ -293,7 +301,7 @@ const recursiveSearch = async (appId, query, params) => {
293
301
  if (rows.length > params.limit - 200) {
294
302
  pageSize = params.limit - rows.length
295
303
  }
296
- const page = await new QueryBuilder(appId, query)
304
+ const page = await new QueryBuilder(query)
297
305
  .setVersion(params.version)
298
306
  .setTable(params.tableId)
299
307
  .setBookmark(bookmark)
@@ -313,14 +321,13 @@ const recursiveSearch = async (appId, query, params) => {
313
321
  bookmark: page.bookmark,
314
322
  rows: [...rows, ...page.rows],
315
323
  }
316
- return await recursiveSearch(appId, query, newParams)
324
+ return await recursiveSearch(query, newParams)
317
325
  }
318
326
 
319
327
  /**
320
328
  * Performs a paginated search. A bookmark will be returned to allow the next
321
329
  * page to be fetched. There is a max limit off 200 results per page in a
322
330
  * paginated search.
323
- * @param appId {string} The app ID to search
324
331
  * @param query {object} The JSON query structure
325
332
  * @param params {object} The search params including:
326
333
  * tableId {string} The table ID to search
@@ -332,13 +339,13 @@ const recursiveSearch = async (appId, query, params) => {
332
339
  * bookmark {string} The bookmark to resume from
333
340
  * @returns {Promise<{hasNextPage: boolean, rows: *[]}>}
334
341
  */
335
- exports.paginatedSearch = async (appId, query, params) => {
342
+ exports.paginatedSearch = async (query, params) => {
336
343
  let limit = params.limit
337
344
  if (limit == null || isNaN(limit) || limit < 0) {
338
345
  limit = 50
339
346
  }
340
347
  limit = Math.min(limit, 200)
341
- const search = new QueryBuilder(appId, query)
348
+ const search = new QueryBuilder(query)
342
349
  .setVersion(params.version)
343
350
  .setTable(params.tableId)
344
351
  .setSort(params.sort)
@@ -367,7 +374,6 @@ exports.paginatedSearch = async (appId, query, params) => {
367
374
  * desired amount of results. There is a limit of 1000 results to avoid
368
375
  * heavy performance hits, and to avoid client components breaking from
369
376
  * handling too much data.
370
- * @param appId {string} The app ID to search
371
377
  * @param query {object} The JSON query structure
372
378
  * @param params {object} The search params including:
373
379
  * tableId {string} The table ID to search
@@ -378,12 +384,12 @@ exports.paginatedSearch = async (appId, query, params) => {
378
384
  * limit {number} The desired number of results
379
385
  * @returns {Promise<{rows: *}>}
380
386
  */
381
- exports.fullSearch = async (appId, query, params) => {
387
+ exports.fullSearch = async (query, params) => {
382
388
  let limit = params.limit
383
389
  if (limit == null || isNaN(limit) || limit < 0) {
384
390
  limit = 1000
385
391
  }
386
392
  params.limit = Math.min(limit, 1000)
387
- const rows = await recursiveSearch(appId, query, params)
393
+ const rows = await recursiveSearch(query, params)
388
394
  return { rows }
389
395
  }