@budibase/backend-core 2.11.42 → 2.11.44
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/dist/index.js +652 -587
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/environment.js +2 -2
- package/dist/src/environment.js.map +1 -1
- package/dist/src/objectStore/buckets/app.d.ts +7 -10
- package/dist/src/objectStore/buckets/app.js +40 -27
- package/dist/src/objectStore/buckets/app.js.map +1 -1
- package/dist/src/objectStore/buckets/plugins.d.ts +4 -4
- package/dist/src/objectStore/buckets/plugins.js +19 -19
- package/dist/src/objectStore/buckets/plugins.js.map +1 -1
- package/dist/src/objectStore/objectStore.d.ts +19 -16
- package/dist/src/objectStore/objectStore.js +257 -218
- package/dist/src/objectStore/objectStore.js.map +1 -1
- package/dist/src/users/users.d.ts +1 -0
- package/dist/src/users/users.js +20 -2
- package/dist/src/users/users.js.map +1 -1
- package/dist/src/users/utils.d.ts +1 -0
- package/dist/src/users/utils.js +2 -1
- package/dist/src/users/utils.js.map +1 -1
- package/dist/tests/core/utilities/structures/licenses.js +5 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +1 -1
- package/dist/tests/core/utilities/structures/quotas.d.ts +1 -1
- package/dist/tests/core/utilities/structures/quotas.js +3 -2
- package/dist/tests/core/utilities/structures/quotas.js.map +1 -1
- package/package.json +4 -4
- package/src/environment.ts +2 -2
- package/src/objectStore/buckets/app.ts +36 -23
- package/src/objectStore/buckets/plugins.ts +8 -8
- package/src/objectStore/buckets/tests/app.spec.ts +16 -26
- package/src/objectStore/objectStore.ts +38 -24
- package/src/users/users.ts +15 -1
- package/src/users/utils.ts +1 -0
- package/tests/core/utilities/structures/licenses.ts +5 -0
- package/tests/core/utilities/structures/quotas.ts +3 -2
package/src/users/users.ts
CHANGED
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
User,
|
|
22
22
|
DatabaseQueryOpts,
|
|
23
23
|
} from "@budibase/types"
|
|
24
|
-
import * as context from "../context"
|
|
25
24
|
import { getGlobalDB } from "../context"
|
|
25
|
+
import * as context from "../context"
|
|
26
|
+
import { isCreator } from "./utils"
|
|
26
27
|
|
|
27
28
|
type GetOpts = { cleanup?: boolean }
|
|
28
29
|
|
|
@@ -286,6 +287,19 @@ export async function getUserCount() {
|
|
|
286
287
|
return response.total_rows
|
|
287
288
|
}
|
|
288
289
|
|
|
290
|
+
export async function getCreatorCount() {
|
|
291
|
+
let creators = 0
|
|
292
|
+
async function iterate(startPage?: string) {
|
|
293
|
+
const page = await paginatedUsers({ bookmark: startPage })
|
|
294
|
+
creators += page.data.filter(isCreator).length
|
|
295
|
+
if (page.hasNextPage) {
|
|
296
|
+
await iterate(page.nextPage)
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
await iterate()
|
|
300
|
+
return creators
|
|
301
|
+
}
|
|
302
|
+
|
|
289
303
|
// used to remove the builder/admin permissions, for processing the
|
|
290
304
|
// user as an app user (they may have some specific role/group
|
|
291
305
|
export function removePortalUserPermissions(user: User | ContextUser) {
|
package/src/users/utils.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { getAccountByTenantId } from "../accounts"
|
|
|
10
10
|
// extract from shared-core to make easily accessible from backend-core
|
|
11
11
|
export const isBuilder = sdk.users.isBuilder
|
|
12
12
|
export const isAdmin = sdk.users.isAdmin
|
|
13
|
+
export const isCreator = sdk.users.isCreator
|
|
13
14
|
export const isGlobalBuilder = sdk.users.isGlobalBuilder
|
|
14
15
|
export const isAdminOrBuilder = sdk.users.isAdminOrBuilder
|
|
15
16
|
export const hasAdminPermissions = sdk.users.hasAdminPermissions
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MonthlyQuotaName, QuotaUsage } from "@budibase/types"
|
|
2
2
|
|
|
3
|
-
export const usage = (): QuotaUsage => {
|
|
3
|
+
export const usage = (users: number = 0, creators: number = 0): QuotaUsage => {
|
|
4
4
|
return {
|
|
5
5
|
_id: "usage_quota",
|
|
6
6
|
quotaReset: new Date().toISOString(),
|
|
@@ -58,7 +58,8 @@ export const usage = (): QuotaUsage => {
|
|
|
58
58
|
usageQuota: {
|
|
59
59
|
apps: 0,
|
|
60
60
|
plugins: 0,
|
|
61
|
-
users
|
|
61
|
+
users,
|
|
62
|
+
creators,
|
|
62
63
|
userGroups: 0,
|
|
63
64
|
rows: 0,
|
|
64
65
|
triggers: {},
|