@budibase/server 2.0.30-alpha.0 → 2.0.30

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 (200) hide show
  1. package/builder/assets/{index.ae93bd4f.js → index.86a96d03.js} +262 -262
  2. package/builder/assets/{index.e56da48a.css → index.dfa4073c.css} +2 -2
  3. package/builder/index.html +2 -2
  4. package/coverage/clover.xml +341 -344
  5. package/coverage/coverage-final.json +24 -24
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/dev.js.html +2 -2
  12. package/coverage/lcov-report/api/controllers/index.html +1 -1
  13. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  19. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/internal.js.html +12 -12
  25. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
  27. package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
  28. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  41. package/coverage/lcov-report/api/index.html +1 -1
  42. package/coverage/lcov-report/api/index.js.html +5 -5
  43. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  44. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  45. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/index.html +1 -1
  53. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  67. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  70. package/coverage/lcov-report/automations/actions.js.html +1 -1
  71. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  72. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  73. package/coverage/lcov-report/automations/index.html +1 -1
  74. package/coverage/lcov-report/automations/index.js.html +5 -5
  75. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  76. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  77. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/index.html +1 -1
  82. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -3
  90. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  92. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  93. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  94. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggers.js.html +22 -22
  101. package/coverage/lcov-report/constants/index.html +1 -1
  102. package/coverage/lcov-report/constants/index.js.html +1 -1
  103. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  104. package/coverage/lcov-report/constants/screens.js.html +1 -1
  105. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  106. package/coverage/lcov-report/db/index.html +1 -1
  107. package/coverage/lcov-report/db/index.js.html +1 -1
  108. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
  109. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  110. package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
  111. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
  112. package/coverage/lcov-report/db/newid.js.html +2 -2
  113. package/coverage/lcov-report/db/utils.js.html +16 -10
  114. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  115. package/coverage/lcov-report/events/index.html +1 -1
  116. package/coverage/lcov-report/events/index.js.html +2 -2
  117. package/coverage/lcov-report/events/utils.js.html +9 -9
  118. package/coverage/lcov-report/index.html +15 -15
  119. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  120. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  121. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  122. package/coverage/lcov-report/middleware/builder.js.html +11 -11
  123. package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
  124. package/coverage/lcov-report/middleware/index.html +1 -1
  125. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  126. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  127. package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
  128. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  129. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  130. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  131. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  132. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  133. package/coverage/lcov-report/utilities/global.js.html +16 -16
  134. package/coverage/lcov-report/utilities/index.html +1 -1
  135. package/coverage/lcov-report/utilities/index.js.html +1 -1
  136. package/coverage/lcov-report/utilities/plugins.js.html +1 -1
  137. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +13 -13
  138. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  139. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  140. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  141. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  142. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +38 -38
  143. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
  144. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  145. package/coverage/lcov-report/utilities/security.js.html +1 -1
  146. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  147. package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
  148. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +11 -23
  149. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  150. package/coverage/lcov-report/utilities/users.js.html +1 -1
  151. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  152. package/coverage/lcov.info +614 -619
  153. package/dist/api/controllers/application.js +2 -2
  154. package/dist/api/controllers/dev.js +1 -1
  155. package/dist/api/controllers/query/index.js +2 -6
  156. package/dist/api/controllers/row/index.js +10 -30
  157. package/dist/api/controllers/static/templates/preview.hbs +0 -10
  158. package/dist/api/controllers/table/internal.js +2 -8
  159. package/dist/api/controllers/table/utils.js +1 -3
  160. package/dist/automations/steps/updateRow.js +2 -2
  161. package/dist/automations/utils.js +3 -5
  162. package/dist/db/utils.js +1 -1
  163. package/dist/index.js +0 -1
  164. package/dist/integrations/rest.js +2 -39
  165. package/dist/migrations/functions/{usageQuotas/syncPlugins.js → pluginCount.js} +3 -1
  166. package/dist/migrations/functions/{syncQuotas.js → quotas1.js} +7 -3
  167. package/dist/migrations/functions/usageQuotas/syncApps.js +1 -0
  168. package/dist/migrations/functions/usageQuotas/syncRows.js +5 -9
  169. package/dist/migrations/index.js +9 -3
  170. package/dist/package.json +1 -1
  171. package/dist/tsconfig.build.tsbuildinfo +1 -1
  172. package/dist/utilities/usageQuota/rows.js +4 -6
  173. package/package.json +7 -7
  174. package/src/api/controllers/application.ts +2 -2
  175. package/src/api/controllers/dev.js +1 -1
  176. package/src/api/controllers/query/index.ts +2 -7
  177. package/src/api/controllers/row/index.ts +13 -36
  178. package/src/api/controllers/static/templates/preview.hbs +0 -10
  179. package/src/api/controllers/table/internal.ts +2 -5
  180. package/src/api/controllers/table/utils.ts +1 -3
  181. package/src/api/routes/tests/row.spec.js +27 -22
  182. package/src/automations/steps/updateRow.js +2 -2
  183. package/src/automations/tests/automation.spec.js +6 -1
  184. package/src/automations/utils.ts +4 -6
  185. package/src/db/utils.js +2 -0
  186. package/src/definitions/datasource.ts +0 -1
  187. package/src/index.ts +0 -1
  188. package/src/integrations/rest.ts +2 -18
  189. package/src/integrations/tests/rest.spec.ts +9 -9
  190. package/src/migrations/functions/backfill/global.ts +1 -1
  191. package/src/migrations/functions/pluginCount.ts +12 -0
  192. package/src/migrations/functions/{syncQuotas.ts → quotas1.ts} +8 -3
  193. package/src/migrations/functions/tests/{syncQuotas.spec.js → quotas1.spec.js} +2 -5
  194. package/src/migrations/functions/usageQuotas/syncApps.ts +1 -0
  195. package/src/migrations/functions/usageQuotas/syncRows.ts +6 -15
  196. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +1 -9
  197. package/src/migrations/index.ts +15 -3
  198. package/src/migrations/tests/index.spec.ts +1 -0
  199. package/src/utilities/usageQuota/rows.js +3 -7
  200. package/src/migrations/functions/usageQuotas/syncPlugins.ts +0 -10
@@ -5,6 +5,7 @@ import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
5
5
 
6
6
  export const run = async () => {
7
7
  // get app count
8
+ // @ts-ignore
8
9
  const devApps = await getAllApps({ dev: true })
9
10
  const appCount = devApps ? devApps.length : 0
10
11
 
@@ -2,28 +2,19 @@ import { getTenantId } from "@budibase/backend-core/tenancy"
2
2
  import { getAllApps } from "@budibase/backend-core/db"
3
3
  import { getUniqueRows } from "../../../utilities/usageQuota/rows"
4
4
  import { quotas } from "@budibase/pro"
5
- import { StaticQuotaName, QuotaUsageType } from "@budibase/types"
5
+ import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
6
6
 
7
7
  export const run = async () => {
8
8
  // get all rows in all apps
9
+ // @ts-ignore
9
10
  const allApps = await getAllApps({ all: true })
11
+ // @ts-ignore
10
12
  const appIds = allApps ? allApps.map((app: { appId: any }) => app.appId) : []
11
- const { appRows } = await getUniqueRows(appIds)
12
-
13
- // get the counts per app
14
- const counts: { [key: string]: number } = {}
15
- let rowCount = 0
16
- Object.entries(appRows).forEach(([appId, rows]) => {
17
- counts[appId] = rows.length
18
- rowCount += rows.length
19
- })
13
+ const rows = await getUniqueRows(appIds)
14
+ const rowCount = rows ? rows.length : 0
20
15
 
21
16
  // sync row count
22
17
  const tenantId = getTenantId()
23
18
  console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`)
24
- await quotas.setUsagePerApp(
25
- counts,
26
- StaticQuotaName.ROWS,
27
- QuotaUsageType.STATIC
28
- )
19
+ await quotas.setUsage(rowCount, StaticQuotaName.ROWS, QuotaUsageType.STATIC)
29
20
  }
@@ -2,7 +2,6 @@ import TestConfig from "../../../../tests/utilities/TestConfiguration"
2
2
  import * as syncRows from "../syncRows"
3
3
  import { quotas } from "@budibase/pro"
4
4
  import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
5
- const { getProdAppID } = require("@budibase/backend-core/db")
6
5
 
7
6
  describe("syncRows", () => {
8
7
  let config = new TestConfig(false)
@@ -23,11 +22,10 @@ describe("syncRows", () => {
23
22
  expect(usageDoc.usageQuota.rows).toEqual(300)
24
23
 
25
24
  // app 1
26
- const app1 = config.app
27
25
  await config.createTable()
28
26
  await config.createRow()
29
27
  // app 2
30
- const app2 = await config.createApp("second-app")
28
+ await config.createApp("second-app")
31
29
  await config.createTable()
32
30
  await config.createRow()
33
31
  await config.createRow()
@@ -38,12 +36,6 @@ describe("syncRows", () => {
38
36
  // assert the migration worked
39
37
  usageDoc = await quotas.getQuotaUsage()
40
38
  expect(usageDoc.usageQuota.rows).toEqual(3)
41
- expect(usageDoc.apps?.[getProdAppID(app1.appId)].usageQuota.rows).toEqual(
42
- 1
43
- )
44
- expect(usageDoc.apps?.[getProdAppID(app2.appId)].usageQuota.rows).toEqual(
45
- 2
46
- )
47
39
  })
48
40
  })
49
41
  })
@@ -4,9 +4,11 @@ import env from "../environment"
4
4
 
5
5
  // migration functions
6
6
  import * as userEmailViewCasing from "./functions/userEmailViewCasing"
7
- import * as syncQuotas from "./functions/syncQuotas"
7
+ import * as quota1 from "./functions/quotas1"
8
8
  import * as appUrls from "./functions/appUrls"
9
9
  import * as backfill from "./functions/backfill"
10
+ import * as pluginCount from "./functions/pluginCount"
11
+
10
12
  /**
11
13
  * Populate the migration function and additional configuration from
12
14
  * the static migration definitions.
@@ -24,10 +26,10 @@ export const buildMigrations = () => {
24
26
  })
25
27
  break
26
28
  }
27
- case MigrationName.SYNC_QUOTAS: {
29
+ case MigrationName.QUOTAS_1: {
28
30
  serverMigrations.push({
29
31
  ...definition,
30
- fn: syncQuotas.run,
32
+ fn: quota1.run,
31
33
  })
32
34
  break
33
35
  }
@@ -67,6 +69,16 @@ export const buildMigrations = () => {
67
69
  })
68
70
  break
69
71
  }
72
+ case MigrationName.PLUGIN_COUNT: {
73
+ if (env.SELF_HOSTED) {
74
+ serverMigrations.push({
75
+ ...definition,
76
+ fn: pluginCount.run,
77
+ silent: !!env.SELF_HOSTED,
78
+ preventRetry: false,
79
+ })
80
+ }
81
+ }
70
82
  }
71
83
  }
72
84
 
@@ -4,6 +4,7 @@ import {
4
4
  tenancy,
5
5
  DocumentType,
6
6
  context,
7
+ db,
7
8
  } from "@budibase/backend-core"
8
9
  import TestConfig from "../../tests/utilities/TestConfiguration"
9
10
  import structures from "../../tests/utilities/structures"
@@ -2,7 +2,6 @@ const { getRowParams, USER_METDATA_PREFIX } = require("../../db/utils")
2
2
  const {
3
3
  isDevAppID,
4
4
  getDevelopmentAppID,
5
- getProdAppID,
6
5
  doWithDB,
7
6
  } = require("@budibase/backend-core/db")
8
7
 
@@ -53,8 +52,7 @@ const getAppRows = async appId => {
53
52
  * Rows duplicates may exist across apps due to data import so they are not filtered out.
54
53
  */
55
54
  exports.getUniqueRows = async appIds => {
56
- let uniqueRows = [],
57
- rowsByApp = {}
55
+ let uniqueRows = []
58
56
  const pairs = getAppPairs(appIds)
59
57
 
60
58
  for (let pair of Object.values(pairs)) {
@@ -75,10 +73,8 @@ exports.getUniqueRows = async appIds => {
75
73
  // this can't be done on all rows because app import results in
76
74
  // duplicate row ids across apps
77
75
  // the array pre-concat is important to avoid stack overflow
78
- const prodId = getProdAppID(pair.devId || pair.prodId)
79
- rowsByApp[prodId] = [...new Set(appRows)]
80
- uniqueRows = uniqueRows.concat(rowsByApp[prodId])
76
+ uniqueRows = uniqueRows.concat([...new Set(appRows)])
81
77
  }
82
78
 
83
- return { rows: uniqueRows, appRows: rowsByApp }
79
+ return uniqueRows
84
80
  }
@@ -1,10 +0,0 @@
1
- import { logging } from "@budibase/backend-core"
2
- import { plugins } from "@budibase/pro"
3
-
4
- export const run = async () => {
5
- try {
6
- await plugins.checkPluginQuotas()
7
- } catch (err) {
8
- logging.logAlert("Failed to update plugin quotas", err)
9
- }
10
- }