@budibase/server 1.0.200-alpha.3 → 1.0.200

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 (285) hide show
  1. package/Dockerfile +0 -2
  2. package/builder/assets/index.f83b3433.js +1315 -0
  3. package/builder/index.html +1 -1
  4. package/coverage/clover.xml +1998 -2086
  5. package/coverage/coverage-final.json +122 -121
  6. package/coverage/lcov-report/api/controllers/analytics.js.html +202 -0
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  8. package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
  9. package/coverage/lcov-report/api/controllers/automation.js.html +72 -174
  10. package/coverage/lcov-report/api/controllers/backup.js.html +6 -30
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
  12. package/coverage/lcov-report/api/controllers/component.js.html +5 -5
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +41 -53
  14. package/coverage/lcov-report/api/controllers/dev.js.html +70 -94
  15. package/coverage/lcov-report/api/controllers/index.html +72 -57
  16. package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
  17. package/coverage/lcov-report/api/controllers/layout.js.html +19 -28
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
  20. package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
  23. package/coverage/lcov-report/api/controllers/role.js.html +48 -78
  24. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  25. package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
  26. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/internal.js.html +54 -54
  28. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
  29. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
  30. package/coverage/lcov-report/api/controllers/row/utils.js.html +24 -24
  31. package/coverage/lcov-report/api/controllers/screen.js.html +20 -56
  32. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  33. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
  34. package/coverage/lcov-report/api/controllers/table/external.js.html +17 -23
  35. package/coverage/lcov-report/api/controllers/table/index.html +26 -26
  36. package/coverage/lcov-report/api/controllers/table/index.js.html +49 -85
  37. package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
  38. package/coverage/lcov-report/api/controllers/user.js.html +19 -19
  39. package/coverage/lcov-report/api/controllers/view/exporters.js.html +11 -11
  40. package/coverage/lcov-report/api/controllers/view/index.html +21 -21
  41. package/coverage/lcov-report/api/controllers/view/index.js.html +65 -275
  42. package/coverage/lcov-report/api/controllers/view/utils.js.html +23 -23
  43. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +40 -40
  44. package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
  45. package/coverage/lcov-report/api/index.html +15 -15
  46. package/coverage/lcov-report/api/index.js.html +45 -39
  47. package/coverage/lcov-report/api/routes/analytics.js.html +13 -7
  48. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  49. package/coverage/lcov-report/api/routes/auth.js.html +6 -6
  50. package/coverage/lcov-report/api/routes/automation.js.html +11 -11
  51. package/coverage/lcov-report/api/routes/backup.js.html +8 -8
  52. package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
  53. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  54. package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
  55. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  56. package/coverage/lcov-report/api/routes/dev.js.html +13 -13
  57. package/coverage/lcov-report/api/routes/index.html +1 -1
  58. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  59. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  60. package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
  61. package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
  62. package/coverage/lcov-report/api/routes/permission.js.html +9 -9
  63. package/coverage/lcov-report/api/routes/query.js.html +10 -10
  64. package/coverage/lcov-report/api/routes/role.js.html +9 -9
  65. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  66. package/coverage/lcov-report/api/routes/screen.js.html +9 -9
  67. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/table.js.html +10 -10
  69. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  70. package/coverage/lcov-report/api/routes/user.js.html +8 -8
  71. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/validators.js.html +36 -36
  73. package/coverage/lcov-report/api/routes/view.js.html +10 -10
  74. package/coverage/lcov-report/api/routes/webhook.js.html +9 -9
  75. package/coverage/lcov-report/automations/actions.js.html +25 -25
  76. package/coverage/lcov-report/automations/automationUtils.js.html +8 -8
  77. package/coverage/lcov-report/automations/bullboard.js.html +35 -35
  78. package/coverage/lcov-report/automations/index.html +29 -29
  79. package/coverage/lcov-report/automations/index.js.html +17 -29
  80. package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
  81. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  82. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  83. package/coverage/lcov-report/automations/steps/executeQuery.js.html +7 -7
  84. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  85. package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
  86. package/coverage/lcov-report/automations/steps/index.html +1 -1
  87. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  88. package/coverage/lcov-report/automations/steps/loop.js.html +2 -2
  89. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  90. package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
  91. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  92. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  93. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  94. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  95. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  96. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  97. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  98. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  99. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  101. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  102. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  103. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  104. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  105. package/coverage/lcov-report/automations/triggers.js.html +18 -18
  106. package/coverage/lcov-report/constants/index.html +1 -1
  107. package/coverage/lcov-report/constants/index.js.html +30 -30
  108. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  109. package/coverage/lcov-report/constants/screens.js.html +4 -4
  110. package/coverage/lcov-report/db/inMemoryView.js.html +5 -5
  111. package/coverage/lcov-report/db/index.html +1 -1
  112. package/coverage/lcov-report/db/index.js.html +9 -9
  113. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
  114. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
  116. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +19 -19
  117. package/coverage/lcov-report/db/newid.js.html +4 -4
  118. package/coverage/lcov-report/db/utils.js.html +81 -81
  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 +7 -7
  122. package/coverage/lcov-report/events/utils.js.html +10 -10
  123. package/coverage/lcov-report/index.html +74 -74
  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 +5 -5
  127. package/coverage/lcov-report/middleware/builder.js.html +20 -20
  128. package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
  129. package/coverage/lcov-report/middleware/index.html +1 -1
  130. package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
  131. package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
  132. package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
  133. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  134. package/coverage/lcov-report/middleware/utils.js.html +4 -4
  135. package/coverage/lcov-report/threads/automation.js.html +1 -1
  136. package/coverage/lcov-report/threads/index.html +1 -1
  137. package/coverage/lcov-report/threads/query.js.html +1 -1
  138. package/coverage/lcov-report/threads/utils.js.html +13 -13
  139. package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
  140. package/coverage/lcov-report/utilities/centralPath.js.html +14 -14
  141. package/coverage/lcov-report/utilities/csvParser.js.html +34 -34
  142. package/coverage/lcov-report/utilities/global.js.html +28 -28
  143. package/coverage/lcov-report/utilities/index.html +25 -25
  144. package/coverage/lcov-report/utilities/index.js.html +41 -41
  145. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
  146. package/coverage/lcov-report/utilities/queue/index.html +15 -15
  147. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  149. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +59 -59
  151. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
  152. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  153. package/coverage/lcov-report/utilities/security.js.html +8 -8
  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 +30 -30
  157. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  158. package/coverage/lcov-report/utilities/users.js.html +7 -7
  159. package/coverage/lcov-report/utilities/workerRequests.js.html +29 -29
  160. package/coverage/lcov.info +2762 -2903
  161. package/dist/api/controllers/analytics.js +30 -7
  162. package/dist/api/controllers/application.js +16 -56
  163. package/dist/api/controllers/automation.js +2 -31
  164. package/dist/api/controllers/backup.js +0 -7
  165. package/dist/api/controllers/datasource.js +2 -8
  166. package/dist/api/controllers/deploy/index.js +2 -6
  167. package/dist/api/controllers/dev.js +2 -9
  168. package/dist/api/controllers/layout.js +0 -3
  169. package/dist/api/controllers/query/import/index.js +2 -12
  170. package/dist/api/controllers/query/import/sources/curl.js +0 -3
  171. package/dist/api/controllers/query/import/sources/openapi2.js +0 -3
  172. package/dist/api/controllers/query/import/sources/openapi3.js +0 -3
  173. package/dist/api/controllers/query/index.js +2 -16
  174. package/dist/api/controllers/role.js +0 -11
  175. package/dist/api/controllers/screen.js +1 -10
  176. package/dist/api/controllers/static/index.js +15 -29
  177. package/dist/api/controllers/table/external.js +0 -2
  178. package/dist/api/controllers/table/index.js +0 -12
  179. package/dist/api/controllers/table/utils.js +3 -3
  180. package/dist/api/controllers/view/index.js +6 -62
  181. package/dist/api/index.js +4 -2
  182. package/dist/api/routes/analytics.js +3 -1
  183. package/dist/app.js +8 -16
  184. package/dist/automations/index.js +0 -4
  185. package/dist/automations/steps/executeQuery.js +1 -1
  186. package/dist/environment.js +2 -4
  187. package/dist/integrations/firebase.js +0 -1
  188. package/dist/migrations/index.js +31 -95
  189. package/dist/package.json +69 -79
  190. package/dist/tests/utilities/TestConfiguration.js +93 -121
  191. package/dist/tests/utilities/structures.js +0 -45
  192. package/dist/tsconfig.build.tsbuildinfo +1 -1
  193. package/nodemon.json +1 -1
  194. package/package.json +70 -80
  195. package/scripts/dev/manage.js +0 -2
  196. package/scripts/jestSetup.js +0 -7
  197. package/scripts/likeCypress.ts +1 -1
  198. package/src/api/controllers/analytics.js +39 -0
  199. package/src/api/controllers/application.ts +18 -60
  200. package/src/api/controllers/automation.js +2 -36
  201. package/src/api/controllers/backup.js +0 -8
  202. package/src/api/controllers/datasource.js +4 -8
  203. package/src/api/controllers/deploy/index.ts +2 -6
  204. package/src/api/controllers/dev.js +2 -10
  205. package/src/api/controllers/layout.js +0 -3
  206. package/src/api/controllers/query/import/index.ts +3 -16
  207. package/src/api/controllers/query/import/sources/base/index.ts +1 -2
  208. package/src/api/controllers/query/import/sources/curl.ts +0 -4
  209. package/src/api/controllers/query/import/sources/openapi2.ts +0 -4
  210. package/src/api/controllers/query/import/sources/openapi3.ts +0 -4
  211. package/src/api/controllers/query/import/tests/index.spec.js +7 -20
  212. package/src/api/controllers/query/index.ts +3 -16
  213. package/src/api/controllers/role.js +0 -10
  214. package/src/api/controllers/screen.js +1 -13
  215. package/src/api/controllers/static/index.js +15 -28
  216. package/src/api/controllers/table/external.js +0 -2
  217. package/src/api/controllers/table/index.js +0 -12
  218. package/src/api/controllers/table/utils.ts +4 -4
  219. package/src/api/controllers/view/index.js +6 -76
  220. package/src/api/index.js +4 -2
  221. package/src/api/routes/analytics.js +3 -1
  222. package/src/api/routes/public/utils/Endpoint.ts +1 -1
  223. package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +1 -5
  224. package/src/api/routes/tests/application.spec.js +4 -64
  225. package/src/api/routes/tests/automation.spec.js +60 -168
  226. package/src/api/routes/tests/backup.spec.js +0 -2
  227. package/src/api/routes/tests/datasource.spec.js +0 -5
  228. package/src/api/routes/tests/layout.spec.js +0 -4
  229. package/src/api/routes/tests/query.spec.js +13 -56
  230. package/src/api/routes/tests/role.spec.js +7 -40
  231. package/src/api/routes/tests/row.spec.js +3 -2
  232. package/src/api/routes/tests/screen.spec.js +4 -30
  233. package/src/api/routes/tests/static.spec.js +54 -120
  234. package/src/api/routes/tests/table.spec.js +38 -102
  235. package/src/api/routes/tests/view.spec.js +43 -222
  236. package/src/app.ts +9 -18
  237. package/src/automations/index.js +0 -4
  238. package/src/automations/steps/executeQuery.js +1 -1
  239. package/src/automations/tests/delay.spec.js +0 -4
  240. package/src/environment.js +2 -5
  241. package/src/integrations/firebase.ts +0 -1
  242. package/src/migrations/index.ts +51 -120
  243. package/src/module.d.ts +1 -0
  244. package/src/tests/utilities/TestConfiguration.js +90 -138
  245. package/src/tests/utilities/structures.js +0 -71
  246. package/tsconfig.build.json +5 -20
  247. package/tsconfig.json +17 -22
  248. package/builder/assets/index.05491b9d.js +0 -1315
  249. package/dist/migrations/functions/backfill/app/automations.js +0 -31
  250. package/dist/migrations/functions/backfill/app/datasources.js +0 -28
  251. package/dist/migrations/functions/backfill/app/layouts.js +0 -33
  252. package/dist/migrations/functions/backfill/app/queries.js +0 -32
  253. package/dist/migrations/functions/backfill/app/roles.js +0 -28
  254. package/dist/migrations/functions/backfill/app/screens.js +0 -28
  255. package/dist/migrations/functions/backfill/app/tables.js +0 -40
  256. package/dist/migrations/functions/backfill/app.js +0 -175
  257. package/dist/migrations/functions/backfill/global/configs.js +0 -61
  258. package/dist/migrations/functions/backfill/global/quotas.js +0 -60
  259. package/dist/migrations/functions/backfill/global/users.js +0 -50
  260. package/dist/migrations/functions/backfill/global.js +0 -189
  261. package/dist/migrations/functions/backfill/index.js +0 -32
  262. package/dist/migrations/functions/backfill/installation.js +0 -80
  263. package/dist/migrations/tests/helpers.js +0 -72
  264. package/dist/migrations/tests/structures.js +0 -37
  265. package/src/api/controllers/analytics.ts +0 -8
  266. package/src/api/routes/tests/data/export.txt +0 -1
  267. package/src/api/routes/tests/deployment.spec.js +0 -25
  268. package/src/api/routes/tests/dev.spec.js +0 -40
  269. package/src/migrations/functions/backfill/app/automations.ts +0 -26
  270. package/src/migrations/functions/backfill/app/datasources.ts +0 -22
  271. package/src/migrations/functions/backfill/app/layouts.ts +0 -29
  272. package/src/migrations/functions/backfill/app/queries.ts +0 -33
  273. package/src/migrations/functions/backfill/app/roles.ts +0 -22
  274. package/src/migrations/functions/backfill/app/screens.ts +0 -22
  275. package/src/migrations/functions/backfill/app/tables.ts +0 -36
  276. package/src/migrations/functions/backfill/app.ts +0 -148
  277. package/src/migrations/functions/backfill/global/configs.ts +0 -66
  278. package/src/migrations/functions/backfill/global/quotas.ts +0 -60
  279. package/src/migrations/functions/backfill/global/users.ts +0 -49
  280. package/src/migrations/functions/backfill/global.ts +0 -194
  281. package/src/migrations/functions/backfill/index.ts +0 -7
  282. package/src/migrations/functions/backfill/installation.ts +0 -50
  283. package/src/migrations/tests/helpers.ts +0 -40
  284. package/src/migrations/tests/index.spec.ts +0 -132
  285. package/src/migrations/tests/structures.ts +0 -66
@@ -1,189 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.getInstallTimestamp = exports.isComplete = exports.run = void 0;
39
- const users = __importStar(require("./global/users"));
40
- const configs = __importStar(require("./global/configs"));
41
- const quotas = __importStar(require("./global/quotas"));
42
- const backend_core_1 = require("@budibase/backend-core");
43
- const types_1 = require("@budibase/types");
44
- const environment_1 = __importDefault(require("../../../environment"));
45
- const _1 = require(".");
46
- const failGraceful = environment_1.default.SELF_HOSTED && !environment_1.default.isDev();
47
- const handleError = (e, errors) => {
48
- if (failGraceful) {
49
- if (errors) {
50
- errors.push(e);
51
- }
52
- return;
53
- }
54
- throw e;
55
- };
56
- const formatUsage = (usage) => {
57
- let maxAutomations = 0;
58
- let maxQueries = 0;
59
- let rows = 0;
60
- let developers = 0;
61
- if (usage) {
62
- if (usage.usageQuota) {
63
- rows = usage.usageQuota.rows;
64
- developers = usage.usageQuota.developers;
65
- }
66
- if (usage.monthly) {
67
- for (const value of Object.values(usage.monthly)) {
68
- if (value.automations > maxAutomations) {
69
- maxAutomations = value.automations;
70
- }
71
- if (value.queries > maxQueries) {
72
- maxQueries = value.queries;
73
- }
74
- }
75
- }
76
- }
77
- return {
78
- maxAutomations,
79
- maxQueries,
80
- rows,
81
- developers,
82
- };
83
- };
84
- const EVENTS = [
85
- types_1.Event.EMAIL_SMTP_CREATED,
86
- types_1.Event.AUTH_SSO_CREATED,
87
- types_1.Event.AUTH_SSO_ACTIVATED,
88
- types_1.Event.ORG_NAME_UPDATED,
89
- types_1.Event.ORG_LOGO_UPDATED,
90
- types_1.Event.ORG_PLATFORM_URL_UPDATED,
91
- types_1.Event.USER_CREATED,
92
- types_1.Event.USER_PERMISSION_ADMIN_ASSIGNED,
93
- types_1.Event.USER_PERMISSION_BUILDER_ASSIGNED,
94
- types_1.Event.ROLE_ASSIGNED,
95
- types_1.Event.ROWS_CREATED,
96
- types_1.Event.QUERIES_RUN,
97
- types_1.Event.AUTOMATIONS_RUN,
98
- ];
99
- /**
100
- * Date:
101
- * May 2022
102
- *
103
- * Description:
104
- * Backfill global events.
105
- */
106
- const run = (db) => __awaiter(void 0, void 0, void 0, function* () {
107
- try {
108
- const tenantId = backend_core_1.tenancy.getTenantId();
109
- let timestamp = _1.DEFAULT_TIMESTAMP;
110
- const totals = {};
111
- const errors = [];
112
- try {
113
- const installTimestamp = yield (0, exports.getInstallTimestamp)(db);
114
- if (installTimestamp) {
115
- timestamp = installTimestamp;
116
- }
117
- }
118
- catch (e) {
119
- handleError(e, errors);
120
- }
121
- let account;
122
- if (!environment_1.default.SELF_HOSTED && !environment_1.default.DISABLE_ACCOUNT_PORTAL) {
123
- account = yield backend_core_1.accounts.getAccountByTenantId(tenantId);
124
- }
125
- try {
126
- yield backend_core_1.events.identification.identifyTenantGroup(tenantId, account, timestamp);
127
- }
128
- catch (e) {
129
- handleError(e, errors);
130
- }
131
- // tell the event pipeline to start caching
132
- // events for this tenant
133
- yield backend_core_1.events.backfillCache.start(EVENTS);
134
- try {
135
- yield configs.backfill(db, timestamp);
136
- }
137
- catch (e) {
138
- handleError(e, errors);
139
- }
140
- try {
141
- totals.users = yield users.backfill(db, account);
142
- }
143
- catch (e) {
144
- handleError(e, errors);
145
- }
146
- try {
147
- const allApps = yield backend_core_1.db.getAllApps({ dev: true });
148
- totals.apps = allApps.length;
149
- totals.usage = yield quotas.backfill(allApps);
150
- }
151
- catch (e) {
152
- handleError(e, errors);
153
- }
154
- const properties = Object.assign(Object.assign({ apps: totals.apps, users: totals.users }, formatUsage(totals.usage)), { usage: totals.usage });
155
- if (errors.length) {
156
- properties.errors = errors.map((e) => JSON.stringify(e, Object.getOwnPropertyNames(e)));
157
- properties.errorCount = errors.length;
158
- }
159
- else {
160
- properties.errorCount = 0;
161
- }
162
- yield backend_core_1.events.backfill.tenantSucceeded(properties);
163
- // tell the event pipeline to stop caching events for this tenant
164
- yield backend_core_1.events.backfillCache.end();
165
- }
166
- catch (e) {
167
- handleError(e);
168
- yield backend_core_1.events.backfill.tenantFailed(e);
169
- }
170
- });
171
- exports.run = run;
172
- const isComplete = () => __awaiter(void 0, void 0, void 0, function* () {
173
- const globalDb = backend_core_1.tenancy.getGlobalDB();
174
- const migrationsDoc = yield backend_core_1.migrations.getMigrationsDoc(globalDb);
175
- return !!migrationsDoc.event_global_backfill;
176
- });
177
- exports.isComplete = isComplete;
178
- const getInstallTimestamp = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
179
- const allUsers = yield users.getUsers(globalDb);
180
- // get the oldest user timestamp
181
- const timestamps = allUsers
182
- .map(user => user.createdAt)
183
- .filter(timestamp => !!timestamp)
184
- .sort((a, b) => new Date(a).getTime() - new Date(b).getTime());
185
- if (timestamps.length) {
186
- return timestamps[0];
187
- }
188
- });
189
- exports.getInstallTimestamp = getInstallTimestamp;
@@ -1,32 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.DEFAULT_TIMESTAMP = exports.installation = exports.global = exports.app = void 0;
27
- exports.app = __importStar(require("./app"));
28
- exports.global = __importStar(require("./global"));
29
- exports.installation = __importStar(require("./installation"));
30
- // historical events are free in posthog - make sure we default to a
31
- // historical time if no other can be found
32
- exports.DEFAULT_TIMESTAMP = new Date(2022, 0, 1).getTime();
@@ -1,80 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.run = void 0;
39
- const index_1 = require("./index");
40
- const backend_core_1 = require("@budibase/backend-core");
41
- const global = __importStar(require("./global"));
42
- const environment_1 = __importDefault(require("../../../environment"));
43
- const failGraceful = environment_1.default.SELF_HOSTED;
44
- const handleError = (e, errors) => {
45
- if (failGraceful) {
46
- if (errors) {
47
- errors.push(e);
48
- }
49
- return;
50
- }
51
- throw e;
52
- };
53
- /**
54
- * Date:
55
- * May 2022
56
- *
57
- * Description:
58
- * Backfill installation events.
59
- */
60
- const run = () => __awaiter(void 0, void 0, void 0, function* () {
61
- try {
62
- // need to use the default tenant to try to get the installation time
63
- yield backend_core_1.tenancy.doInTenant(backend_core_1.tenancy.DEFAULT_TENANT_ID, () => __awaiter(void 0, void 0, void 0, function* () {
64
- const db = backend_core_1.tenancy.getGlobalDB();
65
- let timestamp = index_1.DEFAULT_TIMESTAMP;
66
- const installTimestamp = yield global.getInstallTimestamp(db);
67
- if (installTimestamp) {
68
- timestamp = installTimestamp;
69
- }
70
- const install = yield backend_core_1.installation.getInstall();
71
- yield backend_core_1.events.identification.identifyInstallationGroup(install.installId, timestamp);
72
- }));
73
- yield backend_core_1.events.backfill.installationSucceeded();
74
- }
75
- catch (e) {
76
- handleError(e);
77
- yield backend_core_1.events.backfill.installationFailed(e);
78
- }
79
- });
80
- exports.run = run;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- // Mimic configs test configuration from worker, creation configs directly in database
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
- return new (P || (P = Promise))(function (resolve, reject) {
29
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
- step((generator = generator.apply(thisArg, _arguments || [])).next());
33
- });
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.saveSmtpConfig = exports.saveOIDCConfig = exports.saveGoogleConfig = exports.saveSettingsConfig = void 0;
37
- const structures = __importStar(require("./structures"));
38
- const backend_core_1 = require("@budibase/backend-core");
39
- const saveSettingsConfig = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
40
- const config = structures.settings();
41
- yield saveConfig(config, globalDb);
42
- });
43
- exports.saveSettingsConfig = saveSettingsConfig;
44
- const saveGoogleConfig = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
45
- const config = structures.google();
46
- yield saveConfig(config, globalDb);
47
- });
48
- exports.saveGoogleConfig = saveGoogleConfig;
49
- const saveOIDCConfig = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
50
- const config = structures.oidc();
51
- yield saveConfig(config, globalDb);
52
- });
53
- exports.saveOIDCConfig = saveOIDCConfig;
54
- const saveSmtpConfig = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
55
- const config = structures.smtp();
56
- yield saveConfig(config, globalDb);
57
- });
58
- exports.saveSmtpConfig = saveSmtpConfig;
59
- const saveConfig = (config, globalDb) => __awaiter(void 0, void 0, void 0, function* () {
60
- config._id = backend_core_1.db.generateConfigID({ type: config.type });
61
- let response;
62
- try {
63
- response = yield globalDb.get(config._id);
64
- config._rev = response._rev;
65
- yield globalDb.put(config);
66
- }
67
- catch (e) {
68
- if (e.status === 404) {
69
- yield globalDb.put(config);
70
- }
71
- }
72
- });
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.smtp = exports.google = exports.oidc = void 0;
4
- const backend_core_1 = require("@budibase/backend-core");
5
- const types_1 = require("@budibase/types");
6
- const oidc = (conf) => {
7
- return {
8
- type: types_1.ConfigType.OIDC,
9
- config: {
10
- configs: [
11
- Object.assign({ configUrl: "http://someconfigurl", clientID: "clientId", clientSecret: "clientSecret", logo: "Microsoft", name: "Active Directory", uuid: backend_core_1.utils.newid(), activated: true }, conf),
12
- ],
13
- },
14
- };
15
- };
16
- exports.oidc = oidc;
17
- const google = (conf) => {
18
- return {
19
- type: types_1.ConfigType.GOOGLE,
20
- config: Object.assign({ clientID: "clientId", clientSecret: "clientSecret", activated: true }, conf),
21
- };
22
- };
23
- exports.google = google;
24
- const smtp = (conf) => {
25
- return {
26
- type: types_1.ConfigType.SMTP,
27
- config: Object.assign({ port: 12345, host: "smtptesthost.com", from: "testfrom@test.com", subject: "Hello!", secure: false }, conf),
28
- };
29
- };
30
- exports.smtp = smtp;
31
- const settings = (conf) => {
32
- return {
33
- type: types_1.ConfigType.SETTINGS,
34
- config: Object.assign({ platformUrl: "http://mycustomdomain.com", logoUrl: "http://mylogourl,com", company: "mycompany" }, conf),
35
- };
36
- };
37
- exports.settings = settings;
@@ -1,8 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
-
3
- export const isEnabled = async (ctx: any) => {
4
- const enabled = await events.analytics.enabled()
5
- ctx.body = {
6
- enabled,
7
- }
8
- }
@@ -1 +0,0 @@
1
- {}
@@ -1,25 +0,0 @@
1
- const setup = require("./utilities")
2
- const { events } = require("@budibase/backend-core")
3
-
4
- describe("/deployments", () => {
5
- let request = setup.getRequest()
6
- let config = setup.getConfig()
7
-
8
- afterAll(setup.afterAll)
9
-
10
- beforeEach(async () => {
11
- await config.init()
12
- jest.clearAllMocks()
13
- })
14
-
15
- describe("deploy", () => {
16
- it("should deploy the application", async () => {
17
- await request
18
- .post(`/api/deploy`)
19
- .set(config.defaultHeaders())
20
- .expect("Content-Type", /json/)
21
- .expect(200)
22
- expect(events.app.published.mock.calls.length).toBe(1)
23
- })
24
- })
25
- })
@@ -1,40 +0,0 @@
1
- const setup = require("./utilities")
2
- const { events } = require("@budibase/backend-core")
3
- const version = require("../../../../package.json").version
4
-
5
- describe("/dev", () => {
6
- let request = setup.getRequest()
7
- let config = setup.getConfig()
8
-
9
- afterAll(setup.afterAll)
10
-
11
- beforeEach(async () => {
12
- await config.init()
13
- jest.clearAllMocks()
14
- })
15
-
16
- describe("revert", () => {
17
- it("should revert the application", async () => {
18
- await request
19
- .post(`/api/dev/${config.getAppId()}/revert`)
20
- .set(config.defaultHeaders())
21
- .expect("Content-Type", /json/)
22
- .expect(200)
23
- expect(events.app.reverted).toBeCalledTimes(1)
24
- })
25
- })
26
-
27
- describe("version", () => {
28
- it("should get the installation version", async () => {
29
- const res = await request
30
- .get(`/api/dev/version`)
31
- .set(config.defaultHeaders())
32
- .expect("Content-Type", /json/)
33
- .expect(200)
34
-
35
- expect(res.body.version).toBe(version)
36
- expect(events.version.checked).toBeCalledTimes(1)
37
- expect(events.version.checked).toBeCalledWith(version)
38
- })
39
- })
40
- })
@@ -1,26 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getAutomationParams } from "../../../../db/utils"
3
- import { Automation } from "@budibase/types"
4
-
5
- const getAutomations = async (appDb: any): Promise<Automation[]> => {
6
- const response = await appDb.allDocs(
7
- getAutomationParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- export const backfill = async (appDb: any, timestamp: string | number) => {
15
- const automations = await getAutomations(appDb)
16
-
17
- for (const automation of automations) {
18
- await events.automation.created(automation, timestamp)
19
-
20
- for (const step of automation.definition.steps) {
21
- await events.automation.stepCreated(automation, step, timestamp)
22
- }
23
- }
24
-
25
- return automations.length
26
- }
@@ -1,22 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getDatasourceParams } from "../../../../db/utils"
3
- import { Datasource } from "@budibase/types"
4
-
5
- const getDatasources = async (appDb: any): Promise<Datasource[]> => {
6
- const response = await appDb.allDocs(
7
- getDatasourceParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- export const backfill = async (appDb: any, timestamp: string | number) => {
15
- const datasources: Datasource[] = await getDatasources(appDb)
16
-
17
- for (const datasource of datasources) {
18
- await events.datasource.created(datasource, timestamp)
19
- }
20
-
21
- return datasources.length
22
- }
@@ -1,29 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getLayoutParams } from "../../../../db/utils"
3
- import { Layout } from "@budibase/types"
4
-
5
- const getLayouts = async (appDb: any): Promise<Layout[]> => {
6
- const response = await appDb.allDocs(
7
- getLayoutParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- export const backfill = async (appDb: any, timestamp: string | number) => {
15
- const layouts: Layout[] = await getLayouts(appDb)
16
-
17
- for (const layout of layouts) {
18
- // exclude default layouts
19
- if (
20
- layout._id === "layout_private_master" ||
21
- layout._id === "layout_public_master"
22
- ) {
23
- continue
24
- }
25
- await events.layout.created(layout, timestamp)
26
- }
27
-
28
- return layouts.length
29
- }
@@ -1,33 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getQueryParams } from "../../../../db/utils"
3
- import { Query, Datasource } from "@budibase/types"
4
-
5
- const getQueries = async (appDb: any): Promise<Query[]> => {
6
- const response = await appDb.allDocs(
7
- getQueryParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- const getDatasource = async (
15
- appDb: any,
16
- datasourceId: string
17
- ): Promise<Datasource> => {
18
- return appDb.get(datasourceId)
19
- }
20
-
21
- export const backfill = async (appDb: any, timestamp: string | number) => {
22
- const queries: Query[] = await getQueries(appDb)
23
-
24
- for (const query of queries) {
25
- const datasource: Datasource = await getDatasource(
26
- appDb,
27
- query.datasourceId
28
- )
29
- await events.query.created(datasource, query, timestamp)
30
- }
31
-
32
- return queries.length
33
- }
@@ -1,22 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getRoleParams } from "../../../../db/utils"
3
- import { Role } from "@budibase/types"
4
-
5
- const getRoles = async (appDb: any): Promise<Role[]> => {
6
- const response = await appDb.allDocs(
7
- getRoleParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- export const backfill = async (appDb: any, timestamp: string | number) => {
15
- const roles = await getRoles(appDb)
16
-
17
- for (const role of roles) {
18
- await events.role.created(role, timestamp)
19
- }
20
-
21
- return roles.length
22
- }
@@ -1,22 +0,0 @@
1
- import { events } from "@budibase/backend-core"
2
- import { getScreenParams } from "../../../../db/utils"
3
- import { Screen } from "@budibase/types"
4
-
5
- const getScreens = async (appDb: any): Promise<Screen[]> => {
6
- const response = await appDb.allDocs(
7
- getScreenParams(null, {
8
- include_docs: true,
9
- })
10
- )
11
- return response.rows.map((row: any) => row.doc)
12
- }
13
-
14
- export const backfill = async (appDb: any, timestamp: string | number) => {
15
- const screens = await getScreens(appDb)
16
-
17
- for (const screen of screens) {
18
- await events.screen.created(screen, timestamp)
19
- }
20
-
21
- return screens.length
22
- }