@budibase/worker 3.20.4 → 3.20.6
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.20.
|
|
4
|
+
"version": "3.20.6",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "91ae7d82b9b1311754548f1447db8039b592f6b9"
|
|
113
113
|
}
|
|
@@ -669,16 +669,19 @@ async function handleUserWorkspacePermission(
|
|
|
669
669
|
throw new HTTPError("Feature not enabled, please check license", 400)
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
const
|
|
672
|
+
const creatorForApps = Object.entries(existingUser.roles)
|
|
673
673
|
.filter(([_appId, role]) => role === "CREATOR")
|
|
674
674
|
.map(([appId]) => appId)
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
675
|
+
|
|
676
|
+
const shouldHaveCreatorRole =
|
|
677
|
+
existingUser.builder?.creator || creatorForApps.length
|
|
678
|
+
if (!shouldHaveCreatorRole) {
|
|
679
|
+
delete existingUser.builder?.creator
|
|
680
|
+
delete existingUser.builder?.apps
|
|
681
|
+
} else {
|
|
679
682
|
existingUser.builder ??= {}
|
|
680
683
|
existingUser.builder.creator = true
|
|
681
|
-
existingUser.builder.apps =
|
|
684
|
+
existingUser.builder.apps = creatorForApps
|
|
682
685
|
}
|
|
683
686
|
|
|
684
687
|
const user = await userSdk.db.save(existingUser, {
|
|
@@ -1015,27 +1015,50 @@ describe("/api/global/users", () => {
|
|
|
1015
1015
|
expect(updatedUser.builder?.creator).toBe(true)
|
|
1016
1016
|
expect(updatedUser.builder?.apps).toEqual([workspaceId])
|
|
1017
1017
|
})
|
|
1018
|
+
it("should keep builder creator flag when assigning non-CREATOR roles", async () => {
|
|
1019
|
+
const builderUser = await config.createUser({
|
|
1020
|
+
builder: {
|
|
1021
|
+
creator: true,
|
|
1022
|
+
},
|
|
1023
|
+
})
|
|
1024
|
+
const workspaceId = "app_creator_preserve"
|
|
1018
1025
|
|
|
1019
|
-
it("should remove CREATOR role and clean up builder properties when no creator apps remain", async () => {
|
|
1020
|
-
mocks.licenses.useAppBuilders()
|
|
1021
|
-
const user = await config.createUser()
|
|
1022
|
-
const workspaceId = "app_123456789"
|
|
1023
|
-
|
|
1024
|
-
// First assign CREATOR role
|
|
1025
1026
|
const res = await config.withApp(workspaceId, () =>
|
|
1026
|
-
config.api.users.addUserToWorkspace(
|
|
1027
|
+
config.api.users.addUserToWorkspace(
|
|
1028
|
+
builderUser._id!,
|
|
1029
|
+
builderUser._rev!,
|
|
1030
|
+
"BASIC"
|
|
1031
|
+
)
|
|
1027
1032
|
)
|
|
1028
|
-
|
|
1033
|
+
builderUser._rev = res.body._rev
|
|
1029
1034
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1035
|
+
const updatedUser = await config.getUser(builderUser.email)
|
|
1036
|
+
expect(updatedUser.roles[workspaceId]).toBe("BASIC")
|
|
1037
|
+
expect(updatedUser.builder?.creator).toBe(true)
|
|
1038
|
+
})
|
|
1039
|
+
|
|
1040
|
+
it("should keep builder creator flag when assigning CREATOR roles", async () => {
|
|
1041
|
+
featureMocks.licenses.useAppBuilders()
|
|
1042
|
+
|
|
1043
|
+
const builderUser = await config.createUser({
|
|
1044
|
+
builder: {
|
|
1045
|
+
creator: true,
|
|
1046
|
+
},
|
|
1047
|
+
})
|
|
1048
|
+
const workspaceId = "app_creator_preserve"
|
|
1049
|
+
|
|
1050
|
+
const res = await config.withApp(workspaceId, () =>
|
|
1051
|
+
config.api.users.addUserToWorkspace(
|
|
1052
|
+
builderUser._id!,
|
|
1053
|
+
builderUser._rev!,
|
|
1054
|
+
"CREATOR"
|
|
1055
|
+
)
|
|
1033
1056
|
)
|
|
1057
|
+
builderUser._rev = res.body._rev
|
|
1034
1058
|
|
|
1035
|
-
const updatedUser = await config.getUser(
|
|
1036
|
-
expect(updatedUser.roles[workspaceId]).
|
|
1037
|
-
expect(updatedUser.builder?.creator).
|
|
1038
|
-
expect(updatedUser.builder?.apps).toBeUndefined()
|
|
1059
|
+
const updatedUser = await config.getUser(builderUser.email)
|
|
1060
|
+
expect(updatedUser.roles[workspaceId]).toBe("CREATOR")
|
|
1061
|
+
expect(updatedUser.builder?.creator).toBe(true)
|
|
1039
1062
|
})
|
|
1040
1063
|
|
|
1041
1064
|
it("should maintain builder properties when user has multiple CREATOR roles", async () => {
|