@budibase/server 1.0.212-alpha.10 → 1.0.212-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 (187) hide show
  1. package/builder/assets/{index.88005d52.js → index.8653aa05.js} +164 -165
  2. package/builder/assets/{index.c6912819.css → index.92958011.css} +2 -2
  3. package/builder/assets/{vendor.9bf2fcb4.js → vendor.b4361801.js} +163 -163
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +414 -394
  6. package/coverage/coverage-final.json +8 -8
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +111 -12
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +19 -19
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  45. package/coverage/lcov-report/api/index.html +15 -15
  46. package/coverage/lcov-report/api/index.js.html +18 -9
  47. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/automation.js.html +32 -2
  51. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/index.html +1 -1
  58. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  75. package/coverage/lcov-report/automations/actions.js.html +1 -1
  76. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  77. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  78. package/coverage/lcov-report/automations/index.html +1 -1
  79. package/coverage/lcov-report/automations/index.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/filter.js.html +58 -34
  86. package/coverage/lcov-report/automations/steps/index.html +11 -11
  87. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  106. package/coverage/lcov-report/constants/index.html +1 -1
  107. package/coverage/lcov-report/constants/index.js.html +1 -1
  108. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  109. package/coverage/lcov-report/constants/screens.js.html +1 -1
  110. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  111. package/coverage/lcov-report/db/index.html +14 -14
  112. package/coverage/lcov-report/db/index.js.html +1 -1
  113. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/index.html +13 -13
  115. package/coverage/lcov-report/db/linkedRows/index.js.html +10 -7
  116. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  117. package/coverage/lcov-report/db/newid.js.html +1 -1
  118. package/coverage/lcov-report/db/utils.js.html +14 -41
  119. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  120. package/coverage/lcov-report/events/index.html +1 -1
  121. package/coverage/lcov-report/events/index.js.html +1 -1
  122. package/coverage/lcov-report/events/utils.js.html +1 -1
  123. package/coverage/lcov-report/index.html +52 -52
  124. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  125. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  126. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  127. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  128. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  129. package/coverage/lcov-report/middleware/index.html +1 -1
  130. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  131. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  132. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  133. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  134. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  135. package/coverage/lcov-report/threads/automation.js.html +17 -8
  136. package/coverage/lcov-report/threads/index.html +11 -11
  137. package/coverage/lcov-report/threads/query.js.html +1 -1
  138. package/coverage/lcov-report/threads/utils.js.html +1 -1
  139. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  140. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  141. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  142. package/coverage/lcov-report/utilities/global.js.html +1 -1
  143. package/coverage/lcov-report/utilities/index.html +1 -1
  144. package/coverage/lcov-report/utilities/index.js.html +1 -1
  145. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  146. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  147. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  149. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  152. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  153. package/coverage/lcov-report/utilities/security.js.html +2 -2
  154. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  155. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  158. package/coverage/lcov-report/utilities/users.js.html +1 -1
  159. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  160. package/coverage/lcov.info +721 -687
  161. package/dist/api/controllers/application.js +18 -15
  162. package/dist/api/controllers/automation.js +28 -2
  163. package/dist/api/index.js +4 -1
  164. package/dist/api/routes/automation.js +2 -0
  165. package/dist/automations/logging/index.js +70 -0
  166. package/dist/automations/steps/filter.js +38 -29
  167. package/dist/db/linkedRows/index.js +1 -0
  168. package/dist/db/utils.js +3 -31
  169. package/dist/environment.js +1 -0
  170. package/dist/package.json +6 -6
  171. package/dist/threads/automation.js +5 -2
  172. package/dist/threads/index.js +15 -1
  173. package/dist/tsconfig.build.tsbuildinfo +1 -1
  174. package/package.json +7 -7
  175. package/src/api/controllers/application.ts +18 -14
  176. package/src/api/controllers/automation.js +35 -2
  177. package/src/api/index.js +4 -1
  178. package/src/api/routes/automation.js +10 -0
  179. package/src/automations/logging/index.ts +35 -0
  180. package/src/automations/steps/filter.js +36 -28
  181. package/src/automations/tests/filter.spec.js +2 -1
  182. package/src/db/linkedRows/index.js +1 -0
  183. package/src/db/utils.js +4 -13
  184. package/src/environment.js +1 -0
  185. package/src/module.d.ts +1 -0
  186. package/src/threads/automation.js +5 -2
  187. package/src/threads/index.ts +5 -1
@@ -33,7 +33,8 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
33
33
  const user_1 = require("./user");
34
34
  const { app: appCache } = require("@budibase/backend-core/cache");
35
35
  const utils_2 = require("../../automations/utils");
36
- const { getAppDB, getProdAppDB, updateAppId, } = require("@budibase/backend-core/context");
36
+ const logging_1 = require("../../automations/logging");
37
+ const { getAppDB, getProdAppDB, updateAppId, doInAppContext, } = require("@budibase/backend-core/context");
37
38
  const rows_1 = require("../../utilities/usageQuota/rows");
38
39
  const pro_1 = require("@budibase/pro");
39
40
  const backend_core_1 = require("@budibase/backend-core");
@@ -159,7 +160,7 @@ const fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
159
160
  }
160
161
  }
161
162
  }
162
- ctx.body = apps;
163
+ ctx.body = yield (0, logging_1.checkAppMetadata)(apps);
163
164
  });
164
165
  exports.fetch = fetch;
165
166
  const fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
@@ -486,19 +487,21 @@ const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
486
487
  });
487
488
  exports.sync = sync;
488
489
  const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
489
- const db = getAppDB();
490
- const application = yield db.get(utils_1.DocumentTypes.APP_METADATA);
491
- const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
492
- if (appPackage._rev !== application._rev) {
493
- newAppPackage._rev = application._rev;
494
- }
495
- // the locked by property is attached by server but generated from
496
- // Redis, shouldn't ever store it
497
- delete newAppPackage.lockedBy;
498
- yield db.put(newAppPackage);
499
- // remove any cached metadata, so that it will be updated
500
- yield appCache.invalidateAppMetadata(appId);
501
- return newAppPackage;
490
+ return doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
491
+ const db = getAppDB();
492
+ const application = yield db.get(utils_1.DocumentTypes.APP_METADATA);
493
+ const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
494
+ if (appPackage._rev !== application._rev) {
495
+ newAppPackage._rev = application._rev;
496
+ }
497
+ // the locked by property is attached by server but generated from
498
+ // Redis, shouldn't ever store it
499
+ delete newAppPackage.lockedBy;
500
+ yield db.put(newAppPackage);
501
+ // remove any cached metadata, so that it will be updated
502
+ yield appCache.invalidateAppMetadata(appId);
503
+ return newAppPackage;
504
+ }));
502
505
  });
503
506
  const createEmptyAppPackage = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
504
507
  const db = getAppDB();
@@ -10,13 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  const actions = require("../../automations/actions");
12
12
  const triggers = require("../../automations/triggers");
13
- const { getAutomationParams, generateAutomationID } = require("../../db/utils");
13
+ const { getAutomationParams, generateAutomationID, DocumentTypes, } = require("../../db/utils");
14
14
  const { checkForWebhooks, updateTestHistory, removeDeprecated, } = require("../../automations/utils");
15
15
  const { deleteEntityMetadata } = require("../../utilities");
16
16
  const { MetadataTypes } = require("../../constants");
17
17
  const { setTestFlag, clearTestFlag } = require("../../utilities/redis");
18
- const { getAppDB } = require("@budibase/backend-core/context");
18
+ const { getAppDB, getProdAppDB, doInAppContext, } = require("@budibase/backend-core/context");
19
19
  const { events } = require("@budibase/backend-core");
20
+ const { app } = require("@budibase/backend-core/cache");
21
+ const { automations } = require("@budibase/pro");
20
22
  const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS);
21
23
  const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS);
22
24
  /*************************
@@ -162,6 +164,30 @@ exports.destroy = function (ctx) {
162
164
  yield events.automation.deleted(oldAutomation);
163
165
  });
164
166
  };
167
+ exports.logSearch = function (ctx) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ ctx.body = yield automations.logs.logSearch(ctx.request.body);
170
+ });
171
+ };
172
+ exports.clearLogError = function (ctx) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const { automationId, appId } = ctx.request.body;
175
+ yield doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
176
+ const db = getProdAppDB();
177
+ const metadata = yield db.get(DocumentTypes.APP_METADATA);
178
+ if (!automationId) {
179
+ delete metadata.automationErrors;
180
+ }
181
+ else if (metadata.automationErrors &&
182
+ metadata.automationErrors[automationId]) {
183
+ delete metadata.automationErrors[automationId];
184
+ }
185
+ yield db.put(metadata);
186
+ yield app.invalidateAppMetadata(metadata.appId, metadata);
187
+ ctx.body = { message: `Error logs cleared.` };
188
+ }));
189
+ });
190
+ };
165
191
  exports.getActionList = function (ctx) {
166
192
  return __awaiter(this, void 0, void 0, function* () {
167
193
  ctx.body = ACTION_DEFS;
package/dist/api/index.js CHANGED
@@ -69,7 +69,10 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
69
69
  error,
70
70
  };
71
71
  ctx.log.error(err);
72
- console.trace(err);
72
+ // unauthorised errors don't provide a useful trace
73
+ if (!env.isTest()) {
74
+ console.trace(err);
75
+ }
73
76
  }
74
77
  }));
75
78
  // authenticated routes
@@ -15,6 +15,8 @@ router
15
15
  .get("/api/automations/:id", paramResource("id"), authorized(BUILDER), controller.find)
16
16
  .put("/api/automations", bodyResource("_id"), authorized(BUILDER), automationValidator(true), controller.update)
17
17
  .post("/api/automations", authorized(BUILDER), automationValidator(false), controller.create)
18
+ .post("/api/automations/logs/search", authorized(BUILDER), controller.logSearch)
19
+ .delete("/api/automations/logs", authorized(BUILDER), controller.clearLogError)
18
20
  .delete("/api/automations/:id/:rev", paramResource("id"), authorized(BUILDER), controller.destroy)
19
21
  .post("/api/automations/:id/trigger", appInfoMiddleware({ appType: AppType.PROD }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.trigger)
20
22
  .post("/api/automations/:id/test", appInfoMiddleware({ appType: AppType.DEV }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.test);
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.checkAppMetadata = exports.storeLog = void 0;
36
+ const env = __importStar(require("../../environment"));
37
+ const pro_1 = require("@budibase/pro");
38
+ const backend_core_1 = require("@budibase/backend-core");
39
+ function storeLog(automation, results) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ // can disable this if un-needed in self-host, also only do this for prod apps
42
+ if (env.DISABLE_AUTOMATION_LOGS) {
43
+ return;
44
+ }
45
+ yield pro_1.automations.logs.storeLog(automation, results);
46
+ });
47
+ }
48
+ exports.storeLog = storeLog;
49
+ function checkAppMetadata(apps) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const maxStartDate = yield pro_1.automations.logs.oldestLogDate();
52
+ for (let metadata of apps) {
53
+ if (!metadata.automationErrors) {
54
+ continue;
55
+ }
56
+ for (let [key, errors] of Object.entries(metadata.automationErrors)) {
57
+ const updated = [];
58
+ for (let error of errors) {
59
+ const startDate = error.split(backend_core_1.db.SEPARATOR)[2];
60
+ if (startDate > maxStartDate) {
61
+ updated.push(error);
62
+ }
63
+ }
64
+ metadata.automationErrors[key] = updated;
65
+ }
66
+ }
67
+ return apps;
68
+ });
69
+ }
70
+ exports.checkAppMetadata = checkAppMetadata;
@@ -56,46 +56,55 @@ exports.definition = {
56
56
  outputs: {
57
57
  properties: {
58
58
  success: {
59
+ type: "boolean",
60
+ description: "Whether the action was successful",
61
+ },
62
+ result: {
59
63
  type: "boolean",
60
64
  description: "Whether the logic block passed",
61
65
  },
62
66
  },
63
- required: ["success"],
67
+ required: ["success", "result"],
64
68
  },
65
69
  },
66
70
  };
67
71
  exports.run = function filter({ inputs }) {
68
72
  return __awaiter(this, void 0, void 0, function* () {
69
- let { field, condition, value } = inputs;
70
- // coerce types so that we can use them
71
- if (!isNaN(value) && !isNaN(field)) {
72
- value = parseFloat(value);
73
- field = parseFloat(field);
74
- }
75
- else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
76
- value = Date.parse(value);
77
- field = Date.parse(field);
78
- }
79
- let success = false;
80
- if (typeof field !== "object" && typeof value !== "object") {
81
- switch (condition) {
82
- case FilterConditions.EQUAL:
83
- success = field === value;
84
- break;
85
- case FilterConditions.NOT_EQUAL:
86
- success = field !== value;
87
- break;
88
- case FilterConditions.GREATER_THAN:
89
- success = field > value;
90
- break;
91
- case FilterConditions.LESS_THAN:
92
- success = field < value;
93
- break;
73
+ try {
74
+ let { field, condition, value } = inputs;
75
+ // coerce types so that we can use them
76
+ if (!isNaN(value) && !isNaN(field)) {
77
+ value = parseFloat(value);
78
+ field = parseFloat(field);
79
+ }
80
+ else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
81
+ value = Date.parse(value);
82
+ field = Date.parse(field);
83
+ }
84
+ let result = false;
85
+ if (typeof field !== "object" && typeof value !== "object") {
86
+ switch (condition) {
87
+ case FilterConditions.EQUAL:
88
+ result = field === value;
89
+ break;
90
+ case FilterConditions.NOT_EQUAL:
91
+ result = field !== value;
92
+ break;
93
+ case FilterConditions.GREATER_THAN:
94
+ result = field > value;
95
+ break;
96
+ case FilterConditions.LESS_THAN:
97
+ result = field < value;
98
+ break;
99
+ }
100
+ }
101
+ else {
102
+ result = false;
94
103
  }
104
+ return { success: true, result };
95
105
  }
96
- else {
97
- success = false;
106
+ catch (err) {
107
+ return { success: false, result: false };
98
108
  }
99
- return { success };
100
109
  });
101
110
  };
@@ -56,6 +56,7 @@ function getLinksForRows(rows) {
56
56
  // have to get unique as the previous table query can
57
57
  // return duplicates, could be querying for both tables in a relation
58
58
  return getUniqueByProp(responses
59
+ .filter(el => el != null)
59
60
  // create a unique ID which we can use for getting only unique ones
60
61
  .map(el => (Object.assign(Object.assign({}, el), { unique: el.id + el.thisId + el.fieldName }))), "unique");
61
62
  });
package/dist/db/utils.js CHANGED
@@ -1,39 +1,13 @@
1
1
  "use strict";
2
2
  const newid = require("./newid");
3
- const { DocumentTypes: CoreDocTypes, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, getDevelopmentAppID, generateAppID, } = require("@budibase/backend-core/db");
3
+ const { DocumentTypes: CoreDocTypes, getRoleParams, generateRoleID, APP_DEV_PREFIX, APP_PREFIX, SEPARATOR, StaticDatabases, isDevAppID, isProdAppID, getDevelopmentAppID, generateAppID, getQueryIndex, ViewNames, } = require("@budibase/backend-core/db");
4
4
  const UNICODE_MAX = "\ufff0";
5
5
  const AppStatus = {
6
6
  DEV: "development",
7
7
  ALL: "all",
8
8
  DEPLOYED: "published",
9
9
  };
10
- const DocumentTypes = {
11
- APP: CoreDocTypes.APP,
12
- DEV: CoreDocTypes.DEV,
13
- APP_DEV: CoreDocTypes.APP_DEV,
14
- APP_METADATA: CoreDocTypes.APP_METADATA,
15
- ROLE: CoreDocTypes.ROLE,
16
- TABLE: "ta",
17
- ROW: "ro",
18
- USER: "us",
19
- AUTOMATION: "au",
20
- LINK: "li",
21
- WEBHOOK: "wh",
22
- INSTANCE: "inst",
23
- LAYOUT: "layout",
24
- SCREEN: "screen",
25
- DATASOURCE: "datasource",
26
- DATASOURCE_PLUS: "datasource_plus",
27
- QUERY: "query",
28
- DEPLOYMENTS: "deployments",
29
- METADATA: "metadata",
30
- MEM_VIEW: "view",
31
- USER_FLAG: "flag",
32
- };
33
- const ViewNames = {
34
- LINK: "by_link",
35
- ROUTING: "screen_routes",
36
- };
10
+ const DocumentTypes = Object.assign(Object.assign({}, CoreDocTypes), { TABLE: "ta", ROW: "ro", USER: "us", AUTOMATION: "au", LINK: "li", WEBHOOK: "wh", INSTANCE: "inst", LAYOUT: "layout", SCREEN: "screen", DATASOURCE: "datasource", DATASOURCE_PLUS: "datasource_plus", QUERY: "query", DEPLOYMENTS: "deployments", METADATA: "metadata", MEM_VIEW: "view", USER_FLAG: "flag" });
37
11
  const InternalTables = {
38
12
  USER_METADATA: "ta_users",
39
13
  };
@@ -67,9 +41,7 @@ exports.generateAppID = generateAppID;
67
41
  exports.generateDevAppID = getDevelopmentAppID;
68
42
  exports.generateRoleID = generateRoleID;
69
43
  exports.getRoleParams = getRoleParams;
70
- exports.getQueryIndex = viewName => {
71
- return `database/${viewName}`;
72
- };
44
+ exports.getQueryIndex = getQueryIndex;
73
45
  /**
74
46
  * If creating DB allDocs/query params with only a single top level ID this can be used, this
75
47
  * is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
@@ -66,6 +66,7 @@ module.exports = {
66
66
  ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
67
67
  DISABLE_THREADING: process.env.DISABLE_THREADING,
68
68
  DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
69
+ DISABLE_AUTOMATION_LOGS: process.env.DISABLE_AUTOMATION_LOGS,
69
70
  MULTI_TENANCY: process.env.MULTI_TENANCY,
70
71
  ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
71
72
  SELF_HOSTED: process.env.SELF_HOSTED,
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.212-alpha.9",
4
+ "version": "1.0.212-alpha.12",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -77,11 +77,11 @@
77
77
  "license": "GPL-3.0",
78
78
  "dependencies": {
79
79
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "^1.0.212-alpha.9",
81
- "@budibase/client": "^1.0.212-alpha.9",
82
- "@budibase/pro": "1.0.212-alpha.9",
83
- "@budibase/string-templates": "^1.0.212-alpha.9",
84
- "@budibase/types": "^1.0.212-alpha.9",
80
+ "@budibase/backend-core": "^1.0.212-alpha.12",
81
+ "@budibase/client": "^1.0.212-alpha.12",
82
+ "@budibase/pro": "1.0.212-alpha.12",
83
+ "@budibase/string-templates": "^1.0.212-alpha.12",
84
+ "@budibase/types": "^1.0.212-alpha.12",
85
85
  "@bull-board/api": "3.7.0",
86
86
  "@bull-board/koa": "3.9.4",
87
87
  "@elastic/elasticsearch": "7.10.0",
@@ -19,10 +19,11 @@ const { doInTenant } = require("@budibase/backend-core/tenancy");
19
19
  const { definitions: triggerDefs } = require("../automations/triggerInfo");
20
20
  const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
21
21
  const { AutomationErrors, LoopStepTypes } = require("../constants");
22
+ const { storeLog } = require("../automations/logging");
22
23
  const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
23
24
  const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId;
24
25
  const CRON_STEP_ID = triggerDefs.CRON.stepId;
25
- const STOPPED_STATUS = { success: false, status: "STOPPED" };
26
+ const STOPPED_STATUS = { success: true, status: "STOPPED" };
26
27
  const { cloneDeep } = require("lodash/fp");
27
28
  const env = require("../environment");
28
29
  function typecastForLooping(loopStep, input) {
@@ -248,7 +249,7 @@ class Orchestrator {
248
249
  this._context.steps[stepCount] = outputs;
249
250
  // if filter causes us to stop execution don't break the loop, set a var
250
251
  // so that we can finish iterating through the steps and record that it stopped
251
- if (step.stepId === FILTER_STEP_ID && !outputs.success) {
252
+ if (step.stepId === FILTER_STEP_ID && !outputs.result) {
252
253
  stopped = true;
253
254
  this.updateExecutionOutput(step.id, step.stepId, step.inputs, Object.assign(Object.assign({}, outputs), STOPPED_STATUS));
254
255
  continue;
@@ -289,6 +290,8 @@ class Orchestrator {
289
290
  loopSteps = null;
290
291
  }
291
292
  }
293
+ // store the logs for the automation run
294
+ yield storeLog(this._automation, this.executionOutput);
292
295
  return this.executionOutput;
293
296
  });
294
297
  }
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
@@ -92,7 +101,7 @@ class Thread {
92
101
  });
93
102
  });
94
103
  }
95
- static shutdown() {
104
+ static stopThreads() {
96
105
  return new Promise(resolve => {
97
106
  if (Thread.workerRefs.length === 0) {
98
107
  resolve();
@@ -110,6 +119,11 @@ class Thread {
110
119
  Thread.workerRefs = [];
111
120
  });
112
121
  }
122
+ static shutdown() {
123
+ return __awaiter(this, void 0, void 0, function* () {
124
+ yield Thread.stopThreads();
125
+ });
126
+ }
113
127
  }
114
128
  exports.Thread = Thread;
115
129
  Thread.workerRefs = [];