@budibase/server 2.1.22-alpha.6 → 2.1.22-alpha.7

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 (419) hide show
  1. package/__mocks__/node-fetch.ts +5 -1
  2. package/builder/assets/{index.5ec5f06c.js → index.22484e23.js} +1 -1
  3. package/builder/index.html +1 -1
  4. package/coverage/clover.xml +1182 -1209
  5. package/coverage/coverage-final.json +35 -35
  6. package/coverage/lcov-report/index.html +94 -94
  7. package/coverage/lcov-report/src/api/controllers/analytics.ts.html +1 -1
  8. package/coverage/lcov-report/src/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/src/api/controllers/application.ts.html +45 -60
  10. package/coverage/lcov-report/src/api/controllers/auth.ts.html +7 -4
  11. package/coverage/lcov-report/src/api/controllers/automation.js.html +1 -1
  12. package/coverage/lcov-report/src/api/controllers/backup.ts.html +1 -1
  13. package/coverage/lcov-report/src/api/controllers/cloud.js.html +1 -1
  14. package/coverage/lcov-report/src/api/controllers/component.ts.html +1 -1
  15. package/coverage/lcov-report/src/api/controllers/datasource.js.html +1 -1
  16. package/coverage/lcov-report/src/api/controllers/deploy/Deployment.js.html +1 -1
  17. package/coverage/lcov-report/src/api/controllers/deploy/index.html +10 -10
  18. package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +19 -55
  19. package/coverage/lcov-report/src/api/controllers/{dev.js.html → dev.ts.html} +46 -64
  20. package/coverage/lcov-report/src/api/controllers/index.html +25 -25
  21. package/coverage/lcov-report/src/api/controllers/integration.js.html +1 -1
  22. package/coverage/lcov-report/src/api/controllers/layout.js.html +1 -1
  23. package/coverage/lcov-report/src/api/controllers/metadata.js.html +1 -1
  24. package/coverage/lcov-report/src/api/controllers/migrations.js.html +1 -1
  25. package/coverage/lcov-report/src/api/controllers/permission.js.html +1 -1
  26. package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +1 -1
  27. package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +1 -1
  28. package/coverage/lcov-report/src/api/controllers/plugin/index.html +1 -1
  29. package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +1 -1
  30. package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +1 -1
  31. package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +1 -1
  32. package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +1 -1
  33. package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +1 -1
  34. package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +37 -19
  35. package/coverage/lcov-report/src/api/controllers/public/index.html +16 -16
  36. package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +1 -1
  37. package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
  38. package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +1 -1
  39. package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +1 -1
  40. package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +1 -1
  41. package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +1 -1
  42. package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +1 -1
  43. package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +1 -1
  44. package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +1 -1
  45. package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +1 -1
  46. package/coverage/lcov-report/src/api/controllers/public/users.ts.html +1 -1
  47. package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +1 -1
  48. package/coverage/lcov-report/src/api/controllers/query/import/index.html +1 -1
  49. package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +1 -1
  50. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
  51. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +1 -1
  52. package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +1 -1
  53. package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +1 -1
  54. package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
  55. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +1 -1
  56. package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +1 -1
  57. package/coverage/lcov-report/src/api/controllers/query/index.html +10 -10
  58. package/coverage/lcov-report/src/api/controllers/query/index.ts.html +17 -26
  59. package/coverage/lcov-report/src/api/controllers/query/validation.js.html +1 -1
  60. package/coverage/lcov-report/src/api/controllers/role.js.html +1 -1
  61. package/coverage/lcov-report/src/api/controllers/routing.js.html +1 -1
  62. package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +1 -1
  63. package/coverage/lcov-report/src/api/controllers/row/external.js.html +1 -1
  64. package/coverage/lcov-report/src/api/controllers/row/index.html +1 -1
  65. package/coverage/lcov-report/src/api/controllers/row/index.ts.html +1 -1
  66. package/coverage/lcov-report/src/api/controllers/row/internal.js.html +3 -3
  67. package/coverage/lcov-report/src/api/controllers/row/internalSearch.js.html +1 -1
  68. package/coverage/lcov-report/src/api/controllers/row/staticFormula.js.html +1 -1
  69. package/coverage/lcov-report/src/api/controllers/row/utils.js.html +1 -1
  70. package/coverage/lcov-report/src/api/controllers/screen.ts.html +1 -1
  71. package/coverage/lcov-report/src/api/controllers/script.js.html +1 -1
  72. package/coverage/lcov-report/src/api/controllers/static/index.html +1 -1
  73. package/coverage/lcov-report/src/api/controllers/static/index.ts.html +1 -1
  74. package/coverage/lcov-report/src/api/controllers/table/bulkFormula.js.html +1 -1
  75. package/coverage/lcov-report/src/api/controllers/table/external.js.html +1 -1
  76. package/coverage/lcov-report/src/api/controllers/table/index.html +1 -1
  77. package/coverage/lcov-report/src/api/controllers/table/index.js.html +1 -1
  78. package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +1 -1
  79. package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +1 -1
  80. package/coverage/lcov-report/src/api/controllers/templates.js.html +1 -1
  81. package/coverage/lcov-report/src/api/controllers/user.js.html +1 -1
  82. package/coverage/lcov-report/src/api/controllers/view/exporters.js.html +1 -1
  83. package/coverage/lcov-report/src/api/controllers/view/index.html +1 -1
  84. package/coverage/lcov-report/src/api/controllers/view/index.js.html +1 -1
  85. package/coverage/lcov-report/src/api/controllers/view/utils.js.html +1 -1
  86. package/coverage/lcov-report/src/api/controllers/view/viewBuilder.js.html +1 -1
  87. package/coverage/lcov-report/src/api/controllers/webhook.ts.html +1 -1
  88. package/coverage/lcov-report/src/api/index.html +1 -1
  89. package/coverage/lcov-report/src/api/index.js.html +1 -1
  90. package/coverage/lcov-report/src/api/routes/analytics.js.html +1 -1
  91. package/coverage/lcov-report/src/api/routes/apikeys.js.html +1 -1
  92. package/coverage/lcov-report/src/api/routes/application.ts.html +1 -1
  93. package/coverage/lcov-report/src/api/routes/auth.ts.html +1 -1
  94. package/coverage/lcov-report/src/api/routes/automation.js.html +5 -5
  95. package/coverage/lcov-report/src/api/routes/backup.ts.html +1 -1
  96. package/coverage/lcov-report/src/api/routes/cloud.js.html +1 -1
  97. package/coverage/lcov-report/src/api/routes/component.js.html +1 -1
  98. package/coverage/lcov-report/src/api/routes/datasource.js.html +6 -6
  99. package/coverage/lcov-report/src/api/routes/deploy.js.html +1 -1
  100. package/coverage/lcov-report/src/api/routes/dev.js.html +1 -1
  101. package/coverage/lcov-report/src/api/routes/index.html +1 -1
  102. package/coverage/lcov-report/src/api/routes/index.ts.html +1 -1
  103. package/coverage/lcov-report/src/api/routes/integration.js.html +1 -1
  104. package/coverage/lcov-report/src/api/routes/layout.js.html +1 -1
  105. package/coverage/lcov-report/src/api/routes/metadata.js.html +1 -1
  106. package/coverage/lcov-report/src/api/routes/migrations.js.html +1 -1
  107. package/coverage/lcov-report/src/api/routes/permission.js.html +1 -1
  108. package/coverage/lcov-report/src/api/routes/plugin.ts.html +1 -1
  109. package/coverage/lcov-report/src/api/routes/public/applications.ts.html +1 -1
  110. package/coverage/lcov-report/src/api/routes/public/index.html +1 -1
  111. package/coverage/lcov-report/src/api/routes/public/index.ts.html +11 -11
  112. package/coverage/lcov-report/src/api/routes/public/middleware/index.html +1 -1
  113. package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +1 -1
  114. package/coverage/lcov-report/src/api/routes/public/queries.ts.html +1 -1
  115. package/coverage/lcov-report/src/api/routes/public/rows.ts.html +1 -1
  116. package/coverage/lcov-report/src/api/routes/public/tables.ts.html +1 -1
  117. package/coverage/lcov-report/src/api/routes/public/users.ts.html +1 -1
  118. package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +1 -1
  119. package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
  120. package/coverage/lcov-report/src/api/routes/query.js.html +6 -6
  121. package/coverage/lcov-report/src/api/routes/role.js.html +1 -1
  122. package/coverage/lcov-report/src/api/routes/routing.js.html +1 -1
  123. package/coverage/lcov-report/src/api/routes/row.ts.html +13 -13
  124. package/coverage/lcov-report/src/api/routes/screen.js.html +1 -1
  125. package/coverage/lcov-report/src/api/routes/script.js.html +1 -1
  126. package/coverage/lcov-report/src/api/routes/static.ts.html +6 -6
  127. package/coverage/lcov-report/src/api/routes/table.js.html +4 -4
  128. package/coverage/lcov-report/src/api/routes/templates.js.html +1 -1
  129. package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +1 -1
  130. package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +1 -1
  131. package/coverage/lcov-report/src/api/routes/tests/utilities/index.js.html +1 -1
  132. package/coverage/lcov-report/src/api/routes/user.js.html +11 -11
  133. package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
  134. package/coverage/lcov-report/src/api/routes/utils/validators.js.html +6 -6
  135. package/coverage/lcov-report/src/api/routes/view.js.html +4 -4
  136. package/coverage/lcov-report/src/api/routes/webhook.ts.html +1 -1
  137. package/coverage/lcov-report/src/app.ts.html +1 -1
  138. package/coverage/lcov-report/src/automations/actions.js.html +1 -1
  139. package/coverage/lcov-report/src/automations/automationUtils.js.html +1 -1
  140. package/coverage/lcov-report/src/automations/bullboard.js.html +1 -1
  141. package/coverage/lcov-report/src/automations/index.html +15 -15
  142. package/coverage/lcov-report/src/automations/index.js.html +1 -1
  143. package/coverage/lcov-report/src/automations/logging/index.html +1 -1
  144. package/coverage/lcov-report/src/automations/logging/index.ts.html +1 -1
  145. package/coverage/lcov-report/src/automations/steps/bash.js.html +1 -1
  146. package/coverage/lcov-report/src/automations/steps/createRow.ts.html +1 -1
  147. package/coverage/lcov-report/src/automations/steps/delay.js.html +1 -1
  148. package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +1 -1
  149. package/coverage/lcov-report/src/automations/steps/discord.js.html +1 -1
  150. package/coverage/lcov-report/src/automations/steps/executeQuery.js.html +1 -1
  151. package/coverage/lcov-report/src/automations/steps/executeScript.js.html +1 -1
  152. package/coverage/lcov-report/src/automations/steps/filter.js.html +1 -1
  153. package/coverage/lcov-report/src/automations/steps/index.html +1 -1
  154. package/coverage/lcov-report/src/automations/steps/integromat.js.html +1 -1
  155. package/coverage/lcov-report/src/automations/steps/loop.js.html +1 -1
  156. package/coverage/lcov-report/src/automations/steps/outgoingWebhook.js.html +1 -1
  157. package/coverage/lcov-report/src/automations/steps/queryRows.js.html +1 -1
  158. package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.js.html +1 -1
  159. package/coverage/lcov-report/src/automations/steps/serverLog.js.html +1 -1
  160. package/coverage/lcov-report/src/automations/steps/slack.js.html +1 -1
  161. package/coverage/lcov-report/src/automations/steps/updateRow.js.html +1 -1
  162. package/coverage/lcov-report/src/automations/steps/utils.js.html +1 -1
  163. package/coverage/lcov-report/src/automations/steps/zapier.js.html +1 -1
  164. package/coverage/lcov-report/src/automations/tests/utilities/index.html +17 -17
  165. package/coverage/lcov-report/src/automations/tests/utilities/index.js.html +33 -15
  166. package/coverage/lcov-report/src/automations/triggerInfo/app.js.html +1 -1
  167. package/coverage/lcov-report/src/automations/triggerInfo/cron.js.html +1 -1
  168. package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
  169. package/coverage/lcov-report/src/automations/triggerInfo/index.js.html +1 -1
  170. package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.js.html +1 -1
  171. package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.js.html +1 -1
  172. package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.js.html +1 -1
  173. package/coverage/lcov-report/src/automations/triggerInfo/webhook.js.html +1 -1
  174. package/coverage/lcov-report/src/automations/triggers.js.html +1 -1
  175. package/coverage/lcov-report/src/automations/utils.ts.html +20 -29
  176. package/coverage/lcov-report/src/constants/index.html +1 -1
  177. package/coverage/lcov-report/src/constants/index.js.html +1 -1
  178. package/coverage/lcov-report/src/constants/layouts.js.html +1 -1
  179. package/coverage/lcov-report/src/constants/screens.js.html +1 -1
  180. package/coverage/lcov-report/src/db/dynamoClient.js.html +1 -1
  181. package/coverage/lcov-report/src/db/inMemoryView.js.html +3 -3
  182. package/coverage/lcov-report/src/db/index.html +16 -16
  183. package/coverage/lcov-report/src/db/index.js.html +9 -9
  184. package/coverage/lcov-report/src/db/linkedRows/LinkController.js.html +1 -1
  185. package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
  186. package/coverage/lcov-report/src/db/linkedRows/index.js.html +1 -1
  187. package/coverage/lcov-report/src/db/linkedRows/linkUtils.js.html +1 -1
  188. package/coverage/lcov-report/src/db/newid.js.html +1 -1
  189. package/coverage/lcov-report/src/db/{utils.js.html → utils.ts.html} +97 -145
  190. package/coverage/lcov-report/src/definitions/automations.ts.html +1 -1
  191. package/coverage/lcov-report/src/definitions/datasource.ts.html +1 -1
  192. package/coverage/lcov-report/src/definitions/index.html +1 -1
  193. package/coverage/lcov-report/src/environment.js.html +4 -4
  194. package/coverage/lcov-report/src/events/AutomationEmitter.js.html +1 -1
  195. package/coverage/lcov-report/src/events/index.html +1 -1
  196. package/coverage/lcov-report/src/events/index.js.html +1 -1
  197. package/coverage/lcov-report/src/events/utils.js.html +1 -1
  198. package/coverage/lcov-report/src/index.html +1 -1
  199. package/coverage/lcov-report/src/index.ts.html +1 -1
  200. package/coverage/lcov-report/src/integrations/airtable.ts.html +1 -1
  201. package/coverage/lcov-report/src/integrations/arangodb.ts.html +1 -1
  202. package/coverage/lcov-report/src/integrations/base/index.html +1 -1
  203. package/coverage/lcov-report/src/integrations/base/query.ts.html +1 -1
  204. package/coverage/lcov-report/src/integrations/base/sql.ts.html +1 -1
  205. package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +1 -1
  206. package/coverage/lcov-report/src/integrations/base/utils.ts.html +1 -1
  207. package/coverage/lcov-report/src/integrations/couchdb.ts.html +1 -1
  208. package/coverage/lcov-report/src/integrations/dynamodb.ts.html +1 -1
  209. package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +1 -1
  210. package/coverage/lcov-report/src/integrations/firebase.ts.html +1 -1
  211. package/coverage/lcov-report/src/integrations/googlesheets.ts.html +10 -19
  212. package/coverage/lcov-report/src/integrations/index.html +11 -11
  213. package/coverage/lcov-report/src/integrations/index.ts.html +1 -1
  214. package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +1 -1
  215. package/coverage/lcov-report/src/integrations/mongodb.ts.html +1 -1
  216. package/coverage/lcov-report/src/integrations/mysql.ts.html +1 -1
  217. package/coverage/lcov-report/src/integrations/oracle.ts.html +1 -1
  218. package/coverage/lcov-report/src/integrations/postgres.ts.html +1 -1
  219. package/coverage/lcov-report/src/integrations/queries/index.html +1 -1
  220. package/coverage/lcov-report/src/integrations/queries/sql.ts.html +1 -1
  221. package/coverage/lcov-report/src/integrations/redis.ts.html +1 -1
  222. package/coverage/lcov-report/src/integrations/rest.ts.html +1 -1
  223. package/coverage/lcov-report/src/integrations/s3.ts.html +1 -1
  224. package/coverage/lcov-report/src/integrations/snowflake.ts.html +1 -1
  225. package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
  226. package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
  227. package/coverage/lcov-report/src/integrations/utils.ts.html +1 -1
  228. package/coverage/lcov-report/src/middleware/{appInfo.js.html → appInfo.ts.html} +24 -21
  229. package/coverage/lcov-report/src/middleware/authorized.ts.html +7 -7
  230. package/coverage/lcov-report/src/middleware/{builder.js.html → builder.ts.html} +36 -30
  231. package/coverage/lcov-report/src/middleware/{currentapp.js.html → currentapp.ts.html} +70 -61
  232. package/coverage/lcov-report/src/middleware/index.html +55 -55
  233. package/coverage/lcov-report/src/middleware/{joi-validator.js.html → joi-validator.ts.html} +18 -15
  234. package/coverage/lcov-report/src/middleware/{publicApi.js.html → publicApi.ts.html} +17 -17
  235. package/coverage/lcov-report/src/middleware/{resourceId.js.html → resourceId.ts.html} +33 -18
  236. package/coverage/lcov-report/src/middleware/{selfhost.js.html → selfhost.ts.html} +18 -12
  237. package/coverage/lcov-report/src/middleware/{utils.js.html → utils.ts.html} +12 -6
  238. package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +1 -1
  239. package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +1 -1
  240. package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +1 -1
  241. package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +4 -4
  242. package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +1 -1
  243. package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +1 -1
  244. package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +1 -1
  245. package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +1 -1
  246. package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +6 -15
  247. package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +1 -1
  248. package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +1 -1
  249. package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
  250. package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +1 -1
  251. package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +1 -1
  252. package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +1 -1
  253. package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
  254. package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +1 -1
  255. package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +1 -1
  256. package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
  257. package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +1 -1
  258. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +1 -1
  259. package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +1 -1
  260. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +1 -1
  261. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +1 -1
  262. package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +1 -1
  263. package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +1 -1
  264. package/coverage/lcov-report/src/migrations/index.html +1 -1
  265. package/coverage/lcov-report/src/migrations/index.ts.html +1 -1
  266. package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
  267. package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
  268. package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
  269. package/coverage/lcov-report/src/module.d.ts.html +1 -1
  270. package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
  271. package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +1 -1
  272. package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +1 -1
  273. package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +1 -1
  274. package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +1 -1
  275. package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +7 -16
  276. package/coverage/lcov-report/src/sdk/app/backups/index.html +1 -1
  277. package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +1 -1
  278. package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +12 -39
  279. package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
  280. package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +8 -11
  281. package/coverage/lcov-report/src/sdk/index.html +1 -1
  282. package/coverage/lcov-report/src/sdk/index.ts.html +1 -1
  283. package/coverage/lcov-report/src/startup.ts.html +1 -1
  284. package/coverage/lcov-report/src/tests/utilities/TestConfiguration.js.html +24 -24
  285. package/coverage/lcov-report/src/tests/utilities/controllers.js.html +1 -1
  286. package/coverage/lcov-report/src/tests/utilities/index.html +19 -19
  287. package/coverage/lcov-report/src/tests/utilities/index.js.html +1 -1
  288. package/coverage/lcov-report/src/tests/utilities/structures.js.html +3 -3
  289. package/coverage/lcov-report/src/threads/automation.ts.html +2 -2
  290. package/coverage/lcov-report/src/threads/index.html +1 -1
  291. package/coverage/lcov-report/src/threads/index.ts.html +1 -1
  292. package/coverage/lcov-report/src/threads/query.ts.html +1 -1
  293. package/coverage/lcov-report/src/threads/utils.ts.html +1 -1
  294. package/coverage/lcov-report/src/utilities/budibaseDir.js.html +1 -1
  295. package/coverage/lcov-report/src/utilities/centralPath.js.html +1 -1
  296. package/coverage/lcov-report/src/utilities/csvParser.js.html +1 -1
  297. package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.js.html +1 -1
  298. package/coverage/lcov-report/src/utilities/fileSystem/index.html +1 -1
  299. package/coverage/lcov-report/src/utilities/fileSystem/index.js.html +1 -1
  300. package/coverage/lcov-report/src/utilities/fileSystem/processor.js.html +1 -1
  301. package/coverage/lcov-report/src/utilities/fileSystem/utilities.js.html +1 -1
  302. package/coverage/lcov-report/src/utilities/{global.js.html → global.ts.html} +100 -67
  303. package/coverage/lcov-report/src/utilities/index.html +16 -16
  304. package/coverage/lcov-report/src/utilities/index.js.html +1 -1
  305. package/coverage/lcov-report/src/utilities/plugins.js.html +1 -1
  306. package/coverage/lcov-report/src/utilities/queue/inMemoryQueue.js.html +1 -1
  307. package/coverage/lcov-report/src/utilities/queue/index.html +1 -1
  308. package/coverage/lcov-report/src/utilities/redis.js.html +1 -1
  309. package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
  310. package/coverage/lcov-report/src/utilities/routing/index.js.html +1 -1
  311. package/coverage/lcov-report/src/utilities/rowProcessor/index.html +1 -1
  312. package/coverage/lcov-report/src/utilities/rowProcessor/index.js.html +1 -1
  313. package/coverage/lcov-report/src/utilities/rowProcessor/utils.js.html +1 -1
  314. package/coverage/lcov-report/src/utilities/scriptRunner.js.html +1 -1
  315. package/coverage/lcov-report/src/utilities/security.js.html +13 -13
  316. package/coverage/lcov-report/src/utilities/statusCodes.js.html +1 -1
  317. package/coverage/lcov-report/src/utilities/usageQuota/index.html +1 -1
  318. package/coverage/lcov-report/src/utilities/usageQuota/rows.js.html +1 -1
  319. package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  320. package/coverage/lcov-report/src/utilities/users.js.html +1 -1
  321. package/coverage/lcov-report/src/utilities/workerRequests.js.html +4 -4
  322. package/coverage/lcov-report/src/watch.ts.html +1 -1
  323. package/coverage/lcov-report/src/websocket.ts.html +1 -1
  324. package/coverage/lcov.info +2052 -2049
  325. package/dist/api/controllers/application.js +35 -43
  326. package/dist/api/controllers/deploy/index.js +13 -16
  327. package/dist/api/controllers/dev.js +96 -81
  328. package/dist/api/controllers/public/applications.js +17 -9
  329. package/dist/api/controllers/query/index.js +10 -13
  330. package/dist/api/controllers/row/internal.js +2 -2
  331. package/dist/api/routes/automation.js +3 -3
  332. package/dist/api/routes/datasource.js +4 -4
  333. package/dist/api/routes/public/index.js +9 -9
  334. package/dist/api/routes/query.js +4 -4
  335. package/dist/api/routes/row.js +11 -11
  336. package/dist/api/routes/static.js +3 -3
  337. package/dist/api/routes/table.js +2 -2
  338. package/dist/api/routes/user.js +9 -9
  339. package/dist/api/routes/utils/validators.js +4 -4
  340. package/dist/api/routes/view.js +2 -2
  341. package/dist/automations/tests/utilities/index.js +21 -12
  342. package/dist/automations/utils.js +9 -8
  343. package/dist/db/inMemoryView.js +2 -2
  344. package/dist/db/utils.js +145 -118
  345. package/dist/integrations/googlesheets.js +4 -6
  346. package/dist/middleware/appInfo.js +14 -9
  347. package/dist/middleware/authorized.js +5 -5
  348. package/dist/middleware/builder.js +41 -40
  349. package/dist/middleware/currentapp.js +39 -37
  350. package/dist/middleware/joi-validator.js +17 -10
  351. package/dist/middleware/publicApi.js +5 -6
  352. package/dist/middleware/resourceId.js +16 -9
  353. package/dist/middleware/selfhost.js +5 -4
  354. package/dist/middleware/utils.js +5 -2
  355. package/dist/package.json +6 -6
  356. package/dist/sdk/app/tables/index.js +4 -4
  357. package/dist/tests/utilities/TestConfiguration.js +9 -9
  358. package/dist/tests/utilities/structures.js +2 -2
  359. package/dist/tsconfig.build.tsbuildinfo +1 -1
  360. package/dist/utilities/global.js +87 -66
  361. package/dist/utilities/security.js +10 -10
  362. package/dist/utilities/workerRequests.js +3 -3
  363. package/jest.config.ts +1 -0
  364. package/package.json +7 -7
  365. package/src/api/controllers/application.ts +34 -39
  366. package/src/api/controllers/auth.ts +3 -2
  367. package/src/api/controllers/deploy/index.ts +13 -25
  368. package/src/api/controllers/{dev.js → dev.ts} +31 -37
  369. package/src/api/controllers/public/applications.ts +15 -9
  370. package/src/api/controllers/query/index.ts +11 -14
  371. package/src/api/controllers/row/internal.js +2 -2
  372. package/src/api/routes/automation.js +4 -4
  373. package/src/api/routes/datasource.js +5 -5
  374. package/src/api/routes/public/index.ts +10 -10
  375. package/src/api/routes/public/tests/compare.spec.js +1 -1
  376. package/src/api/routes/query.js +5 -5
  377. package/src/api/routes/row.ts +12 -12
  378. package/src/api/routes/static.ts +5 -5
  379. package/src/api/routes/table.js +3 -3
  380. package/src/api/routes/tests/analytics.spec.js +1 -1
  381. package/src/api/routes/tests/query.spec.js +15 -10
  382. package/src/api/routes/tests/role.spec.js +5 -5
  383. package/src/api/routes/tests/static.spec.js +2 -2
  384. package/src/api/routes/tests/table.spec.js +38 -35
  385. package/src/api/routes/user.js +10 -10
  386. package/src/api/routes/utils/validators.js +5 -5
  387. package/src/api/routes/view.js +3 -3
  388. package/src/automations/tests/updateRow.spec.js +0 -1
  389. package/src/automations/tests/utilities/index.js +10 -4
  390. package/src/automations/utils.ts +9 -12
  391. package/src/db/inMemoryView.js +2 -2
  392. package/src/db/tests/linkController.spec.js +73 -57
  393. package/src/db/tests/linkTests.spec.js +17 -14
  394. package/src/db/{utils.js → utils.ts} +76 -92
  395. package/src/integrations/googlesheets.ts +4 -7
  396. package/src/middleware/appInfo.ts +20 -0
  397. package/src/middleware/authorized.ts +6 -6
  398. package/src/middleware/{builder.js → builder.ts} +17 -15
  399. package/src/middleware/{currentapp.js → currentapp.ts} +42 -39
  400. package/src/middleware/{joi-validator.js → joi-validator.ts} +9 -8
  401. package/src/middleware/publicApi.ts +21 -0
  402. package/src/middleware/{resourceId.js → resourceId.ts} +16 -11
  403. package/src/middleware/{selfhost.js → selfhost.ts} +4 -2
  404. package/src/middleware/tests/authorized.spec.js +5 -5
  405. package/src/middleware/tests/currentapp.spec.js +118 -63
  406. package/src/middleware/{utils.js → utils.ts} +3 -1
  407. package/src/migrations/functions/backfill/app/tables.ts +2 -5
  408. package/src/sdk/app/backups/imports.ts +4 -7
  409. package/src/sdk/app/backups/statistics.ts +9 -18
  410. package/src/sdk/app/tables/index.ts +6 -7
  411. package/src/tests/utilities/TestConfiguration.js +9 -9
  412. package/src/tests/utilities/structures.js +2 -2
  413. package/src/threads/automation.ts +1 -1
  414. package/src/utilities/global.ts +138 -0
  415. package/src/utilities/security.js +12 -12
  416. package/src/utilities/workerRequests.js +3 -3
  417. package/src/middleware/appInfo.js +0 -19
  418. package/src/middleware/publicApi.js +0 -21
  419. package/src/utilities/global.js +0 -127
package/dist/db/utils.js CHANGED
@@ -1,87 +1,93 @@
1
1
  "use strict";
2
- const newid = require("./newid");
3
- const { DocumentType: CoreDocType, InternalTable, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, getDevelopmentAppID, generateAppID, getQueryIndex, ViewName, getDocParams, getRowParams, generateRowID, getUserMetadataParams, generateUserMetadataID, getGlobalIDFromUserMetadataID, } = require("@budibase/backend-core/db");
4
- const UNICODE_MAX = "\ufff0";
5
- const AppStatus = {
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.generateMemoryViewID = exports.getMetadataParams = exports.generateMetadataID = exports.generateUserFlagID = exports.getQueryParams = exports.getAutomationMetadataParams = exports.generateAutomationMetadataID = exports.generateQueryID = exports.getDatasourceParams = exports.generateDatasourceID = exports.getWebhookParams = exports.generateWebhookID = exports.getScreenParams = exports.generateScreenID = exports.getLayoutParams = exports.generateLayoutID = exports.getLinkParams = exports.generateLinkID = exports.generateAutomationID = exports.getAutomationParams = exports.getTableIDFromRowID = exports.generateTableID = exports.getTableParams = exports.getGlobalIDFromUserMetadataID = exports.generateUserMetadataID = exports.getUserMetadataParams = exports.generateRowID = exports.getRowParams = exports.getDocParams = exports.getQueryIndex = exports.getRoleParams = exports.generateRoleID = exports.generateDevAppID = exports.generateAppID = exports.UNICODE_MAX = exports.InternalTables = exports.ViewName = exports.TABLE_ROW_PREFIX = exports.LINK_USER_METADATA_PREFIX = exports.USER_METDATA_PREFIX = exports.isProdAppID = exports.isDevAppID = exports.APP_DEV_PREFIX = exports.APP_PREFIX = exports.DocumentType = exports.StaticDatabases = exports.SEPARATOR = exports.BudibaseInternalDB = exports.SearchIndexes = exports.AppStatus = void 0;
7
+ exports.getMultiIDParams = exports.generatePluginID = exports.getMemoryViewParams = void 0;
8
+ const newid_1 = __importDefault(require("./newid"));
9
+ const backend_core_1 = require("@budibase/backend-core");
10
+ exports.AppStatus = {
6
11
  DEV: "development",
7
12
  ALL: "all",
8
13
  DEPLOYED: "published",
9
14
  };
10
- const DocumentType = CoreDocType;
11
- const SearchIndexes = {
15
+ exports.SearchIndexes = {
12
16
  ROWS: "rows",
13
17
  };
14
- exports.StaticDatabases = StaticDatabases;
15
- const BudibaseInternalDB = {
18
+ exports.BudibaseInternalDB = {
16
19
  _id: "bb_internal",
17
20
  type: "budibase",
18
21
  name: "Budibase DB",
19
22
  source: "BUDIBASE",
20
23
  config: {},
21
24
  };
22
- exports.APP_PREFIX = APP_PREFIX;
23
- exports.APP_DEV_PREFIX = APP_DEV_PREFIX;
24
- exports.isDevAppID = isDevAppID;
25
- exports.isProdAppID = isProdAppID;
26
- exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`;
27
- exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`;
28
- exports.TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`;
29
- exports.ViewName = ViewName;
30
- exports.InternalTables = InternalTable;
31
- exports.DocumentType = DocumentType;
32
- exports.SEPARATOR = SEPARATOR;
33
- exports.UNICODE_MAX = UNICODE_MAX;
34
- exports.SearchIndexes = SearchIndexes;
35
- exports.AppStatus = AppStatus;
36
- exports.BudibaseInternalDB = BudibaseInternalDB;
37
- exports.generateAppID = generateAppID;
38
- exports.generateDevAppID = getDevelopmentAppID;
39
- exports.generateRoleID = generateRoleID;
40
- exports.getRoleParams = getRoleParams;
41
- exports.getQueryIndex = getQueryIndex;
42
- exports.getDocParams = getDocParams;
43
- exports.getRowParams = getRowParams;
44
- exports.generateRowID = generateRowID;
45
- exports.getUserMetadataParams = getUserMetadataParams;
46
- exports.generateUserMetadataID = generateUserMetadataID;
47
- exports.getGlobalIDFromUserMetadataID = getGlobalIDFromUserMetadataID;
25
+ exports.SEPARATOR = backend_core_1.db.SEPARATOR;
26
+ exports.StaticDatabases = backend_core_1.db.StaticDatabases;
27
+ exports.DocumentType = backend_core_1.db.DocumentType;
28
+ exports.APP_PREFIX = backend_core_1.db.APP_PREFIX;
29
+ exports.APP_DEV_PREFIX = backend_core_1.db.APP_DEV_PREFIX;
30
+ exports.isDevAppID = backend_core_1.db.isDevAppID;
31
+ exports.isProdAppID = backend_core_1.db.isProdAppID;
32
+ exports.USER_METDATA_PREFIX = `${exports.DocumentType.ROW}${exports.SEPARATOR}${backend_core_1.db.InternalTable.USER_METADATA}${exports.SEPARATOR}`;
33
+ exports.LINK_USER_METADATA_PREFIX = `${exports.DocumentType.LINK}${exports.SEPARATOR}${backend_core_1.db.InternalTable.USER_METADATA}${exports.SEPARATOR}`;
34
+ exports.TABLE_ROW_PREFIX = `${exports.DocumentType.ROW}${exports.SEPARATOR}${exports.DocumentType.TABLE}`;
35
+ exports.ViewName = backend_core_1.db.ViewName;
36
+ exports.InternalTables = backend_core_1.db.InternalTable;
37
+ exports.UNICODE_MAX = backend_core_1.db.UNICODE_MAX;
38
+ exports.generateAppID = backend_core_1.db.generateAppID;
39
+ exports.generateDevAppID = backend_core_1.db.getDevelopmentAppID;
40
+ exports.generateRoleID = backend_core_1.db.generateRoleID;
41
+ exports.getRoleParams = backend_core_1.db.getRoleParams;
42
+ exports.getQueryIndex = backend_core_1.db.getQueryIndex;
43
+ exports.getDocParams = backend_core_1.db.getDocParams;
44
+ exports.getRowParams = backend_core_1.db.getRowParams;
45
+ exports.generateRowID = backend_core_1.db.generateRowID;
46
+ exports.getUserMetadataParams = backend_core_1.db.getUserMetadataParams;
47
+ exports.generateUserMetadataID = backend_core_1.db.generateUserMetadataID;
48
+ exports.getGlobalIDFromUserMetadataID = backend_core_1.db.getGlobalIDFromUserMetadataID;
48
49
  /**
49
50
  * Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
50
51
  */
51
- exports.getTableParams = (tableId = null, otherProps = {}) => {
52
- return getDocParams(DocumentType.TABLE, tableId, otherProps);
53
- };
52
+ function getTableParams(tableId, otherProps = {}) {
53
+ return (0, exports.getDocParams)(exports.DocumentType.TABLE, tableId, otherProps);
54
+ }
55
+ exports.getTableParams = getTableParams;
54
56
  /**
55
57
  * Generates a new table ID.
56
58
  * @returns {string} The new table ID which the table doc can be stored under.
57
59
  */
58
- exports.generateTableID = () => {
59
- return `${DocumentType.TABLE}${SEPARATOR}${newid()}`;
60
- };
60
+ function generateTableID() {
61
+ return `${exports.DocumentType.TABLE}${exports.SEPARATOR}${(0, newid_1.default)()}`;
62
+ }
63
+ exports.generateTableID = generateTableID;
61
64
  /**
62
65
  * Given a row ID this will find the table ID within it (only works for internal tables).
63
66
  * @param {string} rowId The ID of the row.
64
67
  * @returns {string} The table ID.
65
68
  */
66
- exports.getTableIDFromRowID = rowId => {
69
+ function getTableIDFromRowID(rowId) {
67
70
  const components = rowId
68
- .split(DocumentType.TABLE + SEPARATOR)[1]
69
- .split(SEPARATOR);
70
- return `${DocumentType.TABLE}${SEPARATOR}${components[0]}`;
71
- };
71
+ .split(exports.DocumentType.TABLE + exports.SEPARATOR)[1]
72
+ .split(exports.SEPARATOR);
73
+ return `${exports.DocumentType.TABLE}${exports.SEPARATOR}${components[0]}`;
74
+ }
75
+ exports.getTableIDFromRowID = getTableIDFromRowID;
72
76
  /**
73
77
  * Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
74
78
  */
75
- exports.getAutomationParams = (automationId = null, otherProps = {}) => {
76
- return getDocParams(DocumentType.AUTOMATION, automationId, otherProps);
77
- };
79
+ function getAutomationParams(automationId, otherProps = {}) {
80
+ return (0, exports.getDocParams)(exports.DocumentType.AUTOMATION, automationId, otherProps);
81
+ }
82
+ exports.getAutomationParams = getAutomationParams;
78
83
  /**
79
84
  * Generates a new automation ID.
80
85
  * @returns {string} The new automation ID which the automation doc can be stored under.
81
86
  */
82
- exports.generateAutomationID = () => {
83
- return `${DocumentType.AUTOMATION}${SEPARATOR}${newid()}`;
84
- };
87
+ function generateAutomationID() {
88
+ return `${exports.DocumentType.AUTOMATION}${exports.SEPARATOR}${(0, newid_1.default)()}`;
89
+ }
90
+ exports.generateAutomationID = generateAutomationID;
85
91
  /**
86
92
  * Generates a new link doc ID. This is currently not usable with the alldocs call,
87
93
  * instead a view is built to make walking to tree easier.
@@ -93,131 +99,152 @@ exports.generateAutomationID = () => {
93
99
  * @param {string} fieldName2 the name of the field in the linked row.
94
100
  * @returns {string} The new link doc ID which the automation doc can be stored under.
95
101
  */
96
- exports.generateLinkID = (tableId1, tableId2, rowId1, rowId2, fieldName1, fieldName2) => {
97
- const tables = `${SEPARATOR}${tableId1}${SEPARATOR}${tableId2}`;
98
- const rows = `${SEPARATOR}${rowId1}${SEPARATOR}${rowId2}`;
99
- const fields = `${SEPARATOR}${fieldName1}${SEPARATOR}${fieldName2}`;
100
- return `${DocumentType.LINK}${tables}${rows}${fields}`;
101
- };
102
+ function generateLinkID(tableId1, tableId2, rowId1, rowId2, fieldName1, fieldName2) {
103
+ const tables = `${exports.SEPARATOR}${tableId1}${exports.SEPARATOR}${tableId2}`;
104
+ const rows = `${exports.SEPARATOR}${rowId1}${exports.SEPARATOR}${rowId2}`;
105
+ const fields = `${exports.SEPARATOR}${fieldName1}${exports.SEPARATOR}${fieldName2}`;
106
+ return `${exports.DocumentType.LINK}${tables}${rows}${fields}`;
107
+ }
108
+ exports.generateLinkID = generateLinkID;
102
109
  /**
103
110
  * Gets parameters for retrieving link docs, this is a utility function for the getDocParams function.
104
111
  */
105
- exports.getLinkParams = (otherProps = {}) => {
106
- return getDocParams(DocumentType.LINK, null, otherProps);
107
- };
112
+ function getLinkParams(otherProps = {}) {
113
+ return (0, exports.getDocParams)(exports.DocumentType.LINK, null, otherProps);
114
+ }
115
+ exports.getLinkParams = getLinkParams;
108
116
  /**
109
117
  * Generates a new layout ID.
110
118
  * @returns {string} The new layout ID which the layout doc can be stored under.
111
119
  */
112
- exports.generateLayoutID = id => {
113
- return `${DocumentType.LAYOUT}${SEPARATOR}${id || newid()}`;
114
- };
120
+ function generateLayoutID(id) {
121
+ return `${exports.DocumentType.LAYOUT}${exports.SEPARATOR}${id || (0, newid_1.default)()}`;
122
+ }
123
+ exports.generateLayoutID = generateLayoutID;
115
124
  /**
116
125
  * Gets parameters for retrieving layout, this is a utility function for the getDocParams function.
117
126
  */
118
- exports.getLayoutParams = (layoutId = null, otherProps = {}) => {
119
- return getDocParams(DocumentType.LAYOUT, layoutId, otherProps);
120
- };
127
+ function getLayoutParams(layoutId, otherProps = {}) {
128
+ return (0, exports.getDocParams)(exports.DocumentType.LAYOUT, layoutId, otherProps);
129
+ }
130
+ exports.getLayoutParams = getLayoutParams;
121
131
  /**
122
132
  * Generates a new screen ID.
123
133
  * @returns {string} The new screen ID which the screen doc can be stored under.
124
134
  */
125
- exports.generateScreenID = () => {
126
- return `${DocumentType.SCREEN}${SEPARATOR}${newid()}`;
127
- };
135
+ function generateScreenID() {
136
+ return `${exports.DocumentType.SCREEN}${exports.SEPARATOR}${(0, newid_1.default)()}`;
137
+ }
138
+ exports.generateScreenID = generateScreenID;
128
139
  /**
129
140
  * Gets parameters for retrieving screens, this is a utility function for the getDocParams function.
130
141
  */
131
- exports.getScreenParams = (screenId = null, otherProps = {}) => {
132
- return getDocParams(DocumentType.SCREEN, screenId, otherProps);
133
- };
142
+ function getScreenParams(screenId, otherProps = {}) {
143
+ return (0, exports.getDocParams)(exports.DocumentType.SCREEN, screenId, otherProps);
144
+ }
145
+ exports.getScreenParams = getScreenParams;
134
146
  /**
135
147
  * Generates a new webhook ID.
136
148
  * @returns {string} The new webhook ID which the webhook doc can be stored under.
137
149
  */
138
- exports.generateWebhookID = () => {
139
- return `${DocumentType.WEBHOOK}${SEPARATOR}${newid()}`;
140
- };
150
+ function generateWebhookID() {
151
+ return `${exports.DocumentType.WEBHOOK}${exports.SEPARATOR}${(0, newid_1.default)()}`;
152
+ }
153
+ exports.generateWebhookID = generateWebhookID;
141
154
  /**
142
155
  * Gets parameters for retrieving a webhook, this is a utility function for the getDocParams function.
143
156
  */
144
- exports.getWebhookParams = (webhookId = null, otherProps = {}) => {
145
- return getDocParams(DocumentType.WEBHOOK, webhookId, otherProps);
146
- };
157
+ function getWebhookParams(webhookId, otherProps = {}) {
158
+ return (0, exports.getDocParams)(exports.DocumentType.WEBHOOK, webhookId, otherProps);
159
+ }
160
+ exports.getWebhookParams = getWebhookParams;
147
161
  /**
148
162
  * Generates a new datasource ID.
149
163
  * @returns {string} The new datasource ID which the webhook doc can be stored under.
150
164
  */
151
- exports.generateDatasourceID = ({ plus = false } = {}) => {
152
- return `${plus ? DocumentType.DATASOURCE_PLUS : DocumentType.DATASOURCE}${SEPARATOR}${newid()}`;
153
- };
165
+ function generateDatasourceID({ plus = false } = {}) {
166
+ return `${plus ? exports.DocumentType.DATASOURCE_PLUS : exports.DocumentType.DATASOURCE}${exports.SEPARATOR}${(0, newid_1.default)()}`;
167
+ }
168
+ exports.generateDatasourceID = generateDatasourceID;
154
169
  /**
155
170
  * Gets parameters for retrieving a datasource, this is a utility function for the getDocParams function.
156
171
  */
157
- exports.getDatasourceParams = (datasourceId = null, otherProps = {}) => {
158
- return getDocParams(DocumentType.DATASOURCE, datasourceId, otherProps);
159
- };
172
+ function getDatasourceParams(datasourceId, otherProps = {}) {
173
+ return (0, exports.getDocParams)(exports.DocumentType.DATASOURCE, datasourceId, otherProps);
174
+ }
175
+ exports.getDatasourceParams = getDatasourceParams;
160
176
  /**
161
177
  * Generates a new query ID.
162
178
  * @returns {string} The new query ID which the query doc can be stored under.
163
179
  */
164
- exports.generateQueryID = datasourceId => {
165
- return `${DocumentType.QUERY}${SEPARATOR}${datasourceId}${SEPARATOR}${newid()}`;
166
- };
180
+ function generateQueryID(datasourceId) {
181
+ return `${exports.DocumentType.QUERY}${exports.SEPARATOR}${datasourceId}${exports.SEPARATOR}${(0, newid_1.default)()}`;
182
+ }
183
+ exports.generateQueryID = generateQueryID;
167
184
  /**
168
185
  * Generates a metadata ID for automations, used to track errors in recurring
169
186
  * automations etc.
170
187
  */
171
- exports.generateAutomationMetadataID = automationId => {
172
- return `${DocumentType.AUTOMATION_METADATA}${SEPARATOR}${automationId}`;
173
- };
188
+ function generateAutomationMetadataID(automationId) {
189
+ return `${exports.DocumentType.AUTOMATION_METADATA}${exports.SEPARATOR}${automationId}`;
190
+ }
191
+ exports.generateAutomationMetadataID = generateAutomationMetadataID;
174
192
  /**
175
193
  * Retrieve all automation metadata in an app database.
176
194
  */
177
- exports.getAutomationMetadataParams = (otherProps = {}) => {
178
- return getDocParams(DocumentType.AUTOMATION_METADATA, null, otherProps);
179
- };
195
+ function getAutomationMetadataParams(otherProps = {}) {
196
+ return (0, exports.getDocParams)(exports.DocumentType.AUTOMATION_METADATA, null, otherProps);
197
+ }
198
+ exports.getAutomationMetadataParams = getAutomationMetadataParams;
180
199
  /**
181
200
  * Gets parameters for retrieving a query, this is a utility function for the getDocParams function.
182
201
  */
183
- exports.getQueryParams = (datasourceId = null, otherProps = {}) => {
202
+ function getQueryParams(datasourceId, otherProps = {}) {
184
203
  if (datasourceId == null) {
185
- return getDocParams(DocumentType.QUERY, null, otherProps);
204
+ return (0, exports.getDocParams)(exports.DocumentType.QUERY, null, otherProps);
186
205
  }
187
- return getDocParams(DocumentType.QUERY, `${datasourceId}${SEPARATOR}`, otherProps);
188
- };
206
+ return (0, exports.getDocParams)(exports.DocumentType.QUERY, `${datasourceId}${exports.SEPARATOR}`, otherProps);
207
+ }
208
+ exports.getQueryParams = getQueryParams;
189
209
  /**
190
210
  * Generates a new flag document ID.
191
211
  * @returns {string} The ID of the flag document that was generated.
192
212
  */
193
- exports.generateUserFlagID = userId => {
194
- return `${DocumentType.USER_FLAG}${SEPARATOR}${userId}`;
195
- };
196
- exports.generateMetadataID = (type, entityId) => {
197
- return `${DocumentType.METADATA}${SEPARATOR}${type}${SEPARATOR}${entityId}`;
198
- };
199
- exports.getMetadataParams = (type, entityId = null, otherProps = {}) => {
200
- let docId = `${type}${SEPARATOR}`;
213
+ function generateUserFlagID(userId) {
214
+ return `${exports.DocumentType.USER_FLAG}${exports.SEPARATOR}${userId}`;
215
+ }
216
+ exports.generateUserFlagID = generateUserFlagID;
217
+ function generateMetadataID(type, entityId) {
218
+ return `${exports.DocumentType.METADATA}${exports.SEPARATOR}${type}${exports.SEPARATOR}${entityId}`;
219
+ }
220
+ exports.generateMetadataID = generateMetadataID;
221
+ function getMetadataParams(type, entityId, otherProps = {}) {
222
+ let docId = `${type}${exports.SEPARATOR}`;
201
223
  if (entityId != null) {
202
224
  docId += entityId;
203
225
  }
204
- return getDocParams(DocumentType.METADATA, docId, otherProps);
205
- };
206
- exports.generateMemoryViewID = viewName => {
207
- return `${DocumentType.MEM_VIEW}${SEPARATOR}${viewName}`;
208
- };
209
- exports.getMemoryViewParams = (otherProps = {}) => {
210
- return getDocParams(DocumentType.MEM_VIEW, null, otherProps);
211
- };
212
- exports.generatePluginID = name => {
213
- return `${DocumentType.PLUGIN}${SEPARATOR}${name}`;
214
- };
226
+ return (0, exports.getDocParams)(exports.DocumentType.METADATA, docId, otherProps);
227
+ }
228
+ exports.getMetadataParams = getMetadataParams;
229
+ function generateMemoryViewID(viewName) {
230
+ return `${exports.DocumentType.MEM_VIEW}${exports.SEPARATOR}${viewName}`;
231
+ }
232
+ exports.generateMemoryViewID = generateMemoryViewID;
233
+ function getMemoryViewParams(otherProps = {}) {
234
+ return (0, exports.getDocParams)(exports.DocumentType.MEM_VIEW, null, otherProps);
235
+ }
236
+ exports.getMemoryViewParams = getMemoryViewParams;
237
+ function generatePluginID(name) {
238
+ return `${exports.DocumentType.PLUGIN}${exports.SEPARATOR}${name}`;
239
+ }
240
+ exports.generatePluginID = generatePluginID;
215
241
  /**
216
242
  * This can be used with the db.allDocs to get a list of IDs
217
243
  */
218
- exports.getMultiIDParams = ids => {
244
+ function getMultiIDParams(ids) {
219
245
  return {
220
246
  keys: ids,
221
247
  include_docs: true,
222
248
  };
223
- };
249
+ }
250
+ exports.getMultiIDParams = getMultiIDParams;
@@ -18,9 +18,7 @@ const utils_1 = require("./utils");
18
18
  const constants_1 = require("../constants");
19
19
  const google_spreadsheet_1 = require("google-spreadsheet");
20
20
  const environment_1 = __importDefault(require("../environment"));
21
- const { getGlobalDB } = require("@budibase/backend-core/tenancy");
22
- const { getScopedConfig } = require("@budibase/backend-core/db");
23
- const { Configs } = require("@budibase/backend-core/constants");
21
+ const backend_core_1 = require("@budibase/backend-core");
24
22
  const fetch = require("node-fetch");
25
23
  const SCHEMA = {
26
24
  plus: true,
@@ -140,9 +138,9 @@ class GoogleSheetsIntegration {
140
138
  return __awaiter(this, void 0, void 0, function* () {
141
139
  try {
142
140
  // Initialise oAuth client
143
- const db = getGlobalDB();
144
- let googleConfig = yield getScopedConfig(db, {
145
- type: Configs.GOOGLE,
141
+ const db = backend_core_1.tenancy.getGlobalDB();
142
+ let googleConfig = yield backend_core_1.db.getScopedConfig(db, {
143
+ type: backend_core_1.constants.Config.GOOGLE,
146
144
  });
147
145
  if (!googleConfig) {
148
146
  googleConfig = {
@@ -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
+ };