@budibase/server 2.4.43 → 2.4.44-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.8b377b88.js → index.6846a382.js} +385 -384
- package/builder/assets/index.7f9a008b.css +6 -0
- package/builder/index.html +7 -7
- package/dist/api/controllers/application.js +28 -24
- package/dist/api/controllers/public/metrics.js +113 -0
- package/dist/api/controllers/row/external.js +15 -0
- package/dist/api/controllers/static/index.js +84 -24
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +34 -11
- package/dist/api/controllers/table/utils.js +2 -4
- package/dist/api/routes/public/index.js +8 -0
- package/dist/api/routes/public/metrics.js +30 -0
- package/dist/app.js +1 -0
- package/dist/integrations/googlesheets.js +4 -0
- package/dist/integrations/redis.js +1 -1
- package/dist/middleware/currentapp.js +1 -27
- package/dist/package.json +12 -11
- package/dist/sdk/users/utils.js +11 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/app.js +1 -10
- package/dist/utilities/global.js +17 -7
- package/jest.config.ts +1 -0
- package/package.json +13 -12
- package/specs/openapi.json +39 -0
- package/specs/openapi.yaml +169 -0
- package/specs/resources/application.ts +11 -0
- package/specs/resources/index.ts +2 -0
- package/specs/resources/metrics.ts +81 -0
- package/src/api/controllers/application.ts +20 -21
- package/src/api/controllers/component.ts +2 -2
- package/src/api/controllers/public/metrics.ts +251 -0
- package/src/api/controllers/row/external.ts +14 -0
- package/src/api/controllers/static/index.ts +69 -26
- package/src/api/controllers/static/templates/BudibaseApp.svelte +34 -11
- package/src/api/controllers/table/tests/utils.spec.ts +97 -0
- package/src/api/controllers/table/utils.ts +20 -12
- package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
- package/src/api/routes/public/index.ts +10 -1
- package/src/api/routes/public/metrics.ts +28 -0
- package/src/api/routes/public/tests/metrics.spec.js +34 -0
- package/src/api/routes/tests/__snapshots__/datasource.spec.ts.snap +22 -22
- package/src/api/routes/tests/__snapshots__/view.spec.js.snap +5 -5
- package/src/api/routes/tests/appSync.spec.ts +1 -1
- package/src/api/routes/tests/internalSearch.spec.js +6 -6
- package/src/app.ts +2 -1
- package/src/automations/automationUtils.ts +1 -1
- package/src/automations/tests/automation.spec.ts +99 -0
- package/src/db/defaultData/datasource_bb_default.ts +1 -1
- package/src/definitions/openapi.ts +15 -0
- package/src/integrations/googlesheets.ts +4 -0
- package/src/integrations/redis.ts +1 -1
- package/src/integrations/tests/googlesheets.spec.ts +4 -0
- package/src/integrations/tests/redis.spec.ts +9 -5
- package/src/middleware/currentapp.ts +3 -32
- package/src/middleware/tests/currentapp.spec.js +6 -42
- package/src/sdk/users/tests/utils.spec.ts +159 -0
- package/src/sdk/users/utils.ts +18 -7
- package/src/tests/jestSetup.ts +5 -1
- package/src/tests/utilities/TestConfiguration.ts +7 -19
- package/src/tests/utilities/structures.ts +13 -1
- package/src/utilities/fileSystem/app.ts +2 -9
- package/src/utilities/global.ts +21 -9
- package/src/utilities/rowProcessor/index.ts +1 -1
- package/builder/assets/favicon.e7fc7733.png +0 -0
- package/builder/assets/index.b0e3aca6.css +0 -6
- package/src/automations/tests/automation.spec.js +0 -84
|
@@ -33,15 +33,8 @@ export const deleteApp = async (appId: string) => {
|
|
|
33
33
|
export const getComponentLibraryManifest = async (library: string) => {
|
|
34
34
|
const appId = context.getAppId()
|
|
35
35
|
const filename = "manifest.json"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// as the environment may not be fully fleshed out for dev or prod
|
|
39
|
-
if (env.isTest()) {
|
|
40
|
-
library = library.replace("standard-components", "client")
|
|
41
|
-
const lib = library.split("/")[1]
|
|
42
|
-
const path = require.resolve(library).split(lib)[0]
|
|
43
|
-
return require(join(path, lib, filename))
|
|
44
|
-
} else if (env.isDev()) {
|
|
36
|
+
|
|
37
|
+
if (env.isDev() || env.isTest()) {
|
|
45
38
|
const path = join(NODE_MODULES_PATH, "@budibase", "client", filename)
|
|
46
39
|
// always load from new so that updates are refreshed
|
|
47
40
|
delete require.cache[require.resolve(path)]
|
package/src/utilities/global.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@budibase/backend-core"
|
|
9
9
|
import env from "../environment"
|
|
10
10
|
import { groups } from "@budibase/pro"
|
|
11
|
-
import {
|
|
11
|
+
import { UserCtx, ContextUser, User, UserGroup } from "@budibase/types"
|
|
12
12
|
|
|
13
13
|
export function updateAppRole(
|
|
14
14
|
user: ContextUser,
|
|
@@ -43,33 +43,40 @@ export function updateAppRole(
|
|
|
43
43
|
|
|
44
44
|
async function checkGroupRoles(
|
|
45
45
|
user: ContextUser,
|
|
46
|
-
|
|
46
|
+
opts: { appId?: string; groups?: UserGroup[] } = {}
|
|
47
47
|
) {
|
|
48
48
|
if (user.roleId && user.roleId !== roles.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
49
49
|
return user
|
|
50
50
|
}
|
|
51
|
-
if (appId) {
|
|
52
|
-
user.roleId = await groups.getGroupRoleId(user as User, appId
|
|
51
|
+
if (opts.appId) {
|
|
52
|
+
user.roleId = await groups.getGroupRoleId(user as User, opts.appId, {
|
|
53
|
+
groups: opts.groups,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
// final fallback, simply couldn't find a role - user must be public
|
|
57
|
+
if (!user.roleId) {
|
|
58
|
+
user.roleId = roles.BUILTIN_ROLE_IDS.PUBLIC
|
|
53
59
|
}
|
|
54
60
|
return user
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
async function processUser(
|
|
58
64
|
user: ContextUser,
|
|
59
|
-
|
|
65
|
+
opts: { appId?: string; groups?: UserGroup[] } = {}
|
|
60
66
|
) {
|
|
61
67
|
if (user) {
|
|
62
68
|
delete user.password
|
|
63
69
|
}
|
|
64
|
-
|
|
70
|
+
const appId = opts.appId || context.getAppId()
|
|
71
|
+
user = updateAppRole(user, { appId })
|
|
65
72
|
if (!user.roleId && user?.userGroups?.length) {
|
|
66
|
-
user = await checkGroupRoles(user, { appId })
|
|
73
|
+
user = await checkGroupRoles(user, { appId, groups: opts?.groups })
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
return user
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
export async function getCachedSelf(ctx:
|
|
79
|
+
export async function getCachedSelf(ctx: UserCtx, appId: string) {
|
|
73
80
|
// this has to be tenant aware, can't depend on the context to find it out
|
|
74
81
|
// running some middlewares before the tenancy causes context to break
|
|
75
82
|
const user = await cache.user.getUser(ctx.user?._id!)
|
|
@@ -90,6 +97,7 @@ export async function getGlobalUser(userId: string) {
|
|
|
90
97
|
export async function getGlobalUsers(users?: ContextUser[]) {
|
|
91
98
|
const appId = context.getAppId()
|
|
92
99
|
const db = tenancy.getGlobalDB()
|
|
100
|
+
const allGroups = await groups.fetch()
|
|
93
101
|
let globalUsers
|
|
94
102
|
if (users) {
|
|
95
103
|
const globalIds = users.map(user =>
|
|
@@ -118,7 +126,11 @@ export async function getGlobalUsers(users?: ContextUser[]) {
|
|
|
118
126
|
return globalUsers
|
|
119
127
|
}
|
|
120
128
|
|
|
121
|
-
|
|
129
|
+
// pass in the groups, meaning we don't actually need to retrieve them for
|
|
130
|
+
// each user individually
|
|
131
|
+
return Promise.all(
|
|
132
|
+
globalUsers.map(user => processUser(user, { groups: allGroups }))
|
|
133
|
+
)
|
|
122
134
|
}
|
|
123
135
|
|
|
124
136
|
export async function getGlobalUsersFromMetadata(users: ContextUser[]) {
|
|
@@ -131,7 +131,7 @@ export function coerce(row: any, type: string) {
|
|
|
131
131
|
* @returns {object} the row which has been prepared to be written to the DB.
|
|
132
132
|
*/
|
|
133
133
|
export function inputProcessing(
|
|
134
|
-
user: ContextUser,
|
|
134
|
+
user: ContextUser | null,
|
|
135
135
|
table: Table,
|
|
136
136
|
row: Row,
|
|
137
137
|
opts?: AutoColumnProcessingOpts
|
|
Binary file
|