@soratani-code/samtools 1.3.8 → 1.3.10
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/lib/permission.d.ts +1 -0
- package/lib/permission.js +12 -1
- package/lib/tree.js +6 -4
- package/package.json +1 -1
package/lib/permission.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export interface AuthParams {
|
|
|
10
10
|
export declare function filterPermission(code: number, permissions: number[]): number[];
|
|
11
11
|
export declare function perm(...nums: number[]): number;
|
|
12
12
|
export declare function permissionCompute(resources: Record<string, number>, permissions: Record<string, number>): Record<string, string[]>;
|
|
13
|
+
export declare function computeUserPermission(permissions: Record<string, number>, allPermissions: Record<string, number[]>): Record<string, number[]>;
|
|
13
14
|
export declare function permission(params: AuthParams, userPermission: UserPermission): boolean;
|
|
14
15
|
export {};
|
package/lib/permission.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.permission = exports.permissionCompute = exports.perm = exports.filterPermission = void 0;
|
|
3
|
+
exports.permission = exports.computeUserPermission = exports.permissionCompute = exports.perm = exports.filterPermission = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const judge = (actions, perm) => {
|
|
6
6
|
if (!perm || !perm.length) {
|
|
@@ -62,6 +62,17 @@ function permissionCompute(resources, permissions) {
|
|
|
62
62
|
}, {});
|
|
63
63
|
}
|
|
64
64
|
exports.permissionCompute = permissionCompute;
|
|
65
|
+
function computeUserPermission(permissions, allPermissions) {
|
|
66
|
+
const allKeys = Object.keys(allPermissions);
|
|
67
|
+
const keys = Object.keys(permissions);
|
|
68
|
+
return (0, lodash_1.reduce)(allKeys, (pre, key) => {
|
|
69
|
+
if (keys.includes(key)) {
|
|
70
|
+
pre[key] = filterPermission(permissions[key], allPermissions[key]);
|
|
71
|
+
}
|
|
72
|
+
return pre;
|
|
73
|
+
}, {});
|
|
74
|
+
}
|
|
75
|
+
exports.computeUserPermission = computeUserPermission;
|
|
65
76
|
function permission(params, userPermission) {
|
|
66
77
|
const { requiredPermissions, oneOfPerm } = params;
|
|
67
78
|
if (Array.isArray(requiredPermissions) && requiredPermissions.length) {
|
package/lib/tree.js
CHANGED
|
@@ -43,13 +43,15 @@ function deleteNodeFormKey(key, nodes, id) {
|
|
|
43
43
|
while (queue.length > 0) {
|
|
44
44
|
const node = queue.shift();
|
|
45
45
|
if (node[key] === id) {
|
|
46
|
-
return
|
|
46
|
+
return [];
|
|
47
47
|
}
|
|
48
48
|
if ((0, lodash_1.isArray)(node.children)) {
|
|
49
49
|
const newChildren = [];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
for (let child of node.children) {
|
|
51
|
+
const result = deleteNodeFormKey(key, [child], id);
|
|
52
|
+
if (result.length) {
|
|
53
|
+
newChildren.push(...result);
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
node.children = newChildren;
|
|
55
57
|
}
|