权限相关管理接口

在开启安全配置情况下,需要对应的权限才可以执行, 如对权限进行增删改需要 '管理权限', 查看需要权限需要 '查看权限管理'

interface ProfileManager {
    clone: ((srcProfileId, name) => string);
    create: ((name, desc) => string);
    deleteById: ((id) => void);
    deleteByName: ((name) => void);
    getAppMenuProfilesById: ((profileID, appID) => AppMenuProfile[]);
    getAppProfilesById: ((profileId) => AppProfile[]);
    getById: ((id) => "permission".Profile);
    getByName: ((name) => "permission".Profile);
    getList: (() => "permission".Profile[]);
    getPermissionsById: ((id) => PermissionAssignment[]);
    inheritClone: ((srcProfileId, name) => string);
    partialClone: ((srcProfileID, name, ...parts) => string);
    partialInheritClone: ((srcProfileId, name, ...parts) => string);
    setConnectorPermission: ((id, connectorType, connectorName, accessible) => void);
    setInheritProfilePartial: ((profileID, ...parts) => void);
    setPermission: ((id, permission, accessible) => void);
    setPermissions: ((id, pas) => void);
    updateAppMenuProfilesById: ((profileID, appID, menuProfiles) => void);
    updateAppProfilesById: ((profileID, appProfiles) => void);
    updateProfileById: ((id, values) => void);
    updateProfileByName: ((name, values) => void);
}

Properties

clone: ((srcProfileId, name) => string)

克隆一个权限集并返回其 id

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (srcProfileId, name): string
    • Parameters

      • srcProfileId: string
      • name: string

      Returns string

create: ((name, desc) => string)

创建一个权限集并返回其 id

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (name, desc): string
    • Parameters

      • name: string

        name of profile, should be unique

      • desc: string

        description

      Returns string

deleteById: ((id) => void)

delete profile by id, if profile does not exist, throw error

Type declaration

    • (id): void
    • Parameters

      • id: string

      Returns void

deleteByName: ((name) => void)

delete profile by name, if profile does not exist, throw error

Type declaration

    • (name): void
    • Parameters

      • name: string

        name of profile

      Returns void

getAppMenuProfilesById: ((profileID, appID) => AppMenuProfile[])

根据权限配置ID和应用程序ID获取菜单设置

Type declaration

Example

import * as permission from 'permission';

let mng = permission.newProfileManager();
let appMenuList = mgr.getAppMenuProfilesById("profileID", "appID")
console.log(appMenuList)

Returns

应用菜单配置的列表

getAppProfilesById: ((profileId) => AppProfile[])

根据ID获取权限配置的应用程序设置

Type declaration

Returns

应用程序配置的列表

getById: ((id) => "permission".Profile)

get profile by id

Type declaration

getByName: ((name) => "permission".Profile)

get profile by name, if not found return null

Type declaration

getList: (() => "permission".Profile[])

get all profiles

Type declaration

getPermissionsById: ((id) => PermissionAssignment[])

get service permissions by profile id

Type declaration

inheritClone: ((srcProfileId, name) => string)

继承克隆权限。新的权限仅克隆基本权限与业务权限,克隆后可独立修改。 其他权限项均与父权限保持一致,不允许修改。

子权限不允许被继承克隆。

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (srcProfileId, name): string
    • Parameters

      • srcProfileId: string
      • name: string

      Returns string

Example

import * as ps from 'permission';

let src = "src_profile_id"
let newName = "cloned_name"
let mng = ps.newProfileManager();
let newId = mng.inheritClone(src, newName);
partialClone: ((srcProfileID, name, ...parts) => string)

部分克隆权限集并返回其 id

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (srcProfileID, name, ...parts): string
    • Parameters

      Returns string

Example


import * as permission from 'permission';

let src = "src_profile_id"
let newName = "cloned_name"
let mng = permission.newProfileManager();
mng.partialClone(src, newName, permission.ClonePartType.App, permission.ClonePartType.Menu, permission.ClonePartType.ServicePermission, permission.ClonePartType.SysParameter);
partialInheritClone: ((srcProfileId, name, ...parts) => string)

部分继承克隆权限。新的权限仅克隆基本权限与业务权限,克隆后可独立修改。可选部分权限仅克隆而不继承,可独立修改。

其他权限项均与父权限保持继承关系,不允许修改。

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (srcProfileId, name, ...parts): string
    • Parameters

      • srcProfileId: string
      • name: string
      • Rest ...parts: ClonePartType[]

        仅克隆而不继承的权限。目前仅支持输入ps.ClonePartType.App和ps.ClonePartType.Menu。

      Returns string

Example

import * as ps from 'permission';

let src = "src_profile_id"
let newName = "profile_name"
let mng = ps.newProfileManager();
let newId = mng.partialInheritClone(src, newName, ps.ClonePartType.App, ps.ClonePartType.Menu);

Returns

新权限配置的ID

setConnectorPermission: ((id, connectorType, connectorName, accessible) => void)

set connector permission allows to update accessibility of one connector

Type declaration

    • (id, connectorType, connectorName, accessible): void
    • Parameters

      • id: string

        profile id

      • connectorType: ConnectorType

        type of connector, e.g. obs

      • connectorName: string

        the name of the connector

      • accessible: boolean

      Returns void

setInheritProfilePartial: ((profileID, ...parts) => void)

重新设置继承克隆的子权限的部分继承设置

使用独立的事务,不与调用脚本共用一个事务,执行成功后即持久化到数据库中

Type declaration

    • (profileID, ...parts): void
    • Parameters

      • profileID: string
      • Rest ...parts: ClonePartType[]

        仅克隆而不继承的权限。目前仅支持输入ps.ClonePartType.App和ps.ClonePartType.Menu。

      Returns void

setPermission: ((id, permission, accessible) => void)

set service permission by profile id

Type declaration

    • (id, permission, accessible): void
    • Parameters

      • id: string

        profile id

      • permission: string

        permission name

      • accessible: boolean

      Returns void

setPermissions: ((id, pas) => void)

set multiple service permission

Type declaration

    • (id, pas): void
    • Parameters

      Returns void

updateAppMenuProfilesById: ((profileID, appID, menuProfiles) => void)

更新应用的菜单配置

Type declaration

    • (profileID, appID, menuProfiles): void
    • Parameters

      Returns void

Example

import * as permission from 'permission';

let mng = permission.newProfileManager();
mng.updateAppMenuProfilesById( profileID, appID, [{menu: 'menuID1', default: true, visible: true},{menu: 'menuID2', default: false, visible: false}])
updateAppProfilesById: ((profileID, appProfiles) => void)

根据ProfileID更新指定权限配置的应用程序设置

Type declaration

    • (profileID, appProfiles): void
    • Parameters

      • profileID: string

        Profile ID

      • appProfiles: AppProfile[]

        需要更新的AppProfile配置信息,未指定的AppProfile不会修改。

      Returns void

Example

import * as permission from 'permission';

let mng = permission.newProfileManager();
mng.updateAppProfilesById(id, [{ applicationID: "app_ID", visible: true, default: true }])
updateProfileById: ((id, values) => void)

update profile value by id

Type declaration

Example

import * as ps from 'permission';

let id = "xxxx"
let mng = permission.newProfileManager();
let values = permission.valueMap({ ViewAllData: false, ManageUsers: true, ManageProcesses: true });
mng.updateProfileById(id, values);
updateProfileByName: ((name, values) => void)

update profile value by name

Type declaration

    • (name, values): void
    • Parameters

      Returns void

Example

import * as ps from 'permission';

let name = "name"
let mng = permission.newProfileManager();
let values = permission.valueMap({ ViewAllData: false, ManageUsers: true, ManageProcesses: true });
mng.updateProfileByName(name, values);