@budibase/server 1.0.49-alpha.2 → 1.0.49-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/__mocks__/arangojs.ts +1 -1
  2. package/__mocks__/aws-sdk.ts +4 -4
  3. package/__mocks__/mongodb.ts +4 -5
  4. package/__mocks__/mssql.ts +3 -3
  5. package/__mocks__/node-fetch.ts +2 -1
  6. package/__mocks__/pg.ts +3 -5
  7. package/builder/assets/{index.82e12602.js → index.1b905242.js} +1 -1
  8. package/builder/index.html +1 -1
  9. package/coverage/clover.xml +1917 -1929
  10. package/coverage/coverage-final.json +54 -54
  11. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/application.js.html +58 -37
  14. package/coverage/lcov-report/api/controllers/auth.js.html +11 -14
  15. package/coverage/lcov-report/api/controllers/automation.js.html +21 -51
  16. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/cloud.js.html +8 -11
  18. package/coverage/lcov-report/api/controllers/component.js.html +10 -13
  19. package/coverage/lcov-report/api/controllers/datasource.js.html +17 -23
  20. package/coverage/lcov-report/api/controllers/dev.js.html +6 -6
  21. package/coverage/lcov-report/api/controllers/index.html +52 -52
  22. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/layout.js.html +4 -4
  24. package/coverage/lcov-report/api/controllers/metadata.js.html +6 -21
  25. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/permission.js.html +6 -6
  27. package/coverage/lcov-report/api/controllers/query/index.html +10 -10
  28. package/coverage/lcov-report/api/controllers/query/index.js.html +21 -18
  29. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  31. package/coverage/lcov-report/api/controllers/routing.js.html +7 -10
  32. package/coverage/lcov-report/api/controllers/row/external.js.html +6 -12
  33. package/coverage/lcov-report/api/controllers/row/index.html +22 -22
  34. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/row/internal.js.html +37 -82
  36. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +19 -25
  37. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +14 -17
  38. package/coverage/lcov-report/api/controllers/row/utils.js.html +15 -12
  39. package/coverage/lcov-report/api/controllers/screen.js.html +10 -16
  40. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +20 -50
  42. package/coverage/lcov-report/api/controllers/table/external.js.html +15 -24
  43. package/coverage/lcov-report/api/controllers/table/index.html +37 -37
  44. package/coverage/lcov-report/api/controllers/table/index.js.html +7 -7
  45. package/coverage/lcov-report/api/controllers/table/internal.js.html +36 -45
  46. package/coverage/lcov-report/api/controllers/table/utils.js.html +40 -76
  47. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  48. package/coverage/lcov-report/api/controllers/user.js.html +26 -35
  49. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  50. package/coverage/lcov-report/api/controllers/view/index.html +16 -16
  51. package/coverage/lcov-report/api/controllers/view/index.js.html +15 -21
  52. package/coverage/lcov-report/api/controllers/view/utils.js.html +25 -10
  53. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  54. package/coverage/lcov-report/api/controllers/webhook.js.html +21 -15
  55. package/coverage/lcov-report/api/index.html +1 -1
  56. package/coverage/lcov-report/api/index.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/index.html +1 -1
  69. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  80. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  81. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  82. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  83. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  84. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  85. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  86. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  87. package/coverage/lcov-report/automations/actions.js.html +1 -1
  88. package/coverage/lcov-report/automations/automationUtils.js.html +4 -7
  89. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  90. package/coverage/lcov-report/automations/index.html +18 -18
  91. package/coverage/lcov-report/automations/index.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/createRow.js.html +2 -5
  94. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  100. package/coverage/lcov-report/automations/steps/index.html +1 -1
  101. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  102. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  103. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  104. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  105. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  106. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  107. package/coverage/lcov-report/automations/steps/updateRow.js.html +2 -2
  108. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  109. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  111. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  112. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  113. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  114. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  115. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  116. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  117. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  118. package/coverage/lcov-report/automations/triggers.js.html +46 -40
  119. package/coverage/lcov-report/automations/utils.js.html +24 -12
  120. package/coverage/lcov-report/constants/index.html +1 -1
  121. package/coverage/lcov-report/constants/index.js.html +1 -1
  122. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  123. package/coverage/lcov-report/constants/screens.js.html +1 -1
  124. package/coverage/lcov-report/db/client.js.html +18 -18
  125. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  126. package/coverage/lcov-report/db/index.html +1 -1
  127. package/coverage/lcov-report/db/index.js.html +3 -3
  128. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -23
  129. package/coverage/lcov-report/db/linkedRows/index.html +27 -27
  130. package/coverage/lcov-report/db/linkedRows/index.js.html +24 -66
  131. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +28 -28
  132. package/coverage/lcov-report/db/newid.js.html +1 -1
  133. package/coverage/lcov-report/db/utils.js.html +5 -5
  134. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  135. package/coverage/lcov-report/events/index.html +1 -1
  136. package/coverage/lcov-report/events/index.js.html +1 -1
  137. package/coverage/lcov-report/events/utils.js.html +1 -1
  138. package/coverage/lcov-report/index.html +88 -88
  139. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  140. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  141. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  142. package/coverage/lcov-report/middleware/authorized.js.html +21 -15
  143. package/coverage/lcov-report/middleware/builder.js.html +3 -3
  144. package/coverage/lcov-report/middleware/currentapp.js.html +72 -60
  145. package/coverage/lcov-report/middleware/index.html +28 -28
  146. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  147. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  148. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  149. package/coverage/lcov-report/middleware/usageQuota.js.html +29 -29
  150. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  151. package/coverage/lcov-report/threads/automation.js.html +30 -24
  152. package/coverage/lcov-report/threads/index.html +16 -16
  153. package/coverage/lcov-report/threads/index.js.html +1 -1
  154. package/coverage/lcov-report/threads/query.js.html +17 -17
  155. package/coverage/lcov-report/threads/utils.js.html +1 -1
  156. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  157. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  158. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  159. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  160. package/coverage/lcov-report/utilities/global.js.html +44 -35
  161. package/coverage/lcov-report/utilities/index.html +27 -27
  162. package/coverage/lcov-report/utilities/index.js.html +40 -70
  163. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  164. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  165. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  166. package/coverage/lcov-report/utilities/routing/index.js.html +7 -7
  167. package/coverage/lcov-report/utilities/rowProcessor/index.html +11 -11
  168. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +16 -58
  169. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  170. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  171. package/coverage/lcov-report/utilities/security.js.html +1 -1
  172. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  173. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  174. package/coverage/lcov-report/utilities/usageQuota/index.js.html +5 -2
  175. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +5 -2
  176. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  177. package/coverage/lcov-report/utilities/users.js.html +5 -5
  178. package/coverage/lcov-report/utilities/workerRequests.js.html +5 -5
  179. package/coverage/lcov.info +3189 -3198
  180. package/dist/api/controllers/application.js +31 -28
  181. package/dist/api/controllers/auth.js +4 -5
  182. package/dist/api/controllers/automation.js +14 -19
  183. package/dist/api/controllers/cloud.js +2 -3
  184. package/dist/api/controllers/component.js +3 -4
  185. package/dist/api/controllers/datasource.js +9 -10
  186. package/dist/api/controllers/deploy/Deployment.js +3 -6
  187. package/dist/api/controllers/deploy/index.js +12 -13
  188. package/dist/api/controllers/dev.js +5 -5
  189. package/dist/api/controllers/layout.js +3 -3
  190. package/dist/api/controllers/metadata.js +4 -4
  191. package/dist/api/controllers/permission.js +4 -4
  192. package/dist/api/controllers/query/import/index.js +4 -6
  193. package/dist/api/controllers/query/index.js +11 -10
  194. package/dist/api/controllers/role.js +5 -5
  195. package/dist/api/controllers/routing.js +5 -6
  196. package/dist/api/controllers/row/ExternalRequest.js +76 -63
  197. package/dist/api/controllers/row/external.js +4 -4
  198. package/dist/api/controllers/row/internal.js +29 -44
  199. package/dist/api/controllers/row/internalSearch.js +11 -13
  200. package/dist/api/controllers/row/staticFormula.js +11 -11
  201. package/dist/api/controllers/row/utils.js +7 -6
  202. package/dist/api/controllers/screen.js +5 -7
  203. package/dist/api/controllers/static/index.js +4 -4
  204. package/dist/api/controllers/table/bulkFormula.js +14 -15
  205. package/dist/api/controllers/table/external.js +7 -10
  206. package/dist/api/controllers/table/index.js +5 -5
  207. package/dist/api/controllers/table/internal.js +16 -19
  208. package/dist/api/controllers/table/utils.js +29 -31
  209. package/dist/api/controllers/user.js +16 -20
  210. package/dist/api/controllers/view/index.js +8 -10
  211. package/dist/api/controllers/view/utils.js +9 -4
  212. package/dist/api/controllers/webhook.js +10 -8
  213. package/dist/api/routes/tests/utilities/TestFunctions.js +37 -17
  214. package/dist/automations/automationUtils.js +2 -3
  215. package/dist/automations/steps/createRow.js +1 -1
  216. package/dist/automations/steps/updateRow.js +1 -1
  217. package/dist/automations/triggers.js +27 -25
  218. package/dist/automations/utils.js +10 -5
  219. package/dist/db/linkedRows/LinkController.js +3 -7
  220. package/dist/db/linkedRows/index.js +16 -26
  221. package/dist/db/linkedRows/linkUtils.js +6 -6
  222. package/dist/db/views/staticViews.js +9 -10
  223. package/dist/environment.js +2 -1
  224. package/dist/integrations/utils.js +3 -0
  225. package/dist/middleware/authorized.js +5 -3
  226. package/dist/middleware/builder.js +2 -2
  227. package/dist/middleware/currentapp.js +41 -37
  228. package/dist/middleware/usageQuota.js +2 -2
  229. package/dist/migrations/functions/appUrls.js +11 -2
  230. package/dist/migrations/functions/usageQuotas/syncApps.js +7 -9
  231. package/dist/migrations/functions/usageQuotas/syncRows.js +7 -9
  232. package/dist/package.json +4 -4
  233. package/dist/tests/utilities/TestConfiguration.js +67 -44
  234. package/dist/threads/automation.js +13 -11
  235. package/dist/threads/query.js +11 -11
  236. package/dist/tsconfig.tsbuildinfo +1 -1
  237. package/dist/utilities/fileSystem/index.js +4 -3
  238. package/dist/utilities/global.js +15 -12
  239. package/dist/utilities/index.js +7 -17
  240. package/dist/utilities/routing/index.js +5 -5
  241. package/dist/utilities/rowProcessor/index.js +9 -10
  242. package/dist/utilities/usageQuota/index.js +1 -0
  243. package/dist/utilities/usageQuota/rows.js +1 -0
  244. package/dist/utilities/users.js +3 -3
  245. package/dist/utilities/workerRequests.js +4 -4
  246. package/package.json +5 -5
  247. package/scripts/likeCypress.ts +1 -1
  248. package/src/api/controllers/application.js +35 -28
  249. package/src/api/controllers/auth.js +4 -5
  250. package/src/api/controllers/automation.js +13 -23
  251. package/src/api/controllers/cloud.js +2 -3
  252. package/src/api/controllers/component.js +3 -4
  253. package/src/api/controllers/datasource.js +9 -11
  254. package/src/api/controllers/deploy/Deployment.js +3 -7
  255. package/src/api/controllers/deploy/index.js +20 -13
  256. package/src/api/controllers/dev.js +5 -5
  257. package/src/api/controllers/layout.js +3 -3
  258. package/src/api/controllers/metadata.js +4 -9
  259. package/src/api/controllers/permission.js +4 -4
  260. package/src/api/controllers/query/import/index.ts +4 -6
  261. package/src/api/controllers/query/import/tests/index.spec.js +2 -1
  262. package/src/api/controllers/query/index.js +11 -10
  263. package/src/api/controllers/role.js +5 -5
  264. package/src/api/controllers/routing.js +5 -6
  265. package/src/api/controllers/row/ExternalRequest.ts +53 -42
  266. package/src/api/controllers/row/external.js +4 -6
  267. package/src/api/controllers/row/internal.js +29 -44
  268. package/src/api/controllers/row/internalSearch.js +11 -13
  269. package/src/api/controllers/row/staticFormula.js +10 -11
  270. package/src/api/controllers/row/utils.js +7 -6
  271. package/src/api/controllers/screen.js +5 -7
  272. package/src/api/controllers/static/index.js +4 -4
  273. package/src/api/controllers/table/bulkFormula.js +13 -23
  274. package/src/api/controllers/table/external.js +7 -10
  275. package/src/api/controllers/table/index.js +5 -5
  276. package/src/api/controllers/table/internal.js +18 -21
  277. package/src/api/controllers/table/utils.js +29 -41
  278. package/src/api/controllers/user.js +17 -20
  279. package/src/api/controllers/view/index.js +8 -10
  280. package/src/api/controllers/view/utils.js +9 -4
  281. package/src/api/controllers/webhook.js +10 -8
  282. package/src/api/routes/tests/automation.spec.js +1 -0
  283. package/src/api/routes/tests/misc.spec.js +0 -1
  284. package/src/api/routes/tests/routing.spec.js +21 -12
  285. package/src/api/routes/tests/row.spec.js +7 -4
  286. package/src/api/routes/tests/utilities/TestFunctions.js +39 -17
  287. package/src/automations/automationUtils.js +2 -3
  288. package/src/automations/steps/createRow.js +0 -1
  289. package/src/automations/steps/updateRow.js +1 -1
  290. package/src/automations/triggers.js +33 -31
  291. package/src/automations/utils.js +9 -5
  292. package/src/db/linkedRows/LinkController.js +3 -7
  293. package/src/db/linkedRows/index.js +16 -30
  294. package/src/db/linkedRows/linkUtils.js +6 -6
  295. package/src/db/tests/linkController.spec.js +0 -1
  296. package/src/db/tests/linkTests.spec.js +5 -6
  297. package/src/db/views/staticViews.js +8 -10
  298. package/src/environment.js +2 -1
  299. package/src/integrations/utils.ts +4 -1
  300. package/src/middleware/authorized.js +5 -3
  301. package/src/middleware/builder.js +2 -2
  302. package/src/middleware/currentapp.js +50 -46
  303. package/src/middleware/tests/authorized.spec.js +7 -2
  304. package/src/middleware/tests/currentapp.spec.js +6 -0
  305. package/src/middleware/usageQuota.js +2 -2
  306. package/src/migrations/functions/appUrls.ts +11 -2
  307. package/src/migrations/functions/usageQuotas/syncApps.ts +5 -4
  308. package/src/migrations/functions/usageQuotas/syncRows.ts +5 -4
  309. package/src/tests/utilities/TestConfiguration.js +69 -50
  310. package/src/threads/automation.js +17 -15
  311. package/src/threads/query.js +12 -12
  312. package/src/utilities/fileSystem/index.js +4 -3
  313. package/src/utilities/global.js +15 -12
  314. package/src/utilities/index.js +7 -17
  315. package/src/utilities/routing/index.js +5 -5
  316. package/src/utilities/rowProcessor/index.js +9 -23
  317. package/src/utilities/usageQuota/index.js +1 -0
  318. package/src/utilities/usageQuota/rows.js +1 -0
  319. package/src/utilities/users.js +3 -3
  320. package/src/utilities/workerRequests.js +4 -4
@@ -1,4 +1,3 @@
1
- const CouchDB = require("../db")
2
1
  const emitter = require("../events/index")
3
2
  const { getAutomationParams } = require("../db/utils")
4
3
  const { coerce } = require("../utilities/rowProcessor")
@@ -9,6 +8,7 @@ const { queue } = require("./bullboard")
9
8
  const { checkTestFlag } = require("../utilities/redis")
10
9
  const utils = require("./utils")
11
10
  const env = require("../environment")
11
+ const { doInAppContext, getAppDB } = require("@budibase/backend-core/context")
12
12
 
13
13
  const TRIGGER_DEFINITIONS = definitions
14
14
  const JOB_OPTS = {
@@ -21,39 +21,41 @@ async function queueRelevantRowAutomations(event, eventType) {
21
21
  throw `No appId specified for ${eventType} - check event emitters.`
22
22
  }
23
23
 
24
- const db = new CouchDB(event.appId)
25
- let automations = await db.allDocs(
26
- getAutomationParams(null, { include_docs: true })
27
- )
24
+ doInAppContext(event.appId, async () => {
25
+ const db = getAppDB()
26
+ let automations = await db.allDocs(
27
+ getAutomationParams(null, { include_docs: true })
28
+ )
28
29
 
29
- // filter down to the correct event type
30
- automations = automations.rows
31
- .map(automation => automation.doc)
32
- .filter(automation => {
33
- const trigger = automation.definition.trigger
34
- return trigger && trigger.event === eventType
35
- })
30
+ // filter down to the correct event type
31
+ automations = automations.rows
32
+ .map(automation => automation.doc)
33
+ .filter(automation => {
34
+ const trigger = automation.definition.trigger
35
+ return trigger && trigger.event === eventType
36
+ })
36
37
 
37
- for (let automation of automations) {
38
- let automationDef = automation.definition
39
- let automationTrigger = automationDef ? automationDef.trigger : {}
40
- // don't queue events which are for dev apps, only way to test automations is
41
- // running tests on them, in production the test flag will never
42
- // be checked due to lazy evaluation (first always false)
43
- if (
44
- !env.ALLOW_DEV_AUTOMATIONS &&
45
- isDevAppID(event.appId) &&
46
- !(await checkTestFlag(automation._id))
47
- ) {
48
- continue
38
+ for (let automation of automations) {
39
+ let automationDef = automation.definition
40
+ let automationTrigger = automationDef ? automationDef.trigger : {}
41
+ // don't queue events which are for dev apps, only way to test automations is
42
+ // running tests on them, in production the test flag will never
43
+ // be checked due to lazy evaluation (first always false)
44
+ if (
45
+ !env.ALLOW_DEV_AUTOMATIONS &&
46
+ isDevAppID(event.appId) &&
47
+ !(await checkTestFlag(automation._id))
48
+ ) {
49
+ continue
50
+ }
51
+ if (
52
+ automationTrigger.inputs &&
53
+ automationTrigger.inputs.tableId === event.row.tableId
54
+ ) {
55
+ await queue.add({ automation, event }, JOB_OPTS)
56
+ }
49
57
  }
50
- if (
51
- automationTrigger.inputs &&
52
- automationTrigger.inputs.tableId === event.row.tableId
53
- ) {
54
- await queue.add({ automation, event }, JOB_OPTS)
55
- }
56
- }
58
+ })
57
59
  }
58
60
 
59
61
  emitter.on("row:save", async function (event) {
@@ -6,8 +6,9 @@ const { queue } = require("./bullboard")
6
6
  const newid = require("../db/newid")
7
7
  const { updateEntityMetadata } = require("../utilities")
8
8
  const { MetadataTypes } = require("../constants")
9
- const { getDeployedAppID } = require("@budibase/backend-core/db")
9
+ const { getProdAppID } = require("@budibase/backend-core/db")
10
10
  const { cloneDeep } = require("lodash/fp")
11
+ const { getAppDB, getAppId } = require("@budibase/backend-core/context")
11
12
 
12
13
  const WH_STEP_ID = definitions.WEBHOOK.stepId
13
14
  const CRON_STEP_ID = definitions.CRON.stepId
@@ -27,7 +28,6 @@ exports.processEvent = async job => {
27
28
 
28
29
  exports.updateTestHistory = async (appId, automation, history) => {
29
30
  return updateEntityMetadata(
30
- appId,
31
31
  MetadataTypes.AUTOMATION_TEST_HISTORY,
32
32
  automation._id,
33
33
  metadata => {
@@ -93,6 +93,9 @@ exports.enableCronTrigger = async (appId, automation) => {
93
93
  )
94
94
  // Assign cron job ID from bull so we can remove it later if the cron trigger is removed
95
95
  trigger.cronJobId = job.id
96
+ // can't use getAppDB here as this is likely to be called from dev app,
97
+ // but this call could be for dev app or prod app, need to just use what
98
+ // was passed in
96
99
  const db = new CouchDB(appId)
97
100
  const response = await db.put(automation)
98
101
  automation._id = response.id
@@ -109,7 +112,8 @@ exports.enableCronTrigger = async (appId, automation) => {
109
112
  * @returns {Promise<object|undefined>} After this is complete the new automation object may have been updated and should be
110
113
  * written to DB (this does not write to DB as it would be wasteful to repeat).
111
114
  */
112
- exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
115
+ exports.checkForWebhooks = async ({ oldAuto, newAuto }) => {
116
+ const appId = getAppId()
113
117
  const oldTrigger = oldAuto ? oldAuto.definition.trigger : null
114
118
  const newTrigger = newAuto ? newAuto.definition.trigger : null
115
119
  const triggerChanged =
@@ -128,7 +132,7 @@ exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
128
132
  oldTrigger.webhookId
129
133
  ) {
130
134
  try {
131
- let db = new CouchDB(appId)
135
+ let db = getAppDB()
132
136
  // need to get the webhook to get the rev
133
137
  const webhook = await db.get(oldTrigger.webhookId)
134
138
  const ctx = {
@@ -166,7 +170,7 @@ exports.checkForWebhooks = async ({ appId, oldAuto, newAuto }) => {
166
170
  // the app ID has to be development for this endpoint
167
171
  // it can only be used when building the app
168
172
  // but the trigger endpoint will always be used in production
169
- const prodAppId = getDeployedAppID(appId)
173
+ const prodAppId = getProdAppID(appId)
170
174
  newTrigger.inputs = {
171
175
  schemaUrl: `api/webhooks/schema/${appId}/${id}`,
172
176
  triggerUrl: `api/webhooks/trigger/${prodAppId}/${id}`,
@@ -1,4 +1,3 @@
1
- const CouchDB = require("../index")
2
1
  const { IncludeDocs, getLinkDocuments } = require("./linkUtils")
3
2
  const {
4
3
  generateLinkID,
@@ -7,6 +6,7 @@ const {
7
6
  } = require("../utils")
8
7
  const Sentry = require("@sentry/node")
9
8
  const { FieldTypes, RelationshipTypes } = require("../../constants")
9
+ const { getAppDB } = require("@budibase/backend-core/context")
10
10
 
11
11
  /**
12
12
  * Creates a new link document structure which can be put to the database. It is important to
@@ -52,9 +52,8 @@ function LinkDocument(
52
52
  }
53
53
 
54
54
  class LinkController {
55
- constructor({ appId, tableId, row, table, oldTable }) {
56
- this._appId = appId
57
- this._db = new CouchDB(appId)
55
+ constructor({ tableId, row, table, oldTable }) {
56
+ this._db = getAppDB()
58
57
  this._tableId = tableId
59
58
  this._row = row
60
59
  this._table = table
@@ -99,7 +98,6 @@ class LinkController {
99
98
  */
100
99
  getRowLinkDocs(rowId) {
101
100
  return getLinkDocuments({
102
- appId: this._appId,
103
101
  tableId: this._tableId,
104
102
  rowId,
105
103
  includeDocs: IncludeDocs.INCLUDE,
@@ -111,7 +109,6 @@ class LinkController {
111
109
  */
112
110
  getTableLinkDocs() {
113
111
  return getLinkDocuments({
114
- appId: this._appId,
115
112
  tableId: this._tableId,
116
113
  includeDocs: IncludeDocs.INCLUDE,
117
114
  })
@@ -230,7 +227,6 @@ class LinkController {
230
227
  if (linkedSchema.relationshipType === RelationshipTypes.ONE_TO_MANY) {
231
228
  let links = (
232
229
  await getLinkDocuments({
233
- appId: this._appId,
234
230
  tableId: field.tableId,
235
231
  rowId: linkId,
236
232
  includeDocs: IncludeDocs.EXCLUDE,
@@ -9,12 +9,12 @@ const {
9
9
  getLinkedTable,
10
10
  } = require("./linkUtils")
11
11
  const { flatten } = require("lodash")
12
- const CouchDB = require("../../db")
13
12
  const { FieldTypes } = require("../../constants")
14
13
  const { getMultiIDParams, USER_METDATA_PREFIX } = require("../../db/utils")
15
14
  const { partition } = require("lodash")
16
15
  const { getGlobalUsersFromMetadata } = require("../../utilities/global")
17
16
  const { processFormulas } = require("../../utilities/rowProcessor/utils")
17
+ const { getAppDB } = require("@budibase/backend-core/context")
18
18
 
19
19
  /**
20
20
  * This functionality makes sure that when rows with links are created, updated or deleted they are processed
@@ -48,14 +48,13 @@ function clearRelationshipFields(table, rows) {
48
48
  return rows
49
49
  }
50
50
 
51
- async function getLinksForRows(appId, rows) {
51
+ async function getLinksForRows(rows) {
52
52
  const tableIds = [...new Set(rows.map(el => el.tableId))]
53
53
  // start by getting all the link values for performance reasons
54
54
  const responses = flatten(
55
55
  await Promise.all(
56
56
  tableIds.map(tableId =>
57
57
  getLinkDocuments({
58
- appId,
59
58
  tableId: tableId,
60
59
  includeDocs: IncludeDocs.EXCLUDE,
61
60
  })
@@ -72,9 +71,9 @@ async function getLinksForRows(appId, rows) {
72
71
  )
73
72
  }
74
73
 
75
- async function getFullLinkedDocs(appId, links) {
74
+ async function getFullLinkedDocs(links) {
76
75
  // create DBs
77
- const db = new CouchDB(appId)
76
+ const db = getAppDB()
78
77
  const linkedRowIds = links.map(link => link.id)
79
78
  const uniqueRowIds = [...new Set(linkedRowIds)]
80
79
  let dbRows = (await db.allDocs(getMultiIDParams(uniqueRowIds))).rows.map(
@@ -88,7 +87,7 @@ async function getFullLinkedDocs(appId, links) {
88
87
  let [users, other] = partition(linked, linkRow =>
89
88
  linkRow._id.startsWith(USER_METDATA_PREFIX)
90
89
  )
91
- users = await getGlobalUsersFromMetadata(appId, users)
90
+ users = await getGlobalUsersFromMetadata(users)
92
91
  return [...other, ...users]
93
92
  }
94
93
 
@@ -96,20 +95,16 @@ async function getFullLinkedDocs(appId, links) {
96
95
  * Update link documents for a row or table - this is to be called by the API controller when a change is occurring.
97
96
  * @param {string} args.eventType states what type of change which is occurring, means this can be expanded upon in the
98
97
  * future quite easily (all updates go through one function).
99
- * @param {string} args.appId The ID of the instance in which the change is occurring.
100
98
  * @param {string} args.tableId The ID of the of the table which is being changed.
101
- * @param {object|null} args.row The row which is changing, e.g. created, updated or deleted.
102
- * @param {object|null} args.table If the table has already been retrieved this can be used to reduce database gets.
103
- * @param {object|null} args.oldTable If the table is being updated then the old table can be provided for differencing.
99
+ * @param {object|undefined} args.row The row which is changing, e.g. created, updated or deleted.
100
+ * @param {object|undefined} args.table If the table has already been retrieved this can be used to reduce database gets.
101
+ * @param {object|undefined} args.oldTable If the table is being updated then the old table can be provided for differencing.
104
102
  * @returns {Promise<object>} When the update is complete this will respond successfully. Returns the row for
105
103
  * row operations and the table for table operations.
106
104
  */
107
105
  exports.updateLinks = async function (args) {
108
- const { eventType, appId, row, tableId, table, oldTable } = args
106
+ const { eventType, row, tableId, table, oldTable } = args
109
107
  const baseReturnObj = row == null ? table : row
110
- if (appId == null) {
111
- throw "Cannot operate without an instance ID."
112
- }
113
108
  // make sure table ID is set
114
109
  if (tableId == null && table != null) {
115
110
  args.tableId = table._id
@@ -146,26 +141,23 @@ exports.updateLinks = async function (args) {
146
141
  /**
147
142
  * Given a table and a list of rows this will retrieve all of the attached docs and enrich them into the row.
148
143
  * This is required for formula fields, this may only be utilised internally (for now).
149
- * @param {string} appId The ID of the app which this request is in the context of.
150
144
  * @param {object} table The table from which the rows originated.
151
145
  * @param {array<object>} rows The rows which are to be enriched.
152
146
  * @return {Promise<*>} returns the rows with all of the enriched relationships on it.
153
147
  */
154
- exports.attachFullLinkedDocs = async (appId, table, rows) => {
148
+ exports.attachFullLinkedDocs = async (table, rows) => {
155
149
  const linkedTableIds = getLinkedTableIDs(table)
156
150
  if (linkedTableIds.length === 0) {
157
151
  return rows
158
152
  }
159
- // create DBs
160
- const db = new CouchDB(appId)
161
153
  // get all the links
162
- const links = (await getLinksForRows(appId, rows)).filter(link =>
154
+ const links = (await getLinksForRows(rows)).filter(link =>
163
155
  rows.some(row => row._id === link.thisId)
164
156
  )
165
157
  // clear any existing links that could be dupe'd
166
158
  rows = clearRelationshipFields(table, rows)
167
159
  // now get the docs and combine into the rows
168
- let linked = await getFullLinkedDocs(appId, links)
160
+ let linked = await getFullLinkedDocs(links)
169
161
  const linkedTables = []
170
162
  for (let row of rows) {
171
163
  for (let link of links.filter(link => link.thisId === row._id)) {
@@ -176,11 +168,7 @@ exports.attachFullLinkedDocs = async (appId, table, rows) => {
176
168
  if (linkedRow) {
177
169
  const linkedTableId =
178
170
  linkedRow.tableId || getRelatedTableForField(table, link.fieldName)
179
- const linkedTable = await getLinkedTable(
180
- db,
181
- linkedTableId,
182
- linkedTables
183
- )
171
+ const linkedTable = await getLinkedTable(linkedTableId, linkedTables)
184
172
  if (linkedTable) {
185
173
  row[link.fieldName].push(processFormulas(linkedTable, linkedRow))
186
174
  }
@@ -192,18 +180,16 @@ exports.attachFullLinkedDocs = async (appId, table, rows) => {
192
180
 
193
181
  /**
194
182
  * This function will take the given enriched rows and squash the links to only contain the primary display field.
195
- * @param {string} appId The app in which the tables/rows/links exist.
196
183
  * @param {object} table The table from which the rows originated.
197
184
  * @param {array<object>} enriched The pre-enriched rows (full docs) which are to be squashed.
198
185
  * @returns {Promise<Array>} The rows after having their links squashed to only contain the ID and primary display.
199
186
  */
200
- exports.squashLinksToPrimaryDisplay = async (appId, table, enriched) => {
201
- const db = new CouchDB(appId)
187
+ exports.squashLinksToPrimaryDisplay = async (table, enriched) => {
202
188
  // will populate this as we find them
203
189
  const linkedTables = [table]
204
190
  for (let row of enriched) {
205
191
  // this only fetches the table if its not already in array
206
- const rowTable = await getLinkedTable(db, row.tableId, linkedTables)
192
+ const rowTable = await getLinkedTable(row.tableId, linkedTables)
207
193
  for (let [column, schema] of Object.entries(rowTable.schema)) {
208
194
  if (schema.type !== FieldTypes.LINK || !Array.isArray(row[column])) {
209
195
  continue
@@ -211,7 +197,7 @@ exports.squashLinksToPrimaryDisplay = async (appId, table, enriched) => {
211
197
  const newLinks = []
212
198
  for (let link of row[column]) {
213
199
  const linkTblId = link.tableId || getRelatedTableForField(table, column)
214
- const linkedTable = await getLinkedTable(db, linkTblId, linkedTables)
200
+ const linkedTable = await getLinkedTable(linkTblId, linkedTables)
215
201
  const obj = { _id: link._id }
216
202
  if (link[linkedTable.primaryDisplay]) {
217
203
  obj.primaryDisplay = link[linkedTable.primaryDisplay]
@@ -1,8 +1,8 @@
1
- const CouchDB = require("../index")
2
1
  const Sentry = require("@sentry/node")
3
2
  const { ViewNames, getQueryIndex } = require("../utils")
4
3
  const { FieldTypes } = require("../../constants")
5
4
  const { createLinkView } = require("../views/staticViews")
5
+ const { getAppDB } = require("@budibase/backend-core/context")
6
6
 
7
7
  /**
8
8
  * Only needed so that boolean parameters are being used for includeDocs
@@ -17,7 +17,6 @@ exports.createLinkView = createLinkView
17
17
 
18
18
  /**
19
19
  * Gets the linking documents, not the linked documents themselves.
20
- * @param {string} args.appId The instance in which we are searching for linked rows.
21
20
  * @param {string} args.tableId The table which we are searching for linked rows against.
22
21
  * @param {string|null} args.fieldName The name of column/field which is being altered, only looking for
23
22
  * linking documents that are related to it. If this is not specified then the table level will be assumed.
@@ -30,8 +29,8 @@ exports.createLinkView = createLinkView
30
29
  * (if any).
31
30
  */
32
31
  exports.getLinkDocuments = async function (args) {
33
- const { appId, tableId, rowId, includeDocs } = args
34
- const db = new CouchDB(appId)
32
+ const { tableId, rowId, includeDocs } = args
33
+ const db = getAppDB()
35
34
  let params
36
35
  if (rowId != null) {
37
36
  params = { key: [tableId, rowId] }
@@ -68,7 +67,7 @@ exports.getLinkDocuments = async function (args) {
68
67
  } catch (err) {
69
68
  // check if the view doesn't exist, it should for all new instances
70
69
  if (err != null && err.name === "not_found") {
71
- await exports.createLinkView(appId)
70
+ await exports.createLinkView()
72
71
  return exports.getLinkDocuments(arguments[0])
73
72
  } else {
74
73
  /* istanbul ignore next */
@@ -89,7 +88,8 @@ exports.getLinkedTableIDs = table => {
89
88
  .map(column => column.tableId)
90
89
  }
91
90
 
92
- exports.getLinkedTable = async (db, id, tables) => {
91
+ exports.getLinkedTable = async (id, tables) => {
92
+ const db = getAppDB()
93
93
  let linkedTable = tables.find(table => table._id === id)
94
94
  if (linkedTable) {
95
95
  return linkedTable
@@ -20,7 +20,6 @@ describe("test the link controller", () => {
20
20
 
21
21
  function createLinkController(table, row = null, oldTable = null) {
22
22
  const linkConfig = {
23
- appId: config.getAppId(),
24
23
  tableId: table._id,
25
24
  table,
26
25
  }
@@ -1,8 +1,8 @@
1
1
  const TestConfig = require("../../tests/utilities/TestConfiguration")
2
- const { basicTable, basicLinkedRow } = require("../../tests/utilities/structures")
2
+ const { basicTable } = require("../../tests/utilities/structures")
3
3
  const linkUtils = require("../linkedRows/linkUtils")
4
- const links = require("../linkedRows")
5
4
  const CouchDB = require("../index")
5
+ const { getAppDB } = require("@budibase/backend-core/context")
6
6
 
7
7
  describe("test link functionality", () => {
8
8
  const config = new TestConfig(false)
@@ -11,18 +11,18 @@ describe("test link functionality", () => {
11
11
  let db, table
12
12
  beforeEach(async () => {
13
13
  await config.init()
14
- db = new CouchDB(config.getAppId())
14
+ db = getAppDB()
15
15
  table = await config.createTable()
16
16
  })
17
17
 
18
18
  it("should be able to retrieve a linked table from a list", async () => {
19
- const retrieved = await linkUtils.getLinkedTable(db, table._id, [table])
19
+ const retrieved = await linkUtils.getLinkedTable(table._id, [table])
20
20
  expect(retrieved._id).toBe(table._id)
21
21
  })
22
22
 
23
23
  it("should be able to retrieve a table from DB and update list", async () => {
24
24
  const tables = []
25
- const retrieved = await linkUtils.getLinkedTable(db, table._id, tables)
25
+ const retrieved = await linkUtils.getLinkedTable(table._id, tables)
26
26
  expect(retrieved._id).toBe(table._id)
27
27
  expect(tables[0]).toBeDefined()
28
28
  })
@@ -51,7 +51,6 @@ describe("test link functionality", () => {
51
51
  const db = new CouchDB("test")
52
52
  await db.put({ _id: "_design/database", views: {} })
53
53
  const output = await linkUtils.getLinkDocuments({
54
- appId: "test",
55
54
  tableId: "test",
56
55
  rowId: "test",
57
56
  includeDocs: false,
@@ -1,4 +1,4 @@
1
- const CouchDB = require("../index")
1
+ const { getAppDB } = require("@budibase/backend-core/context")
2
2
  const {
3
3
  DocumentTypes,
4
4
  SEPARATOR,
@@ -21,12 +21,11 @@ const SCREEN_PREFIX = DocumentTypes.SCREEN + SEPARATOR
21
21
  /**
22
22
  * Creates the link view for the instance, this will overwrite the existing one, but this should only
23
23
  * be called if it is found that the view does not exist.
24
- * @param {string} appId The instance to which the view should be added.
25
24
  * @returns {Promise<void>} The view now exists, please note that the next view of this query will actually build it,
26
25
  * so it may be slow.
27
26
  */
28
- exports.createLinkView = async appId => {
29
- const db = new CouchDB(appId)
27
+ exports.createLinkView = async () => {
28
+ const db = getAppDB()
30
29
  const designDoc = await db.get("_design/database")
31
30
  const view = {
32
31
  map: function (doc) {
@@ -57,8 +56,8 @@ exports.createLinkView = async appId => {
57
56
  await db.put(designDoc)
58
57
  }
59
58
 
60
- exports.createRoutingView = async appId => {
61
- const db = new CouchDB(appId)
59
+ exports.createRoutingView = async () => {
60
+ const db = getAppDB()
62
61
  const designDoc = await db.get("_design/database")
63
62
  const view = {
64
63
  // if using variables in a map function need to inject them before use
@@ -78,8 +77,8 @@ exports.createRoutingView = async appId => {
78
77
  await db.put(designDoc)
79
78
  }
80
79
 
81
- async function searchIndex(appId, indexName, fnString) {
82
- const db = new CouchDB(appId)
80
+ async function searchIndex(indexName, fnString) {
81
+ const db = getAppDB()
83
82
  const designDoc = await db.get("_design/database")
84
83
  designDoc.indexes = {
85
84
  [indexName]: {
@@ -90,9 +89,8 @@ async function searchIndex(appId, indexName, fnString) {
90
89
  await db.put(designDoc)
91
90
  }
92
91
 
93
- exports.createAllSearchIndex = async appId => {
92
+ exports.createAllSearchIndex = async () => {
94
93
  await searchIndex(
95
- appId,
96
94
  SearchIndexes.ROWS,
97
95
  function (doc) {
98
96
  function idx(input, prev) {
@@ -2,7 +2,8 @@ function isTest() {
2
2
  return (
3
3
  process.env.NODE_ENV === "jest" ||
4
4
  process.env.NODE_ENV === "cypress" ||
5
- process.env.JEST_WORKER_ID != null
5
+ (process.env.JEST_WORKER_ID != null &&
6
+ process.env.JEST_WORKER_ID !== "null")
6
7
  )
7
8
  }
8
9
 
@@ -52,7 +52,10 @@ export function buildExternalTableId(datasourceId: string, tableName: string) {
52
52
  return `${datasourceId}${DOUBLE_SEPARATOR}${tableName}`
53
53
  }
54
54
 
55
- export function breakExternalTableId(tableId: string) {
55
+ export function breakExternalTableId(tableId: string | undefined) {
56
+ if (!tableId) {
57
+ return {}
58
+ }
56
59
  const parts = tableId.split(DOUBLE_SEPARATOR)
57
60
  let tableName = parts.pop()
58
61
  // if they need joined
@@ -10,6 +10,7 @@ const {
10
10
  const builderMiddleware = require("./builder")
11
11
  const { isWebhookEndpoint } = require("./utils")
12
12
  const { buildCsrfMiddleware } = require("@budibase/backend-core/auth")
13
+ const { getAppId } = require("@budibase/backend-core/context")
13
14
 
14
15
  function hasResource(ctx) {
15
16
  return ctx.resourceId != null
@@ -45,7 +46,7 @@ const checkAuthorizedResource = async (
45
46
  ) => {
46
47
  // get the user's roles
47
48
  const roleId = ctx.roleId || BUILTIN_ROLE_IDS.PUBLIC
48
- const userRoles = await getUserRoleHierarchy(ctx.appId, roleId, {
49
+ const userRoles = await getUserRoleHierarchy(roleId, {
49
50
  idOnly: false,
50
51
  })
51
52
  const permError = "User does not have permission"
@@ -81,8 +82,9 @@ module.exports =
81
82
 
82
83
  // get the resource roles
83
84
  let resourceRoles = []
84
- if (ctx.appId && hasResource(ctx)) {
85
- resourceRoles = await getRequiredResourceRole(ctx.appId, permLevel, ctx)
85
+ const appId = getAppId()
86
+ if (appId && hasResource(ctx)) {
87
+ resourceRoles = await getRequiredResourceRole(permLevel, ctx)
86
88
  }
87
89
 
88
90
  // if the resource is public, proceed
@@ -5,7 +5,7 @@ const {
5
5
  checkDebounce,
6
6
  setDebounce,
7
7
  } = require("../utilities/redis")
8
- const CouchDB = require("../db")
8
+ const { getDB } = require("@budibase/backend-core/db")
9
9
  const { DocumentTypes } = require("../db/utils")
10
10
  const { PermissionTypes } = require("@budibase/backend-core/permissions")
11
11
  const { app: appCache } = require("@budibase/backend-core/cache")
@@ -48,7 +48,7 @@ async function updateAppUpdatedAt(ctx) {
48
48
  if (ctx.method === "GET" || (await checkDebounce(appId))) {
49
49
  return
50
50
  }
51
- const db = new CouchDB(appId)
51
+ const db = getDB(appId)
52
52
  const metadata = await db.get(DocumentTypes.APP_METADATA)
53
53
  metadata.updatedAt = new Date().toISOString()
54
54
  const response = await db.put(metadata)