@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.
Files changed (38) hide show
  1. package/dist/index.js +652 -587
  2. package/dist/index.js.map +3 -3
  3. package/dist/index.js.meta.json +1 -1
  4. package/dist/package.json +4 -4
  5. package/dist/plugins.js.map +1 -1
  6. package/dist/plugins.js.meta.json +1 -1
  7. package/dist/src/environment.js +2 -2
  8. package/dist/src/environment.js.map +1 -1
  9. package/dist/src/objectStore/buckets/app.d.ts +7 -10
  10. package/dist/src/objectStore/buckets/app.js +40 -27
  11. package/dist/src/objectStore/buckets/app.js.map +1 -1
  12. package/dist/src/objectStore/buckets/plugins.d.ts +4 -4
  13. package/dist/src/objectStore/buckets/plugins.js +19 -19
  14. package/dist/src/objectStore/buckets/plugins.js.map +1 -1
  15. package/dist/src/objectStore/objectStore.d.ts +19 -16
  16. package/dist/src/objectStore/objectStore.js +257 -218
  17. package/dist/src/objectStore/objectStore.js.map +1 -1
  18. package/dist/src/users/users.d.ts +1 -0
  19. package/dist/src/users/users.js +20 -2
  20. package/dist/src/users/users.js.map +1 -1
  21. package/dist/src/users/utils.d.ts +1 -0
  22. package/dist/src/users/utils.js +2 -1
  23. package/dist/src/users/utils.js.map +1 -1
  24. package/dist/tests/core/utilities/structures/licenses.js +5 -0
  25. package/dist/tests/core/utilities/structures/licenses.js.map +1 -1
  26. package/dist/tests/core/utilities/structures/quotas.d.ts +1 -1
  27. package/dist/tests/core/utilities/structures/quotas.js +3 -2
  28. package/dist/tests/core/utilities/structures/quotas.js.map +1 -1
  29. package/package.json +4 -4
  30. package/src/environment.ts +2 -2
  31. package/src/objectStore/buckets/app.ts +36 -23
  32. package/src/objectStore/buckets/plugins.ts +8 -8
  33. package/src/objectStore/buckets/tests/app.spec.ts +16 -26
  34. package/src/objectStore/objectStore.ts +38 -24
  35. package/src/users/users.ts +15 -1
  36. package/src/users/utils.ts +1 -0
  37. package/tests/core/utilities/structures/licenses.ts +5 -0
  38. package/tests/core/utilities/structures/quotas.ts +3 -2
@@ -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) {
@@ -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
@@ -72,6 +72,11 @@ export function quotas(): Quotas {
72
72
  value: 1,
73
73
  triggers: [],
74
74
  },
75
+ creators: {
76
+ name: "Creators",
77
+ value: 1,
78
+ triggers: [],
79
+ },
75
80
  userGroups: {
76
81
  name: "User Groups",
77
82
  value: 1,
@@ -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: 0,
61
+ users,
62
+ creators,
62
63
  userGroups: 0,
63
64
  rows: 0,
64
65
  triggers: {},