@budibase/server 2.2.12-alpha.5 → 2.2.13

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 (464) hide show
  1. package/__mocks__/aws-sdk.ts +0 -19
  2. package/__mocks__/node-fetch.ts +0 -78
  3. package/builder/assets/{index.fa480d5b.css → index.9cb087df.css} +2 -2
  4. package/builder/assets/{index.d930bfc5.js → index.ef02c146.js} +369 -372
  5. package/builder/index.html +2 -2
  6. package/coverage/clover.xml +5094 -5122
  7. package/coverage/coverage-final.json +265 -268
  8. package/coverage/lcov-report/index.html +215 -215
  9. package/coverage/lcov-report/src/api/controllers/analytics.ts.html +7 -7
  10. package/coverage/lcov-report/src/api/controllers/apikeys.ts.html +5 -5
  11. package/coverage/lcov-report/src/api/controllers/application.ts.html +183 -258
  12. package/coverage/lcov-report/src/api/controllers/auth.ts.html +11 -11
  13. package/coverage/lcov-report/src/api/controllers/automation.ts.html +51 -51
  14. package/coverage/lcov-report/src/api/controllers/backup.ts.html +6 -6
  15. package/coverage/lcov-report/src/api/controllers/cloud.ts.html +79 -91
  16. package/coverage/lcov-report/src/api/controllers/component.ts.html +5 -5
  17. package/coverage/lcov-report/src/api/controllers/datasource.ts.html +30 -30
  18. package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +14 -17
  19. package/coverage/lcov-report/src/api/controllers/deploy/index.html +19 -19
  20. package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +195 -141
  21. package/coverage/lcov-report/src/api/controllers/dev.ts.html +18 -18
  22. package/coverage/lcov-report/src/api/controllers/index.html +51 -51
  23. package/coverage/lcov-report/src/api/controllers/integration.ts.html +4 -4
  24. package/coverage/lcov-report/src/api/controllers/layout.ts.html +6 -6
  25. package/coverage/lcov-report/src/api/controllers/metadata.ts.html +9 -9
  26. package/coverage/lcov-report/src/api/controllers/migrations.ts.html +4 -4
  27. package/coverage/lcov-report/src/api/controllers/permission.ts.html +13 -13
  28. package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +19 -19
  29. package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +63 -63
  30. package/coverage/lcov-report/src/api/controllers/plugin/index.html +72 -72
  31. package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +135 -150
  32. package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +55 -55
  33. package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +11 -11
  34. package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +18 -18
  35. package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +20 -20
  36. package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +16 -67
  37. package/coverage/lcov-report/src/api/controllers/public/index.html +15 -15
  38. package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +2 -2
  39. package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
  40. package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +7 -7
  41. package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +2 -2
  42. package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +2 -2
  43. package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +2 -2
  44. package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +2 -2
  45. package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +6 -6
  46. package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +10 -10
  47. package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +9 -9
  48. package/coverage/lcov-report/src/api/controllers/public/users.ts.html +11 -11
  49. package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +6 -6
  50. package/coverage/lcov-report/src/api/controllers/query/import/index.html +1 -1
  51. package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +8 -8
  52. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
  53. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +8 -8
  54. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +5 -5
  55. package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +8 -8
  56. package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
  57. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +10 -10
  58. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +14 -14
  59. package/coverage/lcov-report/src/api/controllers/query/index.html +19 -19
  60. package/coverage/lcov-report/src/api/controllers/query/index.ts.html +60 -60
  61. package/coverage/lcov-report/src/api/controllers/query/validation.ts.html +9 -9
  62. package/coverage/lcov-report/src/api/controllers/role.ts.html +8 -8
  63. package/coverage/lcov-report/src/api/controllers/routing.ts.html +6 -6
  64. package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +15 -12
  65. package/coverage/lcov-report/src/api/controllers/row/external.ts.html +20 -20
  66. package/coverage/lcov-report/src/api/controllers/row/index.html +1 -1
  67. package/coverage/lcov-report/src/api/controllers/row/index.ts.html +14 -14
  68. package/coverage/lcov-report/src/api/controllers/row/internal.ts.html +52 -55
  69. package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +9 -9
  70. package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +12 -21
  71. package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +14 -17
  72. package/coverage/lcov-report/src/api/controllers/screen.ts.html +26 -26
  73. package/coverage/lcov-report/src/api/controllers/script.ts.html +18 -18
  74. package/coverage/lcov-report/src/api/controllers/static/index.html +11 -11
  75. package/coverage/lcov-report/src/api/controllers/static/index.ts.html +44 -32
  76. package/coverage/lcov-report/src/api/controllers/table/bulkFormula.ts.html +10 -10
  77. package/coverage/lcov-report/src/api/controllers/table/external.ts.html +14 -14
  78. package/coverage/lcov-report/src/api/controllers/table/index.html +19 -19
  79. package/coverage/lcov-report/src/api/controllers/table/index.ts.html +14 -14
  80. package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +17 -17
  81. package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +70 -52
  82. package/coverage/lcov-report/src/api/controllers/templates.ts.html +7 -7
  83. package/coverage/lcov-report/src/api/controllers/user.ts.html +119 -119
  84. package/coverage/lcov-report/src/api/controllers/view/exporters.ts.html +4 -4
  85. package/coverage/lcov-report/src/api/controllers/view/index.html +24 -24
  86. package/coverage/lcov-report/src/api/controllers/view/index.ts.html +77 -59
  87. package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +22 -22
  88. package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.html +69 -51
  89. package/coverage/lcov-report/src/api/controllers/webhook.ts.html +14 -14
  90. package/coverage/lcov-report/src/api/index.html +1 -1
  91. package/coverage/lcov-report/src/api/index.ts.html +33 -33
  92. package/coverage/lcov-report/src/api/routes/analytics.ts.html +7 -7
  93. package/coverage/lcov-report/src/api/routes/apikeys.ts.html +8 -8
  94. package/coverage/lcov-report/src/api/routes/application.ts.html +11 -44
  95. package/coverage/lcov-report/src/api/routes/auth.ts.html +6 -6
  96. package/coverage/lcov-report/src/api/routes/automation.ts.html +11 -11
  97. package/coverage/lcov-report/src/api/routes/backup.ts.html +8 -8
  98. package/coverage/lcov-report/src/api/routes/cloud.ts.html +8 -8
  99. package/coverage/lcov-report/src/api/routes/component.ts.html +8 -8
  100. package/coverage/lcov-report/src/api/routes/datasource.ts.html +9 -9
  101. package/coverage/lcov-report/src/api/routes/deploy.ts.html +11 -8
  102. package/coverage/lcov-report/src/api/routes/dev.ts.html +13 -13
  103. package/coverage/lcov-report/src/api/routes/index.html +7 -7
  104. package/coverage/lcov-report/src/api/routes/index.ts.html +37 -40
  105. package/coverage/lcov-report/src/api/routes/integration.ts.html +8 -8
  106. package/coverage/lcov-report/src/api/routes/layout.ts.html +8 -8
  107. package/coverage/lcov-report/src/api/routes/metadata.ts.html +9 -9
  108. package/coverage/lcov-report/src/api/routes/migrations.ts.html +7 -7
  109. package/coverage/lcov-report/src/api/routes/permission.ts.html +9 -9
  110. package/coverage/lcov-report/src/api/routes/plugin.ts.html +8 -8
  111. package/coverage/lcov-report/src/api/routes/public/applications.ts.html +14 -146
  112. package/coverage/lcov-report/src/api/routes/public/index.html +7 -7
  113. package/coverage/lcov-report/src/api/routes/public/index.ts.html +52 -52
  114. package/coverage/lcov-report/src/api/routes/public/middleware/index.html +15 -15
  115. package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +16 -28
  116. package/coverage/lcov-report/src/api/routes/public/queries.ts.html +9 -9
  117. package/coverage/lcov-report/src/api/routes/public/rows.ts.html +12 -12
  118. package/coverage/lcov-report/src/api/routes/public/tables.ts.html +12 -12
  119. package/coverage/lcov-report/src/api/routes/public/tests/index.html +1 -1
  120. package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +1 -1
  121. package/coverage/lcov-report/src/api/routes/public/users.ts.html +12 -12
  122. package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +19 -19
  123. package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
  124. package/coverage/lcov-report/src/api/routes/query.ts.html +11 -11
  125. package/coverage/lcov-report/src/api/routes/role.ts.html +9 -9
  126. package/coverage/lcov-report/src/api/routes/routing.ts.html +8 -8
  127. package/coverage/lcov-report/src/api/routes/row.ts.html +11 -11
  128. package/coverage/lcov-report/src/api/routes/screen.ts.html +9 -9
  129. package/coverage/lcov-report/src/api/routes/script.ts.html +1 -1
  130. package/coverage/lcov-report/src/api/routes/static.ts.html +14 -14
  131. package/coverage/lcov-report/src/api/routes/table.ts.html +11 -11
  132. package/coverage/lcov-report/src/api/routes/templates.ts.html +8 -8
  133. package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +15 -15
  134. package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +1 -1
  135. package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +24 -24
  136. package/coverage/lcov-report/src/api/routes/user.ts.html +9 -9
  137. package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
  138. package/coverage/lcov-report/src/api/routes/utils/validators.ts.html +42 -42
  139. package/coverage/lcov-report/src/api/routes/view.ts.html +10 -10
  140. package/coverage/lcov-report/src/api/routes/webhook.ts.html +10 -10
  141. package/coverage/lcov-report/src/app.ts.html +32 -32
  142. package/coverage/lcov-report/src/automations/actions.ts.html +25 -25
  143. package/coverage/lcov-report/src/automations/automationUtils.ts.html +19 -91
  144. package/coverage/lcov-report/src/automations/bullboard.ts.html +11 -11
  145. package/coverage/lcov-report/src/automations/index.html +19 -19
  146. package/coverage/lcov-report/src/automations/index.ts.html +13 -13
  147. package/coverage/lcov-report/src/automations/logging/index.html +1 -1
  148. package/coverage/lcov-report/src/automations/logging/index.ts.html +11 -11
  149. package/coverage/lcov-report/src/automations/steps/bash.ts.html +34 -34
  150. package/coverage/lcov-report/src/automations/steps/createRow.ts.html +7 -7
  151. package/coverage/lcov-report/src/automations/steps/delay.ts.html +5 -5
  152. package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +7 -7
  153. package/coverage/lcov-report/src/automations/steps/discord.ts.html +33 -33
  154. package/coverage/lcov-report/src/automations/steps/executeQuery.ts.html +35 -35
  155. package/coverage/lcov-report/src/automations/steps/executeScript.ts.html +31 -31
  156. package/coverage/lcov-report/src/automations/steps/filter.ts.html +6 -6
  157. package/coverage/lcov-report/src/automations/steps/index.html +83 -83
  158. package/coverage/lcov-report/src/automations/steps/integromat.ts.html +6 -6
  159. package/coverage/lcov-report/src/automations/steps/loop.ts.html +3 -3
  160. package/coverage/lcov-report/src/automations/steps/outgoingWebhook.ts.html +14 -14
  161. package/coverage/lcov-report/src/automations/steps/queryRows.ts.html +17 -17
  162. package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.ts.html +28 -28
  163. package/coverage/lcov-report/src/automations/steps/serverLog.ts.html +18 -18
  164. package/coverage/lcov-report/src/automations/steps/slack.ts.html +6 -6
  165. package/coverage/lcov-report/src/automations/steps/updateRow.ts.html +7 -7
  166. package/coverage/lcov-report/src/automations/steps/utils.ts.html +16 -16
  167. package/coverage/lcov-report/src/automations/steps/zapier.ts.html +22 -22
  168. package/coverage/lcov-report/src/automations/tests/utilities/index.html +5 -5
  169. package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +26 -26
  170. package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +3 -3
  171. package/coverage/lcov-report/src/automations/triggerInfo/cron.ts.html +3 -3
  172. package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
  173. package/coverage/lcov-report/src/automations/triggerInfo/index.ts.html +8 -8
  174. package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.ts.html +3 -3
  175. package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.ts.html +3 -3
  176. package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.ts.html +3 -3
  177. package/coverage/lcov-report/src/automations/triggerInfo/webhook.ts.html +3 -3
  178. package/coverage/lcov-report/src/automations/triggers.ts.html +21 -21
  179. package/coverage/lcov-report/src/automations/utils.ts.html +56 -56
  180. package/coverage/lcov-report/src/constants/index.html +1 -1
  181. package/coverage/lcov-report/src/constants/index.ts.html +92 -92
  182. package/coverage/lcov-report/src/constants/layouts.ts.html +4 -4
  183. package/coverage/lcov-report/src/constants/screens.ts.html +5 -5
  184. package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +23 -23
  185. package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +2 -2
  186. package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +2 -2
  187. package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
  188. package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +2 -2
  189. package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +2 -2
  190. package/coverage/lcov-report/src/db/dynamoClient.ts.html +16 -16
  191. package/coverage/lcov-report/src/db/inMemoryView.ts.html +5 -5
  192. package/coverage/lcov-report/src/db/index.html +19 -19
  193. package/coverage/lcov-report/src/db/index.ts.html +9 -9
  194. package/coverage/lcov-report/src/db/linkedRows/LinkController.ts.html +8 -8
  195. package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +4 -4
  196. package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
  197. package/coverage/lcov-report/src/db/linkedRows/index.ts.html +15 -15
  198. package/coverage/lcov-report/src/db/linkedRows/linkUtils.ts.html +12 -12
  199. package/coverage/lcov-report/src/db/newid.ts.html +4 -4
  200. package/coverage/lcov-report/src/db/utils.ts.html +80 -80
  201. package/coverage/lcov-report/src/definitions/automations.ts.html +4 -4
  202. package/coverage/lcov-report/src/definitions/datasource.ts.html +4 -4
  203. package/coverage/lcov-report/src/definitions/index.html +1 -1
  204. package/coverage/lcov-report/src/environment.ts.html +28 -40
  205. package/coverage/lcov-report/src/events/AutomationEmitter.ts.html +6 -6
  206. package/coverage/lcov-report/src/events/BudibaseEmitter.ts.html +5 -5
  207. package/coverage/lcov-report/src/events/index.html +1 -1
  208. package/coverage/lcov-report/src/events/index.ts.html +4 -4
  209. package/coverage/lcov-report/src/events/utils.ts.html +3 -3
  210. package/coverage/lcov-report/src/index.html +25 -25
  211. package/coverage/lcov-report/src/index.ts.html +1 -1
  212. package/coverage/lcov-report/src/integrations/airtable.ts.html +5 -5
  213. package/coverage/lcov-report/src/integrations/arangodb.ts.html +5 -5
  214. package/coverage/lcov-report/src/integrations/base/index.html +1 -1
  215. package/coverage/lcov-report/src/integrations/base/query.ts.html +3 -3
  216. package/coverage/lcov-report/src/integrations/base/sql.ts.html +14 -14
  217. package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +8 -8
  218. package/coverage/lcov-report/src/integrations/base/utils.ts.html +3 -3
  219. package/coverage/lcov-report/src/integrations/couchdb.ts.html +5 -5
  220. package/coverage/lcov-report/src/integrations/dynamodb.ts.html +6 -6
  221. package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +5 -5
  222. package/coverage/lcov-report/src/integrations/firebase.ts.html +5 -5
  223. package/coverage/lcov-report/src/integrations/googlesheets.ts.html +12 -12
  224. package/coverage/lcov-report/src/integrations/index.html +5 -5
  225. package/coverage/lcov-report/src/integrations/index.ts.html +47 -35
  226. package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +8 -8
  227. package/coverage/lcov-report/src/integrations/mongodb.ts.html +5 -5
  228. package/coverage/lcov-report/src/integrations/mysql.ts.html +10 -10
  229. package/coverage/lcov-report/src/integrations/oracle.ts.html +13 -13
  230. package/coverage/lcov-report/src/integrations/postgres.ts.html +42 -42
  231. package/coverage/lcov-report/src/integrations/queries/index.html +1 -1
  232. package/coverage/lcov-report/src/integrations/queries/sql.ts.html +13 -13
  233. package/coverage/lcov-report/src/integrations/redis.ts.html +5 -5
  234. package/coverage/lcov-report/src/integrations/rest.ts.html +16 -16
  235. package/coverage/lcov-report/src/integrations/s3.ts.html +6 -6
  236. package/coverage/lcov-report/src/integrations/snowflake.ts.html +5 -5
  237. package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
  238. package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
  239. package/coverage/lcov-report/src/integrations/utils.ts.html +36 -36
  240. package/coverage/lcov-report/src/middleware/appInfo.ts.html +7 -7
  241. package/coverage/lcov-report/src/middleware/authorized.ts.html +28 -28
  242. package/coverage/lcov-report/src/middleware/builder.ts.html +17 -17
  243. package/coverage/lcov-report/src/middleware/currentapp.ts.html +39 -39
  244. package/coverage/lcov-report/src/middleware/index.html +1 -1
  245. package/coverage/lcov-report/src/middleware/joi-validator.ts.html +1 -1
  246. package/coverage/lcov-report/src/middleware/publicApi.ts.html +4 -4
  247. package/coverage/lcov-report/src/middleware/resourceId.ts.html +22 -22
  248. package/coverage/lcov-report/src/middleware/selfhost.ts.html +1 -1
  249. package/coverage/lcov-report/src/middleware/utils.ts.html +4 -4
  250. package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +4 -4
  251. package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +5 -5
  252. package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +5 -5
  253. package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +1 -1
  254. package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +5 -5
  255. package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +7 -7
  256. package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +5 -5
  257. package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +5 -5
  258. package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +4 -4
  259. package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +19 -19
  260. package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +10 -13
  261. package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
  262. package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +7 -7
  263. package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +6 -6
  264. package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +15 -15
  265. package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
  266. package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +5 -5
  267. package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +8 -8
  268. package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
  269. package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +6 -6
  270. package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +6 -6
  271. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +1 -1
  272. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +2 -2
  273. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +5 -5
  274. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +4 -4
  275. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +6 -6
  276. package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +3 -3
  277. package/coverage/lcov-report/src/migrations/index.html +1 -1
  278. package/coverage/lcov-report/src/migrations/index.ts.html +32 -32
  279. package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
  280. package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
  281. package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
  282. package/coverage/lcov-report/src/sdk/app/applications/index.html +15 -15
  283. package/coverage/lcov-report/src/sdk/app/applications/index.ts.html +4 -4
  284. package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +34 -34
  285. package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +9 -9
  286. package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
  287. package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +3 -3
  288. package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +6 -6
  289. package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +3 -3
  290. package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +17 -17
  291. package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +53 -41
  292. package/coverage/lcov-report/src/sdk/app/backups/index.html +28 -28
  293. package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +5 -5
  294. package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +73 -73
  295. package/coverage/lcov-report/src/sdk/app/rows/attachments.ts.html +6 -6
  296. package/coverage/lcov-report/src/sdk/app/rows/index.html +1 -1
  297. package/coverage/lcov-report/src/sdk/app/rows/index.ts.html +4 -4
  298. package/coverage/lcov-report/src/sdk/app/rows/rows.ts.html +4 -4
  299. package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
  300. package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +5 -5
  301. package/coverage/lcov-report/src/sdk/index.html +1 -1
  302. package/coverage/lcov-report/src/sdk/index.ts.html +9 -9
  303. package/coverage/lcov-report/src/sdk/users/index.html +5 -5
  304. package/coverage/lcov-report/src/sdk/users/index.ts.html +3 -3
  305. package/coverage/lcov-report/src/sdk/users/utils.ts.html +34 -34
  306. package/coverage/lcov-report/src/startup.ts.html +42 -42
  307. package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +125 -182
  308. package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +15 -15
  309. package/coverage/lcov-report/src/tests/utilities/index.html +15 -15
  310. package/coverage/lcov-report/src/tests/utilities/index.ts.html +1 -1
  311. package/coverage/lcov-report/src/tests/utilities/structures.ts.html +30 -30
  312. package/coverage/lcov-report/src/threads/automation.ts.html +103 -34
  313. package/coverage/lcov-report/src/threads/index.html +19 -19
  314. package/coverage/lcov-report/src/threads/index.ts.html +25 -25
  315. package/coverage/lcov-report/src/threads/query.ts.html +71 -71
  316. package/coverage/lcov-report/src/threads/utils.ts.html +18 -18
  317. package/coverage/lcov-report/src/utilities/budibaseDir.ts.html +3 -3
  318. package/coverage/lcov-report/src/utilities/centralPath.ts.html +4 -4
  319. package/coverage/lcov-report/src/utilities/csvParser.ts.html +8 -8
  320. package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +12 -12
  321. package/coverage/lcov-report/src/utilities/fileSystem/index.html +19 -79
  322. package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1049 -20
  323. package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +1 -1
  324. package/coverage/lcov-report/src/utilities/global.ts.html +43 -43
  325. package/coverage/lcov-report/src/utilities/index.html +63 -48
  326. package/coverage/lcov-report/src/utilities/index.ts.html +168 -36
  327. package/coverage/lcov-report/src/utilities/plugins.ts.html +151 -0
  328. package/coverage/lcov-report/src/utilities/redis.ts.html +32 -32
  329. package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
  330. package/coverage/lcov-report/src/utilities/routing/index.ts.html +5 -5
  331. package/coverage/lcov-report/src/utilities/rowProcessor/index.html +28 -28
  332. package/coverage/lcov-report/src/utilities/rowProcessor/index.ts.html +33 -60
  333. package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +3 -3
  334. package/coverage/lcov-report/src/utilities/rowProcessor/utils.ts.html +38 -38
  335. package/coverage/lcov-report/src/utilities/scriptRunner.ts.html +32 -32
  336. package/coverage/lcov-report/src/utilities/security.ts.html +6 -6
  337. package/coverage/lcov-report/src/utilities/statusCodes.ts.html +1 -1
  338. package/coverage/lcov-report/src/utilities/usageQuota/index.html +1 -1
  339. package/coverage/lcov-report/src/utilities/usageQuota/rows.ts.html +35 -35
  340. package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.ts.html +1 -1
  341. package/coverage/lcov-report/src/utilities/users.ts.html +6 -6
  342. package/coverage/lcov-report/src/utilities/workerRequests.ts.html +56 -56
  343. package/coverage/lcov-report/src/watch.ts.html +9 -9
  344. package/coverage/lcov-report/src/websocket.ts.html +15 -15
  345. package/coverage/lcov.info +7320 -7367
  346. package/dist/api/controllers/application.js +35 -47
  347. package/dist/api/controllers/cloud.js +2 -6
  348. package/dist/api/controllers/deploy/index.js +60 -43
  349. package/dist/api/controllers/plugin/index.js +6 -6
  350. package/dist/api/controllers/public/applications.js +1 -22
  351. package/dist/api/controllers/row/ExternalRequest.js +1 -0
  352. package/dist/api/controllers/row/internal.js +12 -12
  353. package/dist/api/controllers/row/staticFormula.js +1 -1
  354. package/dist/api/controllers/static/index.js +11 -8
  355. package/dist/api/controllers/table/utils.js +2 -1
  356. package/dist/api/controllers/view/index.js +6 -5
  357. package/dist/api/controllers/view/viewBuilder.js +8 -2
  358. package/dist/api/routes/application.js +0 -3
  359. package/dist/api/routes/deploy.js +2 -1
  360. package/dist/api/routes/public/applications.js +0 -37
  361. package/dist/api/routes/public/middleware/mapper.js +0 -3
  362. package/dist/api/routes/tests/utilities/TestFunctions.js +167 -0
  363. package/dist/api/routes/tests/utilities/index.js +131 -0
  364. package/dist/automations/automationUtils.js +1 -26
  365. package/dist/automations/tests/utilities/index.js +81 -0
  366. package/dist/environment.js +1 -5
  367. package/dist/integrations/googlesheets.js +1 -1
  368. package/dist/integrations/index.js +2 -1
  369. package/dist/migrations/functions/backfill/global/configs.js +4 -4
  370. package/dist/package.json +7 -9
  371. package/dist/sdk/app/backups/imports.js +6 -2
  372. package/dist/tests/utilities/TestConfiguration.js +562 -0
  373. package/dist/tests/utilities/controllers.js +40 -0
  374. package/dist/tests/utilities/structures.js +168 -0
  375. package/dist/threads/automation.js +28 -4
  376. package/dist/tsconfig.build.tsbuildinfo +1 -1
  377. package/dist/utilities/fileSystem/clientLibrary.js +3 -3
  378. package/dist/utilities/fileSystem/index.js +342 -18
  379. package/dist/utilities/index.js +44 -1
  380. package/dist/utilities/plugins.js +26 -0
  381. package/dist/utilities/rowProcessor/index.js +4 -12
  382. package/package.json +8 -10
  383. package/scripts/dev/manage.js +16 -0
  384. package/specs/openapi.json +0 -84
  385. package/specs/openapi.yaml +0 -53
  386. package/specs/resources/application.js +0 -19
  387. package/src/api/controllers/application.ts +36 -61
  388. package/src/api/controllers/auth.ts +2 -2
  389. package/src/api/controllers/cloud.ts +6 -10
  390. package/src/api/controllers/deploy/Deployment.ts +0 -1
  391. package/src/api/controllers/deploy/index.ts +58 -40
  392. package/src/api/controllers/plugin/index.ts +9 -14
  393. package/src/api/controllers/public/applications.ts +0 -17
  394. package/src/api/controllers/row/ExternalRequest.ts +1 -0
  395. package/src/api/controllers/row/internal.ts +23 -24
  396. package/src/api/controllers/row/staticFormula.ts +2 -5
  397. package/src/api/controllers/row/utils.ts +1 -2
  398. package/src/api/controllers/static/index.ts +10 -6
  399. package/src/api/controllers/table/utils.ts +7 -1
  400. package/src/api/controllers/view/index.ts +11 -5
  401. package/src/api/controllers/view/viewBuilder.ts +14 -8
  402. package/src/api/routes/application.ts +0 -11
  403. package/src/api/routes/deploy.ts +1 -0
  404. package/src/api/routes/index.ts +3 -4
  405. package/src/api/routes/public/applications.ts +0 -44
  406. package/src/api/routes/public/middleware/mapper.ts +0 -4
  407. package/src/api/routes/tests/__snapshots__/{datasource.spec.ts.snap → datasource.spec.js.snap} +0 -0
  408. package/src/api/routes/tests/{application.spec.ts → application.spec.js} +18 -94
  409. package/src/api/routes/tests/{backup.spec.ts → backup.spec.js} +6 -17
  410. package/src/api/routes/tests/{datasource.spec.ts → datasource.spec.js} +15 -23
  411. package/src/api/routes/tests/deployment.spec.ts +25 -0
  412. package/src/api/routes/tests/permissions.spec.js +1 -1
  413. package/src/api/routes/tests/routing.spec.js +2 -1
  414. package/src/api/routes/tests/row.spec.js +2 -4
  415. package/src/api/routes/tests/static.spec.js +17 -2
  416. package/src/api/routes/tests/table.spec.js +2 -8
  417. package/src/api/routes/tests/user.spec.js +0 -86
  418. package/src/api/routes/tests/utilities/index.ts +2 -2
  419. package/src/api/routes/tests/webhook.spec.js +1 -1
  420. package/src/automations/automationUtils.ts +0 -24
  421. package/src/automations/tests/utilities/index.ts +2 -2
  422. package/src/automations/unitTests/automationUtils.spec.js +17 -0
  423. package/src/definitions/openapi.ts +0 -10
  424. package/src/environment.ts +1 -5
  425. package/src/integrations/googlesheets.ts +1 -1
  426. package/src/integrations/index.ts +5 -1
  427. package/src/migrations/functions/backfill/global/configs.ts +4 -5
  428. package/src/sdk/app/backups/imports.ts +6 -2
  429. package/src/sdk/tests/attachments.spec.ts +4 -1
  430. package/src/tests/jestSetup.ts +1 -4
  431. package/src/tests/utilities/TestConfiguration.ts +4 -23
  432. package/src/threads/automation.ts +27 -4
  433. package/src/utilities/fileSystem/clientLibrary.ts +1 -1
  434. package/src/utilities/fileSystem/index.ts +348 -5
  435. package/src/utilities/index.ts +45 -1
  436. package/src/utilities/plugins.ts +22 -0
  437. package/src/utilities/rowProcessor/index.ts +8 -17
  438. package/tsconfig.build.json +0 -2
  439. package/coverage/lcov-report/src/utilities/fileSystem/app.ts.html +0 -343
  440. package/coverage/lcov-report/src/utilities/fileSystem/filesystem.ts.html +0 -595
  441. package/coverage/lcov-report/src/utilities/fileSystem/plugin.ts.html +0 -280
  442. package/coverage/lcov-report/src/utilities/fileSystem/template.ts.html +0 -193
  443. package/dist/utilities/fileSystem/app.js +0 -97
  444. package/dist/utilities/fileSystem/filesystem.js +0 -182
  445. package/dist/utilities/fileSystem/plugin.js +0 -63
  446. package/dist/utilities/fileSystem/template.js +0 -44
  447. package/src/api/routes/tests/cloud.spec.ts +0 -65
  448. package/src/api/routes/tests/data/budibase-component-1.0.1.tgz +0 -0
  449. package/src/api/routes/tests/data/comment-box-1.0.2.tar.gz +0 -0
  450. package/src/api/routes/tests/data/export-test.tar.gz +0 -0
  451. package/src/api/routes/tests/plugin.spec.ts +0 -179
  452. package/src/automations/tests/bash.spec.js +0 -34
  453. package/src/automations/tests/discord.spec.js +0 -27
  454. package/src/automations/tests/executeQuery.spec.js +0 -49
  455. package/src/automations/tests/executeScript.spec.js +0 -48
  456. package/src/automations/tests/sendSmtpEmail.spec.js +0 -71
  457. package/src/automations/tests/serverLog.spec.js +0 -22
  458. package/src/automations/tests/zapier.spec.js +0 -27
  459. package/src/automations/unitTests/automationUtils.spec.ts +0 -65
  460. package/src/utilities/fileSystem/app.ts +0 -86
  461. package/src/utilities/fileSystem/filesystem.ts +0 -170
  462. package/src/utilities/fileSystem/plugin.ts +0 -65
  463. package/src/utilities/fileSystem/template.ts +0 -36
  464. package/src/utilities/rowProcessor/tests/utils.spec.ts +0 -57
@@ -13,7 +13,7 @@ import {
13
13
  cleanupAttachments,
14
14
  } from "../../../utilities/rowProcessor"
15
15
  import { FieldTypes } from "../../../constants"
16
- import * as utils from "./utils"
16
+ import { validate as rowValidate, findRow } from "./utils"
17
17
  import { fullSearch, paginatedSearch } from "./internalSearch"
18
18
  import { getGlobalUsersFromMetadata } from "../../../utilities/global"
19
19
  import * as inMemoryViews from "../../../db/inMemoryView"
@@ -30,8 +30,7 @@ import { finaliseRow, updateRelatedFormula } from "./staticFormula"
30
30
  import * as exporters from "../view/exporters"
31
31
  import { apiFileReturn } from "../../../utilities/fileSystem"
32
32
  import {
33
- Ctx,
34
- UserCtx,
33
+ BBContext,
35
34
  Database,
36
35
  LinkDocumentValue,
37
36
  Row,
@@ -70,7 +69,7 @@ async function getView(db: Database, viewName: string) {
70
69
  return viewInfo
71
70
  }
72
71
 
73
- async function getRawTableData(ctx: Ctx, db: Database, tableId: string) {
72
+ async function getRawTableData(ctx: BBContext, db: Database, tableId: string) {
74
73
  let rows
75
74
  if (tableId === InternalTables.USER_METADATA) {
76
75
  await userController.fetchMetadata(ctx)
@@ -86,7 +85,7 @@ async function getRawTableData(ctx: Ctx, db: Database, tableId: string) {
86
85
  return rows as Row[]
87
86
  }
88
87
 
89
- export async function patch(ctx: UserCtx) {
88
+ export async function patch(ctx: BBContext) {
90
89
  const db = context.getAppDB()
91
90
  const inputs = ctx.request.body
92
91
  const tableId = inputs.tableId
@@ -96,7 +95,7 @@ export async function patch(ctx: UserCtx) {
96
95
  let dbTable = await db.get(tableId)
97
96
  oldRow = await outputProcessing(
98
97
  dbTable,
99
- await utils.findRow(ctx, tableId, inputs._id)
98
+ await findRow(ctx, tableId, inputs._id)
100
99
  )
101
100
  } catch (err) {
102
101
  if (isUserTable) {
@@ -118,8 +117,8 @@ export async function patch(ctx: UserCtx) {
118
117
  }
119
118
 
120
119
  // this returns the table and row incase they have been updated
121
- let { table, row } = inputProcessing(ctx.user, dbTable, combinedRow)
122
- const validateResult = await utils.validate({
120
+ let { table, row } = inputProcessing(ctx.user!, dbTable, combinedRow)
121
+ const validateResult = await rowValidate({
123
122
  row,
124
123
  table,
125
124
  })
@@ -151,7 +150,7 @@ export async function patch(ctx: UserCtx) {
151
150
  })
152
151
  }
153
152
 
154
- export async function save(ctx: UserCtx) {
153
+ export async function save(ctx: BBContext) {
155
154
  const db = context.getAppDB()
156
155
  let inputs = ctx.request.body
157
156
  inputs.tableId = ctx.params.tableId
@@ -162,8 +161,8 @@ export async function save(ctx: UserCtx) {
162
161
 
163
162
  // this returns the table and row incase they have been updated
164
163
  const dbTable = await db.get(inputs.tableId)
165
- let { table, row } = inputProcessing(ctx.user, dbTable, inputs)
166
- const validateResult = await utils.validate({
164
+ let { table, row } = inputProcessing(ctx.user!, dbTable, inputs)
165
+ const validateResult = await rowValidate({
167
166
  row,
168
167
  table,
169
168
  })
@@ -186,8 +185,8 @@ export async function save(ctx: UserCtx) {
186
185
  })
187
186
  }
188
187
 
189
- export async function fetchView(ctx: Ctx) {
190
- const viewName = decodeURIComponent(ctx.params.viewName)
188
+ export async function fetchView(ctx: BBContext) {
189
+ const viewName = ctx.params.viewName
191
190
 
192
191
  // if this is a table view being looked for just transfer to that
193
192
  if (viewName.startsWith(DocumentType.TABLE)) {
@@ -253,7 +252,7 @@ export async function fetchView(ctx: Ctx) {
253
252
  return rows
254
253
  }
255
254
 
256
- export async function fetch(ctx: Ctx) {
255
+ export async function fetch(ctx: BBContext) {
257
256
  const db = context.getAppDB()
258
257
 
259
258
  const tableId = ctx.params.tableId
@@ -262,15 +261,15 @@ export async function fetch(ctx: Ctx) {
262
261
  return outputProcessing(table, rows)
263
262
  }
264
263
 
265
- export async function find(ctx: Ctx) {
264
+ export async function find(ctx: BBContext) {
266
265
  const db = dbCore.getDB(ctx.appId)
267
266
  const table = await db.get(ctx.params.tableId)
268
- let row = await utils.findRow(ctx, ctx.params.tableId, ctx.params.rowId)
267
+ let row = await findRow(ctx, ctx.params.tableId, ctx.params.rowId)
269
268
  row = await outputProcessing(table, row)
270
269
  return row
271
270
  }
272
271
 
273
- export async function destroy(ctx: Ctx) {
272
+ export async function destroy(ctx: BBContext) {
274
273
  const db = context.getAppDB()
275
274
  const { _id } = ctx.request.body
276
275
  let row = await db.get(_id)
@@ -306,7 +305,7 @@ export async function destroy(ctx: Ctx) {
306
305
  return { response, row }
307
306
  }
308
307
 
309
- export async function bulkDestroy(ctx: Ctx) {
308
+ export async function bulkDestroy(ctx: BBContext) {
310
309
  const db = context.getAppDB()
311
310
  const tableId = ctx.params.tableId
312
311
  const table = await db.get(tableId)
@@ -345,7 +344,7 @@ export async function bulkDestroy(ctx: Ctx) {
345
344
  return { response: { ok: true }, rows: processedRows }
346
345
  }
347
346
 
348
- export async function search(ctx: Ctx) {
347
+ export async function search(ctx: BBContext) {
349
348
  // Fetch the whole table when running in cypress, as search doesn't work
350
349
  if (!env.COUCH_DB_URL && env.isCypress()) {
351
350
  return { rows: await fetch(ctx) }
@@ -377,14 +376,14 @@ export async function search(ctx: Ctx) {
377
376
  return response
378
377
  }
379
378
 
380
- export async function validate(ctx: Ctx) {
381
- return utils.validate({
379
+ export async function validate(ctx: BBContext) {
380
+ return rowValidate({
382
381
  tableId: ctx.params.tableId,
383
382
  row: ctx.request.body,
384
383
  })
385
384
  }
386
385
 
387
- export async function exportRows(ctx: Ctx) {
386
+ export async function exportRows(ctx: BBContext) {
388
387
  const db = context.getAppDB()
389
388
  const table = await db.get(ctx.params.tableId)
390
389
  const rowIds = ctx.request.body.rows
@@ -422,14 +421,14 @@ export async function exportRows(ctx: Ctx) {
422
421
  return apiFileReturn(exporter(headers, rows))
423
422
  }
424
423
 
425
- export async function fetchEnrichedRow(ctx: Ctx) {
424
+ export async function fetchEnrichedRow(ctx: BBContext) {
426
425
  const db = context.getAppDB()
427
426
  const tableId = ctx.params.tableId
428
427
  const rowId = ctx.params.rowId
429
428
  // need table to work out where links go in row
430
429
  let [table, row] = await Promise.all([
431
430
  db.get(tableId),
432
- utils.findRow(ctx, tableId, rowId),
431
+ findRow(ctx, tableId, rowId),
433
432
  ])
434
433
  // get the link docs
435
434
  const linkVals = (await linkRows.getLinkDocuments({
@@ -16,10 +16,7 @@ const { cloneDeep } = require("lodash/fp")
16
16
  * updated.
17
17
  * NOTE: this will only for affect static formulas.
18
18
  */
19
- export async function updateRelatedFormula(
20
- table: Table,
21
- enrichedRows: Row[] | Row
22
- ) {
19
+ export async function updateRelatedFormula(table: Table, enrichedRows: Row[]) {
23
20
  const db = context.getAppDB()
24
21
  // no formula to update, we're done
25
22
  if (!table.relatedFormula) {
@@ -158,7 +155,7 @@ export async function finaliseRow(
158
155
  enrichedRow = await processFormulas(table, enrichedRow, { dynamic: false })
159
156
  // this updates the related formulas in other rows based on the relations to this row
160
157
  if (updateFormula) {
161
- await updateRelatedFormula(table, enrichedRow)
158
+ await exports.updateRelatedFormula(table, enrichedRow)
162
159
  }
163
160
  return { row: enrichedRow, table }
164
161
  }
@@ -7,7 +7,6 @@ import { BBContext, Row, Table } from "@budibase/types"
7
7
  export { removeKeyNumbering } from "../../../integrations/base/utils"
8
8
  const validateJs = require("validate.js")
9
9
  const { cloneDeep } = require("lodash/fp")
10
- import { Ctx } from "@budibase/types"
11
10
 
12
11
  validateJs.extend(validateJs.validators.datetime, {
13
12
  parse: function (value: string) {
@@ -26,7 +25,7 @@ export async function getDatasourceAndQuery(json: any) {
26
25
  return makeExternalQuery(datasource, json)
27
26
  }
28
27
 
29
- export async function findRow(ctx: Ctx, tableId: string, rowId: string) {
28
+ export async function findRow(ctx: BBContext, tableId: string, rowId: string) {
30
29
  const db = context.getAppDB()
31
30
  let row
32
31
  // TODO remove special user case in future
@@ -1,9 +1,11 @@
1
+ import { enrichPluginURLs } from "../../../utilities/plugins"
2
+
1
3
  require("svelte/register")
2
4
 
3
5
  const send = require("koa-send")
4
6
  const { resolve, join } = require("../../../utilities/centralPath")
5
7
  const uuid = require("uuid")
6
- import { ObjectStoreBuckets } from "../../../constants"
8
+ const { ObjectStoreBuckets } = require("../../../constants")
7
9
  const { processString } = require("@budibase/string-templates")
8
10
  const {
9
11
  loadHandlebarsFile,
@@ -11,6 +13,8 @@ const {
11
13
  TOP_LEVEL_PATH,
12
14
  } = require("../../../utilities/fileSystem")
13
15
  const env = require("../../../environment")
16
+ const { clientLibraryPath } = require("../../../utilities")
17
+ const { attachmentsRelativeURL } = require("../../../utilities")
14
18
  const { DocumentType } = require("../../../db/utils")
15
19
  const { context, objectStore, utils } = require("@budibase/backend-core")
16
20
  const AWS = require("aws-sdk")
@@ -29,7 +33,7 @@ async function prepareUpload({ s3Key, bucket, metadata, file }: any) {
29
33
  return {
30
34
  size: file.size,
31
35
  name: file.name,
32
- url: objectStore.getAppFileUrl(s3Key),
36
+ url: attachmentsRelativeURL(response.Key),
33
37
  extension: [...file.name.split(".")].pop(),
34
38
  key: response.Key,
35
39
  }
@@ -81,7 +85,7 @@ export const uploadFile = async function (ctx: any) {
81
85
 
82
86
  return prepareUpload({
83
87
  file,
84
- s3Key: `${context.getProdAppId()}/attachments/${processedFileName}`,
88
+ s3Key: `${ctx.appId}/attachments/${processedFileName}`,
85
89
  bucket: ObjectStoreBuckets.APPS,
86
90
  })
87
91
  })
@@ -103,14 +107,14 @@ export const serveApp = async function (ctx: any) {
103
107
 
104
108
  if (!env.isJest()) {
105
109
  const App = require("./templates/BudibaseApp.svelte").default
106
- const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
110
+ const plugins = enrichPluginURLs(appInfo.usedPlugins)
107
111
  const { head, html, css } = App.render({
108
112
  metaImage:
109
113
  "https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
110
114
  title: appInfo.name,
111
115
  production: env.isProd(),
112
116
  appId,
113
- clientLibPath: objectStore.clientLibraryUrl(appId, appInfo.version),
117
+ clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
114
118
  usedPlugins: plugins,
115
119
  })
116
120
 
@@ -135,7 +139,7 @@ export const serveBuilderPreview = async function (ctx: any) {
135
139
  let appId = context.getAppId()
136
140
  const previewHbs = loadHandlebarsFile(`${__dirname}/templates/preview.hbs`)
137
141
  ctx.body = await processString(previewHbs, {
138
- clientLibPath: objectStore.clientLibraryUrl(appId, appInfo.version),
142
+ clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
139
143
  })
140
144
  } else {
141
145
  // just return the app info for jest to assert on
@@ -316,7 +316,13 @@ export async function checkForViewUpdates(
316
316
 
317
317
  // Update view if required
318
318
  if (needsUpdated) {
319
- const newViewTemplate = viewTemplate(view.meta)
319
+ const groupByField: any = Object.values(table.schema).find(
320
+ (field: any) => field.name == view.groupBy
321
+ )
322
+ const newViewTemplate = viewTemplate(
323
+ view.meta,
324
+ groupByField?.type === FieldTypes.ARRAY
325
+ )
320
326
  await saveView(null, view.name, newViewTemplate)
321
327
  if (!newViewTemplate.meta.schema) {
322
328
  newViewTemplate.meta.schema = table.schema
@@ -25,7 +25,15 @@ export async function fetch(ctx: BBContext) {
25
25
  export async function save(ctx: BBContext) {
26
26
  const db = context.getAppDB()
27
27
  const { originalName, ...viewToSave } = ctx.request.body
28
- const view = viewTemplate(viewToSave)
28
+
29
+ const existingTable = await db.get(ctx.request.body.tableId)
30
+ const table = cloneDeep(existingTable)
31
+
32
+ const groupByField: any = Object.values(table.schema).find(
33
+ (field: any) => field.name == viewToSave.groupBy
34
+ )
35
+
36
+ const view = viewTemplate(viewToSave, groupByField?.type === FieldTypes.ARRAY)
29
37
  const viewName = viewToSave.name
30
38
 
31
39
  if (!viewName) {
@@ -35,8 +43,6 @@ export async function save(ctx: BBContext) {
35
43
  await saveView(originalName, viewName, view)
36
44
 
37
45
  // add views to table document
38
- const existingTable = await db.get(ctx.request.body.tableId)
39
- const table = cloneDeep(existingTable)
40
46
  if (!table.views) table.views = {}
41
47
  if (!view.meta.schema) {
42
48
  view.meta.schema = table.schema
@@ -113,7 +119,7 @@ async function handleViewEvents(existingView: View, newView: View) {
113
119
 
114
120
  export async function destroy(ctx: BBContext) {
115
121
  const db = context.getAppDB()
116
- const viewName = decodeURIComponent(ctx.params.viewName)
122
+ const viewName = decodeURI(ctx.params.viewName)
117
123
  const view = await deleteView(viewName)
118
124
  const table = await db.get(view.meta.tableId)
119
125
  delete table.views[viewName]
@@ -124,7 +130,7 @@ export async function destroy(ctx: BBContext) {
124
130
  }
125
131
 
126
132
  export async function exportView(ctx: BBContext) {
127
- const viewName = decodeURIComponent(ctx.query.view as string)
133
+ const viewName = decodeURI(ctx.query.view as string)
128
134
  const view = await getView(viewName)
129
135
 
130
136
  const format = ctx.query.format as string
@@ -6,6 +6,7 @@ type ViewTemplateOpts = {
6
6
  groupBy: string
7
7
  filters: ViewFilter[]
8
8
  calculation: string
9
+ groupByMulti: boolean
9
10
  }
10
11
 
11
12
  const TOKEN_MAP: Record<string, string> = {
@@ -41,6 +42,12 @@ const GROUP_PROPERTY: Record<string, { type: string }> = {
41
42
  },
42
43
  }
43
44
 
45
+ const GROUP_PROPERTY_MULTI: Record<string, { type: string }> = {
46
+ group: {
47
+ type: "array",
48
+ },
49
+ }
50
+
44
51
  const FIELD_PROPERTY: Record<string, { type: string }> = {
45
52
  field: {
46
53
  type: "string",
@@ -136,13 +143,10 @@ function parseEmitExpression(field: string, groupBy: string) {
136
143
  * filters: Array of filter objects containing predicates that are parsed into a JS expression
137
144
  * calculation: an optional calculation to be performed over the view data.
138
145
  */
139
- export = function ({
140
- field,
141
- tableId,
142
- groupBy,
143
- filters = [],
144
- calculation,
145
- }: ViewTemplateOpts) {
146
+ export = function (
147
+ { field, tableId, groupBy, filters = [], calculation }: ViewTemplateOpts,
148
+ groupByMulti?: boolean
149
+ ) {
146
150
  // first filter can't have a conjunction
147
151
  if (filters && filters.length > 0 && filters[0].conjunction) {
148
152
  delete filters[0].conjunction
@@ -151,9 +155,11 @@ export = function ({
151
155
  let schema = null,
152
156
  statFilter = null
153
157
 
158
+ let groupBySchema = groupByMulti ? GROUP_PROPERTY_MULTI : GROUP_PROPERTY
159
+
154
160
  if (calculation) {
155
161
  schema = {
156
- ...(groupBy ? GROUP_PROPERTY : FIELD_PROPERTY),
162
+ ...(groupBy ? groupBySchema : FIELD_PROPERTY),
157
163
  ...SCHEMA_MAP[calculation],
158
164
  }
159
165
  if (
@@ -1,6 +1,5 @@
1
1
  import Router from "@koa/router"
2
2
  import * as controller from "../controllers/application"
3
- import * as deploymentController from "../controllers/deploy"
4
3
  import authorized from "../../middleware/authorized"
5
4
  import { permissions } from "@budibase/backend-core"
6
5
  import { applicationValidator } from "./utils/validators"
@@ -38,16 +37,6 @@ router
38
37
  authorized(permissions.BUILDER),
39
38
  controller.revertClient
40
39
  )
41
- .post(
42
- "/api/applications/:appId/publish",
43
- authorized(permissions.BUILDER),
44
- deploymentController.publishApp
45
- )
46
- .post(
47
- "/api/applications/:appId/unpublish",
48
- authorized(permissions.BUILDER),
49
- controller.unpublish
50
- )
51
40
  .delete(
52
41
  "/api/applications/:appId",
53
42
  authorized(permissions.BUILDER),
@@ -16,5 +16,6 @@ router
16
16
  authorized(permissions.BUILDER),
17
17
  controller.deploymentProgress
18
18
  )
19
+ .post("/api/deploy", authorized(permissions.BUILDER), controller.deployApp)
19
20
 
20
21
  export = router
@@ -26,14 +26,13 @@ import cloudRoutes from "./cloud"
26
26
  import migrationRoutes from "./migrations"
27
27
  import pluginRoutes from "./plugin"
28
28
  import Router from "@koa/router"
29
- import { api as pro } from "@budibase/pro"
29
+ import { api } from "@budibase/pro"
30
30
 
31
31
  export { default as staticRoutes } from "./static"
32
32
  export { default as publicRoutes } from "./public"
33
33
 
34
- const appBackupRoutes = pro.appBackups
35
- const scheduleRoutes = pro.schedules
36
-
34
+ const appBackupRoutes = api.appBackups
35
+ const scheduleRoutes = api.schedules
37
36
  export const mainRoutes: Router[] = [
38
37
  appBackupRoutes,
39
38
  backupRoutes,
@@ -1,7 +1,6 @@
1
1
  import controller from "../../controllers/public/applications"
2
2
  import Endpoint from "./utils/Endpoint"
3
3
  const { nameValidator, applicationValidator } = require("../utils/validators")
4
- import { db } from "@budibase/backend-core"
5
4
 
6
5
  const read = [],
7
6
  write = []
@@ -95,49 +94,6 @@ write.push(
95
94
  */
96
95
  write.push(new Endpoint("delete", "/applications/:appId", controller.destroy))
97
96
 
98
- /**
99
- * @openapi
100
- * /applications/{appId}/unpublish:
101
- * post:
102
- * operationId: unpublish
103
- * summary: Unpublish an application
104
- * tags:
105
- * - applications
106
- * parameters:
107
- * - $ref: '#/components/parameters/appIdUrl'
108
- * responses:
109
- * 204:
110
- * description: The app was published successfully.
111
- */
112
- write.push(
113
- new Endpoint("post", "/applications/:appId/unpublish", controller.unpublish)
114
- )
115
-
116
- /**
117
- * @openapi
118
- * /applications/{appId}/publish:
119
- * post:
120
- * operationId: publish
121
- * summary: Unpublish an application
122
- * tags:
123
- * - applications
124
- * parameters:
125
- * - $ref: '#/components/parameters/appIdUrl'
126
- * responses:
127
- * 200:
128
- * description: Returns the deployment object.
129
- * content:
130
- * application/json:
131
- * schema:
132
- * $ref: '#/components/schemas/deploymentOutput'
133
- * examples:
134
- * deployment:
135
- * $ref: '#/components/examples/deploymentOutput'
136
- */
137
- write.push(
138
- new Endpoint("post", "/applications/:appId/publish", controller.publish)
139
- )
140
-
141
97
  /**
142
98
  * @openapi
143
99
  * /applications/{appId}:
@@ -54,13 +54,9 @@ function processQueries(ctx: any) {
54
54
  }
55
55
 
56
56
  export default async (ctx: any, next: any) => {
57
- if (!ctx.body) {
58
- return await next()
59
- }
60
57
  let urlParts = ctx.url.split("/")
61
58
  urlParts = urlParts.slice(4, urlParts.length)
62
59
  let body = {}
63
-
64
60
  switch (urlParts[0]) {
65
61
  case Resources.APPLICATION:
66
62
  body = processApplications(ctx)
@@ -11,11 +11,14 @@ jest.mock("../../../utilities/redis", () => ({
11
11
  checkDebounce: jest.fn(),
12
12
  shutdown: jest.fn(),
13
13
  }))
14
- import { clearAllApps, checkBuilderEndpoint } from "./utilities/TestFunctions"
15
- import * as setup from "./utilities"
16
- import { AppStatus } from "../../../db/utils"
17
- import { events } from "@budibase/backend-core"
18
- import env from "../../../environment"
14
+
15
+ const {
16
+ clearAllApps,
17
+ checkBuilderEndpoint,
18
+ } = require("./utilities/TestFunctions")
19
+ const setup = require("./utilities")
20
+ const { AppStatus } = require("../../../db/utils")
21
+ const { events } = require("@budibase/backend-core")
19
22
 
20
23
  describe("/applications", () => {
21
24
  let request = setup.getRequest()
@@ -159,30 +162,33 @@ describe("/applications", () => {
159
162
  })
160
163
  })
161
164
 
162
- describe("publish", () => {
163
- it("should publish app with dev app ID", async () => {
165
+ describe("delete", () => {
166
+ it("should delete app", async () => {
167
+ await config.createApp("to-delete")
164
168
  const appId = config.getAppId()
165
169
  await request
166
- .post(`/api/applications/${appId}/publish`)
170
+ .delete(`/api/applications/${appId}`)
167
171
  .set(config.defaultHeaders())
168
172
  .expect("Content-Type", /json/)
169
173
  .expect(200)
170
- expect(events.app.published).toBeCalledTimes(1)
174
+ expect(events.app.deleted).toBeCalledTimes(1)
171
175
  })
172
176
 
173
- it("should publish app with prod app ID", async () => {
177
+ it("should unpublish app", async () => {
178
+ await config.createApp("to-unpublish")
174
179
  const appId = config.getProdAppId()
175
180
  await request
176
- .post(`/api/applications/${appId}/publish`)
181
+ .delete(`/api/applications/${appId}?unpublish=true`)
177
182
  .set(config.defaultHeaders())
178
183
  .expect("Content-Type", /json/)
179
184
  .expect(200)
180
- expect(events.app.published).toBeCalledTimes(1)
185
+ expect(events.app.unpublished).toBeCalledTimes(1)
181
186
  })
182
187
  })
183
188
 
184
189
  describe("manage client library version", () => {
185
190
  it("should be able to update the app client library version", async () => {
191
+ console.log(config.getAppId())
186
192
  await request
187
193
  .post(`/api/applications/${config.getAppId()}/client/update`)
188
194
  .set(config.defaultHeaders())
@@ -190,7 +196,6 @@ describe("/applications", () => {
190
196
  .expect(200)
191
197
  expect(events.app.versionUpdated).toBeCalledTimes(1)
192
198
  })
193
-
194
199
  it("should be able to revert the app client library version", async () => {
195
200
  // We need to first update the version so that we can then revert
196
201
  await request
@@ -229,85 +234,4 @@ describe("/applications", () => {
229
234
  expect(getRes.body.application.updatedAt).toBeDefined()
230
235
  })
231
236
  })
232
-
233
- describe("sync", () => {
234
- it("app should sync correctly", async () => {
235
- const res = await request
236
- .post(`/api/applications/${config.getAppId()}/sync`)
237
- .set(config.defaultHeaders())
238
- .expect("Content-Type", /json/)
239
- .expect(200)
240
- expect(res.body.message).toEqual("App sync completed successfully.")
241
- })
242
-
243
- it("app should not sync if production", async () => {
244
- const res = await request
245
- .post(`/api/applications/app_123456/sync`)
246
- .set(config.defaultHeaders())
247
- .expect("Content-Type", /json/)
248
- .expect(400)
249
- expect(res.body.message).toEqual(
250
- "This action cannot be performed for production apps"
251
- )
252
- })
253
-
254
- it("app should not sync if sync is disabled", async () => {
255
- env._set("DISABLE_AUTO_PROD_APP_SYNC", true)
256
- const res = await request
257
- .post(`/api/applications/${config.getAppId()}/sync`)
258
- .set(config.defaultHeaders())
259
- .expect("Content-Type", /json/)
260
- .expect(200)
261
- expect(res.body.message).toEqual(
262
- "App sync disabled. You can reenable with the DISABLE_AUTO_PROD_APP_SYNC environment variable."
263
- )
264
- env._set("DISABLE_AUTO_PROD_APP_SYNC", false)
265
- })
266
- })
267
-
268
- describe("unpublish", () => {
269
- it("should unpublish app with dev app ID", async () => {
270
- const appId = config.getAppId()
271
- await request
272
- .post(`/api/applications/${appId}/unpublish`)
273
- .set(config.defaultHeaders())
274
- .expect(204)
275
- expect(events.app.unpublished).toBeCalledTimes(1)
276
- })
277
-
278
- it("should unpublish app with prod app ID", async () => {
279
- const appId = config.getProdAppId()
280
- await request
281
- .post(`/api/applications/${appId}/unpublish`)
282
- .set(config.defaultHeaders())
283
- .expect(204)
284
- expect(events.app.unpublished).toBeCalledTimes(1)
285
- })
286
- })
287
-
288
- describe("delete", () => {
289
- it("should delete published app and dev apps with dev app ID", async () => {
290
- await config.createApp("to-delete")
291
- const appId = config.getAppId()
292
- await request
293
- .delete(`/api/applications/${appId}`)
294
- .set(config.defaultHeaders())
295
- .expect("Content-Type", /json/)
296
- .expect(200)
297
- expect(events.app.deleted).toBeCalledTimes(1)
298
- expect(events.app.unpublished).toBeCalledTimes(1)
299
- })
300
-
301
- it("should delete published app and dev app with prod app ID", async () => {
302
- await config.createApp("to-delete")
303
- const appId = config.getProdAppId()
304
- await request
305
- .delete(`/api/applications/${appId}`)
306
- .set(config.defaultHeaders())
307
- .expect("Content-Type", /json/)
308
- .expect(200)
309
- expect(events.app.deleted).toBeCalledTimes(1)
310
- expect(events.app.unpublished).toBeCalledTimes(1)
311
- })
312
- })
313
237
  })