@budibase/server 2.1.31 → 2.1.32-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/__mocks__/aws-sdk.ts +14 -0
  2. package/__mocks__/node-fetch.ts +5 -1
  3. package/builder/assets/{index.6e202eba.js → index.3a6f5b99.js} +270 -270
  4. package/builder/assets/{index.534f6c29.css → index.7176fd99.css} +1 -1
  5. package/builder/index.html +2 -2
  6. package/coverage/clover.xml +9664 -2787
  7. package/coverage/coverage-final.json +162 -19
  8. package/coverage/lcov-report/index.html +621 -126
  9. package/coverage/lcov-report/src/api/controllers/analytics.ts.html +190 -0
  10. package/coverage/lcov-report/{api → src/api}/controllers/apikeys.js.html +10 -10
  11. package/coverage/lcov-report/src/api/controllers/application.ts.html +1981 -0
  12. package/coverage/lcov-report/src/api/controllers/auth.ts.html +301 -0
  13. package/coverage/lcov-report/{api → src/api}/controllers/automation.js.html +10 -10
  14. package/coverage/lcov-report/src/api/controllers/backup.ts.html +148 -0
  15. package/coverage/lcov-report/{api → src/api}/controllers/cloud.js.html +10 -10
  16. package/coverage/lcov-report/src/api/controllers/component.ts.html +256 -0
  17. package/coverage/lcov-report/{api → src/api}/controllers/datasource.js.html +10 -10
  18. package/coverage/lcov-report/src/api/controllers/deploy/Deployment.js.html +250 -0
  19. package/coverage/lcov-report/src/api/controllers/deploy/index.html +131 -0
  20. package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +730 -0
  21. package/coverage/lcov-report/{api/controllers/dev.js.html → src/api/controllers/dev.ts.html} +53 -71
  22. package/coverage/lcov-report/{api → src/api}/controllers/index.html +134 -29
  23. package/coverage/lcov-report/{api → src/api}/controllers/integration.js.html +10 -10
  24. package/coverage/lcov-report/{api → src/api}/controllers/layout.js.html +10 -10
  25. package/coverage/lcov-report/{api → src/api}/controllers/metadata.js.html +10 -10
  26. package/coverage/lcov-report/{api → src/api}/controllers/migrations.js.html +10 -10
  27. package/coverage/lcov-report/{api → src/api}/controllers/permission.js.html +10 -10
  28. package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +130 -0
  29. package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +310 -0
  30. package/coverage/lcov-report/src/api/controllers/plugin/index.html +206 -0
  31. package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +487 -0
  32. package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +253 -0
  33. package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +97 -0
  34. package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +121 -0
  35. package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +142 -0
  36. package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +334 -0
  37. package/coverage/lcov-report/src/api/controllers/public/index.html +191 -0
  38. package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +181 -0
  39. package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +191 -0
  40. package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +124 -0
  41. package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +202 -0
  42. package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +178 -0
  43. package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +163 -0
  44. package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +181 -0
  45. package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +145 -0
  46. package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +328 -0
  47. package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +253 -0
  48. package/coverage/lcov-report/src/api/controllers/public/users.ts.html +268 -0
  49. package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +220 -0
  50. package/coverage/lcov-report/src/api/controllers/query/import/index.html +116 -0
  51. package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +376 -0
  52. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +131 -0
  53. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +379 -0
  54. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +157 -0
  55. package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +403 -0
  56. package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +146 -0
  57. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +586 -0
  58. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +712 -0
  59. package/coverage/lcov-report/src/api/controllers/query/index.html +131 -0
  60. package/coverage/lcov-report/src/api/controllers/query/index.ts.html +976 -0
  61. package/coverage/lcov-report/{api → src/api}/controllers/query/validation.js.html +10 -10
  62. package/coverage/lcov-report/{api → src/api}/controllers/role.js.html +10 -10
  63. package/coverage/lcov-report/{api → src/api}/controllers/routing.js.html +10 -10
  64. package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +2332 -0
  65. package/coverage/lcov-report/{api → src/api}/controllers/row/external.js.html +10 -10
  66. package/coverage/lcov-report/{api → src/api}/controllers/row/index.html +48 -18
  67. package/coverage/lcov-report/src/api/controllers/row/index.ts.html +541 -0
  68. package/coverage/lcov-report/{api → src/api}/controllers/row/internal.js.html +12 -12
  69. package/coverage/lcov-report/{api → src/api}/controllers/row/internalSearch.js.html +10 -10
  70. package/coverage/lcov-report/{api → src/api}/controllers/row/staticFormula.js.html +10 -10
  71. package/coverage/lcov-report/{api → src/api}/controllers/row/utils.js.html +10 -10
  72. package/coverage/lcov-report/src/api/controllers/screen.ts.html +451 -0
  73. package/coverage/lcov-report/{api → src/api}/controllers/script.js.html +10 -10
  74. package/coverage/lcov-report/src/api/controllers/static/index.html +116 -0
  75. package/coverage/lcov-report/src/api/controllers/static/index.ts.html +700 -0
  76. package/coverage/lcov-report/{api → src/api}/controllers/table/bulkFormula.js.html +10 -10
  77. package/coverage/lcov-report/{api → src/api}/controllers/table/external.js.html +10 -10
  78. package/coverage/lcov-report/{api → src/api}/controllers/table/index.html +49 -19
  79. package/coverage/lcov-report/{api → src/api}/controllers/table/index.js.html +10 -10
  80. package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +664 -0
  81. package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1240 -0
  82. package/coverage/lcov-report/{api → src/api}/controllers/templates.js.html +10 -10
  83. package/coverage/lcov-report/{api → src/api}/controllers/user.js.html +10 -10
  84. package/coverage/lcov-report/{api → src/api}/controllers/view/exporters.js.html +10 -10
  85. package/coverage/lcov-report/{api → src/api}/controllers/view/index.html +10 -10
  86. package/coverage/lcov-report/{api → src/api}/controllers/view/index.js.html +10 -10
  87. package/coverage/lcov-report/{api → src/api}/controllers/view/utils.js.html +10 -10
  88. package/coverage/lcov-report/{api → src/api}/controllers/view/viewBuilder.js.html +10 -10
  89. package/coverage/lcov-report/src/api/controllers/webhook.ts.html +379 -0
  90. package/coverage/lcov-report/{api → src/api}/index.html +10 -10
  91. package/coverage/lcov-report/{api → src/api}/index.js.html +10 -10
  92. package/coverage/lcov-report/{api → src/api}/routes/analytics.js.html +10 -10
  93. package/coverage/lcov-report/{api → src/api}/routes/apikeys.js.html +10 -10
  94. package/coverage/lcov-report/src/api/routes/application.ts.html +199 -0
  95. package/coverage/lcov-report/src/api/routes/auth.ts.html +109 -0
  96. package/coverage/lcov-report/{api → src/api}/routes/automation.js.html +14 -14
  97. package/coverage/lcov-report/src/api/routes/backup.ts.html +115 -0
  98. package/coverage/lcov-report/{api → src/api}/routes/cloud.js.html +10 -10
  99. package/coverage/lcov-report/{api → src/api}/routes/component.js.html +10 -10
  100. package/coverage/lcov-report/{api → src/api}/routes/datasource.js.html +15 -15
  101. package/coverage/lcov-report/{api → src/api}/routes/deploy.js.html +10 -10
  102. package/coverage/lcov-report/{api → src/api}/routes/dev.js.html +10 -10
  103. package/coverage/lcov-report/{api → src/api}/routes/index.html +137 -17
  104. package/coverage/lcov-report/src/api/routes/index.ts.html +289 -0
  105. package/coverage/lcov-report/{api → src/api}/routes/integration.js.html +10 -10
  106. package/coverage/lcov-report/{api → src/api}/routes/layout.js.html +10 -10
  107. package/coverage/lcov-report/{api → src/api}/routes/metadata.js.html +10 -10
  108. package/coverage/lcov-report/{api → src/api}/routes/migrations.js.html +10 -10
  109. package/coverage/lcov-report/{api → src/api}/routes/permission.js.html +10 -10
  110. package/coverage/lcov-report/src/api/routes/plugin.ts.html +127 -0
  111. package/coverage/lcov-report/src/api/routes/public/applications.ts.html +541 -0
  112. package/coverage/lcov-report/src/api/routes/public/index.html +191 -0
  113. package/coverage/lcov-report/src/api/routes/public/index.ts.html +502 -0
  114. package/coverage/lcov-report/src/api/routes/public/middleware/index.html +116 -0
  115. package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +328 -0
  116. package/coverage/lcov-report/src/api/routes/public/queries.ts.html +313 -0
  117. package/coverage/lcov-report/src/api/routes/public/rows.ts.html +598 -0
  118. package/coverage/lcov-report/src/api/routes/public/tables.ts.html +586 -0
  119. package/coverage/lcov-report/src/api/routes/public/users.ts.html +511 -0
  120. package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +238 -0
  121. package/coverage/lcov-report/src/api/routes/public/utils/index.html +116 -0
  122. package/coverage/lcov-report/{api → src/api}/routes/query.js.html +15 -15
  123. package/coverage/lcov-report/{api → src/api}/routes/role.js.html +10 -10
  124. package/coverage/lcov-report/{api → src/api}/routes/routing.js.html +10 -10
  125. package/coverage/lcov-report/src/api/routes/row.ts.html +889 -0
  126. package/coverage/lcov-report/{api → src/api}/routes/screen.js.html +10 -10
  127. package/coverage/lcov-report/{api → src/api}/routes/script.js.html +10 -10
  128. package/coverage/lcov-report/src/api/routes/static.ts.html +289 -0
  129. package/coverage/lcov-report/{api → src/api}/routes/table.js.html +13 -13
  130. package/coverage/lcov-report/{api → src/api}/routes/templates.js.html +10 -10
  131. package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +556 -0
  132. package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +131 -0
  133. package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +367 -0
  134. package/coverage/lcov-report/{api → src/api}/routes/user.js.html +20 -20
  135. package/coverage/lcov-report/{api → src/api}/routes/utils/index.html +10 -10
  136. package/coverage/lcov-report/{api → src/api}/routes/utils/validators.js.html +15 -15
  137. package/coverage/lcov-report/{api → src/api}/routes/view.js.html +13 -13
  138. package/coverage/lcov-report/src/api/routes/webhook.ts.html +166 -0
  139. package/coverage/lcov-report/src/app.ts.html +403 -0
  140. package/coverage/lcov-report/{automations → src/automations}/actions.js.html +10 -10
  141. package/coverage/lcov-report/{automations → src/automations}/automationUtils.js.html +10 -10
  142. package/coverage/lcov-report/{automations → src/automations}/bullboard.js.html +10 -10
  143. package/coverage/lcov-report/{automations → src/automations}/index.html +34 -19
  144. package/coverage/lcov-report/{automations → src/automations}/index.js.html +10 -10
  145. package/coverage/lcov-report/src/automations/logging/index.html +116 -0
  146. package/coverage/lcov-report/src/automations/logging/index.ts.html +199 -0
  147. package/coverage/lcov-report/{automations → src/automations}/steps/bash.js.html +10 -10
  148. package/coverage/lcov-report/src/automations/steps/createRow.ts.html +367 -0
  149. package/coverage/lcov-report/{automations → src/automations}/steps/delay.js.html +10 -10
  150. package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +334 -0
  151. package/coverage/lcov-report/{automations → src/automations}/steps/discord.js.html +10 -10
  152. package/coverage/lcov-report/{automations → src/automations}/steps/executeQuery.js.html +10 -10
  153. package/coverage/lcov-report/{automations → src/automations}/steps/executeScript.js.html +10 -10
  154. package/coverage/lcov-report/{automations → src/automations}/steps/filter.js.html +10 -10
  155. package/coverage/lcov-report/{automations → src/automations}/steps/index.html +56 -26
  156. package/coverage/lcov-report/{automations → src/automations}/steps/integromat.js.html +10 -10
  157. package/coverage/lcov-report/{automations → src/automations}/steps/loop.js.html +10 -10
  158. package/coverage/lcov-report/{automations → src/automations}/steps/outgoingWebhook.js.html +10 -10
  159. package/coverage/lcov-report/{automations → src/automations}/steps/queryRows.js.html +10 -10
  160. package/coverage/lcov-report/{automations → src/automations}/steps/sendSmtpEmail.js.html +10 -10
  161. package/coverage/lcov-report/{automations → src/automations}/steps/serverLog.js.html +10 -10
  162. package/coverage/lcov-report/{automations → src/automations}/steps/slack.js.html +10 -10
  163. package/coverage/lcov-report/{automations → src/automations}/steps/updateRow.js.html +10 -10
  164. package/coverage/lcov-report/{automations → src/automations}/steps/utils.js.html +19 -19
  165. package/coverage/lcov-report/{automations → src/automations}/steps/zapier.js.html +10 -10
  166. package/coverage/lcov-report/src/automations/tests/utilities/index.html +116 -0
  167. package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +256 -0
  168. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/app.js.html +10 -10
  169. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/cron.js.html +10 -10
  170. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.html +10 -10
  171. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/index.js.html +10 -10
  172. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowDeleted.js.html +10 -10
  173. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowSaved.js.html +10 -10
  174. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/rowUpdated.js.html +10 -10
  175. package/coverage/lcov-report/{automations → src/automations}/triggerInfo/webhook.js.html +10 -10
  176. package/coverage/lcov-report/{automations → src/automations}/triggers.js.html +10 -10
  177. package/coverage/lcov-report/src/automations/utils.ts.html +886 -0
  178. package/coverage/lcov-report/{constants → src/constants}/index.html +10 -10
  179. package/coverage/lcov-report/{constants → src/constants}/index.js.html +10 -10
  180. package/coverage/lcov-report/{constants → src/constants}/layouts.js.html +10 -10
  181. package/coverage/lcov-report/{constants → src/constants}/screens.js.html +10 -10
  182. package/coverage/lcov-report/src/db/dynamoClient.js.html +466 -0
  183. package/coverage/lcov-report/{db → src/db}/inMemoryView.js.html +12 -12
  184. package/coverage/lcov-report/{db → src/db}/index.html +42 -27
  185. package/coverage/lcov-report/{db → src/db}/index.js.html +18 -18
  186. package/coverage/lcov-report/{db → src/db}/linkedRows/LinkController.js.html +10 -10
  187. package/coverage/lcov-report/{db → src/db}/linkedRows/index.html +10 -10
  188. package/coverage/lcov-report/{db → src/db}/linkedRows/index.js.html +10 -10
  189. package/coverage/lcov-report/{db → src/db}/linkedRows/linkUtils.js.html +10 -10
  190. package/coverage/lcov-report/{db → src/db}/newid.js.html +10 -10
  191. package/coverage/lcov-report/{db/utils.js.html → src/db/utils.ts.html} +104 -152
  192. package/coverage/lcov-report/src/definitions/automations.ts.html +181 -0
  193. package/coverage/lcov-report/src/definitions/datasource.ts.html +235 -0
  194. package/coverage/lcov-report/src/definitions/index.html +131 -0
  195. package/coverage/lcov-report/src/environment.js.html +445 -0
  196. package/coverage/lcov-report/{events → src/events}/AutomationEmitter.js.html +10 -10
  197. package/coverage/lcov-report/{events → src/events}/index.html +10 -10
  198. package/coverage/lcov-report/{events → src/events}/index.js.html +10 -10
  199. package/coverage/lcov-report/{events → src/events}/utils.js.html +10 -10
  200. package/coverage/lcov-report/src/index.html +206 -0
  201. package/coverage/lcov-report/src/index.ts.html +133 -0
  202. package/coverage/lcov-report/src/integrations/airtable.ts.html +529 -0
  203. package/coverage/lcov-report/src/integrations/arangodb.ts.html +415 -0
  204. package/coverage/lcov-report/src/integrations/base/index.html +161 -0
  205. package/coverage/lcov-report/src/integrations/base/query.ts.html +133 -0
  206. package/coverage/lcov-report/src/integrations/base/sql.ts.html +1951 -0
  207. package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +691 -0
  208. package/coverage/lcov-report/src/integrations/base/utils.ts.html +121 -0
  209. package/coverage/lcov-report/src/integrations/couchdb.ts.html +406 -0
  210. package/coverage/lcov-report/src/integrations/dynamodb.ts.html +745 -0
  211. package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +634 -0
  212. package/coverage/lcov-report/src/integrations/firebase.ts.html +646 -0
  213. package/coverage/lcov-report/src/integrations/googlesheets.ts.html +1312 -0
  214. package/coverage/lcov-report/src/integrations/index.html +371 -0
  215. package/coverage/lcov-report/src/integrations/index.ts.html +433 -0
  216. package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1006 -0
  217. package/coverage/lcov-report/src/integrations/mongodb.ts.html +1867 -0
  218. package/coverage/lcov-report/src/integrations/mysql.ts.html +952 -0
  219. package/coverage/lcov-report/src/integrations/oracle.ts.html +1474 -0
  220. package/coverage/lcov-report/src/integrations/postgres.ts.html +1069 -0
  221. package/coverage/lcov-report/src/integrations/queries/index.html +116 -0
  222. package/coverage/lcov-report/src/integrations/queries/sql.ts.html +463 -0
  223. package/coverage/lcov-report/src/integrations/redis.ts.html +550 -0
  224. package/coverage/lcov-report/src/integrations/rest.ts.html +1381 -0
  225. package/coverage/lcov-report/src/integrations/s3.ts.html +862 -0
  226. package/coverage/lcov-report/src/integrations/snowflake.ts.html +376 -0
  227. package/coverage/lcov-report/{integrations → src/integrations}/tests/TestConfiguration.js.html +10 -10
  228. package/coverage/lcov-report/{integrations → src/integrations}/tests/index.html +10 -10
  229. package/coverage/lcov-report/src/integrations/utils.ts.html +1006 -0
  230. package/coverage/lcov-report/{middleware/appInfo.js.html → src/middleware/appInfo.ts.html} +31 -28
  231. package/coverage/lcov-report/src/middleware/authorized.ts.html +481 -0
  232. package/coverage/lcov-report/{middleware/builder.js.html → src/middleware/builder.ts.html} +43 -37
  233. package/coverage/lcov-report/{middleware/currentapp.js.html → src/middleware/currentapp.ts.html} +77 -68
  234. package/coverage/lcov-report/{middleware → src/middleware}/index.html +78 -63
  235. package/coverage/lcov-report/{middleware/joi-validator.js.html → src/middleware/joi-validator.ts.html} +25 -22
  236. package/coverage/lcov-report/{middleware/publicApi.js.html → src/middleware/publicApi.ts.html} +24 -24
  237. package/coverage/lcov-report/{middleware/resourceId.js.html → src/middleware/resourceId.ts.html} +40 -25
  238. package/coverage/lcov-report/{middleware/selfhost.js.html → src/middleware/selfhost.ts.html} +25 -19
  239. package/coverage/lcov-report/{middleware/utils.js.html → src/middleware/utils.ts.html} +19 -13
  240. package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +187 -0
  241. package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +163 -0
  242. package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +151 -0
  243. package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +206 -0
  244. package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +172 -0
  245. package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +226 -0
  246. package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +151 -0
  247. package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +151 -0
  248. package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +166 -0
  249. package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +532 -0
  250. package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +283 -0
  251. package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +146 -0
  252. package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +265 -0
  253. package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +232 -0
  254. package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +724 -0
  255. package/coverage/lcov-report/src/migrations/functions/backfill/index.html +161 -0
  256. package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +106 -0
  257. package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +235 -0
  258. package/coverage/lcov-report/src/migrations/functions/index.html +146 -0
  259. package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +130 -0
  260. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +161 -0
  261. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +94 -0
  262. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +130 -0
  263. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +115 -0
  264. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +172 -0
  265. package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +124 -0
  266. package/coverage/lcov-report/src/migrations/index.html +116 -0
  267. package/coverage/lcov-report/src/migrations/index.ts.html +403 -0
  268. package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +205 -0
  269. package/coverage/lcov-report/src/migrations/tests/index.html +131 -0
  270. package/coverage/lcov-report/src/migrations/tests/structures.ts.html +283 -0
  271. package/coverage/lcov-report/src/module.d.ts.html +127 -0
  272. package/coverage/lcov-report/src/sdk/app/automations/index.html +131 -0
  273. package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +100 -0
  274. package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +214 -0
  275. package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +91 -0
  276. package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +598 -0
  277. package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +694 -0
  278. package/coverage/lcov-report/src/sdk/app/backups/index.html +176 -0
  279. package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +112 -0
  280. package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +292 -0
  281. package/coverage/lcov-report/src/sdk/app/tables/index.html +116 -0
  282. package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +265 -0
  283. package/coverage/lcov-report/{utilities/routing → src/sdk}/index.html +10 -10
  284. package/coverage/lcov-report/src/sdk/index.ts.html +130 -0
  285. package/coverage/lcov-report/src/startup.ts.html +499 -0
  286. package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +1873 -0
  287. package/coverage/lcov-report/src/tests/utilities/controllers.js.html +133 -0
  288. package/coverage/lcov-report/src/tests/utilities/index.html +161 -0
  289. package/coverage/lcov-report/src/tests/utilities/index.js.html +118 -0
  290. package/coverage/lcov-report/src/tests/utilities/structures.js.html +652 -0
  291. package/coverage/lcov-report/src/threads/automation.ts.html +1597 -0
  292. package/coverage/lcov-report/src/threads/index.html +161 -0
  293. package/coverage/lcov-report/src/threads/index.ts.html +418 -0
  294. package/coverage/lcov-report/src/threads/query.ts.html +976 -0
  295. package/coverage/lcov-report/src/threads/utils.ts.html +376 -0
  296. package/coverage/lcov-report/{utilities → src/utilities}/budibaseDir.js.html +10 -10
  297. package/coverage/lcov-report/{utilities → src/utilities}/centralPath.js.html +10 -10
  298. package/coverage/lcov-report/{utilities → src/utilities}/csvParser.js.html +10 -10
  299. package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +547 -0
  300. package/coverage/lcov-report/src/utilities/fileSystem/index.html +161 -0
  301. package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +1141 -0
  302. package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +148 -0
  303. package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +193 -0
  304. package/coverage/lcov-report/{utilities/global.js.html → src/utilities/global.ts.html} +107 -74
  305. package/coverage/lcov-report/{utilities → src/utilities}/index.html +42 -27
  306. package/coverage/lcov-report/{utilities → src/utilities}/index.js.html +10 -10
  307. package/coverage/lcov-report/{utilities → src/utilities}/plugins.js.html +10 -10
  308. package/coverage/lcov-report/{utilities → src/utilities}/queue/inMemoryQueue.js.html +10 -10
  309. package/coverage/lcov-report/{utilities → src/utilities}/queue/index.html +10 -10
  310. package/coverage/lcov-report/src/utilities/redis.js.html +340 -0
  311. package/coverage/lcov-report/{api/controllers/query → src/utilities/routing}/index.html +8 -8
  312. package/coverage/lcov-report/{utilities → src/utilities}/routing/index.js.html +10 -10
  313. package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.html +10 -10
  314. package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/index.js.html +10 -10
  315. package/coverage/lcov-report/{utilities → src/utilities}/rowProcessor/utils.js.html +10 -10
  316. package/coverage/lcov-report/{utilities → src/utilities}/scriptRunner.js.html +10 -10
  317. package/coverage/lcov-report/{utilities → src/utilities}/security.js.html +22 -22
  318. package/coverage/lcov-report/{utilities → src/utilities}/statusCodes.js.html +10 -10
  319. package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/index.html +10 -10
  320. package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/rows.js.html +10 -10
  321. package/coverage/lcov-report/{utilities → src/utilities}/usageQuota/usageQuoteReset.js.html +10 -10
  322. package/coverage/lcov-report/{utilities → src/utilities}/users.js.html +10 -10
  323. package/coverage/lcov-report/{utilities → src/utilities}/workerRequests.js.html +13 -13
  324. package/coverage/lcov-report/src/watch.ts.html +199 -0
  325. package/coverage/lcov-report/src/websocket.ts.html +163 -0
  326. package/coverage/lcov.info +17589 -5003
  327. package/dist/api/controllers/application.js +35 -43
  328. package/dist/api/controllers/deploy/index.js +13 -16
  329. package/dist/api/controllers/dev.js +96 -81
  330. package/dist/api/controllers/public/applications.js +17 -9
  331. package/dist/api/controllers/query/index.js +10 -13
  332. package/dist/api/controllers/row/ExternalRequest.js +6 -1
  333. package/dist/api/controllers/row/index.js +16 -7
  334. package/dist/api/controllers/row/internal.js +2 -2
  335. package/dist/api/controllers/table/internal.js +4 -4
  336. package/dist/api/routes/automation.js +3 -3
  337. package/dist/api/routes/datasource.js +4 -4
  338. package/dist/api/routes/public/index.js +9 -9
  339. package/dist/api/routes/query.js +4 -4
  340. package/dist/api/routes/row.js +11 -11
  341. package/dist/api/routes/static.js +3 -3
  342. package/dist/api/routes/table.js +2 -2
  343. package/dist/api/routes/user.js +9 -9
  344. package/dist/api/routes/utils/validators.js +4 -4
  345. package/dist/api/routes/view.js +2 -2
  346. package/dist/automations/tests/utilities/index.js +21 -12
  347. package/dist/automations/utils.js +9 -8
  348. package/dist/db/inMemoryView.js +2 -2
  349. package/dist/db/utils.js +145 -118
  350. package/dist/integrations/elasticsearch.js +26 -2
  351. package/dist/integrations/googlesheets.js +4 -6
  352. package/dist/integrations/s3.js +157 -1
  353. package/dist/middleware/appInfo.js +14 -9
  354. package/dist/middleware/authorized.js +5 -5
  355. package/dist/middleware/builder.js +41 -40
  356. package/dist/middleware/currentapp.js +39 -37
  357. package/dist/middleware/joi-validator.js +17 -10
  358. package/dist/middleware/publicApi.js +5 -6
  359. package/dist/middleware/resourceId.js +16 -9
  360. package/dist/middleware/selfhost.js +5 -4
  361. package/dist/middleware/utils.js +5 -2
  362. package/dist/migrations/functions/backfill/global.js +1 -1
  363. package/dist/migrations/functions/usageQuotas/syncRows.js +1 -1
  364. package/dist/package.json +10 -44
  365. package/dist/sdk/app/tables/index.js +4 -4
  366. package/dist/tests/utilities/TestConfiguration.js +12 -10
  367. package/dist/tests/utilities/structures.js +2 -2
  368. package/dist/tsconfig.build.tsbuildinfo +1 -1
  369. package/dist/utilities/global.js +87 -66
  370. package/dist/utilities/security.js +10 -10
  371. package/dist/utilities/workerRequests.js +3 -3
  372. package/jest.config.ts +33 -0
  373. package/package.json +11 -45
  374. package/scripts/localdomain.js +34 -6
  375. package/src/api/controllers/application.ts +34 -39
  376. package/src/api/controllers/auth.ts +3 -2
  377. package/src/api/controllers/deploy/index.ts +13 -25
  378. package/src/api/controllers/{dev.js → dev.ts} +31 -37
  379. package/src/api/controllers/public/applications.ts +15 -9
  380. package/src/api/controllers/query/index.ts +11 -14
  381. package/src/api/controllers/row/ExternalRequest.ts +5 -3
  382. package/src/api/controllers/row/index.ts +17 -9
  383. package/src/api/controllers/row/internal.js +2 -2
  384. package/src/api/controllers/table/internal.ts +4 -4
  385. package/src/api/routes/automation.js +4 -4
  386. package/src/api/routes/datasource.js +5 -5
  387. package/src/api/routes/public/index.ts +10 -10
  388. package/src/api/routes/public/tests/compare.spec.js +1 -1
  389. package/src/api/routes/query.js +5 -5
  390. package/src/api/routes/row.ts +12 -12
  391. package/src/api/routes/static.ts +5 -5
  392. package/src/api/routes/table.js +3 -3
  393. package/src/api/routes/tests/analytics.spec.js +1 -1
  394. package/src/api/routes/tests/query.spec.js +15 -10
  395. package/src/api/routes/tests/role.spec.js +5 -5
  396. package/src/api/routes/tests/static.spec.js +2 -2
  397. package/src/api/routes/tests/table.spec.js +38 -35
  398. package/src/api/routes/user.js +10 -10
  399. package/src/api/routes/utils/validators.js +5 -5
  400. package/src/api/routes/view.js +3 -3
  401. package/src/automations/tests/updateRow.spec.js +0 -1
  402. package/src/automations/tests/utilities/index.js +10 -4
  403. package/src/automations/utils.ts +9 -12
  404. package/src/db/inMemoryView.js +2 -2
  405. package/src/db/tests/linkController.spec.js +73 -57
  406. package/src/db/tests/linkTests.spec.js +17 -14
  407. package/src/db/{utils.js → utils.ts} +76 -92
  408. package/src/integrations/elasticsearch.ts +32 -2
  409. package/src/integrations/googlesheets.ts +4 -7
  410. package/src/integrations/s3.ts +179 -3
  411. package/src/integrations/tests/s3.spec.ts +85 -1
  412. package/src/middleware/appInfo.ts +20 -0
  413. package/src/middleware/authorized.ts +6 -6
  414. package/src/middleware/{builder.js → builder.ts} +17 -15
  415. package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
  416. package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
  417. package/src/middleware/publicApi.ts +21 -0
  418. package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
  419. package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
  420. package/src/middleware/tests/authorized.spec.js +5 -5
  421. package/src/middleware/tests/currentapp.spec.js +118 -63
  422. package/src/middleware/{utils.js → utils.ts} +3 -1
  423. package/src/migrations/functions/backfill/app/tables.ts +2 -5
  424. package/src/migrations/functions/backfill/global.ts +1 -1
  425. package/src/migrations/functions/usageQuotas/syncRows.ts +2 -2
  426. package/src/sdk/app/backups/imports.ts +4 -7
  427. package/src/sdk/app/backups/statistics.ts +9 -18
  428. package/src/sdk/app/tables/index.ts +6 -7
  429. package/{scripts/jestSetup.js → src/tests/jestSetup.ts} +11 -2
  430. package/src/tests/utilities/TestConfiguration.js +12 -10
  431. package/src/tests/utilities/structures.js +2 -2
  432. package/src/threads/automation.ts +1 -1
  433. package/src/utilities/global.ts +138 -0
  434. package/src/utilities/security.js +12 -12
  435. package/src/utilities/workerRequests.js +3 -3
  436. package/tsconfig.json +3 -1
  437. package/src/middleware/appInfo.js +0 -19
  438. package/src/middleware/publicApi.js +0 -21
  439. package/src/utilities/global.js +0 -127
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
- const { isDevAppID, isProdAppID } = require("../db/utils");
3
- exports.AppType = {
4
- DEV: "dev",
5
- PROD: "prod",
6
- };
7
- exports.middleware =
8
- ({ appType } = {}) => (ctx, next) => {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.middleware = exports.AppType = void 0;
4
+ const utils_1 = require("../db/utils");
5
+ var AppType;
6
+ (function (AppType) {
7
+ AppType["DEV"] = "dev";
8
+ AppType["PROD"] = "prod";
9
+ })(AppType = exports.AppType || (exports.AppType = {}));
10
+ function middleware({ appType } = {}) {
11
+ return (ctx, next) => {
9
12
  const appId = ctx.appId;
10
- if (appType === exports.AppType.DEV && appId && !isDevAppID(appId)) {
13
+ if (appType === AppType.DEV && appId && !(0, utils_1.isDevAppID)(appId)) {
11
14
  ctx.throw(400, "Only apps in development support this endpoint");
12
15
  }
13
- if (appType === exports.AppType.PROD && appId && !isProdAppID(appId)) {
16
+ if (appType === AppType.PROD && appId && !(0, utils_1.isProdAppID)(appId)) {
14
17
  ctx.throw(400, "Only apps in production support this endpoint");
15
18
  }
16
19
  return next();
17
20
  };
21
+ }
22
+ exports.middleware = middleware;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const roles_1 = require("@budibase/backend-core/roles");
12
- const { PermissionTypes, PermissionLevels, doesHaveBasePermission, } = require("@budibase/backend-core/permissions");
12
+ const { PermissionType, PermissionLevel, doesHaveBasePermission, } = require("@budibase/backend-core/permissions");
13
13
  const builderMiddleware = require("./builder");
14
14
  const { isWebhookEndpoint } = require("./utils");
15
15
  const { buildCsrfMiddleware } = require("@budibase/backend-core/auth");
@@ -27,7 +27,7 @@ const csrf = buildCsrfMiddleware();
27
27
  const checkAuthorized = (ctx, resourceRoles, permType, permLevel) => __awaiter(void 0, void 0, void 0, function* () {
28
28
  // check if this is a builder api and the user is not a builder
29
29
  const isBuilder = ctx.user && ctx.user.builder && ctx.user.builder.global;
30
- const isBuilderApi = permType === PermissionTypes.BUILDER;
30
+ const isBuilderApi = permType === PermissionType.BUILDER;
31
31
  if (isBuilderApi && !isBuilder) {
32
32
  return ctx.throw(403, "Not Authorized");
33
33
  }
@@ -71,9 +71,9 @@ module.exports = (permType, permLevel = null, opts = { schema: false }) => (ctx,
71
71
  // get the resource roles
72
72
  let resourceRoles = [];
73
73
  let otherLevelRoles = [];
74
- const otherLevel = permLevel === PermissionLevels.READ
75
- ? PermissionLevels.WRITE
76
- : PermissionLevels.READ;
74
+ const otherLevel = permLevel === PermissionLevel.READ
75
+ ? PermissionLevel.WRITE
76
+ : PermissionLevel.READ;
77
77
  const appId = getAppId();
78
78
  if (appId && hasResource(ctx)) {
79
79
  resourceRoles = yield (0, roles_1.getRequiredResourceRole)(permLevel, ctx);
@@ -8,12 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const { APP_DEV_PREFIX } = require("../db/utils");
12
- const { doesUserHaveLock, updateLock, checkDebounce, setDebounce, } = require("../utilities/redis");
13
- const { doWithDB } = require("@budibase/backend-core/db");
14
- const { DocumentType, getGlobalIDFromUserMetadataID } = require("../db/utils");
15
- const { PermissionTypes } = require("@budibase/backend-core/permissions");
16
- const { app: appCache } = require("@budibase/backend-core/cache");
11
+ const utils_1 = require("../db/utils");
12
+ const redis_1 = require("../utilities/redis");
13
+ const backend_core_1 = require("@budibase/backend-core");
17
14
  const DEBOUNCE_TIME_SEC = 30;
18
15
  /************************************************** *
19
16
  * This middleware has been broken out of the *
@@ -24,21 +21,22 @@ const DEBOUNCE_TIME_SEC = 30;
24
21
  * through the authorized middleware *
25
22
  ****************************************************/
26
23
  function checkDevAppLocks(ctx) {
24
+ var _a, _b;
27
25
  return __awaiter(this, void 0, void 0, function* () {
28
26
  const appId = ctx.appId;
29
27
  // if any public usage, don't proceed
30
- if (!ctx.user._id && !ctx.user.userId) {
28
+ if (!((_a = ctx.user) === null || _a === void 0 ? void 0 : _a._id) && !((_b = ctx.user) === null || _b === void 0 ? void 0 : _b.userId)) {
31
29
  return;
32
30
  }
33
31
  // not a development app, don't need to do anything
34
- if (!appId || !appId.startsWith(APP_DEV_PREFIX)) {
32
+ if (!appId || !appId.startsWith(utils_1.APP_DEV_PREFIX)) {
35
33
  return;
36
34
  }
37
- if (!(yield doesUserHaveLock(appId, ctx.user))) {
35
+ if (!(yield (0, redis_1.doesUserHaveLock)(appId, ctx.user))) {
38
36
  ctx.throw(400, "User does not hold app lock.");
39
37
  }
40
38
  // they do have lock, update it
41
- yield updateLock(appId, ctx.user);
39
+ yield (0, redis_1.updateLock)(appId, ctx.user);
42
40
  });
43
41
  }
44
42
  function updateAppUpdatedAt(ctx) {
@@ -46,42 +44,45 @@ function updateAppUpdatedAt(ctx) {
46
44
  const appId = ctx.appId;
47
45
  // if debouncing skip this update
48
46
  // get methods also aren't updating
49
- if (ctx.method === "GET" || (yield checkDebounce(appId))) {
47
+ if (ctx.method === "GET" || (yield (0, redis_1.checkDebounce)(appId))) {
50
48
  return;
51
49
  }
52
- yield doWithDB(appId, (db) => __awaiter(this, void 0, void 0, function* () {
53
- const metadata = yield db.get(DocumentType.APP_METADATA);
50
+ yield backend_core_1.db.doWithDB(appId, (db) => __awaiter(this, void 0, void 0, function* () {
51
+ var _a;
52
+ const metadata = yield db.get(utils_1.DocumentType.APP_METADATA);
54
53
  metadata.updatedAt = new Date().toISOString();
55
- metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user.userId);
54
+ metadata.updatedBy = (0, utils_1.getGlobalIDFromUserMetadataID)((_a = ctx.user) === null || _a === void 0 ? void 0 : _a.userId);
56
55
  const response = yield db.put(metadata);
57
56
  metadata._rev = response.rev;
58
- yield appCache.invalidateAppMetadata(appId, metadata);
57
+ yield backend_core_1.cache.app.invalidateAppMetadata(appId, metadata);
59
58
  // set a new debounce record with a short TTL
60
- yield setDebounce(appId, DEBOUNCE_TIME_SEC);
59
+ yield (0, redis_1.setDebounce)(appId, DEBOUNCE_TIME_SEC);
61
60
  }));
62
61
  });
63
62
  }
64
- module.exports = (ctx, permType) => __awaiter(void 0, void 0, void 0, function* () {
65
- const appId = ctx.appId;
66
- // this only functions within an app context
67
- if (!appId) {
68
- return;
69
- }
70
- const isBuilderApi = permType === PermissionTypes.BUILDER;
71
- const referer = ctx.headers["referer"];
72
- const overviewPath = "/builder/portal/overview/";
73
- const overviewContext = !referer ? false : referer.includes(overviewPath);
74
- if (overviewContext) {
75
- return;
76
- }
77
- const hasAppId = !referer ? false : referer.includes(appId);
78
- const editingApp = referer ? hasAppId : false;
79
- // check this is a builder call and editing
80
- if (!isBuilderApi || !editingApp) {
81
- return;
82
- }
83
- // check locks
84
- yield checkDevAppLocks(ctx);
85
- // set updated at time on app
86
- yield updateAppUpdatedAt(ctx);
87
- });
63
+ module.exports = function builder(ctx, permType) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const appId = ctx.appId;
66
+ // this only functions within an app context
67
+ if (!appId) {
68
+ return;
69
+ }
70
+ const isBuilderApi = permType === backend_core_1.permissions.PermissionType.BUILDER;
71
+ const referer = ctx.headers["referer"];
72
+ const overviewPath = "/builder/portal/overview/";
73
+ const overviewContext = !referer ? false : referer.includes(overviewPath);
74
+ if (overviewContext) {
75
+ return;
76
+ }
77
+ const hasAppId = !referer ? false : referer.includes(appId);
78
+ const editingApp = referer ? hasAppId : false;
79
+ // check this is a builder call and editing
80
+ if (!isBuilderApi || !editingApp) {
81
+ return;
82
+ }
83
+ // check locks
84
+ yield checkDevAppLocks(ctx);
85
+ // set updated at time on app
86
+ yield updateAppUpdatedAt(ctx);
87
+ });
88
+ };
@@ -8,27 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const { getAppIdFromCtx, setCookie, getCookie, clearCookie, } = require("@budibase/backend-core/utils");
12
- const { Cookies, Headers } = require("@budibase/backend-core/constants");
13
- const { getRole } = require("@budibase/backend-core/roles");
14
- const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
15
- const { generateUserMetadataID, isDevAppID } = require("../db/utils");
16
- const { dbExists } = require("@budibase/backend-core/db");
17
- const { isUserInAppTenant } = require("@budibase/backend-core/tenancy");
18
- const { getCachedSelf } = require("../utilities/global");
19
- const env = require("../environment");
20
- const { isWebhookEndpoint } = require("./utils");
21
- const { doInAppContext } = require("@budibase/backend-core/context");
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ const backend_core_1 = require("@budibase/backend-core");
15
+ const utils_1 = require("../db/utils");
16
+ const global_1 = require("../utilities/global");
17
+ const environment_1 = __importDefault(require("../environment"));
18
+ const utils_2 = require("./utils");
22
19
  module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
23
20
  // try to get the appID from the request
24
- let requestAppId = yield getAppIdFromCtx(ctx);
21
+ let requestAppId = yield backend_core_1.utils.getAppIdFromCtx(ctx);
25
22
  // get app cookie if it exists
26
- let appCookie = null;
23
+ let appCookie;
27
24
  try {
28
- appCookie = getCookie(ctx, Cookies.CurrentApp);
25
+ appCookie = backend_core_1.utils.getCookie(ctx, backend_core_1.constants.Cookie.CurrentApp);
29
26
  }
30
27
  catch (err) {
31
- clearCookie(ctx, Cookies.CurrentApp);
28
+ backend_core_1.utils.clearCookie(ctx, backend_core_1.constants.Cookie.CurrentApp);
32
29
  }
33
30
  if (!appCookie && !requestAppId) {
34
31
  return next();
@@ -36,46 +33,49 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
36
33
  // check the app exists referenced in cookie
37
34
  if (appCookie) {
38
35
  const appId = appCookie.appId;
39
- const exists = yield dbExists(appId);
36
+ const exists = yield backend_core_1.db.dbExists(appId);
40
37
  if (!exists) {
41
- clearCookie(ctx, Cookies.CurrentApp);
38
+ backend_core_1.utils.clearCookie(ctx, backend_core_1.constants.Cookie.CurrentApp);
42
39
  return next();
43
40
  }
44
41
  // if the request app ID wasn't set, update it with the cookie
45
42
  requestAppId = requestAppId || appId;
46
43
  }
47
44
  // deny access to application preview
48
- if (!env.isTest()) {
49
- if (isDevAppID(requestAppId) &&
50
- !isWebhookEndpoint(ctx) &&
45
+ if (!environment_1.default.isTest()) {
46
+ if ((0, utils_1.isDevAppID)(requestAppId) &&
47
+ !(0, utils_2.isWebhookEndpoint)(ctx) &&
51
48
  (!ctx.user || !ctx.user.builder || !ctx.user.builder.global)) {
52
- clearCookie(ctx, Cookies.CurrentApp);
49
+ backend_core_1.utils.clearCookie(ctx, backend_core_1.constants.Cookie.CurrentApp);
53
50
  return ctx.redirect("/");
54
51
  }
55
52
  }
56
- let appId, roleId = BUILTIN_ROLE_IDS.PUBLIC;
53
+ let appId, roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
57
54
  if (!ctx.user) {
58
55
  // not logged in, try to set a cookie for public apps
59
56
  appId = requestAppId;
60
57
  }
61
58
  else if (requestAppId != null) {
62
59
  // Different App ID means cookie needs reset, or if the same public user has logged in
63
- const globalUser = yield getCachedSelf(ctx, requestAppId);
60
+ const globalUser = yield (0, global_1.getCachedSelf)(ctx, requestAppId);
64
61
  appId = requestAppId;
65
62
  // retrieving global user gets the right role
66
63
  roleId = globalUser.roleId || roleId;
67
64
  // Allow builders to specify their role via a header
68
65
  const isBuilder = globalUser && globalUser.builder && globalUser.builder.global;
69
- const isDevApp = appId && isDevAppID(appId);
70
- const roleHeader = ctx.request && ctx.request.headers[Headers.PREVIEW_ROLE];
66
+ const isDevApp = appId && (0, utils_1.isDevAppID)(appId);
67
+ const roleHeader = ctx.request &&
68
+ ctx.request.headers[backend_core_1.constants.Header.PREVIEW_ROLE];
71
69
  if (isBuilder && isDevApp && roleHeader) {
72
70
  // Ensure the role is valid by ensuring a definition exists
73
71
  try {
74
- yield getRole(roleHeader);
75
- roleId = roleHeader;
76
- // Delete admin and builder flags so that the specified role is honoured
77
- delete ctx.user.builder;
78
- delete ctx.user.admin;
72
+ if (roleHeader) {
73
+ yield backend_core_1.roles.getRole(roleHeader);
74
+ roleId = roleHeader;
75
+ // Delete admin and builder flags so that the specified role is honoured
76
+ delete ctx.user.builder;
77
+ delete ctx.user.admin;
78
+ }
79
79
  }
80
80
  catch (error) {
81
81
  // Swallow error and do nothing
@@ -86,38 +86,40 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
86
86
  if (!appId) {
87
87
  return next();
88
88
  }
89
- return doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
89
+ return backend_core_1.context.doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
90
90
  let skipCookie = false;
91
91
  // if the user not in the right tenant then make sure they have no permissions
92
92
  // need to judge this only based on the request app ID,
93
- if (env.MULTI_TENANCY &&
93
+ if (environment_1.default.MULTI_TENANCY &&
94
94
  ctx.user &&
95
95
  requestAppId &&
96
- !isUserInAppTenant(requestAppId, ctx.user)) {
96
+ !backend_core_1.tenancy.isUserInAppTenant(requestAppId, ctx.user)) {
97
97
  // don't error, simply remove the users rights (they are a public user)
98
98
  delete ctx.user.builder;
99
99
  delete ctx.user.admin;
100
100
  delete ctx.user.roles;
101
101
  ctx.isAuthenticated = false;
102
- roleId = BUILTIN_ROLE_IDS.PUBLIC;
102
+ roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
103
103
  skipCookie = true;
104
104
  }
105
105
  ctx.appId = appId;
106
106
  if (roleId) {
107
107
  ctx.roleId = roleId;
108
108
  const globalId = ctx.user ? ctx.user._id : undefined;
109
- const userId = ctx.user ? generateUserMetadataID(ctx.user._id) : null;
109
+ const userId = ctx.user
110
+ ? (0, utils_1.generateUserMetadataID)(ctx.user._id)
111
+ : undefined;
110
112
  ctx.user = Object.assign(Object.assign({}, ctx.user), {
111
113
  // override userID with metadata one
112
114
  _id: userId, userId,
113
115
  globalId,
114
- roleId, role: yield getRole(roleId) });
116
+ roleId, role: yield backend_core_1.roles.getRole(roleId) });
115
117
  }
116
118
  if ((requestAppId !== appId ||
117
119
  appCookie == null ||
118
120
  appCookie.appId !== requestAppId) &&
119
121
  !skipCookie) {
120
- setCookie(ctx, { appId }, Cookies.CurrentApp);
122
+ backend_core_1.utils.setCookie(ctx, { appId }, backend_core_1.constants.Cookie.CurrentApp);
121
123
  }
122
124
  return next();
123
125
  }));
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
- const Joi = require("joi");
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.params = exports.body = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
3
8
  function validate(schema, property) {
4
9
  // Return a Koa middleware function
5
10
  return (ctx, next) => {
@@ -10,14 +15,14 @@ function validate(schema, property) {
10
15
  if (ctx[property] != null) {
11
16
  params = ctx[property];
12
17
  }
13
- else if (ctx.request[property] != null) {
14
- params = ctx.request[property];
18
+ else if (ctx.request.get(property) != null) {
19
+ params = ctx.request.get(property);
15
20
  }
16
21
  // not all schemas have the append property e.g. array schemas
17
- if (schema.append) {
22
+ if ("append" in schema && schema.append) {
18
23
  schema = schema.append({
19
- createdAt: Joi.any().optional(),
20
- updatedAt: Joi.any().optional(),
24
+ createdAt: joi_1.default.any().optional(),
25
+ updatedAt: joi_1.default.any().optional(),
21
26
  });
22
27
  }
23
28
  const { error } = schema.validate(params);
@@ -28,9 +33,11 @@ function validate(schema, property) {
28
33
  return next();
29
34
  };
30
35
  }
31
- module.exports.body = schema => {
36
+ function body(schema) {
32
37
  return validate(schema, "body");
33
- };
34
- module.exports.params = schema => {
38
+ }
39
+ exports.body = body;
40
+ function params(schema) {
35
41
  return validate(schema, "params");
36
- };
42
+ }
43
+ exports.params = params;
@@ -8,16 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const { Headers } = require("@budibase/backend-core/constants");
12
- const { getAppIdFromCtx } = require("@budibase/backend-core/utils");
11
+ const backend_core_1 = require("@budibase/backend-core");
13
12
  module.exports = function ({ requiresAppId } = {}) {
14
13
  return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
15
- const appId = yield getAppIdFromCtx(ctx);
14
+ const appId = yield backend_core_1.utils.getAppIdFromCtx(ctx);
16
15
  if (requiresAppId && !appId) {
17
- ctx.throw(400, `Invalid app ID provided, please check the ${Headers.APP_ID} header.`);
16
+ ctx.throw(400, `Invalid app ID provided, please check the ${backend_core_1.constants.Header.APP_ID} header.`);
18
17
  }
19
- if (!ctx.headers[Headers.API_KEY]) {
20
- ctx.throw(400, `Invalid API key provided, please check the ${Headers.API_KEY} header.`);
18
+ if (!ctx.headers[backend_core_1.constants.Header.API_KEY]) {
19
+ ctx.throw(400, `Invalid API key provided, please check the ${backend_core_1.constants.Header.API_KEY} header.`);
21
20
  }
22
21
  return next();
23
22
  });
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bodySubResource = exports.bodyResource = exports.paramSubResource = exports.paramResource = exports.ResourceIdGetter = void 0;
2
4
  class ResourceIdGetter {
3
5
  constructor(ctxProperty) {
4
6
  this.parameter = ctxProperty;
@@ -17,6 +19,7 @@ class ResourceIdGetter {
17
19
  build() {
18
20
  const parameter = this.parameter, main = this.main, sub = this.sub;
19
21
  return (ctx, next) => {
22
+ // @ts-ignore
20
23
  const request = ctx.request[parameter] || ctx[parameter];
21
24
  if (request == null) {
22
25
  return next();
@@ -31,22 +34,26 @@ class ResourceIdGetter {
31
34
  };
32
35
  }
33
36
  }
34
- module.exports.ResourceIdGetter = ResourceIdGetter;
35
- module.exports.paramResource = main => {
37
+ exports.ResourceIdGetter = ResourceIdGetter;
38
+ function paramResource(main) {
36
39
  return new ResourceIdGetter("params").mainResource(main).build();
37
- };
38
- module.exports.paramSubResource = (main, sub) => {
40
+ }
41
+ exports.paramResource = paramResource;
42
+ function paramSubResource(main, sub) {
39
43
  return new ResourceIdGetter("params")
40
44
  .mainResource(main)
41
45
  .subResource(sub)
42
46
  .build();
43
- };
44
- module.exports.bodyResource = main => {
47
+ }
48
+ exports.paramSubResource = paramSubResource;
49
+ function bodyResource(main) {
45
50
  return new ResourceIdGetter("body").mainResource(main).build();
46
- };
47
- module.exports.bodySubResource = (main, sub) => {
51
+ }
52
+ exports.bodyResource = bodyResource;
53
+ function bodySubResource(main, sub) {
48
54
  return new ResourceIdGetter("body")
49
55
  .mainResource(main)
50
56
  .subResource(sub)
51
57
  .build();
52
- };
58
+ }
59
+ exports.bodySubResource = bodySubResource;
@@ -8,11 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const env = require("../environment");
12
- // if added as a middleware will stop requests unless builder is in self host mode
13
- // or cloud is in self host
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ const environment_1 = __importDefault(require("../environment"));
14
15
  module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
15
- if (env.SELF_HOSTED) {
16
+ if (environment_1.default.SELF_HOSTED) {
16
17
  yield next();
17
18
  return;
18
19
  }
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWebhookEndpoint = void 0;
2
4
  const WEBHOOK_ENDPOINTS = new RegExp(["webhooks/trigger", "webhooks/schema"].join("|"));
3
- exports.isWebhookEndpoint = ctx => {
5
+ function isWebhookEndpoint(ctx) {
4
6
  return WEBHOOK_ENDPOINTS.test(ctx.request.url);
5
- };
7
+ }
8
+ exports.isWebhookEndpoint = isWebhookEndpoint;
@@ -156,7 +156,7 @@ const run = (db) => __awaiter(void 0, void 0, void 0, function* () {
156
156
  handleError(e, errors);
157
157
  }
158
158
  try {
159
- const allApps = yield backend_core_1.db.getAllApps({ dev: true });
159
+ const allApps = (yield backend_core_1.db.getAllApps({ dev: true }));
160
160
  totals.apps = allApps.length;
161
161
  totals.usage = yield quotas.backfill(allApps);
162
162
  }
@@ -17,7 +17,7 @@ const pro_1 = require("@budibase/pro");
17
17
  const types_1 = require("@budibase/types");
18
18
  const run = () => __awaiter(void 0, void 0, void 0, function* () {
19
19
  // get all rows in all apps
20
- const allApps = yield (0, db_1.getAllApps)({ all: true });
20
+ const allApps = (yield (0, db_1.getAllApps)({ all: true }));
21
21
  const appIds = allApps ? allApps.map((app) => app.appId) : [];
22
22
  const { appRows } = yield (0, rows_1.getUniqueRows)(appIds);
23
23
  // get the counts per app
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.1.30",
4
+ "version": "2.1.31",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -36,40 +36,6 @@
36
36
  "env:account:enable": "node scripts/account.js enable",
37
37
  "env:account:disable": "node scripts/account.js disable"
38
38
  },
39
- "jest": {
40
- "preset": "ts-jest",
41
- "testEnvironment": "node",
42
- "moduleNameMapper": {
43
- "@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
44
- "@budibase/backend-core": "<rootDir>/../backend-core/src",
45
- "@budibase/types": "<rootDir>/../types/src"
46
- },
47
- "setupFiles": [
48
- "./scripts/jestSetup.js"
49
- ],
50
- "collectCoverageFrom": [
51
- "src/**/*.js",
52
- "!**/node_modules/**",
53
- "!src/db/views/*.js",
54
- "!src/api/controllers/deploy/**/*.js",
55
- "!src/*.js",
56
- "!src/api/controllers/static/**/*",
57
- "!src/db/dynamoClient.js",
58
- "!src/utilities/usageQuota.js",
59
- "!src/api/routes/tests/**/*",
60
- "!src/db/tests/**/*",
61
- "!src/tests/**/*",
62
- "!src/automations/tests/**/*",
63
- "!src/utilities/fileProcessor.js",
64
- "!src/utilities/fileSystem/**/*",
65
- "!src/utilities/redis.js"
66
- ],
67
- "coverageReporters": [
68
- "lcov",
69
- "json",
70
- "clover"
71
- ]
72
- },
73
39
  "keywords": [
74
40
  "budibase"
75
41
  ],
@@ -77,11 +43,11 @@
77
43
  "license": "GPL-3.0",
78
44
  "dependencies": {
79
45
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "^2.1.30",
81
- "@budibase/client": "^2.1.30",
82
- "@budibase/pro": "2.1.30",
83
- "@budibase/string-templates": "^2.1.30",
84
- "@budibase/types": "^2.1.30",
46
+ "@budibase/backend-core": "^2.1.31",
47
+ "@budibase/client": "^2.1.31",
48
+ "@budibase/pro": "2.1.31",
49
+ "@budibase/string-templates": "^2.1.31",
50
+ "@budibase/types": "^2.1.31",
85
51
  "@bull-board/api": "3.7.0",
86
52
  "@bull-board/koa": "3.9.4",
87
53
  "@elastic/elasticsearch": "7.10.0",
@@ -179,7 +145,7 @@
179
145
  "eslint": "6.8.0",
180
146
  "ioredis-mock": "7.2.0",
181
147
  "is-wsl": "2.2.0",
182
- "jest": "27.5.1",
148
+ "jest": "28.1.1",
183
149
  "jest-openapi": "0.14.2",
184
150
  "nodemon": "2.0.15",
185
151
  "openapi-types": "9.3.1",
@@ -190,10 +156,10 @@
190
156
  "supertest": "4.0.2",
191
157
  "swagger-jsdoc": "6.1.0",
192
158
  "timekeeper": "2.2.0",
193
- "ts-jest": "27.1.3",
194
- "ts-node": "10.5.0",
159
+ "ts-jest": "28.0.4",
160
+ "ts-node": "10.8.1",
195
161
  "tsconfig-paths": "4.0.0",
196
- "typescript": "4.6.2",
162
+ "typescript": "4.7.3",
197
163
  "update-dotenv": "1.1.1"
198
164
  },
199
165
  "optionalDependencies": {
@@ -9,13 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const context_1 = require("@budibase/backend-core/context");
12
+ const backend_core_1 = require("@budibase/backend-core");
13
13
  const utils_1 = require("../../../db/utils");
14
14
  const utils_2 = require("../../../integrations/utils");
15
15
  function getAllInternalTables(db) {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
17
  if (!db) {
18
- db = (0, context_1.getAppDB)();
18
+ db = backend_core_1.context.getAppDB();
19
19
  }
20
20
  const internalTables = yield db.allDocs((0, utils_1.getTableParams)(null, {
21
21
  include_docs: true,
@@ -25,7 +25,7 @@ function getAllInternalTables(db) {
25
25
  }
26
26
  function getAllExternalTables(datasourceId) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- const db = (0, context_1.getAppDB)();
28
+ const db = backend_core_1.context.getAppDB();
29
29
  const datasource = yield db.get(datasourceId);
30
30
  if (!datasource || !datasource.entities) {
31
31
  throw "Datasource is not configured fully.";
@@ -41,7 +41,7 @@ function getExternalTable(datasourceId, tableName) {
41
41
  }
42
42
  function getTable(tableId) {
43
43
  return __awaiter(this, void 0, void 0, function* () {
44
- const db = (0, context_1.getAppDB)();
44
+ const db = backend_core_1.context.getAppDB();
45
45
  if ((0, utils_2.isExternalTable)(tableId)) {
46
46
  let { datasourceId, tableName } = (0, utils_2.breakExternalTableId)(tableId);
47
47
  const datasource = yield db.get(datasourceId);