@budibase/server 2.0.39 → 2.0.40-alpha.1

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 (297) hide show
  1. package/__mocks__/mongodb.ts +1 -1
  2. package/__mocks__/node-fetch.ts +12 -2
  3. package/builder/assets/backups-default.8c011f1b.png +0 -0
  4. package/builder/assets/{index.e0ddd30b.css → index.442de33f.css} +2 -2
  5. package/builder/assets/{index.b20dee52.js → index.b09e13ca.js} +340 -332
  6. package/builder/index.html +2 -2
  7. package/coverage/clover.xml +1125 -1250
  8. package/coverage/coverage-final.json +73 -77
  9. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  10. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +79 -67
  12. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/dev.js.html +21 -21
  14. package/coverage/lcov-report/api/controllers/index.html +17 -47
  15. package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
  16. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
  18. package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
  19. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/validation.js.html +4 -4
  22. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  24. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/internal.js.html +13 -13
  27. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
  29. package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
  30. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +12 -9
  32. package/coverage/lcov-report/api/controllers/table/external.js.html +10 -10
  33. package/coverage/lcov-report/api/controllers/table/index.html +16 -16
  34. package/coverage/lcov-report/api/controllers/table/index.js.html +5 -5
  35. package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
  36. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
  40. package/coverage/lcov-report/api/controllers/view/utils.js.html +13 -13
  41. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +8 -8
  42. package/coverage/lcov-report/api/index.html +1 -1
  43. package/coverage/lcov-report/api/index.js.html +30 -30
  44. package/coverage/lcov-report/api/routes/analytics.js.html +7 -7
  45. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  46. package/coverage/lcov-report/api/routes/automation.js.html +11 -11
  47. package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
  48. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  49. package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
  50. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  51. package/coverage/lcov-report/api/routes/dev.js.html +13 -13
  52. package/coverage/lcov-report/api/routes/index.html +5 -35
  53. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  54. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  55. package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
  56. package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
  57. package/coverage/lcov-report/api/routes/permission.js.html +9 -9
  58. package/coverage/lcov-report/api/routes/query.js.html +10 -10
  59. package/coverage/lcov-report/api/routes/role.js.html +9 -9
  60. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  61. package/coverage/lcov-report/api/routes/screen.js.html +9 -9
  62. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/table.js.html +10 -10
  64. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  65. package/coverage/lcov-report/api/routes/user.js.html +8 -8
  66. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  67. package/coverage/lcov-report/api/routes/utils/validators.js.html +45 -45
  68. package/coverage/lcov-report/api/routes/view.js.html +10 -10
  69. package/coverage/lcov-report/automations/actions.js.html +1 -1
  70. package/coverage/lcov-report/automations/automationUtils.js.html +6 -6
  71. package/coverage/lcov-report/automations/bullboard.js.html +24 -84
  72. package/coverage/lcov-report/automations/index.html +21 -21
  73. package/coverage/lcov-report/automations/index.js.html +9 -9
  74. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  75. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  76. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  77. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/index.html +15 -15
  81. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -3
  89. package/coverage/lcov-report/automations/steps/utils.js.html +10 -10
  90. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  91. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  92. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  93. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  94. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggers.js.html +49 -49
  100. package/coverage/lcov-report/constants/index.html +5 -5
  101. package/coverage/lcov-report/constants/index.js.html +10 -28
  102. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  103. package/coverage/lcov-report/constants/screens.js.html +1 -1
  104. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  105. package/coverage/lcov-report/db/index.html +19 -19
  106. package/coverage/lcov-report/db/index.js.html +1 -1
  107. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
  108. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  109. package/coverage/lcov-report/db/linkedRows/index.js.html +28 -28
  110. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +15 -15
  111. package/coverage/lcov-report/db/newid.js.html +2 -2
  112. package/coverage/lcov-report/db/utils.js.html +37 -316
  113. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  114. package/coverage/lcov-report/events/index.html +1 -1
  115. package/coverage/lcov-report/events/index.js.html +3 -3
  116. package/coverage/lcov-report/events/utils.js.html +9 -9
  117. package/coverage/lcov-report/index.html +88 -88
  118. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  119. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  120. package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
  121. package/coverage/lcov-report/middleware/builder.js.html +19 -19
  122. package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
  123. package/coverage/lcov-report/middleware/index.html +1 -1
  124. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  125. package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
  126. package/coverage/lcov-report/middleware/resourceId.js.html +28 -28
  127. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  128. package/coverage/lcov-report/middleware/utils.js.html +4 -4
  129. package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
  130. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  131. package/coverage/lcov-report/utilities/csvParser.js.html +15 -12
  132. package/coverage/lcov-report/utilities/global.js.html +31 -31
  133. package/coverage/lcov-report/utilities/index.html +28 -28
  134. package/coverage/lcov-report/utilities/index.js.html +8 -8
  135. package/coverage/lcov-report/utilities/plugins.js.html +1 -1
  136. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +52 -52
  137. package/coverage/lcov-report/utilities/queue/index.html +21 -21
  138. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  139. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  140. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  141. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +72 -57
  142. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
  143. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  144. package/coverage/lcov-report/utilities/security.js.html +2 -2
  145. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  146. package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
  147. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +23 -11
  148. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  149. package/coverage/lcov-report/utilities/users.js.html +1 -1
  150. package/coverage/lcov-report/utilities/workerRequests.js.html +46 -46
  151. package/coverage/lcov.info +1691 -1899
  152. package/dist/api/controllers/application.js +4 -7
  153. package/dist/api/controllers/backup.js +19 -13
  154. package/dist/api/controllers/cloud.js +38 -35
  155. package/dist/api/controllers/deploy/index.js +11 -2
  156. package/dist/api/controllers/dev.js +1 -1
  157. package/dist/api/controllers/query/index.js +7 -2
  158. package/dist/api/controllers/row/index.js +40 -66
  159. package/dist/api/controllers/row/internal.js +1 -1
  160. package/dist/api/controllers/static/index.js +3 -2
  161. package/dist/api/controllers/static/templates/BudibaseApp.svelte +11 -0
  162. package/dist/api/controllers/static/templates/preview.hbs +10 -0
  163. package/dist/api/controllers/table/bulkFormula.js +4 -3
  164. package/dist/api/controllers/table/external.js +5 -4
  165. package/dist/api/controllers/table/index.js +4 -4
  166. package/dist/api/controllers/table/internal.js +10 -3
  167. package/dist/api/controllers/table/utils.js +7 -49
  168. package/dist/api/controllers/view/index.js +2 -2
  169. package/dist/api/controllers/webhook.js +88 -89
  170. package/dist/api/routes/backup.js +34 -7
  171. package/dist/api/routes/index.js +9 -4
  172. package/dist/api/routes/utils/validators.js +2 -2
  173. package/dist/api/routes/webhook.js +39 -11
  174. package/dist/app.js +2 -68
  175. package/dist/automations/automationUtils.js +2 -2
  176. package/dist/automations/bullboard.js +12 -35
  177. package/dist/automations/index.js +4 -4
  178. package/dist/automations/steps/updateRow.js +2 -2
  179. package/dist/automations/triggers.js +6 -6
  180. package/dist/automations/utils.js +23 -49
  181. package/dist/constants/index.js +4 -8
  182. package/dist/db/utils.js +10 -75
  183. package/dist/index.js +1 -0
  184. package/dist/integrations/arangodb.js +2 -0
  185. package/dist/integrations/base/sqlTable.js +1 -0
  186. package/dist/integrations/elasticsearch.js +26 -2
  187. package/dist/integrations/mongodb.js +300 -11
  188. package/dist/integrations/rest.js +38 -5
  189. package/dist/migrations/functions/backfill/app/tables.js +5 -8
  190. package/dist/migrations/functions/{quotas1.js → syncQuotas.js} +3 -7
  191. package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
  192. package/dist/migrations/functions/{pluginCount.js → usageQuotas/syncPlugins.js} +1 -3
  193. package/dist/migrations/functions/usageQuotas/syncRows.js +9 -5
  194. package/dist/migrations/index.js +10 -38
  195. package/dist/package.json +14 -14
  196. package/dist/sdk/app/automations/index.js +29 -0
  197. package/dist/sdk/app/automations/webhook.js +54 -0
  198. package/dist/sdk/app/backups/constants.js +5 -0
  199. package/dist/sdk/app/backups/exports.js +172 -0
  200. package/dist/sdk/app/backups/imports.js +190 -0
  201. package/dist/sdk/app/backups/index.js +29 -0
  202. package/dist/sdk/app/backups/statistics.js +73 -0
  203. package/dist/sdk/app/tables/index.js +61 -0
  204. package/dist/sdk/index.js +17 -0
  205. package/dist/startup.js +152 -0
  206. package/dist/tests/utilities/TestConfiguration.js +12 -2
  207. package/dist/threads/automation.js +12 -17
  208. package/dist/tsconfig.build.tsbuildinfo +1 -1
  209. package/dist/utilities/csvParser.js +1 -0
  210. package/dist/utilities/fileSystem/index.js +3 -95
  211. package/dist/utilities/fileSystem/utilities.js +2 -1
  212. package/dist/utilities/rowProcessor/index.js +5 -0
  213. package/dist/utilities/usageQuota/rows.js +6 -4
  214. package/package.json +15 -15
  215. package/specs/openapi.json +3 -0
  216. package/specs/openapi.yaml +3 -0
  217. package/src/api/controllers/application.ts +5 -12
  218. package/src/api/controllers/{backup.js → backup.ts} +7 -7
  219. package/src/api/controllers/cloud.js +44 -40
  220. package/src/api/controllers/deploy/index.ts +20 -8
  221. package/src/api/controllers/dev.js +1 -1
  222. package/src/api/controllers/query/index.ts +8 -2
  223. package/src/api/controllers/row/index.ts +50 -65
  224. package/src/api/controllers/row/internal.js +1 -1
  225. package/src/api/controllers/static/index.ts +4 -2
  226. package/src/api/controllers/static/templates/BudibaseApp.svelte +11 -0
  227. package/src/api/controllers/static/templates/preview.hbs +10 -0
  228. package/src/api/controllers/table/bulkFormula.js +4 -3
  229. package/src/api/controllers/table/external.js +4 -4
  230. package/src/api/controllers/table/index.js +4 -4
  231. package/src/api/controllers/table/internal.ts +8 -9
  232. package/src/api/controllers/table/utils.ts +4 -53
  233. package/src/api/controllers/view/index.js +2 -2
  234. package/src/api/controllers/{webhook.js → webhook.ts} +33 -48
  235. package/src/api/routes/backup.ts +10 -0
  236. package/src/api/routes/index.ts +11 -5
  237. package/src/api/routes/tests/backup.spec.js +1 -1
  238. package/src/api/routes/tests/{deployment.spec.js → deployment.spec.ts} +4 -4
  239. package/src/api/routes/tests/row.spec.js +22 -27
  240. package/src/api/routes/utils/validators.js +2 -2
  241. package/src/api/routes/{webhook.js → webhook.ts} +7 -6
  242. package/src/app.ts +3 -91
  243. package/src/automations/automationUtils.js +2 -2
  244. package/src/automations/bullboard.js +14 -34
  245. package/src/automations/index.js +4 -4
  246. package/src/automations/steps/updateRow.js +2 -2
  247. package/src/automations/tests/automation.spec.js +1 -6
  248. package/src/automations/triggers.js +6 -6
  249. package/src/automations/utils.ts +30 -32
  250. package/src/constants/index.js +4 -10
  251. package/src/db/utils.js +17 -110
  252. package/src/definitions/automations.ts +1 -18
  253. package/src/definitions/datasource.ts +1 -0
  254. package/src/index.ts +1 -0
  255. package/src/integrations/arangodb.ts +2 -0
  256. package/src/integrations/base/sqlTable.ts +1 -0
  257. package/src/integrations/elasticsearch.ts +32 -2
  258. package/src/integrations/mongodb.ts +290 -27
  259. package/src/integrations/rest.ts +17 -5
  260. package/src/integrations/tests/mongo.spec.ts +19 -19
  261. package/src/integrations/tests/rest.spec.ts +38 -22
  262. package/src/migrations/functions/backfill/app/tables.ts +7 -13
  263. package/src/migrations/functions/backfill/global.ts +1 -1
  264. package/src/migrations/functions/{quotas1.ts → syncQuotas.ts} +3 -8
  265. package/src/migrations/functions/tests/{quotas1.spec.js → syncQuotas.spec.js} +6 -5
  266. package/src/migrations/functions/tests/userEmailViewCasing.spec.js +6 -4
  267. package/src/migrations/functions/usageQuotas/syncApps.ts +0 -1
  268. package/src/migrations/functions/usageQuotas/syncPlugins.ts +10 -0
  269. package/src/migrations/functions/usageQuotas/syncRows.ts +15 -6
  270. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +9 -1
  271. package/src/migrations/index.ts +21 -45
  272. package/src/migrations/tests/index.spec.ts +0 -1
  273. package/src/sdk/app/automations/index.ts +5 -0
  274. package/src/sdk/app/automations/webhook.ts +43 -0
  275. package/src/sdk/app/backups/constants.ts +2 -0
  276. package/src/sdk/app/backups/exports.ts +171 -0
  277. package/src/sdk/app/backups/imports.ts +206 -0
  278. package/src/sdk/app/backups/index.ts +9 -0
  279. package/src/sdk/app/backups/statistics.ts +78 -0
  280. package/src/sdk/app/tables/index.ts +61 -0
  281. package/src/sdk/index.ts +15 -0
  282. package/src/startup.ts +138 -0
  283. package/src/tests/utilities/TestConfiguration.js +12 -2
  284. package/src/threads/automation.ts +20 -27
  285. package/src/utilities/csvParser.js +1 -0
  286. package/src/utilities/fileSystem/index.js +2 -119
  287. package/src/utilities/fileSystem/utilities.js +2 -0
  288. package/src/utilities/rowProcessor/index.js +5 -0
  289. package/src/utilities/usageQuota/rows.js +7 -3
  290. package/coverage/lcov-report/api/controllers/backup.js.html +0 -142
  291. package/coverage/lcov-report/api/controllers/webhook.js.html +0 -424
  292. package/coverage/lcov-report/api/routes/backup.js.html +0 -115
  293. package/coverage/lcov-report/api/routes/webhook.js.html +0 -163
  294. package/dist/automations/listeners.js +0 -102
  295. package/src/api/routes/backup.js +0 -10
  296. package/src/automations/listeners.ts +0 -78
  297. package/src/migrations/functions/pluginCount.ts +0 -12
@@ -13,6 +13,7 @@ const { FieldTypes } = require("../constants");
13
13
  const VALIDATORS = {
14
14
  [FieldTypes.STRING]: () => true,
15
15
  [FieldTypes.OPTIONS]: () => true,
16
+ [FieldTypes.BARCODEQR]: () => true,
16
17
  [FieldTypes.NUMBER]: attribute => {
17
18
  // allow not to be present
18
19
  if (!attribute) {
@@ -12,14 +12,11 @@ const { budibaseTempDir } = require("../budibaseDir");
12
12
  const fs = require("fs");
13
13
  const { join } = require("path");
14
14
  const uuid = require("uuid/v4");
15
- const { doWithDB, dangerousGetDB, closeDB, } = require("@budibase/backend-core/db");
16
15
  const { ObjectStoreBuckets } = require("../../constants");
17
- const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, downloadTarballDirect, deleteFiles, } = require("./utilities");
16
+ const { upload, retrieve, retrieveToTmp, deleteFolder, downloadTarball, downloadTarballDirect, deleteFiles, } = require("./utilities");
18
17
  const { updateClientLibrary } = require("./clientLibrary");
19
18
  const { checkSlashesInUrl } = require("../");
20
19
  const env = require("../../environment");
21
- const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, TABLE_ROW_PREFIX, } = require("../../db/utils");
22
- const MemoryStream = require("memorystream");
23
20
  const { getAppId } = require("@budibase/backend-core/context");
24
21
  const tar = require("tar");
25
22
  const fetch = require("node-fetch");
@@ -75,21 +72,6 @@ exports.checkDevelopmentEnvironment = () => {
75
72
  process.exit(-1);
76
73
  }
77
74
  };
78
- /**
79
- * This function manages temporary template files which are stored by Koa.
80
- * @param {Object} template The template object retrieved from the Koa context object.
81
- * @returns {Object} Returns an fs read stream which can be loaded into the database.
82
- */
83
- exports.getTemplateStream = (template) => __awaiter(void 0, void 0, void 0, function* () {
84
- if (template.file) {
85
- return fs.createReadStream(template.file.path);
86
- }
87
- else {
88
- const [type, name] = template.key.split("/");
89
- const tmpPath = yield exports.downloadTemplate(type, name);
90
- return fs.createReadStream(join(tmpPath, name, "db", "dump.txt"));
91
- }
92
- });
93
75
  /**
94
76
  * Used to retrieve a handlebars file from the system which will be used as a template.
95
77
  * This is allowable as the template handlebars files should be static and identical across
@@ -111,83 +93,9 @@ exports.apiFileReturn = contents => {
111
93
  fs.writeFileSync(path, contents);
112
94
  return fs.createReadStream(path);
113
95
  };
114
- exports.defineFilter = excludeRows => {
115
- const ids = [USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX];
116
- if (excludeRows) {
117
- ids.push(TABLE_ROW_PREFIX);
118
- }
119
- return doc => !ids.map(key => doc._id.includes(key)).reduce((prev, curr) => prev || curr);
96
+ exports.streamFile = path => {
97
+ return fs.createReadStream(path);
120
98
  };
121
- /**
122
- * Local utility to back up the database state for an app, excluding global user
123
- * data or user relationships.
124
- * @param {string} appId The app to backup
125
- * @param {object} config Config to send to export DB
126
- * @param {boolean} excludeRows Flag to state whether the export should include data.
127
- * @returns {*} either a string or a stream of the backup
128
- */
129
- const backupAppData = (appId, config, excludeRows) => __awaiter(void 0, void 0, void 0, function* () {
130
- return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter: exports.defineFilter(excludeRows) }));
131
- });
132
- /**
133
- * Takes a copy of the database state for an app to the object store.
134
- * @param {string} appId The ID of the app which is to be backed up.
135
- * @param {string} backupName The name of the backup located in the object store.
136
- * @return {*} a readable stream to the completed backup file
137
- */
138
- exports.performBackup = (appId, backupName) => __awaiter(void 0, void 0, void 0, function* () {
139
- return yield backupAppData(appId, { exportName: backupName });
140
- });
141
- /**
142
- * Streams a backup of the database state for an app
143
- * @param {string} appId The ID of the app which is to be backed up.
144
- * @param {boolean} excludeRows Flag to state whether the export should include data.
145
- * @returns {*} a readable stream of the backup which is written in real time
146
- */
147
- exports.streamBackup = (appId, excludeRows) => __awaiter(void 0, void 0, void 0, function* () {
148
- return yield backupAppData(appId, { stream: true }, excludeRows);
149
- });
150
- /**
151
- * Exports a DB to either file or a variable (memory).
152
- * @param {string} dbName the DB which is to be exported.
153
- * @param {string} exportName optional - provide a filename to write the backup to a file
154
- * @param {boolean} stream optional - whether to perform a full backup
155
- * @param {function} filter optional - a filter function to clear out any un-wanted docs.
156
- * @return {*} either a readable stream or a string
157
- */
158
- exports.exportDB = (dbName, { stream, filter, exportName } = {}) => __awaiter(void 0, void 0, void 0, function* () {
159
- // streaming a DB dump is a bit more complicated, can't close DB
160
- if (stream) {
161
- const db = dangerousGetDB(dbName);
162
- const memStream = new MemoryStream();
163
- memStream.on("end", () => __awaiter(void 0, void 0, void 0, function* () {
164
- yield closeDB(db);
165
- }));
166
- db.dump(memStream, { filter });
167
- return memStream;
168
- }
169
- return doWithDB(dbName, (db) => __awaiter(void 0, void 0, void 0, function* () {
170
- // Write the dump to file if required
171
- if (exportName) {
172
- const path = join(budibaseTempDir(), exportName);
173
- const writeStream = fs.createWriteStream(path);
174
- yield db.dump(writeStream, { filter });
175
- // Upload the dump to the object store if self hosted
176
- if (env.SELF_HOSTED) {
177
- yield streamUpload(ObjectStoreBuckets.BACKUPS, join(dbName, exportName), fs.createReadStream(path));
178
- }
179
- return fs.createReadStream(path);
180
- }
181
- // Stringify the dump in memory if required
182
- const memStream = new MemoryStream();
183
- let appString = "";
184
- memStream.on("data", chunk => {
185
- appString += chunk.toString();
186
- });
187
- yield db.dump(memStream, { filter });
188
- return appString;
189
- }));
190
- });
191
99
  /**
192
100
  * Writes the provided contents to a temporary file, which can be used briefly.
193
101
  * @param {string} fileContents contents which will be written to a temp file.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const { ObjectStore, makeSureBucketExists, upload, deleteFiles, streamUpload, retrieve, retrieveToTmp, deleteFolder, uploadDirectory, downloadTarball, downloadTarballDirect, } = require("@budibase/backend-core/objectStore");
2
+ const { ObjectStore, makeSureBucketExists, upload, deleteFiles, streamUpload, retrieve, retrieveToTmp, retrieveDirectory, deleteFolder, uploadDirectory, downloadTarball, downloadTarballDirect, } = require("@budibase/backend-core/objectStore");
3
3
  /***********************************
4
4
  * NOTE *
5
5
  * This file purely exists so that *
@@ -14,6 +14,7 @@ exports.upload = upload;
14
14
  exports.streamUpload = streamUpload;
15
15
  exports.retrieve = retrieve;
16
16
  exports.retrieveToTmp = retrieveToTmp;
17
+ exports.retrieveDirectory = retrieveDirectory;
17
18
  exports.deleteFolder = deleteFolder;
18
19
  exports.uploadDirectory = uploadDirectory;
19
20
  exports.downloadTarball = downloadTarball;
@@ -52,6 +52,11 @@ const TYPE_TRANSFORM_MAP = {
52
52
  [null]: "",
53
53
  [undefined]: undefined,
54
54
  },
55
+ [FieldTypes.BARCODEQR]: {
56
+ "": "",
57
+ [null]: "",
58
+ [undefined]: undefined,
59
+ },
55
60
  [FieldTypes.FORMULA]: {
56
61
  "": "",
57
62
  [null]: "",
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const { getRowParams, USER_METDATA_PREFIX } = require("../../db/utils");
12
- const { isDevAppID, getDevelopmentAppID, doWithDB, } = require("@budibase/backend-core/db");
12
+ const { isDevAppID, getDevelopmentAppID, getProdAppID, doWithDB, } = require("@budibase/backend-core/db");
13
13
  const ROW_EXCLUSIONS = [USER_METDATA_PREFIX];
14
14
  const getAppPairs = appIds => {
15
15
  // collect the app ids into dev / prod pairs
@@ -53,7 +53,7 @@ const getAppRows = (appId) => __awaiter(void 0, void 0, void 0, function* () {
53
53
  * Rows duplicates may exist across apps due to data import so they are not filtered out.
54
54
  */
55
55
  exports.getUniqueRows = (appIds) => __awaiter(void 0, void 0, void 0, function* () {
56
- let uniqueRows = [];
56
+ let uniqueRows = [], rowsByApp = {};
57
57
  const pairs = getAppPairs(appIds);
58
58
  for (let pair of Object.values(pairs)) {
59
59
  let appRows = [];
@@ -73,7 +73,9 @@ exports.getUniqueRows = (appIds) => __awaiter(void 0, void 0, void 0, function*
73
73
  // this can't be done on all rows because app import results in
74
74
  // duplicate row ids across apps
75
75
  // the array pre-concat is important to avoid stack overflow
76
- uniqueRows = uniqueRows.concat([...new Set(appRows)]);
76
+ const prodId = getProdAppID(pair.devId || pair.prodId);
77
+ rowsByApp[prodId] = [...new Set(appRows)];
78
+ uniqueRows = uniqueRows.concat(rowsByApp[prodId]);
77
79
  }
78
- return uniqueRows;
80
+ return { rows: uniqueRows, appRows: rowsByApp };
79
81
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.0.39",
4
+ "version": "2.0.40-alpha.1",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -77,23 +77,23 @@
77
77
  "license": "GPL-3.0",
78
78
  "dependencies": {
79
79
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "^2.0.39",
81
- "@budibase/client": "^2.0.39",
82
- "@budibase/pro": "2.0.38",
83
- "@budibase/string-templates": "^2.0.39",
84
- "@budibase/types": "^2.0.39",
80
+ "@budibase/backend-core": "2.0.40-alpha.1",
81
+ "@budibase/client": "2.0.40-alpha.1",
82
+ "@budibase/pro": "2.0.40-alpha.0",
83
+ "@budibase/string-templates": "2.0.40-alpha.1",
84
+ "@budibase/types": "2.0.40-alpha.1",
85
85
  "@bull-board/api": "3.7.0",
86
86
  "@bull-board/koa": "3.9.4",
87
87
  "@elastic/elasticsearch": "7.10.0",
88
88
  "@google-cloud/firestore": "5.0.2",
89
- "@koa/router": "8.0.0",
89
+ "@koa/router": "8.0.8",
90
90
  "@sendgrid/mail": "7.1.1",
91
91
  "@sentry/node": "6.17.7",
92
92
  "airtable": "0.10.1",
93
93
  "arangojs": "7.2.0",
94
94
  "aws-sdk": "2.1030.0",
95
95
  "bcryptjs": "2.4.3",
96
- "bull": "4.8.5",
96
+ "bull": "4.10.1",
97
97
  "chmodr": "1.2.0",
98
98
  "chokidar": "3.5.3",
99
99
  "csvtojson": "2.0.10",
@@ -112,7 +112,7 @@
112
112
  "js-yaml": "4.1.0",
113
113
  "jsonschema": "1.4.0",
114
114
  "knex": "0.95.15",
115
- "koa": "2.7.0",
115
+ "koa": "2.13.4",
116
116
  "koa-body": "4.2.0",
117
117
  "koa-compress": "4.0.1",
118
118
  "koa-connect": "2.1.0",
@@ -123,7 +123,7 @@
123
123
  "koa2-ratelimit": "1.1.1",
124
124
  "lodash": "4.17.21",
125
125
  "memorystream": "0.3.1",
126
- "mongodb": "3.6.3",
126
+ "mongodb": "4.9",
127
127
  "mssql": "6.2.3",
128
128
  "mysql2": "2.3.3",
129
129
  "node-fetch": "2.6.7",
@@ -146,7 +146,7 @@
146
146
  "to-json-schema": "0.2.5",
147
147
  "uuid": "3.3.2",
148
148
  "validate.js": "0.13.1",
149
- "vm2": "3.9.6",
149
+ "vm2": "3.9.11",
150
150
  "worker-farm": "1.7.0",
151
151
  "xml2js": "0.4.23",
152
152
  "yargs": "13.2.4",
@@ -159,17 +159,17 @@
159
159
  "@jest/test-sequencer": "24.9.0",
160
160
  "@types/apidoc": "0.50.0",
161
161
  "@types/bson": "4.2.0",
162
- "@types/bull": "3.15.8",
163
162
  "@types/global-agent": "2.1.1",
164
163
  "@types/google-spreadsheet": "3.1.5",
164
+ "@types/ioredis": "4.28.10",
165
165
  "@types/jest": "27.5.1",
166
166
  "@types/koa": "2.13.4",
167
- "@types/koa__router": "8.0.0",
167
+ "@types/koa__router": "8.0.11",
168
168
  "@types/lodash": "4.14.180",
169
- "@types/mongodb": "3.6.3",
170
169
  "@types/node": "14.18.20",
171
170
  "@types/node-fetch": "2.6.1",
172
171
  "@types/oracledb": "5.2.2",
172
+ "@types/pouchdb": "6.4.0",
173
173
  "@types/redis": "4.0.11",
174
174
  "@typescript-eslint/parser": "5.12.0",
175
175
  "apidoc": "0.50.4",
@@ -199,5 +199,5 @@
199
199
  "optionalDependencies": {
200
200
  "oracledb": "5.3.0"
201
201
  },
202
- "gitHead": "dce0d52b0ad22c3214c348154a7090f872a82ecf"
202
+ "gitHead": "d7ab0afac13397f1dcc34fe581a270287c17c177"
203
203
  }
@@ -783,6 +783,7 @@
783
783
  "type": "string",
784
784
  "enum": [
785
785
  "string",
786
+ "barcodeqr",
786
787
  "longform",
787
788
  "options",
788
789
  "number",
@@ -986,6 +987,7 @@
986
987
  "type": "string",
987
988
  "enum": [
988
989
  "string",
990
+ "barcodeqr",
989
991
  "longform",
990
992
  "options",
991
993
  "number",
@@ -1200,6 +1202,7 @@
1200
1202
  "type": "string",
1201
1203
  "enum": [
1202
1204
  "string",
1205
+ "barcodeqr",
1203
1206
  "longform",
1204
1207
  "options",
1205
1208
  "number",
@@ -579,6 +579,7 @@ components:
579
579
  type: string
580
580
  enum:
581
581
  - string
582
+ - barcodeqr
582
583
  - longform
583
584
  - options
584
585
  - number
@@ -741,6 +742,7 @@ components:
741
742
  type: string
742
743
  enum:
743
744
  - string
745
+ - barcodeqr
744
746
  - longform
745
747
  - options
746
748
  - number
@@ -910,6 +912,7 @@ components:
910
912
  type: string
911
913
  enum:
912
914
  - string
915
+ - barcodeqr
913
916
  - longform
914
917
  - options
915
918
  - number
@@ -5,11 +5,7 @@ import {
5
5
  createRoutingView,
6
6
  createAllSearchIndex,
7
7
  } from "../../db/views/staticViews"
8
- import {
9
- getTemplateStream,
10
- createApp,
11
- deleteApp,
12
- } from "../../utilities/fileSystem"
8
+ import { createApp, deleteApp } from "../../utilities/fileSystem"
13
9
  import {
14
10
  generateAppID,
15
11
  getLayoutParams,
@@ -50,6 +46,7 @@ import { errors, events, migrations } from "@budibase/backend-core"
50
46
  import { App, Layout, Screen, MigrationType } from "@budibase/types"
51
47
  import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
52
48
  import { enrichPluginURLs } from "../../utilities/plugins"
49
+ import sdk from "../../sdk"
53
50
 
54
51
  const URL_REGEX_SLASH = /\/|\\/g
55
52
 
@@ -153,11 +150,7 @@ async function createInstance(template: any) {
153
150
  throw "Error loading database dump from memory."
154
151
  }
155
152
  } else if (template && template.useTemplate === "true") {
156
- /* istanbul ignore next */
157
- const { ok } = await db.load(await getTemplateStream(template))
158
- if (!ok) {
159
- throw "Error loading database dump from template."
160
- }
153
+ await sdk.backups.importApp(appId, db, template)
161
154
  } else {
162
155
  // create the users table
163
156
  await db.put(USERS_TABLE_SCHEMA)
@@ -359,7 +352,7 @@ const appPostCreate = async (ctx: any, app: App) => {
359
352
  await creationEvents(ctx.request, app)
360
353
  // app import & template creation
361
354
  if (ctx.request.body.useTemplate === "true") {
362
- const rows = await getUniqueRows([app.appId])
355
+ const { rows } = await getUniqueRows([app.appId])
363
356
  const rowCount = rows ? rows.length : 0
364
357
  if (rowCount) {
365
358
  try {
@@ -493,7 +486,7 @@ const destroyApp = async (ctx: any) => {
493
486
  }
494
487
 
495
488
  const preDestroyApp = async (ctx: any) => {
496
- const rows = await getUniqueRows([ctx.params.appId])
489
+ const { rows } = await getUniqueRows([ctx.params.appId])
497
490
  ctx.rowCount = rows.length
498
491
  }
499
492
 
@@ -1,15 +1,15 @@
1
- const { streamBackup } = require("../../utilities/fileSystem")
2
- const { events, context } = require("@budibase/backend-core")
3
- const { DocumentType } = require("../../db/utils")
4
- const { isQsTrue } = require("../../utilities")
1
+ import sdk from "../../sdk"
2
+ import { events, context } from "@budibase/backend-core"
3
+ import { DocumentType } from "../../db/utils"
4
+ import { isQsTrue } from "../../utilities"
5
5
 
6
- exports.exportAppDump = async function (ctx) {
6
+ export async function exportAppDump(ctx: any) {
7
7
  let { appId, excludeRows } = ctx.query
8
8
  const appName = decodeURI(ctx.query.appname)
9
9
  excludeRows = isQsTrue(excludeRows)
10
- const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
10
+ const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz`
11
11
  ctx.attachment(backupIdentifier)
12
- ctx.body = await streamBackup(appId, excludeRows)
12
+ ctx.body = await sdk.backups.streamExportApp(appId, excludeRows)
13
13
 
14
14
  await context.doInAppContext(appId, async () => {
15
15
  const appDb = context.getAppDB()
@@ -1,58 +1,59 @@
1
1
  const env = require("../../environment")
2
2
  const { getAllApps, getGlobalDBName } = require("@budibase/backend-core/db")
3
- const {
4
- exportDB,
5
- sendTempFile,
6
- readFileSync,
7
- } = require("../../utilities/fileSystem")
8
- const { stringToReadStream } = require("../../utilities")
9
3
  const { getGlobalDB } = require("@budibase/backend-core/tenancy")
10
- const { create } = require("./application")
4
+ const { streamFile } = require("../../utilities/fileSystem")
5
+ const { stringToReadStream } = require("../../utilities")
11
6
  const { getDocParams, DocumentType, isDevAppID } = require("../../db/utils")
7
+ const { create } = require("./application")
8
+ const { join } = require("path")
9
+ const sdk = require("../../sdk")
12
10
 
13
- async function createApp(appName, appImport) {
11
+ async function createApp(appName, appDirectory) {
14
12
  const ctx = {
15
13
  request: {
16
14
  body: {
17
- templateString: appImport,
15
+ useTemplate: true,
18
16
  name: appName,
19
17
  },
18
+ files: {
19
+ templateFile: {
20
+ path: appDirectory,
21
+ },
22
+ },
20
23
  },
21
24
  }
22
25
  return create(ctx)
23
26
  }
24
27
 
28
+ async function getAllDocType(db, docType) {
29
+ const response = await db.allDocs(
30
+ getDocParams(docType, null, {
31
+ include_docs: true,
32
+ })
33
+ )
34
+ return response.rows.map(row => row.doc)
35
+ }
36
+
25
37
  exports.exportApps = async ctx => {
26
38
  if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
27
39
  ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
28
40
  }
29
41
  const apps = await getAllApps({ all: true })
30
- const globalDBString = await exportDB(getGlobalDBName(), {
42
+ const globalDBString = await sdk.backups.exportDB(getGlobalDBName(), {
31
43
  filter: doc => !doc._id.startsWith(DocumentType.USER),
32
44
  })
33
- let allDBs = {
34
- global: globalDBString,
35
- }
36
- for (let app of apps) {
37
- const appId = app.appId || app._id
38
- // only export the dev apps as they will be the latest, the user can republish the apps
39
- // in their self hosted environment
40
- if (isDevAppID(appId)) {
41
- allDBs[app.name] = await exportDB(appId)
42
- }
43
- }
44
- const filename = `cloud-export-${new Date().getTime()}.txt`
45
- ctx.attachment(filename)
46
- ctx.body = sendTempFile(JSON.stringify(allDBs))
47
- }
48
-
49
- async function getAllDocType(db, docType) {
50
- const response = await db.allDocs(
51
- getDocParams(docType, null, {
52
- include_docs: true,
53
- })
45
+ // only export the dev apps as they will be the latest, the user can republish the apps
46
+ // in their self-hosted environment
47
+ let appMetadata = apps
48
+ .filter(app => isDevAppID(app.appId || app._id))
49
+ .map(app => ({ appId: app.appId || app._id, name: app.name }))
50
+ const tmpPath = await sdk.backups.exportMultipleApps(
51
+ appMetadata,
52
+ globalDBString
54
53
  )
55
- return response.rows.map(row => row.doc)
54
+ const filename = `cloud-export-${new Date().getTime()}.tar.gz`
55
+ ctx.attachment(filename)
56
+ ctx.body = streamFile(tmpPath)
56
57
  }
57
58
 
58
59
  async function hasBeenImported() {
@@ -80,17 +81,20 @@ exports.importApps = async ctx => {
80
81
  "Import file is required and environment must be fresh to import apps."
81
82
  )
82
83
  }
83
- const importFile = ctx.request.files.importFile
84
- const importString = readFileSync(importFile.path)
85
- const dbs = JSON.parse(importString)
86
- const globalDbImport = dbs.global
87
- // remove from the list of apps
88
- delete dbs.global
84
+ if (ctx.request.files.importFile.type !== "application/gzip") {
85
+ ctx.throw(400, "Import file must be a gzipped tarball.")
86
+ }
87
+
88
+ // initially get all the app databases out of the tarball
89
+ const tmpPath = sdk.backups.untarFile(ctx.request.files.importFile)
90
+ const globalDbImport = sdk.backups.getGlobalDBFile(tmpPath)
91
+ const appNames = sdk.backups.getListOfAppsInMulti(tmpPath)
92
+
89
93
  const globalDb = getGlobalDB()
90
94
  // load the global db first
91
95
  await globalDb.load(stringToReadStream(globalDbImport))
92
- for (let [appName, appImport] of Object.entries(dbs)) {
93
- await createApp(appName, appImport)
96
+ for (let appName of appNames) {
97
+ await createApp(appName, join(tmpPath, appName))
94
98
  }
95
99
 
96
100
  // if there are any users make sure to remove them
@@ -1,24 +1,25 @@
1
1
  import Deployment from "./Deployment"
2
2
  import {
3
- Replication,
4
- getProdAppID,
5
3
  getDevelopmentAppID,
4
+ getProdAppID,
5
+ Replication,
6
6
  } from "@budibase/backend-core/db"
7
7
  import { DocumentType, getAutomationParams } from "../../../db/utils"
8
8
  import {
9
+ clearMetadata,
9
10
  disableAllCrons,
10
11
  enableCronTrigger,
11
- clearMetadata,
12
12
  } from "../../../automations/utils"
13
13
  import { app as appCache } from "@budibase/backend-core/cache"
14
14
  import {
15
- getAppId,
16
15
  getAppDB,
17
- getProdAppDB,
16
+ getAppId,
18
17
  getDevAppDB,
18
+ getProdAppDB,
19
19
  } from "@budibase/backend-core/context"
20
- import { quotas } from "@budibase/pro"
21
20
  import { events } from "@budibase/backend-core"
21
+ import { backups } from "@budibase/pro"
22
+ import { AppBackupTrigger } from "@budibase/types"
22
23
 
23
24
  // the max time we can wait for an invalidation to complete before considering it failed
24
25
  const MAX_PENDING_TIME_MS = 30 * 60000
@@ -99,13 +100,24 @@ async function initDeployedApp(prodAppId: any) {
99
100
  console.log("Enabled cron triggers for deployed app..")
100
101
  }
101
102
 
102
- async function deployApp(deployment: any) {
103
+ async function deployApp(deployment: any, userId: string) {
103
104
  let replication
104
105
  try {
105
106
  const appId = getAppId()
106
107
  const devAppId = getDevelopmentAppID(appId)
107
108
  const productionAppId = getProdAppID(appId)
108
109
 
110
+ // don't try this if feature isn't allowed, will error
111
+ if (await backups.isEnabled()) {
112
+ // trigger backup initially
113
+ await backups.triggerAppBackup(
114
+ productionAppId,
115
+ AppBackupTrigger.PUBLISH,
116
+ {
117
+ createdBy: userId,
118
+ }
119
+ )
120
+ }
109
121
  const config: any = {
110
122
  source: devAppId,
111
123
  target: productionAppId,
@@ -206,7 +218,7 @@ const _deployApp = async function (ctx: any) {
206
218
 
207
219
  console.log("Deploying app...")
208
220
 
209
- let app = await deployApp(deployment)
221
+ let app = await deployApp(deployment, ctx.user._id)
210
222
 
211
223
  await events.app.published(app)
212
224
  ctx.body = deployment
@@ -103,7 +103,7 @@ exports.revert = async ctx => {
103
103
  target: appId,
104
104
  })
105
105
  try {
106
- if (!env.isTest()) {
106
+ if (env.COUCH_DB_URL) {
107
107
  // in-memory db stalls on rollback
108
108
  await replication.rollback()
109
109
  }
@@ -56,6 +56,7 @@ const _import = async (ctx: any) => {
56
56
  config: {
57
57
  url: info.url,
58
58
  defaultHeaders: [],
59
+ rejectUnauthorized: true,
59
60
  },
60
61
  name: info.name,
61
62
  }
@@ -153,7 +154,10 @@ export async function preview(ctx: any) {
153
154
  auth: { ...authConfigCtx },
154
155
  },
155
156
  })
156
- const { rows, keys, info, extra } = await quotas.addQuery(runFn)
157
+
158
+ const { rows, keys, info, extra } = await quotas.addQuery(runFn, {
159
+ datasourceId: datasource._id,
160
+ })
157
161
  const schemaFields: any = {}
158
162
  if (rows?.length > 0) {
159
163
  for (let key of [...new Set(keys)] as string[]) {
@@ -234,7 +238,9 @@ async function execute(
234
238
  },
235
239
  })
236
240
 
237
- const { rows, pagination, extra } = await quotas.addQuery(runFn)
241
+ const { rows, pagination, extra } = await quotas.addQuery(runFn, {
242
+ datasourceId: datasource._id,
243
+ })
238
244
  // remove the raw from execution incase transformer being used to hide data
239
245
  if (extra?.raw) {
240
246
  delete extra.raw