@budibase/backend-core 2.13.15 → 2.13.17
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 +278 -250
- 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.meta.json +1 -1
- package/dist/src/security/permissions.d.ts +1 -0
- package/dist/src/security/permissions.js +2 -1
- package/dist/src/security/permissions.js.map +1 -1
- package/dist/src/users/db.d.ts +1 -1
- package/dist/src/users/db.js +1 -6
- package/dist/src/users/db.js.map +1 -1
- package/dist/src/users/users.d.ts +2 -0
- package/dist/src/users/users.js +26 -1
- package/dist/src/users/users.js.map +1 -1
- package/package.json +4 -4
- package/src/security/permissions.ts +1 -0
- package/src/users/db.ts +2 -9
- package/src/users/users.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.17",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.3",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.13.
|
|
27
|
-
"@budibase/types": "2.13.
|
|
26
|
+
"@budibase/shared-core": "2.13.17",
|
|
27
|
+
"@budibase/types": "2.13.17",
|
|
28
28
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "d700bb57d466691e2f0b4f8c6c1664a3c76efa81"
|
|
100
100
|
}
|
|
@@ -160,4 +160,5 @@ export function isPermissionLevelHigherThanRead(level: PermissionLevel) {
|
|
|
160
160
|
|
|
161
161
|
// utility as a lot of things need simply the builder permission
|
|
162
162
|
export const BUILDER = PermissionType.BUILDER
|
|
163
|
+
export const CREATOR = PermissionType.CREATOR
|
|
163
164
|
export const GLOBAL_BUILDER = PermissionType.GLOBAL_BUILDER
|
package/src/users/db.ts
CHANGED
|
@@ -146,12 +146,12 @@ export class UserDB {
|
|
|
146
146
|
|
|
147
147
|
static async allUsers() {
|
|
148
148
|
const db = getGlobalDB()
|
|
149
|
-
const response = await db.allDocs(
|
|
149
|
+
const response = await db.allDocs<User>(
|
|
150
150
|
dbUtils.getGlobalUserParams(null, {
|
|
151
151
|
include_docs: true,
|
|
152
152
|
})
|
|
153
153
|
)
|
|
154
|
-
return response.rows.map(
|
|
154
|
+
return response.rows.map(row => row.doc!)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
static async countUsersByApp(appId: string) {
|
|
@@ -209,13 +209,6 @@ export class UserDB {
|
|
|
209
209
|
throw new Error("_id or email is required")
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
if (
|
|
213
|
-
user.builder?.apps?.length &&
|
|
214
|
-
!(await UserDB.features.isAppBuildersEnabled())
|
|
215
|
-
) {
|
|
216
|
-
throw new Error("Unable to update app builders, please check license")
|
|
217
|
-
}
|
|
218
|
-
|
|
219
212
|
let dbUser: User | undefined
|
|
220
213
|
if (_id) {
|
|
221
214
|
// try to get existing user from db
|
package/src/users/users.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { getGlobalDB } from "../context"
|
|
26
26
|
import * as context from "../context"
|
|
27
27
|
import { isCreator } from "./utils"
|
|
28
|
+
import { UserDB } from "./db"
|
|
28
29
|
|
|
29
30
|
type GetOpts = { cleanup?: boolean }
|
|
30
31
|
|
|
@@ -336,3 +337,20 @@ export function cleanseUserObject(user: User | ContextUser, base?: User) {
|
|
|
336
337
|
}
|
|
337
338
|
return user
|
|
338
339
|
}
|
|
340
|
+
|
|
341
|
+
export async function addAppBuilder(user: User, appId: string) {
|
|
342
|
+
const prodAppId = getProdAppID(appId)
|
|
343
|
+
user.builder ??= {}
|
|
344
|
+
user.builder.creator = true
|
|
345
|
+
user.builder.apps ??= []
|
|
346
|
+
user.builder.apps.push(prodAppId)
|
|
347
|
+
await UserDB.save(user, { hashPassword: false })
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export async function removeAppBuilder(user: User, appId: string) {
|
|
351
|
+
const prodAppId = getProdAppID(appId)
|
|
352
|
+
if (user.builder && user.builder.apps?.includes(prodAppId)) {
|
|
353
|
+
user.builder.apps = user.builder.apps.filter(id => id !== prodAppId)
|
|
354
|
+
}
|
|
355
|
+
await UserDB.save(user, { hashPassword: false })
|
|
356
|
+
}
|