@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,31 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getAutomations = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getAutomationParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- const automations = yield getAutomations(appDb);
23
- for (const automation of automations) {
24
- yield backend_core_1.events.automation.created(automation, timestamp);
25
- for (const step of automation.definition.steps) {
26
- yield backend_core_1.events.automation.stepCreated(automation, step, timestamp);
27
- }
28
- }
29
- return automations.length;
30
- });
31
- exports.backfill = backfill;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getDatasources = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getDatasourceParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- const datasources = yield getDatasources(appDb);
23
- for (const datasource of datasources) {
24
- yield backend_core_1.events.datasource.created(datasource, timestamp);
25
- }
26
- return datasources.length;
27
- });
28
- exports.backfill = backfill;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getLayouts = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getLayoutParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- const layouts = yield getLayouts(appDb);
23
- for (const layout of layouts) {
24
- // exclude default layouts
25
- if (layout._id === "layout_private_master" ||
26
- layout._id === "layout_public_master") {
27
- continue;
28
- }
29
- yield backend_core_1.events.layout.created(layout, timestamp);
30
- }
31
- return layouts.length;
32
- });
33
- exports.backfill = backfill;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getQueries = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getQueryParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const getDatasource = (appDb, datasourceId) => __awaiter(void 0, void 0, void 0, function* () {
22
- return appDb.get(datasourceId);
23
- });
24
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
25
- const queries = yield getQueries(appDb);
26
- for (const query of queries) {
27
- const datasource = yield getDatasource(appDb, query.datasourceId);
28
- yield backend_core_1.events.query.created(datasource, query, timestamp);
29
- }
30
- return queries.length;
31
- });
32
- exports.backfill = backfill;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getRoles = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getRoleParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- const roles = yield getRoles(appDb);
23
- for (const role of roles) {
24
- yield backend_core_1.events.role.created(role, timestamp);
25
- }
26
- return roles.length;
27
- });
28
- exports.backfill = backfill;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getScreens = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getScreenParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- const screens = yield getScreens(appDb);
23
- for (const screen of screens) {
24
- yield backend_core_1.events.screen.created(screen, timestamp);
25
- }
26
- return screens.length;
27
- });
28
- exports.backfill = backfill;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const utils_1 = require("../../../../db/utils");
15
- const getTables = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
16
- const response = yield appDb.allDocs((0, utils_1.getTableParams)(null, {
17
- include_docs: true,
18
- }));
19
- return response.rows.map((row) => row.doc);
20
- });
21
- const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
22
- var _a;
23
- const tables = yield getTables(appDb);
24
- for (const table of tables) {
25
- yield backend_core_1.events.table.created(table, timestamp);
26
- if (table.views) {
27
- for (const view of Object.values(table.views)) {
28
- yield backend_core_1.events.view.created(view, timestamp);
29
- if (view.calculation) {
30
- yield backend_core_1.events.view.calculationCreated(view, timestamp);
31
- }
32
- if ((_a = view.filters) === null || _a === void 0 ? void 0 : _a.length) {
33
- yield backend_core_1.events.view.filterCreated(view, timestamp);
34
- }
35
- }
36
- }
37
- }
38
- return tables.length;
39
- });
40
- exports.backfill = backfill;
@@ -1,175 +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 automations = __importStar(require("./app/automations"));
40
- const datasources = __importStar(require("./app/datasources"));
41
- const layouts = __importStar(require("./app/layouts"));
42
- const queries = __importStar(require("./app/queries"));
43
- const roles = __importStar(require("./app/roles"));
44
- const tables = __importStar(require("./app/tables"));
45
- const screens = __importStar(require("./app/screens"));
46
- const global = __importStar(require("./global"));
47
- const types_1 = require("@budibase/types");
48
- const backend_core_1 = require("@budibase/backend-core");
49
- const environment_1 = __importDefault(require("../../../environment"));
50
- const _1 = require(".");
51
- const failGraceful = environment_1.default.SELF_HOSTED && !environment_1.default.isDev();
52
- const handleError = (e, errors) => {
53
- if (failGraceful) {
54
- if (errors) {
55
- errors.push(e);
56
- }
57
- return;
58
- }
59
- throw e;
60
- };
61
- const EVENTS = [
62
- types_1.Event.AUTOMATION_CREATED,
63
- types_1.Event.AUTOMATION_STEP_CREATED,
64
- types_1.Event.DATASOURCE_CREATED,
65
- types_1.Event.LAYOUT_CREATED,
66
- types_1.Event.QUERY_CREATED,
67
- types_1.Event.ROLE_CREATED,
68
- types_1.Event.SCREEN_CREATED,
69
- types_1.Event.TABLE_CREATED,
70
- types_1.Event.VIEW_CREATED,
71
- types_1.Event.VIEW_CALCULATION_CREATED,
72
- types_1.Event.VIEW_FILTER_CREATED,
73
- types_1.Event.APP_PUBLISHED,
74
- types_1.Event.APP_CREATED,
75
- ];
76
- /**
77
- * Date:
78
- * May 2022
79
- *
80
- * Description:
81
- * Backfill app events.
82
- */
83
- const run = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
84
- try {
85
- if (yield global.isComplete()) {
86
- // make sure new apps aren't backfilled
87
- // return if the global migration for this tenant is complete
88
- // which runs after the app migrations
89
- return;
90
- }
91
- // tell the event pipeline to start caching
92
- // events for this tenant
93
- yield backend_core_1.events.backfillCache.start(EVENTS);
94
- let timestamp = _1.DEFAULT_TIMESTAMP;
95
- const app = yield appDb.get(backend_core_1.db.DocumentTypes.APP_METADATA);
96
- if (app.createdAt) {
97
- timestamp = app.createdAt;
98
- }
99
- if (backend_core_1.db.isProdAppID(app.appId)) {
100
- yield backend_core_1.events.app.published(app, timestamp);
101
- }
102
- const totals = {};
103
- const errors = [];
104
- if (backend_core_1.db.isDevAppID(app.appId)) {
105
- yield backend_core_1.events.app.created(app, timestamp);
106
- try {
107
- totals.automations = yield automations.backfill(appDb, timestamp);
108
- }
109
- catch (e) {
110
- handleError(e, errors);
111
- }
112
- try {
113
- totals.datasources = yield datasources.backfill(appDb, timestamp);
114
- }
115
- catch (e) {
116
- handleError(e, errors);
117
- }
118
- try {
119
- totals.layouts = yield layouts.backfill(appDb, timestamp);
120
- }
121
- catch (e) {
122
- handleError(e, errors);
123
- }
124
- try {
125
- totals.queries = yield queries.backfill(appDb, timestamp);
126
- }
127
- catch (e) {
128
- handleError(e, errors);
129
- }
130
- try {
131
- totals.roles = yield roles.backfill(appDb, timestamp);
132
- }
133
- catch (e) {
134
- handleError(e, errors);
135
- }
136
- try {
137
- totals.screens = yield screens.backfill(appDb, timestamp);
138
- }
139
- catch (e) {
140
- handleError(e, errors);
141
- }
142
- try {
143
- totals.tables = yield tables.backfill(appDb, timestamp);
144
- }
145
- catch (e) {
146
- handleError(e, errors);
147
- }
148
- }
149
- const properties = {
150
- appId: app.appId,
151
- automations: totals.automations,
152
- datasources: totals.datasources,
153
- layouts: totals.layouts,
154
- queries: totals.queries,
155
- roles: totals.roles,
156
- tables: totals.tables,
157
- screens: totals.screens,
158
- };
159
- if (errors.length) {
160
- properties.errors = errors.map((e) => JSON.stringify(e, Object.getOwnPropertyNames(e)));
161
- properties.errorCount = errors.length;
162
- }
163
- else {
164
- properties.errorCount = 0;
165
- }
166
- yield backend_core_1.events.backfill.appSucceeded(properties);
167
- // tell the event pipeline to stop caching events for this tenant
168
- yield backend_core_1.events.backfillCache.end();
169
- }
170
- catch (e) {
171
- handleError(e);
172
- yield backend_core_1.events.backfill.appFailed(e);
173
- }
174
- });
175
- exports.run = run;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.backfill = void 0;
16
- const backend_core_1 = require("@budibase/backend-core");
17
- const types_1 = require("@budibase/types");
18
- const environment_1 = __importDefault(require("./../../../../environment"));
19
- const getConfigs = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
20
- const response = yield globalDb.allDocs(backend_core_1.db.getConfigParams({}, {
21
- include_docs: true,
22
- }));
23
- return response.rows.map((row) => row.doc);
24
- });
25
- const backfill = (globalDb, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
26
- const configs = yield getConfigs(globalDb);
27
- for (const config of configs) {
28
- if ((0, types_1.isSMTPConfig)(config)) {
29
- yield backend_core_1.events.email.SMTPCreated(timestamp);
30
- }
31
- if ((0, types_1.isGoogleConfig)(config)) {
32
- yield backend_core_1.events.auth.SSOCreated("google", timestamp);
33
- if (config.config.activated) {
34
- yield backend_core_1.events.auth.SSOActivated("google", timestamp);
35
- }
36
- }
37
- if ((0, types_1.isOIDCConfig)(config)) {
38
- yield backend_core_1.events.auth.SSOCreated("oidc", timestamp);
39
- if (config.config.configs[0].activated) {
40
- yield backend_core_1.events.auth.SSOActivated("oidc", timestamp);
41
- }
42
- }
43
- if ((0, types_1.isSettingsConfig)(config)) {
44
- const company = config.config.company;
45
- if (company && company !== "Budibase") {
46
- yield backend_core_1.events.org.nameUpdated(timestamp);
47
- }
48
- const logoUrl = config.config.logoUrl;
49
- if (logoUrl) {
50
- yield backend_core_1.events.org.logoUpdated(timestamp);
51
- }
52
- const platformUrl = config.config.platformUrl;
53
- if (platformUrl &&
54
- platformUrl !== "http://localhost:10000" &&
55
- environment_1.default.SELF_HOSTED) {
56
- yield backend_core_1.events.org.platformURLUpdated(timestamp);
57
- }
58
- }
59
- }
60
- });
61
- exports.backfill = backfill;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = void 0;
13
- const index_1 = require("./../index");
14
- const backend_core_1 = require("@budibase/backend-core");
15
- const pro_1 = require("@budibase/pro");
16
- const getOldestCreatedAt = (allApps) => {
17
- const timestamps = allApps
18
- .filter(app => !!app.createdAt)
19
- .map(app => app.createdAt)
20
- .sort((a, b) => new Date(a).getTime() - new Date(b).getTime());
21
- if (timestamps.length) {
22
- return timestamps[0];
23
- }
24
- };
25
- const getMonthTimestamp = (monthString) => {
26
- const parts = monthString.split("-");
27
- const month = parseInt(parts[0]) - 1; // we already do +1 in month string calculation
28
- const year = parseInt(parts[1]);
29
- // using 0 as the day in next month gives us last day in previous month
30
- const date = new Date(year, month + 1, 0).getTime();
31
- const now = new Date().getTime();
32
- if (date > now) {
33
- return now;
34
- }
35
- else {
36
- return date;
37
- }
38
- };
39
- const backfill = (allApps) => __awaiter(void 0, void 0, void 0, function* () {
40
- const usage = yield pro_1.quotas.getQuotaUsage();
41
- const rows = usage.usageQuota.rows;
42
- let timestamp = index_1.DEFAULT_TIMESTAMP;
43
- const oldestAppTimestamp = getOldestCreatedAt(allApps);
44
- if (oldestAppTimestamp) {
45
- timestamp = oldestAppTimestamp;
46
- }
47
- yield backend_core_1.events.rows.created(rows, timestamp);
48
- for (const [monthString, quotas] of Object.entries(usage.monthly)) {
49
- if (monthString === "current") {
50
- continue;
51
- }
52
- const monthTimestamp = getMonthTimestamp(monthString);
53
- const queries = quotas.queries;
54
- yield backend_core_1.events.query.run(queries, monthTimestamp);
55
- const automations = quotas.automations;
56
- yield backend_core_1.events.automation.run(automations, monthTimestamp);
57
- }
58
- return usage;
59
- });
60
- exports.backfill = backfill;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.backfill = exports.getUsers = void 0;
13
- const backend_core_1 = require("@budibase/backend-core");
14
- const __1 = require("..");
15
- // manually define user doc params - normally server doesn't read users from the db
16
- const getUserParams = (props) => {
17
- return backend_core_1.db.getDocParams(backend_core_1.db.DocumentTypes.USER, null, props);
18
- };
19
- const getUsers = (globalDb) => __awaiter(void 0, void 0, void 0, function* () {
20
- const response = yield globalDb.allDocs(getUserParams({
21
- include_docs: true,
22
- }));
23
- return response.rows.map((row) => row.doc);
24
- });
25
- exports.getUsers = getUsers;
26
- const backfill = (globalDb, account) => __awaiter(void 0, void 0, void 0, function* () {
27
- var _a, _b;
28
- const users = yield (0, exports.getUsers)(globalDb);
29
- for (const user of users) {
30
- let timestamp = __1.DEFAULT_TIMESTAMP;
31
- if (user.createdAt) {
32
- timestamp = user.createdAt;
33
- }
34
- yield backend_core_1.events.identification.identifyUser(user, account, timestamp);
35
- yield backend_core_1.events.user.created(user, timestamp);
36
- if ((_a = user.admin) === null || _a === void 0 ? void 0 : _a.global) {
37
- yield backend_core_1.events.user.permissionAdminAssigned(user, timestamp);
38
- }
39
- if ((_b = user.builder) === null || _b === void 0 ? void 0 : _b.global) {
40
- yield backend_core_1.events.user.permissionBuilderAssigned(user, timestamp);
41
- }
42
- if (user.roles) {
43
- for (const [appId, role] of Object.entries(user.roles)) {
44
- yield backend_core_1.events.role.assigned(user, role, timestamp);
45
- }
46
- }
47
- }
48
- return users.length;
49
- });
50
- exports.backfill = backfill;