npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hecom/authority

v1.6.4

Published

Authority of Application and Meta Object

Downloads

20

Readme

Authority

npm version Build Status

这是应用和业务对象的权限模块,包括加载权限、判断权限以及变更通知等功能。

接口

  • name: string:模块名称。
  • initGlobal: () => void:全局初始化模块。
  • load: (canDiff) => Promise:重新加载权限列表,并根据canDiff决定判断是否需要发出相应的权限更新事件。
  • get: (level, innerAppName, actionName) => object:根据层级结构的键,获取权限项。
  • app:应用相关操作。
    • levelName: (appName) => string:获取应用权限的首层键。
    • get: (appName, innerAppName, actionName) => object:获取应用模块的权限。如果不存在,则返回null
    • register: (func, name, innerAppName, actionName) => string:注册应用处理事件,返回事件Id。
    • unregister: (funcId, name, innerAppName, actionName) => boolean:注销应用处理事件。
    • verify: (appName, innerAppName, actionName, data) => boolean:验证应用模块的权限,如果传了data,则验证数据权限。
    • verifyData: (metaName, objectid, actionName, data) => Promise<boolean>:通过接口形式校验是否有数据权限,当有data时,会或上verify的结果。
  • obj:元数据相关操作。结构和参数同app部分,appName改为metaName即可。
  • verifyField: (authFieldType, metaName, fieldname) => boolean:验证字段权限,authFieldType是权限类型,参照Foundation.AuthField中的常量,然后指定元数据名称和字段名称。
  • verifyDept: (deptPath, deptCode, actionItem) => boolean:验证部门是否在部门(含下级或不含下级)列表中。deptPath是待判断的部门路径,deptCode是待判断的部门Code,actionItem是权限项。
  • showForceLogoutAlert: () => void:显示权限更新对话框,强制登出操作,多次操作有加锁,不会弹出多个对话框。
  • type:权限值的判断。
    • isAll: () => boolean:是否是全部门。
    • isDeptWithSub: () => boolean:是否是部门含下级。
    • isDeptWithoutSub: () => boolean:是否是部门不含下级。
    • isOnlyMe: () => boolean:是否是仅自己。
    • isZeroScope: () => boolean:有数据权限但是数据范围是0。

事件类型

  • 接收环信透传传递的控制消息,用于权限更新。
  • 权限更新事件:类型为[authUpdateEvent, name, innerAppName, action],其中authUpdateEvent是事件分类,name是业务对象或应用的分组,innerAppName是内部权限的分配,action是具体操作。数据是{oldObj, newObj, keys, isDeleted, isCreated, isUpdated},其中前两个是新旧权限项,keys是三层路径,可能小于三层,后三者表示是删除或新增或更新。