@budibase/server 1.0.27-alpha.1 → 1.0.27-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/__mocks__/node-fetch.ts +18 -0
  2. package/builder/assets/{index.4a13c4cb.css → index.176f00e0.css} +1 -1
  3. package/builder/assets/index.5776ef20.js +1348 -0
  4. package/builder/index.html +2 -2
  5. package/coverage/clover.xml +1193 -1027
  6. package/coverage/coverage-final.json +72 -72
  7. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +3 -3
  9. package/coverage/lcov-report/api/controllers/application.js.html +73 -64
  10. package/coverage/lcov-report/api/controllers/auth.js.html +2 -2
  11. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/cloud.js.html +13 -4
  14. package/coverage/lcov-report/api/controllers/component.js.html +4 -4
  15. package/coverage/lcov-report/api/controllers/datasource.js.html +150 -48
  16. package/coverage/lcov-report/api/controllers/dev.js.html +3 -3
  17. package/coverage/lcov-report/api/controllers/hosting.js.html +3 -3
  18. package/coverage/lcov-report/api/controllers/index.html +20 -20
  19. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
  23. package/coverage/lcov-report/api/controllers/query/index.html +21 -21
  24. package/coverage/lcov-report/api/controllers/query/index.js.html +101 -122
  25. package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -3
  26. package/coverage/lcov-report/api/controllers/role.js.html +2 -2
  27. package/coverage/lcov-report/api/controllers/routing.js.html +2 -2
  28. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/index.html +22 -22
  30. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/internal.js.html +38 -11
  32. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -5
  33. package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -20
  34. package/coverage/lcov-report/api/controllers/screen.js.html +2 -2
  35. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/user.js.html +14 -5
  43. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  46. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  47. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  48. package/coverage/lcov-report/api/controllers/webhook.js.html +2 -2
  49. package/coverage/lcov-report/api/index.html +1 -1
  50. package/coverage/lcov-report/api/index.js.html +6 -6
  51. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/apikeys.js.html +2 -2
  53. package/coverage/lcov-report/api/routes/application.js.html +2 -2
  54. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/automation.js.html +2 -2
  56. package/coverage/lcov-report/api/routes/backup.js.html +2 -2
  57. package/coverage/lcov-report/api/routes/cloud.js.html +2 -2
  58. package/coverage/lcov-report/api/routes/component.js.html +2 -2
  59. package/coverage/lcov-report/api/routes/datasource.js.html +2 -2
  60. package/coverage/lcov-report/api/routes/deploy.js.html +2 -2
  61. package/coverage/lcov-report/api/routes/dev.js.html +2 -2
  62. package/coverage/lcov-report/api/routes/hosting.js.html +2 -2
  63. package/coverage/lcov-report/api/routes/index.html +1 -1
  64. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/integration.js.html +2 -2
  66. package/coverage/lcov-report/api/routes/layout.js.html +2 -2
  67. package/coverage/lcov-report/api/routes/metadata.js.html +2 -2
  68. package/coverage/lcov-report/api/routes/permission.js.html +12 -3
  69. package/coverage/lcov-report/api/routes/query.js.html +25 -4
  70. package/coverage/lcov-report/api/routes/role.js.html +2 -2
  71. package/coverage/lcov-report/api/routes/routing.js.html +2 -2
  72. package/coverage/lcov-report/api/routes/row.js.html +2 -2
  73. package/coverage/lcov-report/api/routes/screen.js.html +2 -2
  74. package/coverage/lcov-report/api/routes/script.js.html +2 -2
  75. package/coverage/lcov-report/api/routes/static.js.html +2 -2
  76. package/coverage/lcov-report/api/routes/table.js.html +2 -2
  77. package/coverage/lcov-report/api/routes/templates.js.html +2 -2
  78. package/coverage/lcov-report/api/routes/user.js.html +2 -2
  79. package/coverage/lcov-report/api/routes/view.js.html +2 -2
  80. package/coverage/lcov-report/api/routes/webhook.js.html +2 -2
  81. package/coverage/lcov-report/automations/actions.js.html +1 -1
  82. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  83. package/coverage/lcov-report/automations/bullboard.js.html +2 -2
  84. package/coverage/lcov-report/automations/index.html +1 -1
  85. package/coverage/lcov-report/automations/index.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/executeQuery.js.html +32 -8
  92. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/index.html +11 -11
  95. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  100. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  101. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  102. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  103. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  108. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  111. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  112. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  113. package/coverage/lcov-report/automations/utils.js.html +6 -6
  114. package/coverage/lcov-report/constants/index.html +1 -1
  115. package/coverage/lcov-report/constants/index.js.html +4 -4
  116. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  117. package/coverage/lcov-report/constants/screens.js.html +2 -2
  118. package/coverage/lcov-report/db/client.js.html +2 -2
  119. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  120. package/coverage/lcov-report/db/index.html +1 -1
  121. package/coverage/lcov-report/db/index.js.html +1 -1
  122. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  123. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  124. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  125. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  126. package/coverage/lcov-report/db/newid.js.html +2 -2
  127. package/coverage/lcov-report/db/utils.js.html +19 -19
  128. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  129. package/coverage/lcov-report/events/index.html +1 -1
  130. package/coverage/lcov-report/events/index.js.html +1 -1
  131. package/coverage/lcov-report/events/utils.js.html +1 -1
  132. package/coverage/lcov-report/index.html +64 -64
  133. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  134. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  135. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  136. package/coverage/lcov-report/middleware/authorized.js.html +12 -12
  137. package/coverage/lcov-report/middleware/builder.js.html +10 -10
  138. package/coverage/lcov-report/middleware/currentapp.js.html +48 -36
  139. package/coverage/lcov-report/middleware/index.html +1 -1
  140. package/coverage/lcov-report/middleware/joi-validator.js.html +9 -9
  141. package/coverage/lcov-report/middleware/resourceId.js.html +18 -18
  142. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  143. package/coverage/lcov-report/middleware/usageQuota.js.html +2 -2
  144. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  145. package/coverage/lcov-report/threads/automation.js.html +3 -3
  146. package/coverage/lcov-report/threads/index.html +31 -31
  147. package/coverage/lcov-report/threads/index.js.html +12 -12
  148. package/coverage/lcov-report/threads/query.js.html +369 -93
  149. package/coverage/lcov-report/threads/utils.js.html +359 -14
  150. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  151. package/coverage/lcov-report/utilities/budibaseDir.js.html +2 -2
  152. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  153. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  154. package/coverage/lcov-report/utilities/global.js.html +28 -19
  155. package/coverage/lcov-report/utilities/index.html +1 -1
  156. package/coverage/lcov-report/utilities/index.js.html +11 -11
  157. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
  158. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  159. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  160. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  161. package/coverage/lcov-report/utilities/rowProcessor/index.html +19 -19
  162. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +247 -10
  163. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  164. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  165. package/coverage/lcov-report/utilities/security.js.html +13 -4
  166. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  167. package/coverage/lcov-report/utilities/users.js.html +1 -1
  168. package/coverage/lcov-report/utilities/workerRequests.js.html +22 -22
  169. package/coverage/lcov.info +2027 -1725
  170. package/dist/api/controllers/apikeys.js +2 -2
  171. package/dist/api/controllers/application.js +4 -4
  172. package/dist/api/controllers/auth.js +1 -1
  173. package/dist/api/controllers/cloud.js +2 -2
  174. package/dist/api/controllers/datasource.js +29 -0
  175. package/dist/api/controllers/deploy/index.js +2 -2
  176. package/dist/api/controllers/dev.js +2 -2
  177. package/dist/api/controllers/hosting.js +2 -2
  178. package/dist/api/controllers/permission.js +2 -2
  179. package/dist/api/controllers/query/import/sources/base/index.js +2 -1
  180. package/dist/api/controllers/query/import/sources/curl.js +11 -5
  181. package/dist/api/controllers/query/import/sources/openapi2.js +8 -5
  182. package/dist/api/controllers/query/index.js +45 -47
  183. package/dist/api/controllers/query/validation.js +2 -1
  184. package/dist/api/controllers/role.js +1 -1
  185. package/dist/api/controllers/routing.js +1 -1
  186. package/dist/api/controllers/row/internal.js +14 -6
  187. package/dist/api/controllers/row/internalSearch.js +3 -2
  188. package/dist/api/controllers/row/utils.js +13 -6
  189. package/dist/api/controllers/screen.js +1 -1
  190. package/dist/api/controllers/user.js +3 -3
  191. package/dist/api/controllers/webhook.js +1 -1
  192. package/dist/api/index.js +1 -1
  193. package/dist/api/routes/apikeys.js +1 -1
  194. package/dist/api/routes/application.js +1 -1
  195. package/dist/api/routes/automation.js +1 -1
  196. package/dist/api/routes/backup.js +1 -1
  197. package/dist/api/routes/cloud.js +1 -1
  198. package/dist/api/routes/component.js +1 -1
  199. package/dist/api/routes/datasource.js +1 -1
  200. package/dist/api/routes/deploy.js +1 -1
  201. package/dist/api/routes/dev.js +1 -1
  202. package/dist/api/routes/hosting.js +1 -1
  203. package/dist/api/routes/integration.js +1 -1
  204. package/dist/api/routes/layout.js +1 -1
  205. package/dist/api/routes/metadata.js +1 -1
  206. package/dist/api/routes/permission.js +1 -1
  207. package/dist/api/routes/query.js +4 -2
  208. package/dist/api/routes/role.js +1 -1
  209. package/dist/api/routes/routing.js +1 -1
  210. package/dist/api/routes/row.js +1 -1
  211. package/dist/api/routes/screen.js +1 -1
  212. package/dist/api/routes/script.js +1 -1
  213. package/dist/api/routes/static.js +1 -1
  214. package/dist/api/routes/table.js +1 -1
  215. package/dist/api/routes/templates.js +1 -1
  216. package/dist/api/routes/tests/utilities/TestFunctions.js +1 -1
  217. package/dist/api/routes/user.js +1 -1
  218. package/dist/api/routes/view.js +1 -1
  219. package/dist/api/routes/webhook.js +1 -1
  220. package/dist/app.js +1 -1
  221. package/dist/automations/bullboard.js +1 -1
  222. package/dist/automations/steps/executeQuery.js +9 -2
  223. package/dist/automations/utils.js +1 -1
  224. package/dist/constants/index.js +3 -3
  225. package/dist/constants/screens.js +1 -1
  226. package/dist/db/client.js +1 -1
  227. package/dist/db/utils.js +1 -1
  228. package/dist/integrations/base/sqlTable.js +1 -1
  229. package/dist/integrations/rest.js +3 -3
  230. package/dist/middleware/authorized.js +2 -2
  231. package/dist/middleware/builder.js +2 -2
  232. package/dist/middleware/currentapp.js +6 -6
  233. package/dist/middleware/usageQuota.js +1 -1
  234. package/dist/package.json +5 -4
  235. package/dist/tests/utilities/TestConfiguration.js +55 -8
  236. package/dist/tests/utilities/structures.js +2 -2
  237. package/dist/threads/automation.js +2 -2
  238. package/dist/threads/query.js +148 -52
  239. package/dist/threads/utils.js +106 -1
  240. package/dist/tsconfig.tsbuildinfo +1 -1
  241. package/dist/utilities/budibaseDir.js +1 -1
  242. package/dist/utilities/fileSystem/utilities.js +2 -1
  243. package/dist/utilities/global.js +5 -5
  244. package/dist/utilities/index.js +1 -1
  245. package/dist/utilities/redis.js +1 -1
  246. package/dist/utilities/rowProcessor/index.js +76 -0
  247. package/dist/utilities/security.js +2 -2
  248. package/dist/utilities/usageQuota.js +2 -2
  249. package/dist/utilities/workerRequests.js +3 -3
  250. package/package.json +6 -5
  251. package/scripts/replicateApp.js +1 -1
  252. package/src/api/controllers/apikeys.js +2 -2
  253. package/src/api/controllers/application.js +7 -4
  254. package/src/api/controllers/auth.js +1 -1
  255. package/src/api/controllers/cloud.js +5 -2
  256. package/src/api/controllers/datasource.js +34 -0
  257. package/src/api/controllers/deploy/index.js +2 -2
  258. package/src/api/controllers/dev.js +2 -2
  259. package/src/api/controllers/hosting.js +2 -2
  260. package/src/api/controllers/permission.js +2 -2
  261. package/src/api/controllers/query/import/sources/base/index.ts +3 -1
  262. package/src/api/controllers/query/import/sources/curl.ts +12 -4
  263. package/src/api/controllers/query/import/sources/openapi2.ts +9 -5
  264. package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +2 -3
  265. package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +6 -7
  266. package/src/api/controllers/query/import/tests/index.spec.js +0 -6
  267. package/src/api/controllers/query/index.js +48 -55
  268. package/src/api/controllers/query/validation.js +2 -1
  269. package/src/api/controllers/role.js +1 -1
  270. package/src/api/controllers/routing.js +1 -1
  271. package/src/api/controllers/row/internal.js +14 -5
  272. package/src/api/controllers/row/internalSearch.js +3 -2
  273. package/src/api/controllers/row/utils.js +11 -8
  274. package/src/api/controllers/screen.js +1 -1
  275. package/src/api/controllers/user.js +6 -3
  276. package/src/api/controllers/webhook.js +1 -1
  277. package/src/api/index.js +1 -1
  278. package/src/api/routes/apikeys.js +1 -1
  279. package/src/api/routes/application.js +1 -1
  280. package/src/api/routes/automation.js +1 -1
  281. package/src/api/routes/backup.js +1 -1
  282. package/src/api/routes/cloud.js +1 -1
  283. package/src/api/routes/component.js +1 -1
  284. package/src/api/routes/datasource.js +1 -1
  285. package/src/api/routes/deploy.js +1 -1
  286. package/src/api/routes/dev.js +1 -1
  287. package/src/api/routes/hosting.js +1 -1
  288. package/src/api/routes/integration.js +1 -1
  289. package/src/api/routes/layout.js +1 -1
  290. package/src/api/routes/metadata.js +1 -1
  291. package/src/api/routes/permission.js +4 -1
  292. package/src/api/routes/query.js +9 -2
  293. package/src/api/routes/role.js +1 -1
  294. package/src/api/routes/routing.js +1 -1
  295. package/src/api/routes/row.js +1 -1
  296. package/src/api/routes/screen.js +1 -1
  297. package/src/api/routes/script.js +1 -1
  298. package/src/api/routes/static.js +1 -1
  299. package/src/api/routes/table.js +1 -1
  300. package/src/api/routes/templates.js +1 -1
  301. package/src/api/routes/tests/datasource.spec.js +45 -0
  302. package/src/api/routes/tests/permissions.spec.js +1 -1
  303. package/src/api/routes/tests/query.spec.js +70 -1
  304. package/src/api/routes/tests/role.spec.js +2 -2
  305. package/src/api/routes/tests/routing.spec.js +1 -1
  306. package/src/api/routes/tests/user.spec.js +1 -1
  307. package/src/api/routes/tests/utilities/TestFunctions.js +1 -1
  308. package/src/api/routes/user.js +1 -1
  309. package/src/api/routes/view.js +1 -1
  310. package/src/api/routes/webhook.js +1 -1
  311. package/src/app.ts +1 -1
  312. package/src/automations/bullboard.js +1 -1
  313. package/src/automations/steps/executeQuery.js +10 -2
  314. package/src/automations/utils.js +1 -1
  315. package/src/constants/index.js +3 -3
  316. package/src/constants/screens.js +1 -1
  317. package/src/db/client.js +1 -1
  318. package/src/db/utils.js +1 -1
  319. package/src/definitions/datasource.ts +10 -0
  320. package/src/integrations/base/sqlTable.ts +1 -1
  321. package/src/integrations/rest.ts +6 -3
  322. package/src/middleware/authorized.js +2 -2
  323. package/src/middleware/builder.js +2 -2
  324. package/src/middleware/currentapp.js +11 -7
  325. package/src/middleware/tests/authorized.spec.js +2 -2
  326. package/src/middleware/tests/currentapp.spec.js +35 -41
  327. package/src/middleware/tests/usageQuota.spec.js +1 -1
  328. package/src/middleware/usageQuota.js +1 -1
  329. package/src/tests/utilities/TestConfiguration.js +65 -8
  330. package/src/tests/utilities/structures.js +2 -2
  331. package/src/threads/automation.js +2 -2
  332. package/src/threads/query.js +148 -56
  333. package/src/threads/utils.js +116 -1
  334. package/src/utilities/budibaseDir.js +1 -1
  335. package/src/utilities/fileSystem/utilities.js +3 -1
  336. package/src/utilities/global.js +8 -5
  337. package/src/utilities/index.js +1 -1
  338. package/src/utilities/redis.js +1 -1
  339. package/src/utilities/rowProcessor/index.js +79 -0
  340. package/src/utilities/security.js +5 -2
  341. package/src/utilities/usageQuota.js +2 -2
  342. package/src/utilities/workerRequests.js +3 -3
  343. package/builder/assets/index.00c4135e.js +0 -1320
@@ -1,4 +1,4 @@
1
- const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles")
1
+ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
2
2
  const env = require("../../environment")
3
3
  const {
4
4
  basicTable,
@@ -15,14 +15,14 @@ const {
15
15
  const controllers = require("./controllers")
16
16
  const supertest = require("supertest")
17
17
  const { cleanup } = require("../../utilities/fileSystem")
18
- const { Cookies, Headers } = require("@budibase/auth").constants
19
- const { jwt } = require("@budibase/auth").auth
20
- const auth = require("@budibase/auth")
21
- const { getGlobalDB } = require("@budibase/auth/tenancy")
22
- const { createASession } = require("@budibase/auth/sessions")
23
- const { user: userCache } = require("@budibase/auth/cache")
18
+ const { Cookies, Headers } = require("@budibase/backend-core/constants")
19
+ const { jwt } = require("@budibase/backend-core/auth")
20
+ const core = require("@budibase/backend-core")
21
+ const { getGlobalDB } = require("@budibase/backend-core/tenancy")
22
+ const { createASession } = require("@budibase/backend-core/sessions")
23
+ const { user: userCache } = require("@budibase/backend-core/cache")
24
24
  const CouchDB = require("../../db")
25
- auth.init(CouchDB)
25
+ core.init(CouchDB)
26
26
 
27
27
  const GLOBAL_USER_ID = "us_uuid1"
28
28
  const EMAIL = "babs@babs.com"
@@ -316,6 +316,63 @@ class TestConfiguration {
316
316
  return this.datasource
317
317
  }
318
318
 
319
+ async updateDatasource(datasource) {
320
+ const response = await this._req(
321
+ datasource,
322
+ { datasourceId: datasource._id },
323
+ controllers.datasource.update
324
+ )
325
+ this.datasource = response.datasource
326
+ return this.datasource
327
+ }
328
+
329
+ async restDatasource(cfg) {
330
+ return this.createDatasource({
331
+ datasource: {
332
+ ...basicDatasource().datasource,
333
+ source: "REST",
334
+ config: cfg || {},
335
+ },
336
+ })
337
+ }
338
+
339
+ async dynamicVariableDatasource() {
340
+ let datasource = await this.restDatasource()
341
+ const basedOnQuery = await this.createQuery({
342
+ ...basicQuery(datasource._id),
343
+ fields: {
344
+ path: "www.google.com",
345
+ },
346
+ })
347
+ datasource = await this.updateDatasource({
348
+ ...datasource,
349
+ config: {
350
+ dynamicVariables: [
351
+ {
352
+ queryId: basedOnQuery._id,
353
+ name: "variable3",
354
+ value: "{{ data.0.[value] }}",
355
+ },
356
+ ],
357
+ },
358
+ })
359
+ return { datasource, query: basedOnQuery }
360
+ }
361
+
362
+ async previewQuery(request, config, datasource, fields) {
363
+ return request
364
+ .post(`/api/queries/preview`)
365
+ .send({
366
+ datasourceId: datasource._id,
367
+ parameters: {},
368
+ fields,
369
+ queryVerb: "read",
370
+ })
371
+ .set(config.defaultHeaders())
372
+ .expect("Content-Type", /json/)
373
+ .expect(200)
374
+ }
375
+
319
376
  async createQuery(config = null) {
320
377
  if (!this.datasource && !config) {
321
378
  throw "No data source created for query."
@@ -1,5 +1,5 @@
1
- const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles")
2
- const { BUILTIN_PERMISSION_IDS } = require("@budibase/auth/permissions")
1
+ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
2
+ const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions")
3
3
  const { createHomeScreen } = require("../../constants/screens")
4
4
  const { EMPTY_LAYOUT } = require("../../constants/layouts")
5
5
  const { cloneDeep } = require("lodash/fp")
@@ -4,10 +4,10 @@ const actions = require("../automations/actions")
4
4
  const automationUtils = require("../automations/automationUtils")
5
5
  const AutomationEmitter = require("../events/AutomationEmitter")
6
6
  const { processObject } = require("@budibase/string-templates")
7
- const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants
7
+ const { DEFAULT_TENANT_ID } = require("@budibase/backend-core/constants")
8
8
  const CouchDB = require("../db")
9
9
  const { DocumentTypes, isDevAppID } = require("../db/utils")
10
- const { doInTenant } = require("@budibase/auth/tenancy")
10
+ const { doInTenant } = require("@budibase/backend-core/tenancy")
11
11
  const usage = require("../utilities/usageQuota")
12
12
  const { definitions: triggerDefs } = require("../automations/triggerInfo")
13
13
 
@@ -1,77 +1,169 @@
1
- require("./utils").threadSetup()
1
+ const threadUtils = require("./utils")
2
+ threadUtils.threadSetup()
2
3
  const ScriptRunner = require("../utilities/scriptRunner")
3
4
  const { integrations } = require("../integrations")
5
+ const { processStringSync } = require("@budibase/string-templates")
6
+ const CouchDB = require("../db")
4
7
 
5
- function formatResponse(resp) {
6
- if (typeof resp === "string") {
7
- try {
8
- resp = JSON.parse(resp)
9
- } catch (err) {
10
- resp = { response: resp }
11
- }
8
+ class QueryRunner {
9
+ constructor(input, flags = { noRecursiveQuery: false }) {
10
+ this.appId = input.appId
11
+ this.datasource = input.datasource
12
+ this.queryVerb = input.queryVerb
13
+ this.fields = input.fields
14
+ this.parameters = input.parameters
15
+ this.transformer = input.transformer
16
+ this.queryId = input.queryId
17
+ this.noRecursiveQuery = flags.noRecursiveQuery
18
+ this.cachedVariables = []
19
+ // allows the response from a query to be stored throughout this
20
+ // execution so that if it needs to be re-used for another variable
21
+ // it can be
22
+ this.queryResponse = {}
23
+ this.hasRerun = false
12
24
  }
13
- return resp
14
- }
15
25
 
16
- function hasExtraData(response) {
17
- return (
18
- typeof response === "object" &&
19
- !Array.isArray(response) &&
20
- response.data != null &&
21
- response.info != null
22
- )
23
- }
26
+ async execute() {
27
+ let { datasource, fields, queryVerb, transformer } = this
28
+ // pre-query, make sure datasource variables are added to parameters
29
+ const parameters = await this.addDatasourceVariables()
30
+ const query = threadUtils.enrichQueryFields(fields, parameters)
31
+ const Integration = integrations[datasource.source]
32
+ if (!Integration) {
33
+ throw "Integration type does not exist."
34
+ }
35
+ const integration = new Integration(datasource.config)
24
36
 
25
- async function runAndTransform(datasource, queryVerb, query, transformer) {
26
- const Integration = integrations[datasource.source]
27
- if (!Integration) {
28
- throw "Integration type does not exist."
29
- }
30
- const integration = new Integration(datasource.config)
37
+ let output = threadUtils.formatResponse(await integration[queryVerb](query))
38
+ let rows = output,
39
+ info = undefined,
40
+ extra = undefined
41
+ if (threadUtils.hasExtraData(output)) {
42
+ rows = output.data
43
+ info = output.info
44
+ extra = output.extra
45
+ }
31
46
 
32
- let output = formatResponse(await integration[queryVerb](query))
33
- let rows = output,
34
- info = undefined,
35
- extra = undefined
36
- if (hasExtraData(output)) {
37
- rows = output.data
38
- info = output.info
39
- extra = output.extra
40
- }
47
+ // transform as required
48
+ if (transformer) {
49
+ const runner = new ScriptRunner(transformer, {
50
+ data: rows,
51
+ params: parameters,
52
+ })
53
+ rows = runner.execute()
54
+ }
41
55
 
42
- // transform as required
43
- if (transformer) {
44
- const runner = new ScriptRunner(transformer, { data: rows })
45
- rows = runner.execute()
46
- }
56
+ // if the request fails we retry once, invalidating the cached value
57
+ if (
58
+ info &&
59
+ info.code >= 400 &&
60
+ this.cachedVariables.length > 0 &&
61
+ !this.hasRerun
62
+ ) {
63
+ this.hasRerun = true
64
+ // invalidate the cache value
65
+ await threadUtils.invalidateDynamicVariables(this.cachedVariables)
66
+ return this.execute()
67
+ }
47
68
 
48
- // needs to an array for next step
49
- if (!Array.isArray(rows)) {
50
- rows = [rows]
51
- }
69
+ // needs to an array for next step
70
+ if (!Array.isArray(rows)) {
71
+ rows = [rows]
72
+ }
52
73
 
53
- // map into JSON if just raw primitive here
54
- if (rows.find(row => typeof row !== "object")) {
55
- rows = rows.map(value => ({ value }))
74
+ // map into JSON if just raw primitive here
75
+ if (rows.find(row => typeof row !== "object")) {
76
+ rows = rows.map(value => ({ value }))
77
+ }
78
+
79
+ // get all the potential fields in the schema
80
+ let keys = rows.flatMap(Object.keys)
81
+
82
+ if (integration.end) {
83
+ integration.end()
84
+ }
85
+
86
+ return { rows, keys, info, extra }
56
87
  }
57
88
 
58
- // get all the potential fields in the schema
59
- let keys = rows.flatMap(Object.keys)
89
+ async runAnotherQuery(queryId, parameters) {
90
+ const db = new CouchDB(this.appId)
91
+ const query = await db.get(queryId)
92
+ const datasource = await db.get(query.datasourceId)
93
+ return new QueryRunner(
94
+ {
95
+ appId: this.appId,
96
+ datasource,
97
+ queryVerb: query.queryVerb,
98
+ fields: query.fields,
99
+ parameters,
100
+ transformer: query.transformer,
101
+ },
102
+ { noRecursiveQuery: true }
103
+ ).execute()
104
+ }
60
105
 
61
- if (integration.end) {
62
- integration.end()
106
+ async getDynamicVariable(variable) {
107
+ let { parameters } = this
108
+ const queryId = variable.queryId,
109
+ name = variable.name
110
+ let value = await threadUtils.checkCacheForDynamicVariable(queryId, name)
111
+ if (!value) {
112
+ value = this.queryResponse[queryId]
113
+ ? this.queryResponse[queryId]
114
+ : await this.runAnotherQuery(queryId, parameters)
115
+ // store incase this query is to be called again
116
+ this.queryResponse[queryId] = value
117
+ await threadUtils.storeDynamicVariable(queryId, name, value)
118
+ } else {
119
+ this.cachedVariables.push({ queryId, name })
120
+ }
121
+ return value
63
122
  }
64
123
 
65
- return { rows, keys, info, extra }
124
+ async addDatasourceVariables() {
125
+ let { datasource, parameters, fields } = this
126
+ if (!datasource || !datasource.config) {
127
+ return parameters
128
+ }
129
+ const staticVars = datasource.config.staticVariables || {}
130
+ const dynamicVars = datasource.config.dynamicVariables || []
131
+ for (let [key, value] of Object.entries(staticVars)) {
132
+ if (!parameters[key]) {
133
+ parameters[key] = value
134
+ }
135
+ }
136
+ if (!this.noRecursiveQuery) {
137
+ // need to see if this uses any variables
138
+ const stringFields = JSON.stringify(fields)
139
+ const foundVars = dynamicVars.filter(variable => {
140
+ // don't allow a query to use its own dynamic variable (loop)
141
+ if (variable.queryId === this.queryId) {
142
+ return false
143
+ }
144
+ // look for {{ variable }} but allow spaces between handlebars
145
+ const regex = new RegExp(`{{[ ]*${variable.name}[ ]*}}`)
146
+ return regex.test(stringFields)
147
+ })
148
+ const dynamics = foundVars.map(dynVar => this.getDynamicVariable(dynVar))
149
+ const responses = await Promise.all(dynamics)
150
+ for (let i = 0; i < foundVars.length; i++) {
151
+ const variable = foundVars[i]
152
+ parameters[variable.name] = processStringSync(variable.value, {
153
+ data: responses[i].rows,
154
+ info: responses[i].extra,
155
+ })
156
+ // make sure its known that this uses dynamic variables in case it fails
157
+ this.hasDynamicVariables = true
158
+ }
159
+ }
160
+ return parameters
161
+ }
66
162
  }
67
163
 
68
164
  module.exports = (input, callback) => {
69
- runAndTransform(
70
- input.datasource,
71
- input.queryVerb,
72
- input.query,
73
- input.transformer
74
- )
165
+ const Runner = new QueryRunner(input)
166
+ Runner.execute()
75
167
  .then(response => {
76
168
  callback(null, response)
77
169
  })
@@ -1,6 +1,26 @@
1
1
  const env = require("../environment")
2
2
  const CouchDB = require("../db")
3
- const { init } = require("@budibase/auth")
3
+ const { init } = require("@budibase/backend-core")
4
+ const redis = require("@budibase/backend-core/redis")
5
+ const { SEPARATOR } = require("@budibase/backend-core/db")
6
+ const { processStringSync } = require("@budibase/string-templates")
7
+
8
+ const VARIABLE_TTL_SECONDS = 3600
9
+ let client
10
+
11
+ const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/)
12
+ const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/)
13
+
14
+ async function getClient() {
15
+ if (!client) {
16
+ client = await new redis.Client(redis.utils.Databases.QUERY_VARS).init()
17
+ }
18
+ return client
19
+ }
20
+
21
+ process.on("exit", async () => {
22
+ if (client) await client.finish()
23
+ })
4
24
 
5
25
  exports.threadSetup = () => {
6
26
  // don't run this if not threading
@@ -11,3 +31,98 @@ exports.threadSetup = () => {
11
31
  env.setInThread()
12
32
  init(CouchDB)
13
33
  }
34
+
35
+ function makeVariableKey(queryId, variable) {
36
+ return `${queryId}${SEPARATOR}${variable}`
37
+ }
38
+
39
+ exports.checkCacheForDynamicVariable = async (queryId, variable) => {
40
+ const cache = await getClient()
41
+ return cache.get(makeVariableKey(queryId, variable))
42
+ }
43
+
44
+ exports.invalidateDynamicVariables = async cachedVars => {
45
+ const cache = await getClient()
46
+ let promises = []
47
+ for (let variable of cachedVars) {
48
+ promises.push(
49
+ cache.delete(makeVariableKey(variable.queryId, variable.name))
50
+ )
51
+ }
52
+ await Promise.all(promises)
53
+ }
54
+
55
+ exports.storeDynamicVariable = async (queryId, variable, value) => {
56
+ const cache = await getClient()
57
+ await cache.store(
58
+ makeVariableKey(queryId, variable),
59
+ value,
60
+ VARIABLE_TTL_SECONDS
61
+ )
62
+ }
63
+
64
+ exports.formatResponse = resp => {
65
+ if (typeof resp === "string") {
66
+ try {
67
+ resp = JSON.parse(resp)
68
+ } catch (err) {
69
+ resp = { response: resp }
70
+ }
71
+ }
72
+ return resp
73
+ }
74
+
75
+ exports.hasExtraData = response => {
76
+ return (
77
+ typeof response === "object" &&
78
+ !Array.isArray(response) &&
79
+ response.data != null &&
80
+ response.info != null
81
+ )
82
+ }
83
+
84
+ exports.enrichQueryFields = (fields, parameters = {}) => {
85
+ const enrichedQuery = {}
86
+
87
+ // enrich the fields with dynamic parameters
88
+ for (let key of Object.keys(fields)) {
89
+ if (fields[key] == null) {
90
+ continue
91
+ }
92
+ if (typeof fields[key] === "object") {
93
+ // enrich nested fields object
94
+ enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters)
95
+ } else if (typeof fields[key] === "string") {
96
+ // enrich string value as normal
97
+ let value = fields[key]
98
+ // add triple brace to avoid escaping e.g. '=' in cookie header
99
+ if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
100
+ value = `{${value}}`
101
+ }
102
+ enrichedQuery[key] = processStringSync(value, parameters, {
103
+ noHelpers: true,
104
+ })
105
+ } else {
106
+ enrichedQuery[key] = fields[key]
107
+ }
108
+ }
109
+
110
+ if (
111
+ enrichedQuery.json ||
112
+ enrichedQuery.customData ||
113
+ enrichedQuery.requestBody
114
+ ) {
115
+ try {
116
+ enrichedQuery.json = JSON.parse(
117
+ enrichedQuery.json ||
118
+ enrichedQuery.customData ||
119
+ enrichedQuery.requestBody
120
+ )
121
+ } catch (err) {
122
+ // no json found, ignore
123
+ }
124
+ delete enrichedQuery.customData
125
+ }
126
+
127
+ return enrichedQuery
128
+ }
@@ -1,7 +1,7 @@
1
1
  const { join } = require("./centralPath")
2
2
  const { homedir } = require("os")
3
3
  const env = require("../environment")
4
- const { budibaseTempDir } = require("@budibase/auth").objectStore
4
+ const { budibaseTempDir } = require("@budibase/backend-core/objectStore")
5
5
 
6
6
  module.exports.budibaseAppsDir = function () {
7
7
  return env.BUDIBASE_DIR || join(homedir(), ".budibase")
@@ -2,13 +2,14 @@ const {
2
2
  ObjectStore,
3
3
  makeSureBucketExists,
4
4
  upload,
5
+ deleteFiles,
5
6
  streamUpload,
6
7
  retrieve,
7
8
  retrieveToTmp,
8
9
  deleteFolder,
9
10
  uploadDirectory,
10
11
  downloadTarball,
11
- } = require("@budibase/auth").objectStore
12
+ } = require("@budibase/backend-core/objectStore")
12
13
 
13
14
  /***********************************
14
15
  * NOTE *
@@ -28,3 +29,4 @@ exports.retrieveToTmp = retrieveToTmp
28
29
  exports.deleteFolder = deleteFolder
29
30
  exports.uploadDirectory = uploadDirectory
30
31
  exports.downloadTarball = downloadTarball
32
+ exports.deleteFiles = deleteFiles
@@ -2,11 +2,14 @@ const {
2
2
  getMultiIDParams,
3
3
  getGlobalIDFromUserMetadataID,
4
4
  } = require("../db/utils")
5
- const { BUILTIN_ROLE_IDS } = require("@budibase/auth/roles")
6
- const { getDeployedAppID } = require("@budibase/auth/db")
7
- const { getGlobalUserParams } = require("@budibase/auth/db")
8
- const { user: userCache } = require("@budibase/auth/cache")
9
- const { getGlobalDB, isUserInAppTenant } = require("@budibase/auth/tenancy")
5
+ const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
6
+ const { getDeployedAppID } = require("@budibase/backend-core/db")
7
+ const { getGlobalUserParams } = require("@budibase/backend-core/db")
8
+ const { user: userCache } = require("@budibase/backend-core/cache")
9
+ const {
10
+ getGlobalDB,
11
+ isUserInAppTenant,
12
+ } = require("@budibase/backend-core/tenancy")
10
13
  const env = require("../environment")
11
14
 
12
15
  exports.updateAppRole = (appId, user) => {
@@ -1,6 +1,6 @@
1
1
  const env = require("../environment")
2
2
  const { OBJ_STORE_DIRECTORY } = require("../constants")
3
- const { sanitizeKey } = require("@budibase/auth/src/objectStore")
3
+ const { sanitizeKey } = require("@budibase/backend-core/objectStore")
4
4
  const CouchDB = require("../db")
5
5
  const { generateMetadataID } = require("../db/utils")
6
6
  const Readable = require("stream").Readable
@@ -1,4 +1,4 @@
1
- const { Client, utils } = require("@budibase/auth/redis")
1
+ const { Client, utils } = require("@budibase/backend-core/redis")
2
2
  const { getGlobalIDFromUserMetadataID } = require("../db/utils")
3
3
 
4
4
  const APP_DEV_LOCK_SECONDS = 600
@@ -3,6 +3,14 @@ const { cloneDeep } = require("lodash/fp")
3
3
  const { FieldTypes, AutoFieldSubTypes } = require("../../constants")
4
4
  const { attachmentsRelativeURL } = require("../index")
5
5
  const { processFormulas } = require("./utils")
6
+ const { deleteFiles } = require("../../utilities/fileSystem/utilities")
7
+ const { ObjectStoreBuckets } = require("../../constants")
8
+ const {
9
+ isProdAppID,
10
+ getDeployedAppID,
11
+ dbExists,
12
+ } = require("@budibase/backend-core/db")
13
+ const CouchDB = require("../../db")
6
14
 
7
15
  const BASE_AUTO_ID = 1
8
16
 
@@ -81,6 +89,35 @@ const TYPE_TRANSFORM_MAP = {
81
89
  [FieldTypes.AUTO]: {
82
90
  parse: () => undefined,
83
91
  },
92
+ [FieldTypes.JSON]: {
93
+ parse: input => {
94
+ try {
95
+ if (input === "") {
96
+ return undefined
97
+ }
98
+ return JSON.parse(input)
99
+ } catch (err) {
100
+ return input
101
+ }
102
+ },
103
+ },
104
+ }
105
+
106
+ /**
107
+ * Given the old state of the row and the new one after an update, this will
108
+ * find the keys that have been removed in the updated row.
109
+ */
110
+ function getRemovedAttachmentKeys(oldRow, row, attachmentKey) {
111
+ if (!oldRow[attachmentKey]) {
112
+ return []
113
+ }
114
+ const oldKeys = oldRow[attachmentKey].map(attachment => attachment.key)
115
+ // no attachments in new row, all removed
116
+ if (!row[attachmentKey]) {
117
+ return oldKeys
118
+ }
119
+ const newKeys = row[attachmentKey].map(attachment => attachment.key)
120
+ return oldKeys.filter(key => newKeys.indexOf(key) === -1)
84
121
  }
85
122
 
86
123
  /**
@@ -260,3 +297,45 @@ exports.outputProcessing = async (
260
297
  }
261
298
  return wasArray ? enriched : enriched[0]
262
299
  }
300
+
301
+ /**
302
+ * Clean up any attachments that were attached to a row.
303
+ * @param {string} appId The ID of the app from which a row is being deleted.
304
+ * @param {object} table The table from which a row is being removed.
305
+ * @param {any} row optional - the row being removed.
306
+ * @param {any} rows optional - if multiple rows being deleted can do this in bulk.
307
+ * @param {any} oldRow optional - if updating a row this will determine the difference.
308
+ * @return {Promise<void>} When all attachments have been removed this will return.
309
+ */
310
+ exports.cleanupAttachments = async (appId, table, { row, rows, oldRow }) => {
311
+ if (!isProdAppID(appId)) {
312
+ const prodAppId = getDeployedAppID(appId)
313
+ // if prod exists, then don't allow deleting
314
+ const exists = await dbExists(CouchDB, prodAppId)
315
+ if (exists) {
316
+ return
317
+ }
318
+ }
319
+ let files = []
320
+ function addFiles(row, key) {
321
+ if (row[key]) {
322
+ files = files.concat(row[key].map(attachment => attachment.key))
323
+ }
324
+ }
325
+ for (let [key, schema] of Object.entries(table.schema)) {
326
+ if (schema.type !== FieldTypes.ATTACHMENT) {
327
+ continue
328
+ }
329
+ // if updating, need to manage the differences
330
+ if (oldRow && row) {
331
+ files = files.concat(getRemovedAttachmentKeys(oldRow, row, key))
332
+ } else if (row) {
333
+ addFiles(row, key)
334
+ } else if (rows) {
335
+ rows.forEach(row => addFiles(row, key))
336
+ }
337
+ }
338
+ if (files.length > 0) {
339
+ return deleteFiles(ObjectStoreBuckets.APPS, files)
340
+ }
341
+ }
@@ -3,8 +3,11 @@ const {
3
3
  PermissionTypes,
4
4
  getBuiltinPermissionByID,
5
5
  isPermissionLevelHigherThanRead,
6
- } = require("@budibase/auth/permissions")
7
- const { lowerBuiltinRoleID, getBuiltinRoles } = require("@budibase/auth/roles")
6
+ } = require("@budibase/backend-core/permissions")
7
+ const {
8
+ lowerBuiltinRoleID,
9
+ getBuiltinRoles,
10
+ } = require("@budibase/backend-core/roles")
8
11
  const { DocumentTypes } = require("../db/utils")
9
12
 
10
13
  const CURRENTLY_SUPPORTED_LEVELS = [
@@ -1,9 +1,9 @@
1
1
  const env = require("../environment")
2
- const { getGlobalDB } = require("@budibase/auth/tenancy")
2
+ const { getGlobalDB } = require("@budibase/backend-core/tenancy")
3
3
  const {
4
4
  StaticDatabases,
5
5
  generateNewUsageQuotaDoc,
6
- } = require("@budibase/auth/db")
6
+ } = require("@budibase/backend-core/db")
7
7
 
8
8
  function getNewQuotaReset() {
9
9
  return Date.now() + 2592000000
@@ -1,10 +1,10 @@
1
1
  const fetch = require("node-fetch")
2
2
  const env = require("../environment")
3
3
  const { checkSlashesInUrl } = require("./index")
4
- const { getDeployedAppID } = require("@budibase/auth/db")
4
+ const { getDeployedAppID } = require("@budibase/backend-core/db")
5
5
  const { updateAppRole } = require("./global")
6
- const { Headers } = require("@budibase/auth/constants")
7
- const { getTenantId, isTenantIdSet } = require("@budibase/auth/tenancy")
6
+ const { Headers } = require("@budibase/backend-core/constants")
7
+ const { getTenantId, isTenantIdSet } = require("@budibase/backend-core/tenancy")
8
8
 
9
9
  function request(ctx, request) {
10
10
  if (!request.headers) {