Role API typing.
This commit is contained in:
parent
c0df3e67b3
commit
54c11e33c5
|
@ -6,3 +6,4 @@ export * from "./scim"
|
||||||
export * from "./license"
|
export * from "./license"
|
||||||
export * from "./oldMigration"
|
export * from "./oldMigration"
|
||||||
export * from "./email"
|
export * from "./email"
|
||||||
|
export * from "./role"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Role } from "../../../documents"
|
||||||
|
|
||||||
|
interface GlobalRoleResponse {
|
||||||
|
roles: Role[]
|
||||||
|
name: string
|
||||||
|
version: string
|
||||||
|
url?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FetchGlobalRolesResponse
|
||||||
|
extends Record<string, GlobalRoleResponse> {}
|
||||||
|
|
||||||
|
export interface FindGlobalRoleResponse extends GlobalRoleResponse {}
|
||||||
|
|
||||||
|
export interface RemoveAppRoleResponse {
|
||||||
|
message: string
|
||||||
|
}
|
|
@ -6,9 +6,15 @@ import {
|
||||||
tenancy,
|
tenancy,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
import { Ctx, App } from "@budibase/types"
|
import {
|
||||||
|
Ctx,
|
||||||
|
App,
|
||||||
|
FetchGlobalRolesResponse,
|
||||||
|
FindGlobalRoleResponse,
|
||||||
|
RemoveAppRoleResponse,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
export async function fetch(ctx: Ctx) {
|
export async function fetch(ctx: Ctx<void, FetchGlobalRolesResponse>) {
|
||||||
const tenantId = ctx.user!.tenantId
|
const tenantId = ctx.user!.tenantId
|
||||||
// always use the dev apps as they'll be most up to date (true)
|
// always use the dev apps as they'll be most up to date (true)
|
||||||
const apps = (await dbCore.getAllApps({ tenantId, all: true })) as App[]
|
const apps = (await dbCore.getAllApps({ tenantId, all: true })) as App[]
|
||||||
|
@ -31,7 +37,7 @@ export async function fetch(ctx: Ctx) {
|
||||||
ctx.body = response
|
ctx.body = response
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function find(ctx: Ctx) {
|
export async function find(ctx: Ctx<void, FindGlobalRoleResponse>) {
|
||||||
const appId = ctx.params.appId
|
const appId = ctx.params.appId
|
||||||
await context.doInAppContext(dbCore.getDevAppID(appId), async () => {
|
await context.doInAppContext(dbCore.getDevAppID(appId), async () => {
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
|
@ -45,7 +51,7 @@ export async function find(ctx: Ctx) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeAppRole(ctx: Ctx) {
|
export async function removeAppRole(ctx: Ctx<void, RemoveAppRoleResponse>) {
|
||||||
const { appId } = ctx.params
|
const { appId } = ctx.params
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
const users = await sdk.users.db.allUsers()
|
const users = await sdk.users.db.allUsers()
|
||||||
|
|
Loading…
Reference in New Issue