https://github.com/paraboly/permissionservice
Generic Permission Service with Jest Test via Paraboly
https://github.com/paraboly/permissionservice
Last synced: about 1 year ago
JSON representation
Generic Permission Service with Jest Test via Paraboly
- Host: GitHub
- URL: https://github.com/paraboly/permissionservice
- Owner: Paraboly
- License: apache-2.0
- Created: 2019-10-22T08:35:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T08:22:02.000Z (over 3 years ago)
- Last Synced: 2025-03-30T09:13:33.991Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://paraboly.com
- Size: 248 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/Paraboly/pwc-permission-service)
[](https://www.npmjs.com/package/@paraboly/pwc-permission-service)
[](https://www.npmjs.com/package/@paraboly/pwc-permission-service)

[](https://opensource.org/licenses/MIT)
# Architecture of Using Permission Service
| Types | Values | Example | Example2 |
| ---------------- | ------ | ---------- | ------------- |
| NAMESPACE | 0 | permission | permission |
| MODULE | 1 | system | system |
| PAGE | 2 | globalMap | globalMap |
| COMPONENT | 3 | * | button |
| COMPONENT ID | 4 | * | delete_button |
| PERMISSION VALUE | 5 | 7 | 0 |
## Installation
```js
npm i @paraboly/pwc-permission-service
```
# Usage
## Import
```js
import PermissionService from "@paraboly/pwc-permission-service";
```
## Basic Usage
### Generate Permission Object from Encoded Permission String
Generate (Decode) the given encoded permission string to usable object
```js
const {
generatePermissionObj,
} = PermissionService;
const permissionObj = generatePermissionObj(permission);
console.log("Permission Object: ", permissionObj);
```
### Decode Selected Permission
Please check the permission architecture about the permission of the each type.
```js
const {
decodeSelectedPermission
} = PermissionService;
const module = decodeSelectedPermission(1, permission);
const page = decodeSelectedPermission(2, permission);
const permissionValue = decodeSelectedPermission(
5,
permission
);
```
### Generate Permission Encode
Generate the fundamental encoded permission string with given parameters
```js
PermissionService.generatePermissionEncode(
"permission",
"system",
"globalMap",
"*",
"delete_button",
7
)
```
## Authors
FreakyCoder, kuray.ogun@paraboly.com | kurayogun@gmail.com
## License
Permission Service is available under the Apache License 2.0 license. See the LICENSE file for more info.