@budibase/server 2.1.32-alpha.4 → 2.1.32-alpha.6

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 (583) hide show
  1. package/builder/assets/{index.dfb2f13a.js → index.3ca79a83.js} +1 -1
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +3112 -3177
  4. package/coverage/coverage-final.json +105 -106
  5. package/coverage/lcov-report/index.html +145 -145
  6. package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
  7. package/coverage/lcov-report/src/api/controllers/{apikeys.js.html → apikeys.ts.html} +19 -19
  8. package/coverage/lcov-report/src/api/controllers/application.ts.html +1 -1
  9. package/coverage/lcov-report/src/api/controllers/auth.ts.html +3 -3
  10. package/coverage/lcov-report/src/api/controllers/{automation.js.html → automation.ts.html} +68 -68
  11. package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
  12. package/coverage/lcov-report/src/api/controllers/{cloud.js.html → cloud.ts.html} +40 -40
  13. package/coverage/lcov-report/src/api/controllers/component.ts.html +6 -3
  14. package/coverage/lcov-report/src/api/controllers/{datasource.js.html → datasource.ts.html} +100 -79
  15. package/coverage/lcov-report/src/api/controllers/deploy/{Deployment.js.html → Deployment.ts.html} +30 -21
  16. package/coverage/lcov-report/src/api/controllers/deploy/index.html +6 -6
  17. package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +1 -1
  18. package/coverage/lcov-report/src/api/controllers/dev.ts.html +1 -1
  19. package/coverage/lcov-report/src/api/controllers/index.html +108 -108
  20. package/coverage/lcov-report/src/api/controllers/integration.js.html +1 -1
  21. package/coverage/lcov-report/src/api/controllers/{layout.js.html → layout.ts.html} +19 -19
  22. package/coverage/lcov-report/src/api/controllers/{metadata.js.html → metadata.ts.html} +19 -16
  23. package/coverage/lcov-report/src/api/controllers/migrations.js.html +1 -1
  24. package/coverage/lcov-report/src/api/controllers/{permission.js.html → permission.ts.html} +73 -64
  25. package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +1 -1
  26. package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +1 -1
  27. package/coverage/lcov-report/src/api/controllers/plugin/index.html +11 -11
  28. package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +10 -13
  29. package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +1 -1
  30. package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +1 -1
  31. package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +1 -1
  32. package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +1 -1
  33. package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +1 -1
  34. package/coverage/lcov-report/src/api/controllers/public/index.html +1 -1
  35. package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +1 -1
  36. package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
  37. package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +1 -1
  38. package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +1 -1
  39. package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +1 -1
  40. package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +1 -1
  41. package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +1 -1
  42. package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +1 -1
  43. package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +1 -1
  44. package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +3 -3
  45. package/coverage/lcov-report/src/api/controllers/public/users.ts.html +1 -1
  46. package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +1 -1
  47. package/coverage/lcov-report/src/api/controllers/query/import/index.html +11 -11
  48. package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +8 -11
  49. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
  50. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +1 -1
  51. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +1 -1
  52. package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +1 -1
  53. package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
  54. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +1 -1
  55. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +1 -1
  56. package/coverage/lcov-report/src/api/controllers/query/index.html +2 -2
  57. package/coverage/lcov-report/src/api/controllers/query/index.ts.html +1 -1
  58. package/coverage/lcov-report/src/api/controllers/query/{validation.js.html → validation.ts.html} +10 -10
  59. package/coverage/lcov-report/src/api/controllers/{role.js.html → role.ts.html} +37 -49
  60. package/coverage/lcov-report/src/api/controllers/{routing.js.html → routing.ts.html} +58 -49
  61. package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +6 -18
  62. package/coverage/lcov-report/src/api/controllers/row/external.js.html +4 -4
  63. package/coverage/lcov-report/src/api/controllers/row/index.html +35 -35
  64. package/coverage/lcov-report/src/api/controllers/row/index.ts.html +1 -1
  65. package/coverage/lcov-report/src/api/controllers/row/internal.js.html +17 -20
  66. package/coverage/lcov-report/src/api/controllers/row/{internalSearch.js.html → internalSearch.ts.html} +175 -103
  67. package/coverage/lcov-report/src/api/controllers/row/{staticFormula.js.html → staticFormula.ts.html} +62 -47
  68. package/coverage/lcov-report/src/api/controllers/row/{utils.js.html → utils.ts.html} +57 -36
  69. package/coverage/lcov-report/src/api/controllers/screen.ts.html +29 -17
  70. package/coverage/lcov-report/src/api/controllers/{script.js.html → script.ts.html} +10 -7
  71. package/coverage/lcov-report/src/api/controllers/static/index.html +10 -10
  72. package/coverage/lcov-report/src/api/controllers/static/index.ts.html +15 -27
  73. package/coverage/lcov-report/src/api/controllers/table/{bulkFormula.js.html → bulkFormula.ts.html} +89 -47
  74. package/coverage/lcov-report/src/api/controllers/table/{external.js.html → external.ts.html} +192 -87
  75. package/coverage/lcov-report/src/api/controllers/table/index.html +39 -39
  76. package/coverage/lcov-report/src/api/controllers/table/{index.js.html → index.ts.html} +28 -28
  77. package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +3 -6
  78. package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +18 -18
  79. package/coverage/lcov-report/src/api/controllers/{templates.js.html → templates.ts.html} +27 -18
  80. package/coverage/lcov-report/src/api/controllers/{user.js.html → user.ts.html} +72 -78
  81. package/coverage/lcov-report/src/api/controllers/view/{exporters.js.html → exporters.ts.html} +13 -7
  82. package/coverage/lcov-report/src/api/controllers/view/index.html +21 -21
  83. package/coverage/lcov-report/src/api/controllers/view/{index.js.html → index.ts.html} +68 -41
  84. package/coverage/lcov-report/src/api/controllers/view/{utils.js.html → utils.ts.html} +54 -36
  85. package/coverage/lcov-report/src/api/controllers/view/viewBuilder.js.html +1 -1
  86. package/coverage/lcov-report/src/api/controllers/webhook.ts.html +1 -1
  87. package/coverage/lcov-report/src/api/index.html +14 -14
  88. package/coverage/lcov-report/src/api/{index.js.html → index.ts.html} +28 -49
  89. package/coverage/lcov-report/src/api/routes/{analytics.js.html → analytics.ts.html} +7 -7
  90. package/coverage/lcov-report/src/api/routes/{apikeys.js.html → apikeys.ts.html} +11 -11
  91. package/coverage/lcov-report/src/api/routes/application.ts.html +35 -11
  92. package/coverage/lcov-report/src/api/routes/auth.ts.html +3 -3
  93. package/coverage/lcov-report/src/api/routes/{automation.js.html → automation.ts.html} +41 -35
  94. package/coverage/lcov-report/src/api/routes/backup.ts.html +18 -6
  95. package/coverage/lcov-report/src/api/routes/{deploy.js.html → cloud.ts.html} +18 -15
  96. package/coverage/lcov-report/src/api/routes/{component.js.html → component.ts.html} +10 -10
  97. package/coverage/lcov-report/src/api/routes/{datasource.js.html → datasource.ts.html} +53 -26
  98. package/coverage/lcov-report/src/api/routes/deploy.ts.html +148 -0
  99. package/coverage/lcov-report/src/api/routes/{dev.js.html → dev.ts.html} +54 -18
  100. package/coverage/lcov-report/src/api/routes/index.html +41 -41
  101. package/coverage/lcov-report/src/api/routes/index.ts.html +3 -3
  102. package/coverage/lcov-report/src/api/routes/integration.ts.html +133 -0
  103. package/coverage/lcov-report/src/api/routes/{layout.js.html → layout.ts.html} +11 -11
  104. package/coverage/lcov-report/src/api/routes/{metadata.js.html → metadata.ts.html} +17 -17
  105. package/coverage/lcov-report/src/api/routes/{migrations.js.html → migrations.ts.html} +12 -12
  106. package/coverage/lcov-report/src/api/routes/{permission.js.html → permission.ts.html} +41 -17
  107. package/coverage/lcov-report/src/api/routes/plugin.ts.html +32 -8
  108. package/coverage/lcov-report/src/api/routes/public/applications.ts.html +1 -1
  109. package/coverage/lcov-report/src/api/routes/public/index.html +1 -1
  110. package/coverage/lcov-report/src/api/routes/public/index.ts.html +1 -1
  111. package/coverage/lcov-report/src/api/routes/public/middleware/index.html +1 -1
  112. package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +1 -1
  113. package/coverage/lcov-report/src/api/routes/public/queries.ts.html +1 -1
  114. package/coverage/lcov-report/src/api/routes/public/rows.ts.html +1 -1
  115. package/coverage/lcov-report/src/api/routes/public/tables.ts.html +1 -1
  116. package/coverage/lcov-report/src/api/routes/public/users.ts.html +1 -1
  117. package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +1 -1
  118. package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
  119. package/coverage/lcov-report/src/api/routes/{query.js.html → query.ts.html} +24 -33
  120. package/coverage/lcov-report/src/{utilities/routing/index.js.html → api/routes/role.ts.html} +32 -35
  121. package/coverage/lcov-report/src/api/routes/{routing.js.html → routing.ts.html} +10 -10
  122. package/coverage/lcov-report/src/api/routes/row.ts.html +8 -14
  123. package/coverage/lcov-report/src/api/routes/{screen.js.html → screen.ts.html} +29 -14
  124. package/coverage/lcov-report/src/api/routes/{script.js.html → script.ts.html} +10 -10
  125. package/coverage/lcov-report/src/api/routes/static.ts.html +9 -18
  126. package/coverage/lcov-report/src/api/routes/{table.js.html → table.ts.html} +16 -25
  127. package/coverage/lcov-report/src/api/routes/{templates.js.html → templates.ts.html} +11 -11
  128. package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +12 -18
  129. package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +10 -10
  130. package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +1 -1
  131. package/coverage/lcov-report/src/api/routes/{user.js.html → user.ts.html} +14 -20
  132. package/coverage/lcov-report/src/api/routes/utils/index.html +6 -6
  133. package/coverage/lcov-report/src/api/routes/utils/{validators.js.html → validators.ts.html} +39 -51
  134. package/coverage/lcov-report/src/api/routes/{view.js.html → view.ts.html} +33 -24
  135. package/coverage/lcov-report/src/api/routes/webhook.ts.html +3 -3
  136. package/coverage/lcov-report/src/app.ts.html +9 -12
  137. package/coverage/lcov-report/src/automations/actions.js.html +1 -1
  138. package/coverage/lcov-report/src/automations/automationUtils.js.html +1 -1
  139. package/coverage/lcov-report/src/automations/bullboard.js.html +1 -1
  140. package/coverage/lcov-report/src/automations/index.html +10 -10
  141. package/coverage/lcov-report/src/automations/index.js.html +1 -1
  142. package/coverage/lcov-report/src/automations/logging/index.html +1 -1
  143. package/coverage/lcov-report/src/automations/logging/index.ts.html +1 -1
  144. package/coverage/lcov-report/src/automations/steps/bash.js.html +1 -1
  145. package/coverage/lcov-report/src/automations/steps/createRow.ts.html +1 -1
  146. package/coverage/lcov-report/src/automations/steps/delay.js.html +1 -1
  147. package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +1 -1
  148. package/coverage/lcov-report/src/automations/steps/discord.js.html +1 -1
  149. package/coverage/lcov-report/src/automations/steps/executeQuery.js.html +1 -1
  150. package/coverage/lcov-report/src/automations/steps/executeScript.js.html +1 -1
  151. package/coverage/lcov-report/src/automations/steps/filter.js.html +1 -1
  152. package/coverage/lcov-report/src/automations/steps/index.html +1 -1
  153. package/coverage/lcov-report/src/automations/steps/integromat.js.html +1 -1
  154. package/coverage/lcov-report/src/automations/steps/loop.js.html +1 -1
  155. package/coverage/lcov-report/src/automations/steps/outgoingWebhook.js.html +1 -1
  156. package/coverage/lcov-report/src/automations/steps/queryRows.js.html +1 -1
  157. package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.js.html +1 -1
  158. package/coverage/lcov-report/src/automations/steps/serverLog.js.html +1 -1
  159. package/coverage/lcov-report/src/automations/steps/slack.js.html +1 -1
  160. package/coverage/lcov-report/src/automations/steps/updateRow.js.html +1 -1
  161. package/coverage/lcov-report/src/automations/steps/utils.js.html +1 -1
  162. package/coverage/lcov-report/src/automations/steps/zapier.js.html +1 -1
  163. package/coverage/lcov-report/src/automations/tests/utilities/index.html +1 -1
  164. package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +1 -1
  165. package/coverage/lcov-report/src/automations/triggerInfo/app.js.html +1 -1
  166. package/coverage/lcov-report/src/automations/triggerInfo/cron.js.html +1 -1
  167. package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
  168. package/coverage/lcov-report/src/automations/triggerInfo/index.js.html +1 -1
  169. package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.js.html +1 -1
  170. package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.js.html +1 -1
  171. package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.js.html +1 -1
  172. package/coverage/lcov-report/src/automations/triggerInfo/webhook.js.html +1 -1
  173. package/coverage/lcov-report/src/automations/triggers.js.html +11 -14
  174. package/coverage/lcov-report/src/automations/utils.ts.html +1 -1
  175. package/coverage/lcov-report/src/constants/index.html +5 -5
  176. package/coverage/lcov-report/src/constants/index.js.html +7 -13
  177. package/coverage/lcov-report/src/constants/layouts.js.html +1 -1
  178. package/coverage/lcov-report/src/constants/screens.js.html +3 -3
  179. package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.js.html +1 -1
  180. package/coverage/lcov-report/src/db/defaultData/employeeImport.js.html +1 -1
  181. package/coverage/lcov-report/src/db/defaultData/expensesImport.js.html +1 -1
  182. package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
  183. package/coverage/lcov-report/src/db/defaultData/inventoryImport.js.html +1 -1
  184. package/coverage/lcov-report/src/db/defaultData/jobsImport.js.html +1 -1
  185. package/coverage/lcov-report/src/db/dynamoClient.js.html +1 -1
  186. package/coverage/lcov-report/src/db/inMemoryView.js.html +4 -4
  187. package/coverage/lcov-report/src/db/index.html +1 -1
  188. package/coverage/lcov-report/src/db/index.js.html +1 -1
  189. package/coverage/lcov-report/src/db/linkedRows/LinkController.js.html +3 -3
  190. package/coverage/lcov-report/src/db/linkedRows/LinkDocument.js.html +1 -1
  191. package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
  192. package/coverage/lcov-report/src/db/linkedRows/index.js.html +3 -3
  193. package/coverage/lcov-report/src/db/linkedRows/linkUtils.js.html +4 -4
  194. package/coverage/lcov-report/src/db/newid.js.html +1 -1
  195. package/coverage/lcov-report/src/db/utils.ts.html +2 -2
  196. package/coverage/lcov-report/src/definitions/automations.ts.html +1 -1
  197. package/coverage/lcov-report/src/definitions/datasource.ts.html +1 -1
  198. package/coverage/lcov-report/src/definitions/index.html +1 -1
  199. package/coverage/lcov-report/src/environment.js.html +1 -1
  200. package/coverage/lcov-report/src/events/AutomationEmitter.js.html +1 -1
  201. package/coverage/lcov-report/src/events/index.html +1 -1
  202. package/coverage/lcov-report/src/events/index.js.html +1 -1
  203. package/coverage/lcov-report/src/events/utils.js.html +1 -1
  204. package/coverage/lcov-report/src/index.html +17 -32
  205. package/coverage/lcov-report/src/index.ts.html +1 -1
  206. package/coverage/lcov-report/src/integrations/airtable.ts.html +1 -1
  207. package/coverage/lcov-report/src/integrations/arangodb.ts.html +1 -1
  208. package/coverage/lcov-report/src/integrations/base/index.html +1 -1
  209. package/coverage/lcov-report/src/integrations/base/query.ts.html +1 -1
  210. package/coverage/lcov-report/src/integrations/base/sql.ts.html +2 -2
  211. package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +2 -2
  212. package/coverage/lcov-report/src/integrations/base/utils.ts.html +1 -1
  213. package/coverage/lcov-report/src/integrations/couchdb.ts.html +1 -1
  214. package/coverage/lcov-report/src/integrations/dynamodb.ts.html +1 -1
  215. package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +1 -1
  216. package/coverage/lcov-report/src/integrations/firebase.ts.html +1 -1
  217. package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1 -1
  218. package/coverage/lcov-report/src/integrations/index.html +4 -4
  219. package/coverage/lcov-report/src/integrations/index.ts.html +58 -46
  220. package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1 -1
  221. package/coverage/lcov-report/src/integrations/mongodb.ts.html +1 -1
  222. package/coverage/lcov-report/src/integrations/mysql.ts.html +1 -1
  223. package/coverage/lcov-report/src/integrations/oracle.ts.html +1 -1
  224. package/coverage/lcov-report/src/integrations/postgres.ts.html +1 -1
  225. package/coverage/lcov-report/src/integrations/queries/index.html +1 -1
  226. package/coverage/lcov-report/src/integrations/queries/sql.ts.html +1 -1
  227. package/coverage/lcov-report/src/integrations/redis.ts.html +1 -1
  228. package/coverage/lcov-report/src/integrations/rest.ts.html +1 -1
  229. package/coverage/lcov-report/src/integrations/s3.ts.html +1 -1
  230. package/coverage/lcov-report/src/integrations/snowflake.ts.html +1 -1
  231. package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
  232. package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
  233. package/coverage/lcov-report/src/integrations/utils.ts.html +1 -1
  234. package/coverage/lcov-report/src/middleware/appInfo.ts.html +1 -1
  235. package/coverage/lcov-report/src/middleware/authorized.ts.html +30 -51
  236. package/coverage/lcov-report/src/middleware/builder.ts.html +1 -1
  237. package/coverage/lcov-report/src/middleware/currentapp.ts.html +1 -1
  238. package/coverage/lcov-report/src/middleware/index.html +10 -10
  239. package/coverage/lcov-report/src/middleware/joi-validator.ts.html +1 -1
  240. package/coverage/lcov-report/src/middleware/publicApi.ts.html +1 -1
  241. package/coverage/lcov-report/src/middleware/resourceId.ts.html +1 -1
  242. package/coverage/lcov-report/src/middleware/selfhost.ts.html +1 -1
  243. package/coverage/lcov-report/src/middleware/utils.ts.html +1 -1
  244. package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +3 -3
  245. package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +1 -1
  246. package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +1 -1
  247. package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +1 -1
  248. package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +1 -1
  249. package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +1 -1
  250. package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +1 -1
  251. package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +1 -1
  252. package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +1 -1
  253. package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +1 -1
  254. package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +1 -1
  255. package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
  256. package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +1 -1
  257. package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +1 -1
  258. package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +1 -1
  259. package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
  260. package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +1 -1
  261. package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +1 -1
  262. package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
  263. package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +1 -1
  264. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +9 -9
  265. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +1 -1
  266. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +7 -10
  267. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +1 -1
  268. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +7 -10
  269. package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +4 -4
  270. package/coverage/lcov-report/src/migrations/index.html +1 -1
  271. package/coverage/lcov-report/src/migrations/index.ts.html +1 -1
  272. package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
  273. package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
  274. package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
  275. package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
  276. package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +1 -1
  277. package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +1 -1
  278. package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +1 -1
  279. package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +16 -10
  280. package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +9 -21
  281. package/coverage/lcov-report/src/sdk/app/backups/index.html +16 -16
  282. package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +1 -1
  283. package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +1 -1
  284. package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
  285. package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +1 -1
  286. package/coverage/lcov-report/src/sdk/index.html +1 -1
  287. package/coverage/lcov-report/src/sdk/index.ts.html +1 -1
  288. package/coverage/lcov-report/src/startup.ts.html +3 -3
  289. package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +61 -49
  290. package/coverage/lcov-report/src/tests/utilities/controllers.js.html +1 -1
  291. package/coverage/lcov-report/src/tests/utilities/index.html +15 -15
  292. package/coverage/lcov-report/src/tests/utilities/index.js.html +1 -1
  293. package/coverage/lcov-report/src/tests/utilities/structures.js.html +9 -12
  294. package/coverage/lcov-report/src/threads/automation.ts.html +20 -23
  295. package/coverage/lcov-report/src/threads/index.html +24 -24
  296. package/coverage/lcov-report/src/threads/index.ts.html +1 -1
  297. package/coverage/lcov-report/src/threads/query.ts.html +18 -33
  298. package/coverage/lcov-report/src/threads/utils.ts.html +10 -13
  299. package/coverage/lcov-report/src/utilities/{budibaseDir.js.html → budibaseDir.ts.html} +5 -5
  300. package/coverage/lcov-report/src/utilities/centralPath.js.html +1 -1
  301. package/coverage/lcov-report/src/utilities/csvParser.js.html +1 -1
  302. package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +13 -13
  303. package/coverage/lcov-report/src/utilities/fileSystem/index.html +5 -20
  304. package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +15 -15
  305. package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +1 -1
  306. package/coverage/lcov-report/src/utilities/global.ts.html +1 -1
  307. package/coverage/lcov-report/src/utilities/index.html +44 -44
  308. package/coverage/lcov-report/src/utilities/{index.js.html → index.ts.html} +68 -44
  309. package/coverage/lcov-report/src/utilities/plugins.js.html +1 -1
  310. package/coverage/lcov-report/src/utilities/queue/inMemoryQueue.js.html +1 -1
  311. package/coverage/lcov-report/src/utilities/queue/index.html +1 -1
  312. package/coverage/lcov-report/src/utilities/{redis.js.html → redis.ts.html} +36 -33
  313. package/coverage/lcov-report/src/utilities/routing/index.html +6 -6
  314. package/coverage/lcov-report/src/utilities/routing/index.ts.html +181 -0
  315. package/coverage/lcov-report/src/utilities/rowProcessor/index.html +38 -23
  316. package/coverage/lcov-report/src/utilities/rowProcessor/{index.js.html → index.ts.html} +106 -337
  317. package/coverage/lcov-report/src/utilities/rowProcessor/map.js.html +370 -0
  318. package/coverage/lcov-report/src/utilities/rowProcessor/{utils.js.html → utils.ts.html} +43 -31
  319. package/coverage/lcov-report/src/utilities/scriptRunner.js.html +1 -1
  320. package/coverage/lcov-report/src/utilities/{security.js.html → security.ts.html} +49 -67
  321. package/coverage/lcov-report/src/utilities/statusCodes.js.html +1 -1
  322. package/coverage/lcov-report/src/utilities/usageQuota/index.html +18 -18
  323. package/coverage/lcov-report/src/utilities/usageQuota/{rows.js.html → rows.ts.html} +27 -39
  324. package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  325. package/coverage/lcov-report/src/utilities/{users.js.html → users.ts.html} +22 -28
  326. package/coverage/lcov-report/src/utilities/{workerRequests.js.html → workerRequests.ts.html} +69 -54
  327. package/coverage/lcov-report/src/watch.ts.html +8 -11
  328. package/coverage/lcov-report/src/websocket.ts.html +1 -1
  329. package/coverage/lcov.info +5516 -5765
  330. package/dist/api/controllers/apikeys.js +12 -9
  331. package/dist/api/controllers/automation.js +104 -84
  332. package/dist/api/controllers/cloud.js +84 -71
  333. package/dist/api/controllers/component.js +4 -2
  334. package/dist/api/controllers/datasource.js +125 -111
  335. package/dist/api/controllers/deploy/Deployment.js +10 -6
  336. package/dist/api/controllers/layout.js +18 -15
  337. package/dist/api/controllers/metadata.js +51 -37
  338. package/dist/api/controllers/permission.js +52 -43
  339. package/dist/api/controllers/plugin/index.js +6 -7
  340. package/dist/api/controllers/public/tables.js +29 -9
  341. package/dist/api/controllers/query/import/index.js +1 -2
  342. package/dist/api/controllers/query/validation.js +41 -33
  343. package/dist/api/controllers/role.js +29 -27
  344. package/dist/api/controllers/routing.js +71 -58
  345. package/dist/api/controllers/row/ExternalRequest.js +6 -7
  346. package/dist/api/controllers/row/external.js +3 -3
  347. package/dist/api/controllers/row/internal.js +11 -12
  348. package/dist/api/controllers/row/internalSearch.js +95 -80
  349. package/dist/api/controllers/row/staticFormula.js +85 -75
  350. package/dist/api/controllers/row/utils.js +118 -84
  351. package/dist/api/controllers/screen.js +81 -66
  352. package/dist/api/controllers/script.js +13 -6
  353. package/dist/api/controllers/static/index.js +9 -11
  354. package/dist/api/controllers/table/bulkFormula.js +47 -35
  355. package/dist/api/controllers/table/external.js +67 -54
  356. package/dist/api/controllers/table/index.js +66 -33
  357. package/dist/api/controllers/table/internal.js +1 -2
  358. package/dist/api/controllers/table/utils.js +8 -9
  359. package/dist/api/controllers/templates.js +17 -10
  360. package/dist/api/controllers/user.js +82 -70
  361. package/dist/api/controllers/view/exporters.js +8 -4
  362. package/dist/api/controllers/view/index.js +201 -153
  363. package/dist/api/controllers/view/utils.js +151 -121
  364. package/dist/api/index.js +38 -34
  365. package/dist/api/routes/analytics.js +29 -3
  366. package/dist/api/routes/apikeys.js +33 -7
  367. package/dist/api/routes/application.js +8 -9
  368. package/dist/api/routes/auth.js +1 -2
  369. package/dist/api/routes/automation.js +46 -20
  370. package/dist/api/routes/backup.js +3 -4
  371. package/dist/api/routes/cloud.js +32 -6
  372. package/dist/api/routes/component.js +32 -6
  373. package/dist/api/routes/datasource.js +39 -13
  374. package/dist/api/routes/deploy.js +34 -8
  375. package/dist/api/routes/dev.js +36 -10
  376. package/dist/api/routes/integration.js +10 -7
  377. package/dist/api/routes/layout.js +33 -7
  378. package/dist/api/routes/metadata.js +36 -10
  379. package/dist/api/routes/migrations.js +32 -6
  380. package/dist/api/routes/permission.js +38 -12
  381. package/dist/api/routes/plugin.js +5 -5
  382. package/dist/api/routes/query.js +42 -15
  383. package/dist/api/routes/role.js +36 -10
  384. package/dist/api/routes/routing.js +32 -6
  385. package/dist/api/routes/row.js +2 -1
  386. package/dist/api/routes/screen.js +35 -9
  387. package/dist/api/routes/script.js +32 -6
  388. package/dist/api/routes/static.js +9 -9
  389. package/dist/api/routes/table.js +40 -13
  390. package/dist/api/routes/templates.js +33 -7
  391. package/dist/api/routes/tests/utilities/TestFunctions.js +6 -8
  392. package/dist/api/routes/user.js +40 -13
  393. package/dist/api/routes/utils/validators.js +142 -126
  394. package/dist/api/routes/view.js +38 -12
  395. package/dist/api/routes/webhook.js +1 -2
  396. package/dist/app.js +3 -4
  397. package/dist/automations/triggers.js +5 -6
  398. package/dist/constants/index.js +3 -5
  399. package/dist/constants/screens.js +2 -2
  400. package/dist/db/inMemoryView.js +3 -3
  401. package/dist/db/linkedRows/LinkController.js +2 -2
  402. package/dist/db/linkedRows/index.js +2 -2
  403. package/dist/db/linkedRows/linkUtils.js +3 -3
  404. package/dist/db/views/staticViews.js +4 -4
  405. package/dist/integrations/index.js +15 -6
  406. package/dist/middleware/authorized.js +22 -21
  407. package/dist/migrations/functions/appUrls.js +2 -2
  408. package/dist/migrations/functions/usageQuotas/syncApps.js +3 -4
  409. package/dist/migrations/functions/usageQuotas/syncRows.js +3 -4
  410. package/dist/migrations/functions/userEmailViewCasing.js +3 -3
  411. package/dist/package.json +6 -6
  412. package/dist/sdk/app/backups/exports.js +1 -2
  413. package/dist/sdk/app/backups/imports.js +2 -3
  414. package/dist/startup.js +4 -4
  415. package/dist/tests/utilities/TestConfiguration.js +27 -35
  416. package/dist/tests/utilities/structures.js +3 -4
  417. package/dist/threads/automation.js +15 -16
  418. package/dist/threads/query.js +17 -19
  419. package/dist/threads/utils.js +11 -9
  420. package/dist/tsconfig.build.tsbuildinfo +1 -1
  421. package/dist/utilities/budibaseDir.js +4 -2
  422. package/dist/utilities/fileSystem/clientLibrary.js +12 -12
  423. package/dist/utilities/fileSystem/index.js +3 -3
  424. package/dist/utilities/index.js +102 -75
  425. package/dist/utilities/redis.js +100 -65
  426. package/dist/utilities/routing/index.js +27 -23
  427. package/dist/utilities/rowProcessor/index.js +124 -191
  428. package/dist/utilities/rowProcessor/map.js +96 -0
  429. package/dist/utilities/rowProcessor/utils.js +35 -26
  430. package/dist/utilities/security.js +39 -35
  431. package/dist/utilities/usageQuota/rows.js +56 -49
  432. package/dist/utilities/users.js +31 -28
  433. package/dist/utilities/workerRequests.js +115 -82
  434. package/dist/watch.js +1 -2
  435. package/package.json +7 -7
  436. package/scripts/exportAppTemplate.js +2 -2
  437. package/src/api/controllers/{apikeys.js → apikeys.ts} +10 -10
  438. package/src/api/controllers/auth.ts +2 -2
  439. package/src/api/controllers/{automation.js → automation.ts} +48 -48
  440. package/src/api/controllers/{cloud.js → cloud.ts} +24 -24
  441. package/src/api/controllers/component.ts +2 -1
  442. package/src/api/controllers/{datasource.js → datasource.ts} +55 -48
  443. package/src/api/controllers/deploy/{Deployment.js → Deployment.ts} +13 -10
  444. package/src/api/controllers/{layout.js → layout.ts} +8 -8
  445. package/src/api/controllers/{metadata.js → metadata.ts} +11 -10
  446. package/src/api/controllers/{permission.js → permission.ts} +49 -46
  447. package/src/api/controllers/plugin/index.ts +4 -5
  448. package/src/api/controllers/public/tables.ts +2 -2
  449. package/src/api/controllers/query/import/index.ts +2 -3
  450. package/src/api/controllers/query/{validation.js → validation.ts} +7 -7
  451. package/src/api/controllers/{role.js → role.ts} +21 -25
  452. package/src/api/controllers/{routing.js → routing.ts} +37 -34
  453. package/src/api/controllers/row/ExternalRequest.ts +4 -8
  454. package/src/api/controllers/row/external.js +3 -3
  455. package/src/api/controllers/row/internal.js +11 -12
  456. package/src/api/controllers/row/{internalSearch.js → internalSearch.ts} +92 -68
  457. package/src/api/controllers/row/{staticFormula.js → staticFormula.ts} +28 -23
  458. package/src/api/controllers/row/{utils.js → utils.ts} +25 -18
  459. package/src/api/controllers/screen.ts +10 -6
  460. package/src/api/controllers/script.ts +12 -0
  461. package/src/api/controllers/static/index.ts +9 -13
  462. package/src/api/controllers/table/{bulkFormula.js → bulkFormula.ts} +39 -25
  463. package/src/api/controllers/table/{external.js → external.ts} +86 -51
  464. package/src/api/controllers/table/{index.js → index.ts} +17 -17
  465. package/src/api/controllers/table/internal.ts +1 -2
  466. package/src/api/controllers/table/utils.ts +10 -10
  467. package/src/api/controllers/{templates.js → templates.ts} +10 -7
  468. package/src/api/controllers/{user.js → user.ts} +47 -49
  469. package/src/api/controllers/view/{exporters.js → exporters.ts} +5 -3
  470. package/src/api/controllers/view/{index.js → index.ts} +36 -27
  471. package/src/api/controllers/view/{utils.js → utils.ts} +26 -20
  472. package/src/api/{index.js → index.ts} +15 -22
  473. package/src/api/routes/analytics.ts +9 -0
  474. package/src/api/routes/apikeys.ts +12 -0
  475. package/src/api/routes/application.ts +17 -9
  476. package/src/api/routes/auth.ts +2 -2
  477. package/src/api/routes/automation.ts +87 -0
  478. package/src/api/routes/backup.ts +8 -4
  479. package/src/api/routes/cloud.ts +18 -0
  480. package/src/api/routes/component.ts +14 -0
  481. package/src/api/routes/datasource.ts +60 -0
  482. package/src/api/routes/deploy.ts +21 -0
  483. package/src/api/routes/dev.ts +38 -0
  484. package/src/api/routes/integration.ts +16 -0
  485. package/src/api/routes/layout.ts +16 -0
  486. package/src/api/routes/{metadata.js → metadata.ts} +13 -13
  487. package/src/api/routes/migrations.ts +14 -0
  488. package/src/api/routes/permission.ts +41 -0
  489. package/src/api/routes/plugin.ts +14 -6
  490. package/src/api/routes/{query.js → query.ts} +17 -20
  491. package/src/api/routes/role.ts +24 -0
  492. package/src/api/routes/routing.ts +14 -0
  493. package/src/api/routes/row.ts +3 -5
  494. package/src/api/routes/screen.ts +23 -0
  495. package/src/api/routes/script.ts +10 -0
  496. package/src/api/routes/static.ts +4 -7
  497. package/src/api/routes/{table.js → table.ts} +9 -12
  498. package/src/api/routes/templates.ts +16 -0
  499. package/src/api/routes/tests/backup.spec.js +9 -1
  500. package/src/api/routes/tests/permissions.spec.js +2 -1
  501. package/src/api/routes/tests/role.spec.js +3 -5
  502. package/src/api/routes/tests/routing.spec.js +2 -1
  503. package/src/api/routes/tests/row.spec.js +3 -4
  504. package/src/api/routes/tests/user.spec.js +2 -1
  505. package/src/api/routes/tests/utilities/TestFunctions.ts +6 -8
  506. package/src/api/routes/{user.js → user.ts} +7 -9
  507. package/src/api/routes/utils/{validators.js → validators.ts} +33 -37
  508. package/src/api/routes/view.ts +34 -0
  509. package/src/api/routes/webhook.ts +2 -2
  510. package/src/app.ts +3 -4
  511. package/src/automations/triggers.js +5 -6
  512. package/src/constants/index.js +3 -5
  513. package/src/constants/screens.js +2 -2
  514. package/src/db/inMemoryView.js +3 -3
  515. package/src/db/linkedRows/LinkController.js +2 -2
  516. package/src/db/linkedRows/index.js +2 -2
  517. package/src/db/linkedRows/linkUtils.js +3 -3
  518. package/src/db/utils.ts +1 -1
  519. package/src/db/views/staticViews.js +4 -4
  520. package/src/integrations/base/sql.ts +1 -1
  521. package/src/integrations/base/sqlTable.ts +1 -1
  522. package/src/integrations/index.ts +45 -41
  523. package/src/middleware/authorized.ts +21 -28
  524. package/src/middleware/tests/authorized.spec.js +5 -6
  525. package/src/migrations/functions/appUrls.ts +2 -2
  526. package/src/migrations/functions/tests/appUrls.spec.js +4 -4
  527. package/src/migrations/functions/tests/userEmailViewCasing.spec.js +14 -9
  528. package/src/migrations/functions/usageQuotas/syncApps.ts +3 -4
  529. package/src/migrations/functions/usageQuotas/syncRows.ts +3 -4
  530. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +7 -7
  531. package/src/migrations/functions/userEmailViewCasing.ts +3 -3
  532. package/src/sdk/app/backups/exports.ts +5 -3
  533. package/src/sdk/app/backups/imports.ts +3 -7
  534. package/src/startup.ts +2 -2
  535. package/src/tests/utilities/TestConfiguration.js +39 -35
  536. package/src/tests/utilities/structures.js +3 -4
  537. package/src/threads/automation.ts +14 -15
  538. package/src/threads/query.ts +11 -16
  539. package/src/threads/utils.ts +4 -5
  540. package/src/utilities/budibaseDir.ts +3 -0
  541. package/src/utilities/fileSystem/clientLibrary.js +12 -12
  542. package/src/utilities/fileSystem/index.js +8 -8
  543. package/src/utilities/{index.js → index.ts} +40 -32
  544. package/src/utilities/{redis.js → redis.ts} +21 -20
  545. package/src/utilities/routing/index.ts +32 -0
  546. package/src/utilities/rowProcessor/{index.js → index.ts} +65 -142
  547. package/src/utilities/rowProcessor/map.js +95 -0
  548. package/src/utilities/rowProcessor/{utils.js → utils.ts} +19 -15
  549. package/src/utilities/security.ts +65 -0
  550. package/src/utilities/usageQuota/{rows.js → rows.ts} +14 -18
  551. package/src/utilities/{users.js → users.ts} +11 -13
  552. package/src/utilities/{workerRequests.js → workerRequests.ts} +43 -38
  553. package/src/watch.ts +2 -3
  554. package/coverage/lcov-report/src/api/routes/cloud.js.html +0 -127
  555. package/coverage/lcov-report/src/api/routes/integration.js.html +0 -121
  556. package/coverage/lcov-report/src/api/routes/role.js.html +0 -130
  557. package/coverage/lcov-report/src/module.d.ts.html +0 -127
  558. package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +0 -193
  559. package/dist/utilities/fileSystem/utilities.js +0 -22
  560. package/src/api/controllers/script.js +0 -11
  561. package/src/api/routes/analytics.js +0 -9
  562. package/src/api/routes/apikeys.js +0 -12
  563. package/src/api/routes/automation.js +0 -85
  564. package/src/api/routes/cloud.js +0 -14
  565. package/src/api/routes/component.js +0 -14
  566. package/src/api/routes/datasource.js +0 -51
  567. package/src/api/routes/deploy.js +0 -17
  568. package/src/api/routes/dev.js +0 -26
  569. package/src/api/routes/integration.js +0 -12
  570. package/src/api/routes/layout.js +0 -16
  571. package/src/api/routes/migrations.js +0 -14
  572. package/src/api/routes/permission.js +0 -33
  573. package/src/api/routes/role.js +0 -15
  574. package/src/api/routes/routing.js +0 -14
  575. package/src/api/routes/screen.js +0 -18
  576. package/src/api/routes/script.js +0 -10
  577. package/src/api/routes/templates.js +0 -16
  578. package/src/api/routes/view.js +0 -31
  579. package/src/module.d.ts +0 -14
  580. package/src/utilities/budibaseDir.js +0 -3
  581. package/src/utilities/fileSystem/utilities.js +0 -36
  582. package/src/utilities/routing/index.js +0 -25
  583. package/src/utilities/security.js +0 -71
@@ -6,7 +6,6 @@ const {
6
6
  DocumentType,
7
7
  InternalTables,
8
8
  } = require("../../../db/utils")
9
- const { getDB } = require("@budibase/backend-core/db")
10
9
  const userController = require("../user")
11
10
  const {
12
11
  inputProcessing,
@@ -26,7 +25,7 @@ const {
26
25
  getFromMemoryDoc,
27
26
  } = require("../view/utils")
28
27
  const { cloneDeep } = require("lodash/fp")
29
- const { getAppDB } = require("@budibase/backend-core/context")
28
+ const { context, db: dbCore } = require("@budibase/backend-core")
30
29
  const { finaliseRow, updateRelatedFormula } = require("./staticFormula")
31
30
  const exporters = require("../view/exporters")
32
31
  const { apiFileReturn } = require("../../../utilities/fileSystem")
@@ -80,7 +79,7 @@ async function getRawTableData(ctx, db, tableId) {
80
79
  }
81
80
 
82
81
  exports.patch = async ctx => {
83
- const db = getAppDB()
82
+ const db = context.getAppDB()
84
83
  const inputs = ctx.request.body
85
84
  const tableId = inputs.tableId
86
85
  const isUserTable = tableId === InternalTables.USER_METADATA
@@ -145,7 +144,7 @@ exports.patch = async ctx => {
145
144
  }
146
145
 
147
146
  exports.save = async function (ctx) {
148
- const db = getAppDB()
147
+ const db = context.getAppDB()
149
148
  let inputs = ctx.request.body
150
149
  inputs.tableId = ctx.params.tableId
151
150
 
@@ -188,7 +187,7 @@ exports.fetchView = async ctx => {
188
187
  return exports.fetch(ctx)
189
188
  }
190
189
 
191
- const db = getAppDB()
190
+ const db = context.getAppDB()
192
191
  const { calculation, group, field } = ctx.query
193
192
  const viewInfo = await getView(db, viewName)
194
193
  let response
@@ -242,7 +241,7 @@ exports.fetchView = async ctx => {
242
241
  }
243
242
 
244
243
  exports.fetch = async ctx => {
245
- const db = getAppDB()
244
+ const db = context.getAppDB()
246
245
 
247
246
  const tableId = ctx.params.tableId
248
247
  let table = await db.get(tableId)
@@ -251,7 +250,7 @@ exports.fetch = async ctx => {
251
250
  }
252
251
 
253
252
  exports.find = async ctx => {
254
- const db = getDB(ctx.appId)
253
+ const db = dbCore.getDB(ctx.appId)
255
254
  const table = await db.get(ctx.params.tableId)
256
255
  let row = await findRow(ctx, ctx.params.tableId, ctx.params.rowId)
257
256
  row = await outputProcessing(table, row)
@@ -259,7 +258,7 @@ exports.find = async ctx => {
259
258
  }
260
259
 
261
260
  exports.destroy = async function (ctx) {
262
- const db = getAppDB()
261
+ const db = context.getAppDB()
263
262
  const { _id } = ctx.request.body
264
263
  let row = await db.get(_id)
265
264
  let _rev = ctx.request.body._rev || row._rev
@@ -295,7 +294,7 @@ exports.destroy = async function (ctx) {
295
294
  }
296
295
 
297
296
  exports.bulkDestroy = async ctx => {
298
- const db = getAppDB()
297
+ const db = context.getAppDB()
299
298
  const tableId = ctx.params.tableId
300
299
  const table = await db.get(tableId)
301
300
  let { rows } = ctx.request.body
@@ -338,7 +337,7 @@ exports.search = async ctx => {
338
337
  }
339
338
 
340
339
  const { tableId } = ctx.params
341
- const db = getAppDB()
340
+ const db = context.getAppDB()
342
341
  const { paginate, query, ...params } = ctx.request.body
343
342
  params.version = ctx.version
344
343
  params.tableId = tableId
@@ -371,7 +370,7 @@ exports.validate = async ctx => {
371
370
  }
372
371
 
373
372
  exports.exportRows = async ctx => {
374
- const db = getAppDB()
373
+ const db = context.getAppDB()
375
374
  const table = await db.get(ctx.params.tableId)
376
375
  const rowIds = ctx.request.body.rows
377
376
  let format = ctx.query.format
@@ -408,7 +407,7 @@ exports.exportRows = async ctx => {
408
407
  }
409
408
 
410
409
  exports.fetchEnrichedRow = async ctx => {
411
- const db = getAppDB()
410
+ const db = context.getAppDB()
412
411
  const tableId = ctx.params.tableId
413
412
  const rowId = ctx.params.rowId
414
413
  // need table to work out where links go in row
@@ -1,15 +1,35 @@
1
- const { SearchIndexes } = require("../../../db/utils")
2
- const { removeKeyNumbering } = require("./utils")
3
- const fetch = require("node-fetch")
4
- const { getCouchInfo } = require("@budibase/backend-core/db")
5
- const { getAppId } = require("@budibase/backend-core/context")
1
+ import { SearchIndexes } from "../../../db/utils"
2
+ import { removeKeyNumbering } from "./utils"
3
+ import fetch from "node-fetch"
4
+ import { db as dbCore, context } from "@budibase/backend-core"
5
+ import { SearchFilters, Row } from "@budibase/types"
6
+
7
+ type SearchParams = {
8
+ tableId: string
9
+ sort?: string
10
+ sortOrder?: string
11
+ sortType?: string
12
+ limit?: number
13
+ bookmark?: string
14
+ version?: string
15
+ rows?: Row[]
16
+ }
6
17
 
7
18
  /**
8
19
  * Class to build lucene query URLs.
9
20
  * Optionally takes a base lucene query object.
10
21
  */
11
- class QueryBuilder {
12
- constructor(base) {
22
+ export class QueryBuilder {
23
+ query: SearchFilters
24
+ limit: number
25
+ sort?: string
26
+ bookmark?: string
27
+ sortOrder: string
28
+ sortType: string
29
+ includeDocs: boolean
30
+ version?: string
31
+
32
+ constructor(base?: SearchFilters) {
13
33
  this.query = {
14
34
  allOr: false,
15
35
  string: {},
@@ -29,49 +49,52 @@ class QueryBuilder {
29
49
  this.sortOrder = "ascending"
30
50
  this.sortType = "string"
31
51
  this.includeDocs = true
32
- this.version = null
33
52
  }
34
53
 
35
- setVersion(version) {
36
- this.version = version
54
+ setVersion(version?: string) {
55
+ if (version != null) {
56
+ this.version = version
57
+ }
37
58
  return this
38
59
  }
39
60
 
40
- setTable(tableId) {
41
- this.query.equal.tableId = tableId
61
+ setTable(tableId: string) {
62
+ this.query.equal!.tableId = tableId
42
63
  return this
43
64
  }
44
65
 
45
- setLimit(limit) {
66
+ setLimit(limit?: number) {
46
67
  if (limit != null) {
47
68
  this.limit = limit
48
69
  }
49
70
  return this
50
71
  }
51
72
 
52
- setSort(sort) {
73
+ setSort(sort?: string) {
53
74
  if (sort != null) {
54
75
  this.sort = sort
55
76
  }
56
77
  return this
57
78
  }
58
79
 
59
- setSortOrder(sortOrder) {
80
+ setSortOrder(sortOrder?: string) {
60
81
  if (sortOrder != null) {
61
82
  this.sortOrder = sortOrder
62
83
  }
63
84
  return this
64
85
  }
65
86
 
66
- setSortType(sortType) {
87
+ setSortType(sortType?: string) {
67
88
  if (sortType != null) {
68
89
  this.sortType = sortType
69
90
  }
70
91
  return this
71
92
  }
72
93
 
73
- setBookmark(bookmark) {
74
- this.bookmark = bookmark
94
+ setBookmark(bookmark?: string) {
95
+ if (bookmark != null) {
96
+ this.bookmark = bookmark
97
+ }
75
98
  return this
76
99
  }
77
100
 
@@ -80,61 +103,61 @@ class QueryBuilder {
80
103
  return this
81
104
  }
82
105
 
83
- addString(key, partial) {
84
- this.query.string[key] = partial
106
+ addString(key: string, partial: string) {
107
+ this.query.string![key] = partial
85
108
  return this
86
109
  }
87
110
 
88
- addFuzzy(key, fuzzy) {
89
- this.query.fuzzy[key] = fuzzy
111
+ addFuzzy(key: string, fuzzy: string) {
112
+ this.query.fuzzy![key] = fuzzy
90
113
  return this
91
114
  }
92
115
 
93
- addRange(key, low, high) {
94
- this.query.range = {
116
+ addRange(key: string, low: string | number, high: string | number) {
117
+ this.query.range![key] = {
95
118
  low,
96
119
  high,
97
120
  }
98
121
  return this
99
122
  }
100
123
 
101
- addEqual(key, value) {
102
- this.query.equal[key] = value
124
+ addEqual(key: string, value: any) {
125
+ this.query.equal![key] = value
103
126
  return this
104
127
  }
105
128
 
106
- addNotEqual(key, value) {
107
- this.query.notEqual[key] = value
129
+ addNotEqual(key: string, value: any) {
130
+ this.query.notEqual![key] = value
108
131
  return this
109
132
  }
110
133
 
111
- addEmpty(key, value) {
112
- this.query.empty[key] = value
134
+ addEmpty(key: string, value: any) {
135
+ this.query.empty![key] = value
113
136
  return this
114
137
  }
115
138
 
116
- addNotEmpty(key, value) {
117
- this.query.notEmpty[key] = value
139
+ addNotEmpty(key: string, value: any) {
140
+ this.query.notEmpty![key] = value
118
141
  return this
119
142
  }
120
143
 
121
- addOneOf(key, value) {
122
- this.query.oneOf[key] = value
144
+ addOneOf(key: string, value: any) {
145
+ this.query.oneOf![key] = value
123
146
  return this
124
147
  }
125
148
 
126
- addContains(key, value) {
127
- this.query.contains[key] = value
149
+ addContains(key: string, value: any) {
150
+ this.query.contains![key] = value
128
151
  return this
129
152
  }
130
153
 
131
- addNotContains(key, value) {
132
- this.query.notContains[key] = value
154
+ addNotContains(key: string, value: any) {
155
+ this.query.notContains![key] = value
133
156
  return this
134
157
  }
135
158
 
136
- addContainsAny(key, value) {
137
- this.query.containsAny[key] = value
159
+ addContainsAny(key: string, value: any) {
160
+ this.query.containsAny![key] = value
138
161
  return this
139
162
  }
140
163
 
@@ -145,7 +168,7 @@ class QueryBuilder {
145
168
  * @param options The preprocess options
146
169
  * @returns {string|*}
147
170
  */
148
- preprocess(value, { escape, lowercase, wrap, type } = {}) {
171
+ preprocess(value: any, { escape, lowercase, wrap, type }: any = {}) {
149
172
  const hasVersion = !!this.version
150
173
  // Determine if type needs wrapped
151
174
  const originalType = typeof value
@@ -173,12 +196,12 @@ class QueryBuilder {
173
196
  let query = allOr ? "" : "*:*"
174
197
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }
175
198
  let tableId
176
- if (this.query.equal.tableId) {
177
- tableId = this.query.equal.tableId
178
- delete this.query.equal.tableId
199
+ if (this.query.equal!.tableId) {
200
+ tableId = this.query.equal!.tableId
201
+ delete this.query.equal!.tableId
179
202
  }
180
203
 
181
- const equal = (key, value) => {
204
+ const equal = (key: string, value: any) => {
182
205
  // 0 evaluates to false, which means we would return all rows if we don't check it
183
206
  if (!value && value !== 0) {
184
207
  return null
@@ -186,7 +209,7 @@ class QueryBuilder {
186
209
  return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
187
210
  }
188
211
 
189
- const contains = (key, value, mode = "AND") => {
212
+ const contains = (key: string, value: any, mode = "AND") => {
190
213
  if (Array.isArray(value) && value.length === 0) {
191
214
  return null
192
215
  }
@@ -202,16 +225,17 @@ class QueryBuilder {
202
225
  return `${key}:(${statement})`
203
226
  }
204
227
 
205
- const notContains = (key, value) => {
228
+ const notContains = (key: string, value: any) => {
229
+ // @ts-ignore
206
230
  const allPrefix = allOr === "" ? "*:* AND" : ""
207
231
  return allPrefix + "NOT " + contains(key, value)
208
232
  }
209
233
 
210
- const containsAny = (key, value) => {
234
+ const containsAny = (key: string, value: any) => {
211
235
  return contains(key, value, "OR")
212
236
  }
213
237
 
214
- const oneOf = (key, value) => {
238
+ const oneOf = (key: string, value: any) => {
215
239
  if (!Array.isArray(value)) {
216
240
  if (typeof value === "string") {
217
241
  value = value.split(",")
@@ -229,7 +253,7 @@ class QueryBuilder {
229
253
  return `${key}:(${orStatement})`
230
254
  }
231
255
 
232
- function build(structure, queryFn) {
256
+ function build(structure: any, queryFn: any) {
233
257
  for (let [key, value] of Object.entries(structure)) {
234
258
  // check for new format - remove numbering if needed
235
259
  key = removeKeyNumbering(key)
@@ -249,7 +273,7 @@ class QueryBuilder {
249
273
 
250
274
  // Construct the actual lucene search query string from JSON structure
251
275
  if (this.query.string) {
252
- build(this.query.string, (key, value) => {
276
+ build(this.query.string, (key: string, value: any) => {
253
277
  if (!value) {
254
278
  return null
255
279
  }
@@ -262,7 +286,7 @@ class QueryBuilder {
262
286
  })
263
287
  }
264
288
  if (this.query.range) {
265
- build(this.query.range, (key, value) => {
289
+ build(this.query.range, (key: string, value: any) => {
266
290
  if (!value) {
267
291
  return null
268
292
  }
@@ -278,7 +302,7 @@ class QueryBuilder {
278
302
  })
279
303
  }
280
304
  if (this.query.fuzzy) {
281
- build(this.query.fuzzy, (key, value) => {
305
+ build(this.query.fuzzy, (key: string, value: any) => {
282
306
  if (!value) {
283
307
  return null
284
308
  }
@@ -294,7 +318,7 @@ class QueryBuilder {
294
318
  build(this.query.equal, equal)
295
319
  }
296
320
  if (this.query.notEqual) {
297
- build(this.query.notEqual, (key, value) => {
321
+ build(this.query.notEqual, (key: string, value: any) => {
298
322
  if (!value) {
299
323
  return null
300
324
  }
@@ -302,10 +326,10 @@ class QueryBuilder {
302
326
  })
303
327
  }
304
328
  if (this.query.empty) {
305
- build(this.query.empty, key => `!${key}:["" TO *]`)
329
+ build(this.query.empty, (key: string) => `!${key}:["" TO *]`)
306
330
  }
307
331
  if (this.query.notEmpty) {
308
- build(this.query.notEmpty, key => `${key}:["" TO *]`)
332
+ build(this.query.notEmpty, (key: string) => `${key}:["" TO *]`)
309
333
  }
310
334
  if (this.query.oneOf) {
311
335
  build(this.query.oneOf, oneOf)
@@ -329,7 +353,7 @@ class QueryBuilder {
329
353
  }
330
354
 
331
355
  buildSearchBody() {
332
- let body = {
356
+ let body: any = {
333
357
  q: this.buildSearchQuery(),
334
358
  limit: Math.min(this.limit, 200),
335
359
  include_docs: this.includeDocs,
@@ -346,17 +370,14 @@ class QueryBuilder {
346
370
  }
347
371
 
348
372
  async run() {
349
- const appId = getAppId()
350
- const { url, cookie } = getCouchInfo()
373
+ const appId = context.getAppId()
374
+ const { url, cookie } = dbCore.getCouchInfo()
351
375
  const fullPath = `${url}/${appId}/_design/database/_search/${SearchIndexes.ROWS}`
352
376
  const body = this.buildSearchBody()
353
377
  return await runQuery(fullPath, body, cookie)
354
378
  }
355
379
  }
356
380
 
357
- // exported for unit testing
358
- exports.QueryBuilder = QueryBuilder
359
-
360
381
  /**
361
382
  * Executes a lucene search query.
362
383
  * @param url The query URL
@@ -364,7 +385,7 @@ exports.QueryBuilder = QueryBuilder
364
385
  * @param cookie The auth cookie for CouchDB
365
386
  * @returns {Promise<{rows: []}>}
366
387
  */
367
- const runQuery = async (url, body, cookie) => {
388
+ const runQuery = async (url: string, body: any, cookie: string) => {
368
389
  const response = await fetch(url, {
369
390
  body: JSON.stringify(body),
370
391
  method: "POST",
@@ -374,11 +395,11 @@ const runQuery = async (url, body, cookie) => {
374
395
  })
375
396
  const json = await response.json()
376
397
 
377
- let output = {
398
+ let output: any = {
378
399
  rows: [],
379
400
  }
380
401
  if (json.rows != null && json.rows.length > 0) {
381
- output.rows = json.rows.map(row => row.doc)
402
+ output.rows = json.rows.map((row: any) => row.doc)
382
403
  }
383
404
  if (json.bookmark) {
384
405
  output.bookmark = json.bookmark
@@ -402,7 +423,7 @@ const runQuery = async (url, body, cookie) => {
402
423
  * rows {array|null} Current results in the recursive search
403
424
  * @returns {Promise<*[]|*>}
404
425
  */
405
- const recursiveSearch = async (query, params) => {
426
+ async function recursiveSearch(query: any, params: any): Promise<any> {
406
427
  const bookmark = params.bookmark
407
428
  const rows = params.rows || []
408
429
  if (rows.length >= params.limit) {
@@ -450,7 +471,10 @@ const recursiveSearch = async (query, params) => {
450
471
  * bookmark {string} The bookmark to resume from
451
472
  * @returns {Promise<{hasNextPage: boolean, rows: *[]}>}
452
473
  */
453
- exports.paginatedSearch = async (query, params) => {
474
+ export async function paginatedSearch(
475
+ query: SearchFilters,
476
+ params: SearchParams
477
+ ) {
454
478
  let limit = params.limit
455
479
  if (limit == null || isNaN(limit) || limit < 0) {
456
480
  limit = 50
@@ -496,7 +520,7 @@ exports.paginatedSearch = async (query, params) => {
496
520
  * limit {number} The desired number of results
497
521
  * @returns {Promise<{rows: *}>}
498
522
  */
499
- exports.fullSearch = async (query, params) => {
523
+ export async function fullSearch(query: SearchFilters, params: SearchParams) {
500
524
  let limit = params.limit
501
525
  if (limit == null || isNaN(limit) || limit < 0) {
502
526
  limit = 1000
@@ -1,13 +1,14 @@
1
- const { getRowParams } = require("../../../db/utils")
2
- const {
1
+ import { getRowParams } from "../../../db/utils"
2
+ import {
3
3
  outputProcessing,
4
4
  processAutoColumn,
5
5
  processFormulas,
6
- } = require("../../../utilities/rowProcessor")
7
- const { FieldTypes, FormulaTypes } = require("../../../constants")
6
+ } from "../../../utilities/rowProcessor"
7
+ import { FieldTypes, FormulaTypes } from "../../../constants"
8
+ import { context } from "@budibase/backend-core"
9
+ import { Table, Row } from "@budibase/types"
8
10
  const { isEqual } = require("lodash")
9
11
  const { cloneDeep } = require("lodash/fp")
10
- const { getAppDB } = require("@budibase/backend-core/context")
11
12
 
12
13
  /**
13
14
  * This function runs through a list of enriched rows, looks at the rows which
@@ -15,22 +16,22 @@ const { getAppDB } = require("@budibase/backend-core/context")
15
16
  * updated.
16
17
  * NOTE: this will only for affect static formulas.
17
18
  */
18
- exports.updateRelatedFormula = async (table, enrichedRows) => {
19
- const db = getAppDB()
19
+ exports.updateRelatedFormula = async (table: Table, enrichedRows: Row[]) => {
20
+ const db = context.getAppDB()
20
21
  // no formula to update, we're done
21
22
  if (!table.relatedFormula) {
22
23
  return
23
24
  }
24
- let promises = []
25
+ let promises: Promise<any>[] = []
25
26
  for (let enrichedRow of Array.isArray(enrichedRows)
26
27
  ? enrichedRows
27
28
  : [enrichedRows]) {
28
29
  // the related rows by tableId
29
- let relatedRows = {}
30
+ let relatedRows: Record<string, Row[]> = {}
30
31
  for (let [key, field] of Object.entries(enrichedRow)) {
31
32
  const columnDefinition = table.schema[key]
32
33
  if (columnDefinition && columnDefinition.type === FieldTypes.LINK) {
33
- const relatedTableId = columnDefinition.tableId
34
+ const relatedTableId = columnDefinition.tableId!
34
35
  if (!relatedRows[relatedTableId]) {
35
36
  relatedRows[relatedTableId] = []
36
37
  }
@@ -38,7 +39,7 @@ exports.updateRelatedFormula = async (table, enrichedRows) => {
38
39
  }
39
40
  }
40
41
  for (let tableId of table.relatedFormula) {
41
- let relatedTable
42
+ let relatedTable: Table
42
43
  try {
43
44
  // no rows to update, skip
44
45
  if (!relatedRows[tableId] || relatedRows[tableId].length === 0) {
@@ -48,7 +49,7 @@ exports.updateRelatedFormula = async (table, enrichedRows) => {
48
49
  } catch (err) {
49
50
  // no error scenario, table doesn't seem to exist anymore, ignore
50
51
  }
51
- for (let column of Object.values(relatedTable.schema)) {
52
+ for (let column of Object.values(relatedTable!.schema)) {
52
53
  // needs updated in related rows
53
54
  if (
54
55
  column.type === FieldTypes.FORMULA &&
@@ -57,7 +58,7 @@ exports.updateRelatedFormula = async (table, enrichedRows) => {
57
58
  // re-enrich rows for all the related, don't update the related formula for them
58
59
  promises = promises.concat(
59
60
  relatedRows[tableId].map(related =>
60
- exports.finaliseRow(relatedTable, related, {
61
+ finaliseRow(relatedTable, related, {
61
62
  updateFormula: false,
62
63
  })
63
64
  )
@@ -70,8 +71,8 @@ exports.updateRelatedFormula = async (table, enrichedRows) => {
70
71
  await Promise.all(promises)
71
72
  }
72
73
 
73
- exports.updateAllFormulasInTable = async table => {
74
- const db = getAppDB()
74
+ export async function updateAllFormulasInTable(table: Table) {
75
+ const db = context.getAppDB()
75
76
  // start by getting the raw rows (which will be written back to DB after update)
76
77
  let rows = (
77
78
  await db.allDocs(
@@ -88,7 +89,9 @@ exports.updateAllFormulasInTable = async table => {
88
89
  const updatedRows = []
89
90
  for (let row of rows) {
90
91
  // find the enriched row, if found process the formulas
91
- const enrichedRow = enrichedRows.find(enriched => enriched._id === row._id)
92
+ const enrichedRow = enrichedRows.find(
93
+ (enriched: any) => enriched._id === row._id
94
+ )
92
95
  if (enrichedRow) {
93
96
  const processed = processFormulas(table, cloneDeep(row), {
94
97
  dynamic: false,
@@ -109,12 +112,14 @@ exports.updateAllFormulasInTable = async table => {
109
112
  * row. The reason we need to return the enriched row is that the automation row created trigger
110
113
  * expects the row to be totally enriched/contain all relationships.
111
114
  */
112
- exports.finaliseRow = async (
113
- table,
114
- row,
115
- { oldTable, updateFormula } = { updateFormula: true }
116
- ) => {
117
- const db = getAppDB()
115
+ export async function finaliseRow(
116
+ table: Table,
117
+ row: Row,
118
+ { oldTable, updateFormula }: { oldTable?: Table; updateFormula: boolean } = {
119
+ updateFormula: true,
120
+ }
121
+ ) {
122
+ const db = context.getAppDB()
118
123
  row.type = "row"
119
124
  // process the row before return, to include relationships
120
125
  let enrichedRow = await outputProcessing(table, cloneDeep(row), {
@@ -131,7 +136,7 @@ exports.finaliseRow = async (
131
136
  if (oldTable && !isEqual(oldTable, table)) {
132
137
  try {
133
138
  await db.put(table)
134
- } catch (err) {
139
+ } catch (err: any) {
135
140
  if (err.status === 409) {
136
141
  const updatedTable = await db.get(table._id)
137
142
  let response = processAutoColumn(null, updatedTable, row, {
@@ -1,33 +1,32 @@
1
+ import { InternalTables } from "../../../db/utils"
2
+ import * as userController from "../user"
3
+ import { FieldTypes } from "../../../constants"
4
+ import { context } from "@budibase/backend-core"
5
+ import { makeExternalQuery } from "../../../integrations/base/query"
6
+ import { BBContext, Row, Table } from "@budibase/types"
7
+ export { removeKeyNumbering } from "../../../integrations/base/utils"
1
8
  const validateJs = require("validate.js")
2
9
  const { cloneDeep } = require("lodash/fp")
3
- const { InternalTables } = require("../../../db/utils")
4
- const userController = require("../user")
5
- const { FieldTypes } = require("../../../constants")
6
- const { getAppDB } = require("@budibase/backend-core/context")
7
- const { makeExternalQuery } = require("../../../integrations/base/query")
8
- const { removeKeyNumbering } = require("../../../integrations/base/utils")
9
10
 
10
11
  validateJs.extend(validateJs.validators.datetime, {
11
- parse: function (value) {
12
+ parse: function (value: string) {
12
13
  return new Date(value).getTime()
13
14
  },
14
15
  // Input is a unix timestamp
15
- format: function (value) {
16
+ format: function (value: string) {
16
17
  return new Date(value).toISOString()
17
18
  },
18
19
  })
19
20
 
20
- exports.removeKeyNumbering = removeKeyNumbering
21
-
22
- exports.getDatasourceAndQuery = async json => {
21
+ export async function getDatasourceAndQuery(json: any) {
23
22
  const datasourceId = json.endpoint.datasourceId
24
- const db = getAppDB()
23
+ const db = context.getAppDB()
25
24
  const datasource = await db.get(datasourceId)
26
25
  return makeExternalQuery(datasource, json)
27
26
  }
28
27
 
29
- exports.findRow = async (ctx, tableId, rowId) => {
30
- const db = getAppDB()
28
+ export async function findRow(ctx: BBContext, tableId: string, rowId: string) {
29
+ const db = context.getAppDB()
31
30
  let row
32
31
  // TODO remove special user case in future
33
32
  if (tableId === InternalTables.USER_METADATA) {
@@ -45,12 +44,20 @@ exports.findRow = async (ctx, tableId, rowId) => {
45
44
  return row
46
45
  }
47
46
 
48
- exports.validate = async ({ tableId, row, table }) => {
47
+ export async function validate({
48
+ tableId,
49
+ row,
50
+ table,
51
+ }: {
52
+ tableId?: string
53
+ row: Row
54
+ table: Table
55
+ }) {
49
56
  if (!table) {
50
- const db = getAppDB()
57
+ const db = context.getAppDB()
51
58
  table = await db.get(tableId)
52
59
  }
53
- const errors = {}
60
+ const errors: any = {}
54
61
  for (let fieldName of Object.keys(table.schema)) {
55
62
  const constraints = cloneDeep(table.schema[fieldName].constraints)
56
63
  const type = table.schema[fieldName].type
@@ -70,7 +77,7 @@ exports.validate = async ({ tableId, row, table }) => {
70
77
  if (!Array.isArray(row[fieldName])) {
71
78
  row[fieldName] = row[fieldName].split(",")
72
79
  }
73
- row[fieldName].map(val => {
80
+ row[fieldName].map((val: any) => {
74
81
  if (
75
82
  !constraints.inclusion.includes(val) &&
76
83
  constraints.inclusion.length !== 0