@budibase/server 2.0.33 → 2.0.34-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 (277) hide show
  1. package/__mocks__/mongodb.ts +1 -1
  2. package/builder/assets/backups-default.8c011f1b.png +0 -0
  3. package/builder/assets/{index.dfa4073c.css → index.b15ffe95.css} +2 -2
  4. package/builder/assets/{index.ce49a649.js → index.cf543543.js} +340 -332
  5. package/builder/index.html +2 -2
  6. package/coverage/clover.xml +635 -690
  7. package/coverage/coverage-final.json +34 -36
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/cloud.js.html +74 -62
  11. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/dev.js.html +2 -2
  13. package/coverage/lcov-report/api/controllers/index.html +17 -32
  14. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/internal.js.html +12 -12
  26. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
  29. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +12 -9
  31. package/coverage/lcov-report/api/controllers/table/external.js.html +10 -10
  32. package/coverage/lcov-report/api/controllers/table/index.html +16 -16
  33. package/coverage/lcov-report/api/controllers/table/index.js.html +5 -5
  34. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
  39. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  42. package/coverage/lcov-report/api/index.html +1 -1
  43. package/coverage/lcov-report/api/index.js.html +7 -7
  44. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  45. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/index.html +5 -20
  53. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  67. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  70. package/coverage/lcov-report/automations/actions.js.html +1 -1
  71. package/coverage/lcov-report/automations/automationUtils.js.html +6 -6
  72. package/coverage/lcov-report/automations/bullboard.js.html +17 -92
  73. package/coverage/lcov-report/automations/index.html +20 -20
  74. package/coverage/lcov-report/automations/index.js.html +9 -9
  75. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  76. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  77. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/index.html +1 -1
  82. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -3
  90. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  92. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  93. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  94. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggers.js.html +30 -30
  101. package/coverage/lcov-report/constants/index.html +5 -5
  102. package/coverage/lcov-report/constants/index.js.html +10 -16
  103. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  104. package/coverage/lcov-report/constants/screens.js.html +1 -1
  105. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  106. package/coverage/lcov-report/db/index.html +19 -19
  107. package/coverage/lcov-report/db/index.js.html +1 -1
  108. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
  109. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  110. package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
  111. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
  112. package/coverage/lcov-report/db/newid.js.html +2 -2
  113. package/coverage/lcov-report/db/utils.js.html +37 -316
  114. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  115. package/coverage/lcov-report/events/index.html +1 -1
  116. package/coverage/lcov-report/events/index.js.html +2 -2
  117. package/coverage/lcov-report/events/utils.js.html +9 -9
  118. package/coverage/lcov-report/index.html +77 -77
  119. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  120. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  121. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  122. package/coverage/lcov-report/middleware/builder.js.html +11 -11
  123. package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
  124. package/coverage/lcov-report/middleware/index.html +1 -1
  125. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  126. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  127. package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
  128. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  129. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  130. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  131. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  132. package/coverage/lcov-report/utilities/csvParser.js.html +11 -8
  133. package/coverage/lcov-report/utilities/global.js.html +16 -16
  134. package/coverage/lcov-report/utilities/index.html +15 -15
  135. package/coverage/lcov-report/utilities/index.js.html +7 -7
  136. package/coverage/lcov-report/utilities/plugins.js.html +1 -1
  137. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +52 -52
  138. package/coverage/lcov-report/utilities/queue/index.html +21 -21
  139. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  140. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  141. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  142. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +54 -39
  143. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
  144. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  145. package/coverage/lcov-report/utilities/security.js.html +2 -2
  146. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  147. package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
  148. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +23 -11
  149. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  150. package/coverage/lcov-report/utilities/users.js.html +1 -1
  151. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  152. package/coverage/lcov.info +1144 -1248
  153. package/dist/api/controllers/application.js +4 -7
  154. package/dist/api/controllers/backup.js +19 -13
  155. package/dist/api/controllers/cloud.js +38 -35
  156. package/dist/api/controllers/deploy/index.js +11 -2
  157. package/dist/api/controllers/dev.js +1 -1
  158. package/dist/api/controllers/query/index.js +7 -2
  159. package/dist/api/controllers/row/index.js +30 -10
  160. package/dist/api/controllers/static/index.js +2 -2
  161. package/dist/api/controllers/static/templates/preview.hbs +10 -0
  162. package/dist/api/controllers/table/bulkFormula.js +4 -3
  163. package/dist/api/controllers/table/external.js +5 -4
  164. package/dist/api/controllers/table/index.js +4 -4
  165. package/dist/api/controllers/table/internal.js +10 -3
  166. package/dist/api/controllers/table/utils.js +7 -49
  167. package/dist/api/controllers/view/index.js +2 -2
  168. package/dist/api/routes/backup.js +34 -7
  169. package/dist/api/routes/index.js +9 -4
  170. package/dist/app.js +18 -2
  171. package/dist/automations/automationUtils.js +2 -2
  172. package/dist/automations/bullboard.js +5 -33
  173. package/dist/automations/index.js +4 -4
  174. package/dist/automations/steps/updateRow.js +2 -2
  175. package/dist/automations/triggers.js +6 -6
  176. package/dist/automations/utils.js +18 -12
  177. package/dist/constants/index.js +4 -5
  178. package/dist/db/utils.js +10 -75
  179. package/dist/index.js +1 -0
  180. package/dist/integrations/arangodb.js +2 -0
  181. package/dist/integrations/base/sqlTable.js +1 -0
  182. package/dist/integrations/mongodb.js +300 -11
  183. package/dist/integrations/rest.js +38 -5
  184. package/dist/migrations/functions/backfill/app/tables.js +5 -8
  185. package/dist/migrations/functions/{quotas1.js → syncQuotas.js} +3 -7
  186. package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
  187. package/dist/migrations/functions/{pluginCount.js → usageQuotas/syncPlugins.js} +1 -3
  188. package/dist/migrations/functions/usageQuotas/syncRows.js +9 -5
  189. package/dist/migrations/index.js +10 -38
  190. package/dist/package.json +14 -14
  191. package/dist/sdk/app/backups/constants.js +5 -0
  192. package/dist/sdk/app/backups/exports.js +172 -0
  193. package/dist/sdk/app/backups/imports.js +162 -0
  194. package/dist/sdk/app/backups/index.js +29 -0
  195. package/dist/sdk/app/backups/statistics.js +73 -0
  196. package/dist/sdk/app/tables/index.js +61 -0
  197. package/dist/sdk/index.js +15 -0
  198. package/dist/tests/utilities/TestConfiguration.js +4 -2
  199. package/dist/threads/automation.js +12 -17
  200. package/dist/tsconfig.build.tsbuildinfo +1 -1
  201. package/dist/utilities/csvParser.js +1 -0
  202. package/dist/utilities/fileSystem/index.js +3 -95
  203. package/dist/utilities/fileSystem/utilities.js +2 -1
  204. package/dist/utilities/rowProcessor/index.js +5 -0
  205. package/dist/utilities/usageQuota/rows.js +6 -4
  206. package/package.json +15 -15
  207. package/specs/openapi.json +3 -0
  208. package/specs/openapi.yaml +3 -0
  209. package/src/api/controllers/application.ts +5 -12
  210. package/src/api/controllers/{backup.js → backup.ts} +7 -7
  211. package/src/api/controllers/cloud.js +44 -40
  212. package/src/api/controllers/deploy/index.ts +20 -8
  213. package/src/api/controllers/dev.js +1 -1
  214. package/src/api/controllers/query/index.ts +8 -2
  215. package/src/api/controllers/row/index.ts +36 -13
  216. package/src/api/controllers/static/index.ts +2 -2
  217. package/src/api/controllers/static/templates/preview.hbs +10 -0
  218. package/src/api/controllers/table/bulkFormula.js +4 -3
  219. package/src/api/controllers/table/external.js +4 -4
  220. package/src/api/controllers/table/index.js +4 -4
  221. package/src/api/controllers/table/internal.ts +8 -9
  222. package/src/api/controllers/table/utils.ts +4 -53
  223. package/src/api/controllers/view/index.js +2 -2
  224. package/src/api/routes/backup.ts +10 -0
  225. package/src/api/routes/index.ts +11 -5
  226. package/src/api/routes/tests/backup.spec.js +1 -1
  227. package/src/api/routes/tests/{deployment.spec.js → deployment.spec.ts} +4 -4
  228. package/src/api/routes/tests/row.spec.js +22 -27
  229. package/src/app.ts +19 -2
  230. package/src/automations/automationUtils.js +2 -2
  231. package/src/automations/bullboard.js +8 -33
  232. package/src/automations/index.js +4 -4
  233. package/src/automations/steps/updateRow.js +2 -2
  234. package/src/automations/tests/automation.spec.js +1 -6
  235. package/src/automations/triggers.js +6 -6
  236. package/src/automations/utils.ts +18 -12
  237. package/src/constants/index.js +4 -6
  238. package/src/db/utils.js +17 -110
  239. package/src/definitions/automations.ts +0 -12
  240. package/src/definitions/datasource.ts +1 -0
  241. package/src/index.ts +1 -0
  242. package/src/integrations/arangodb.ts +2 -0
  243. package/src/integrations/base/sqlTable.ts +1 -0
  244. package/src/integrations/mongodb.ts +290 -27
  245. package/src/integrations/rest.ts +17 -5
  246. package/src/integrations/tests/mongo.spec.ts +19 -19
  247. package/src/integrations/tests/rest.spec.ts +38 -22
  248. package/src/migrations/functions/backfill/app/tables.ts +7 -13
  249. package/src/migrations/functions/backfill/global.ts +1 -1
  250. package/src/migrations/functions/{quotas1.ts → syncQuotas.ts} +3 -8
  251. package/src/migrations/functions/tests/{quotas1.spec.js → syncQuotas.spec.js} +5 -2
  252. package/src/migrations/functions/usageQuotas/syncApps.ts +0 -1
  253. package/src/migrations/functions/usageQuotas/syncPlugins.ts +10 -0
  254. package/src/migrations/functions/usageQuotas/syncRows.ts +15 -6
  255. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +9 -1
  256. package/src/migrations/index.ts +21 -45
  257. package/src/migrations/tests/index.spec.ts +0 -1
  258. package/src/sdk/app/backups/constants.ts +2 -0
  259. package/src/sdk/app/backups/exports.ts +171 -0
  260. package/src/sdk/app/backups/imports.ts +169 -0
  261. package/src/sdk/app/backups/index.ts +9 -0
  262. package/src/sdk/app/backups/statistics.ts +78 -0
  263. package/src/sdk/app/tables/index.ts +61 -0
  264. package/src/sdk/index.ts +13 -0
  265. package/src/tests/utilities/TestConfiguration.js +5 -2
  266. package/src/threads/automation.ts +20 -27
  267. package/src/utilities/csvParser.js +1 -0
  268. package/src/utilities/fileSystem/index.js +2 -119
  269. package/src/utilities/fileSystem/utilities.js +2 -0
  270. package/src/utilities/rowProcessor/index.js +5 -0
  271. package/src/utilities/usageQuota/rows.js +7 -3
  272. package/coverage/lcov-report/api/controllers/backup.js.html +0 -142
  273. package/coverage/lcov-report/api/routes/backup.js.html +0 -115
  274. package/dist/automations/listeners.js +0 -102
  275. package/src/api/routes/backup.js +0 -10
  276. package/src/automations/listeners.ts +0 -78
  277. package/src/migrations/functions/pluginCount.ts +0 -12
@@ -72,16 +72,12 @@ function getLoopIterations(loopStep, input) {
72
72
  * inputs and handles any outputs.
73
73
  */
74
74
  class Orchestrator {
75
- constructor(automation, triggerOutput, opts) {
75
+ constructor(job) {
76
+ let automation = job.data.automation, triggerOutput = job.data.event;
76
77
  const metadata = triggerOutput.metadata;
77
78
  this._chainCount = metadata ? metadata.automationChainCount : 0;
78
79
  this._appId = triggerOutput.appId;
79
- if (opts === null || opts === void 0 ? void 0 : opts.repeat) {
80
- this._repeat = {
81
- jobId: opts.repeat.jobId,
82
- jobKey: opts.repeat.key,
83
- };
84
- }
80
+ this._job = job;
85
81
  const triggerStepId = automation.definition.trigger.stepId;
86
82
  triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput);
87
83
  // remove from context
@@ -131,15 +127,14 @@ class Orchestrator {
131
127
  });
132
128
  }
133
129
  stopCron(reason) {
134
- var _a, _b;
135
130
  return __awaiter(this, void 0, void 0, function* () {
136
- if (!this._repeat) {
131
+ if (!this._job.opts.repeat) {
137
132
  return;
138
133
  }
139
134
  logWarn(`CRON disabled reason=${reason} - ${this._appId}/${this._automation._id}`);
140
135
  const automation = this._automation;
141
136
  const trigger = automation.definition.trigger;
142
- yield (0, utils_2.disableCron)((_a = this._repeat) === null || _a === void 0 ? void 0 : _a.jobId, (_b = this._repeat) === null || _b === void 0 ? void 0 : _b.jobKey);
137
+ yield (0, utils_2.disableCronById)(this._job.id);
143
138
  this.updateExecutionOutput(trigger.id, trigger.stepId, {}, {
144
139
  status: types_1.AutomationStatus.STOPPED_ERROR,
145
140
  success: false,
@@ -149,7 +144,7 @@ class Orchestrator {
149
144
  }
150
145
  checkIfShouldStop(metadata) {
151
146
  return __awaiter(this, void 0, void 0, function* () {
152
- if (!metadata.errorCount || !this._repeat) {
147
+ if (!metadata.errorCount || !this._job.opts.repeat) {
153
148
  return false;
154
149
  }
155
150
  if (metadata.errorCount >= constants_1.MAX_AUTOMATION_RECURRING_ERRORS) {
@@ -404,13 +399,13 @@ class Orchestrator {
404
399
  });
405
400
  }
406
401
  }
407
- function execute(input, callback) {
408
- const appId = input.data.event.appId;
402
+ function execute(job, callback) {
403
+ const appId = job.data.event.appId;
409
404
  if (!appId) {
410
405
  throw new Error("Unable to execute, event doesn't contain app ID.");
411
406
  }
412
407
  doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
413
- const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event, input.opts);
408
+ const automationOrchestrator = new Orchestrator(job);
414
409
  try {
415
410
  const response = yield automationOrchestrator.execute();
416
411
  callback(null, response);
@@ -421,13 +416,13 @@ function execute(input, callback) {
421
416
  }));
422
417
  }
423
418
  exports.execute = execute;
424
- const removeStalled = (input) => __awaiter(void 0, void 0, void 0, function* () {
425
- const appId = input.data.event.appId;
419
+ const removeStalled = (job) => __awaiter(void 0, void 0, void 0, function* () {
420
+ const appId = job.data.event.appId;
426
421
  if (!appId) {
427
422
  throw new Error("Unable to execute, event doesn't contain app ID.");
428
423
  }
429
424
  yield doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
430
- const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event, input.opts);
425
+ const automationOrchestrator = new Orchestrator(job);
431
426
  yield automationOrchestrator.stopCron("stalled");
432
427
  }));
433
428
  });