@budibase/server 2.0.28 → 2.0.30-alpha.0
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.
- package/builder/assets/{index.ffdc4f66.js → index.ae93bd4f.js} +258 -258
- package/builder/assets/{index.dfa4073c.css → index.e56da48a.css} +2 -2
- package/builder/index.html +2 -2
- package/coverage/clover.xml +344 -341
- package/coverage/coverage-final.json +24 -24
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +2 -2
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +12 -12
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +5 -5
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -3
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +22 -22
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +10 -16
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +2 -2
- package/coverage/lcov-report/events/utils.js.html +9 -9
- package/coverage/lcov-report/index.html +15 -15
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +11 -11
- package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +13 -13
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +38 -38
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +23 -11
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +619 -614
- package/dist/api/controllers/application.js +2 -2
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/query/index.js +6 -2
- package/dist/api/controllers/row/index.js +30 -10
- package/dist/api/controllers/static/templates/preview.hbs +10 -0
- package/dist/api/controllers/table/internal.js +8 -2
- package/dist/api/controllers/table/utils.js +3 -1
- package/dist/automations/steps/updateRow.js +2 -2
- package/dist/automations/utils.js +5 -3
- package/dist/db/utils.js +1 -1
- package/dist/index.js +1 -0
- package/dist/integrations/rest.js +39 -2
- package/dist/migrations/functions/{quotas1.js → syncQuotas.js} +3 -7
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
- package/dist/migrations/functions/{pluginCount.js → usageQuotas/syncPlugins.js} +1 -3
- package/dist/migrations/functions/usageQuotas/syncRows.js +9 -5
- package/dist/migrations/index.js +3 -9
- package/dist/package.json +7 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/usageQuota/rows.js +6 -4
- package/package.json +8 -8
- package/src/api/controllers/application.ts +2 -2
- package/src/api/controllers/dev.js +1 -1
- package/src/api/controllers/query/index.ts +7 -2
- package/src/api/controllers/row/index.ts +36 -13
- package/src/api/controllers/static/templates/preview.hbs +10 -0
- package/src/api/controllers/table/internal.ts +5 -2
- package/src/api/controllers/table/utils.ts +3 -1
- package/src/api/routes/tests/row.spec.js +22 -27
- package/src/automations/steps/updateRow.js +2 -2
- package/src/automations/tests/automation.spec.js +1 -6
- package/src/automations/utils.ts +6 -4
- package/src/db/utils.js +0 -2
- package/src/definitions/datasource.ts +1 -0
- package/src/index.ts +1 -0
- package/src/integrations/rest.ts +18 -2
- package/src/integrations/tests/rest.spec.ts +9 -9
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/{quotas1.ts → syncQuotas.ts} +3 -8
- package/src/migrations/functions/tests/{quotas1.spec.js → syncQuotas.spec.js} +5 -2
- package/src/migrations/functions/usageQuotas/syncApps.ts +0 -1
- package/src/migrations/functions/usageQuotas/syncPlugins.ts +10 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +15 -6
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +9 -1
- package/src/migrations/index.ts +3 -15
- package/src/migrations/tests/index.spec.ts +0 -1
- package/src/utilities/usageQuota/rows.js +7 -3
- package/src/migrations/functions/pluginCount.ts +0 -12
|
@@ -2,19 +2,28 @@ 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 {
|
|
5
|
+
import { StaticQuotaName, QuotaUsageType } from "@budibase/types"
|
|
6
6
|
|
|
7
7
|
export const run = async () => {
|
|
8
8
|
// get all rows in all apps
|
|
9
|
-
// @ts-ignore
|
|
10
9
|
const allApps = await getAllApps({ all: true })
|
|
11
|
-
// @ts-ignore
|
|
12
10
|
const appIds = allApps ? allApps.map((app: { appId: any }) => app.appId) : []
|
|
13
|
-
const
|
|
14
|
-
|
|
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
|
+
})
|
|
15
20
|
|
|
16
21
|
// sync row count
|
|
17
22
|
const tenantId = getTenantId()
|
|
18
23
|
console.log(`[Tenant: ${tenantId}] Syncing row count: ${rowCount}`)
|
|
19
|
-
await quotas.
|
|
24
|
+
await quotas.setUsagePerApp(
|
|
25
|
+
counts,
|
|
26
|
+
StaticQuotaName.ROWS,
|
|
27
|
+
QuotaUsageType.STATIC
|
|
28
|
+
)
|
|
20
29
|
}
|
|
@@ -2,6 +2,7 @@ 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")
|
|
5
6
|
|
|
6
7
|
describe("syncRows", () => {
|
|
7
8
|
let config = new TestConfig(false)
|
|
@@ -22,10 +23,11 @@ describe("syncRows", () => {
|
|
|
22
23
|
expect(usageDoc.usageQuota.rows).toEqual(300)
|
|
23
24
|
|
|
24
25
|
// app 1
|
|
26
|
+
const app1 = config.app
|
|
25
27
|
await config.createTable()
|
|
26
28
|
await config.createRow()
|
|
27
29
|
// app 2
|
|
28
|
-
await config.createApp("second-app")
|
|
30
|
+
const app2 = await config.createApp("second-app")
|
|
29
31
|
await config.createTable()
|
|
30
32
|
await config.createRow()
|
|
31
33
|
await config.createRow()
|
|
@@ -36,6 +38,12 @@ describe("syncRows", () => {
|
|
|
36
38
|
// assert the migration worked
|
|
37
39
|
usageDoc = await quotas.getQuotaUsage()
|
|
38
40
|
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
|
+
)
|
|
39
47
|
})
|
|
40
48
|
})
|
|
41
49
|
})
|
package/src/migrations/index.ts
CHANGED
|
@@ -4,11 +4,9 @@ import env from "../environment"
|
|
|
4
4
|
|
|
5
5
|
// migration functions
|
|
6
6
|
import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
|
7
|
-
import * as
|
|
7
|
+
import * as syncQuotas from "./functions/syncQuotas"
|
|
8
8
|
import * as appUrls from "./functions/appUrls"
|
|
9
9
|
import * as backfill from "./functions/backfill"
|
|
10
|
-
import * as pluginCount from "./functions/pluginCount"
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* Populate the migration function and additional configuration from
|
|
14
12
|
* the static migration definitions.
|
|
@@ -26,10 +24,10 @@ export const buildMigrations = () => {
|
|
|
26
24
|
})
|
|
27
25
|
break
|
|
28
26
|
}
|
|
29
|
-
case MigrationName.
|
|
27
|
+
case MigrationName.SYNC_QUOTAS: {
|
|
30
28
|
serverMigrations.push({
|
|
31
29
|
...definition,
|
|
32
|
-
fn:
|
|
30
|
+
fn: syncQuotas.run,
|
|
33
31
|
})
|
|
34
32
|
break
|
|
35
33
|
}
|
|
@@ -69,16 +67,6 @@ export const buildMigrations = () => {
|
|
|
69
67
|
})
|
|
70
68
|
break
|
|
71
69
|
}
|
|
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
|
-
}
|
|
82
70
|
}
|
|
83
71
|
}
|
|
84
72
|
|
|
@@ -2,6 +2,7 @@ const { getRowParams, USER_METDATA_PREFIX } = require("../../db/utils")
|
|
|
2
2
|
const {
|
|
3
3
|
isDevAppID,
|
|
4
4
|
getDevelopmentAppID,
|
|
5
|
+
getProdAppID,
|
|
5
6
|
doWithDB,
|
|
6
7
|
} = require("@budibase/backend-core/db")
|
|
7
8
|
|
|
@@ -52,7 +53,8 @@ const getAppRows = async appId => {
|
|
|
52
53
|
* Rows duplicates may exist across apps due to data import so they are not filtered out.
|
|
53
54
|
*/
|
|
54
55
|
exports.getUniqueRows = async appIds => {
|
|
55
|
-
let uniqueRows = []
|
|
56
|
+
let uniqueRows = [],
|
|
57
|
+
rowsByApp = {}
|
|
56
58
|
const pairs = getAppPairs(appIds)
|
|
57
59
|
|
|
58
60
|
for (let pair of Object.values(pairs)) {
|
|
@@ -73,8 +75,10 @@ exports.getUniqueRows = async appIds => {
|
|
|
73
75
|
// this can't be done on all rows because app import results in
|
|
74
76
|
// duplicate row ids across apps
|
|
75
77
|
// the array pre-concat is important to avoid stack overflow
|
|
76
|
-
|
|
78
|
+
const prodId = getProdAppID(pair.devId || pair.prodId)
|
|
79
|
+
rowsByApp[prodId] = [...new Set(appRows)]
|
|
80
|
+
uniqueRows = uniqueRows.concat(rowsByApp[prodId])
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
return uniqueRows
|
|
83
|
+
return { rows: uniqueRows, appRows: rowsByApp }
|
|
80
84
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { tenancy, logging } from "@budibase/backend-core"
|
|
2
|
-
import { plugins } from "@budibase/pro"
|
|
3
|
-
|
|
4
|
-
export const run = async () => {
|
|
5
|
-
try {
|
|
6
|
-
await tenancy.doInTenant(tenancy.DEFAULT_TENANT_ID, async () => {
|
|
7
|
-
await plugins.checkPluginQuotas()
|
|
8
|
-
})
|
|
9
|
-
} catch (err) {
|
|
10
|
-
logging.logAlert("Failed to update plugin quotas", err)
|
|
11
|
-
}
|
|
12
|
-
}
|