@edular/permissions 4.1.0 → 4.3.0
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/package.json +1 -1
- package/lib/constants.d.ts +0 -48
- package/lib/constants.js +0 -53
- package/lib/helpers.d.ts +0 -4
- package/lib/helpers.js +0 -30
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -15
- package/lib/permissions.d.ts +0 -895
- package/lib/permissions.js +0 -898
package/package.json
CHANGED
package/lib/constants.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export declare enum UserProfileType {
|
|
2
|
-
ApiKey = "api_key",
|
|
3
|
-
Admin = "admin",
|
|
4
|
-
Staff = "staff",
|
|
5
|
-
Student = "student",
|
|
6
|
-
Others = "others"
|
|
7
|
-
}
|
|
8
|
-
export declare type PermissionDetails = {
|
|
9
|
-
permissionId: number;
|
|
10
|
-
name: string;
|
|
11
|
-
departmentId?: number;
|
|
12
|
-
subunitId?: number;
|
|
13
|
-
};
|
|
14
|
-
export declare enum PermissionType {
|
|
15
|
-
View = "view",
|
|
16
|
-
Add = "add",
|
|
17
|
-
Edit = "edit",
|
|
18
|
-
Delete = "delete"
|
|
19
|
-
}
|
|
20
|
-
export declare enum DepartmentPermissionTarget {
|
|
21
|
-
DocumentsListView = "documents.list_view",
|
|
22
|
-
DocumentsDetailView = "documents.detail_view",
|
|
23
|
-
Activities = "activities",
|
|
24
|
-
Tasks = "tasks",
|
|
25
|
-
TasksAccessOthers = "tasks.access_others"
|
|
26
|
-
}
|
|
27
|
-
export declare const DepartmentPermissionTargetTypes: {
|
|
28
|
-
"documents.list_view": PermissionType[];
|
|
29
|
-
"documents.detail_view": PermissionType[];
|
|
30
|
-
activities: PermissionType[];
|
|
31
|
-
tasks: PermissionType[];
|
|
32
|
-
"tasks.access_others": PermissionType[];
|
|
33
|
-
};
|
|
34
|
-
export declare type ProfilePermissionsDetails = {
|
|
35
|
-
type: UserProfileType.Staff;
|
|
36
|
-
enabledPermissionIds: number[];
|
|
37
|
-
enabledDepartmentPermissionIds: number[];
|
|
38
|
-
} | {
|
|
39
|
-
type: UserProfileType.Student;
|
|
40
|
-
enabledPermissionIds: number[];
|
|
41
|
-
} | {
|
|
42
|
-
type: UserProfileType.Admin;
|
|
43
|
-
} | {
|
|
44
|
-
type: UserProfileType.ApiKey;
|
|
45
|
-
} | {
|
|
46
|
-
type: UserProfileType.Others;
|
|
47
|
-
enabledPermissionIds: number[];
|
|
48
|
-
};
|
package/lib/constants.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.DepartmentPermissionTargetTypes = exports.DepartmentPermissionTarget = exports.PermissionType = exports.UserProfileType = void 0;
|
|
5
|
-
var UserProfileType;
|
|
6
|
-
(function (UserProfileType) {
|
|
7
|
-
UserProfileType["ApiKey"] = "api_key";
|
|
8
|
-
UserProfileType["Admin"] = "admin";
|
|
9
|
-
UserProfileType["Staff"] = "staff";
|
|
10
|
-
UserProfileType["Student"] = "student";
|
|
11
|
-
UserProfileType["Others"] = "others";
|
|
12
|
-
})(UserProfileType = exports.UserProfileType || (exports.UserProfileType = {}));
|
|
13
|
-
var PermissionType;
|
|
14
|
-
(function (PermissionType) {
|
|
15
|
-
PermissionType["View"] = "view";
|
|
16
|
-
PermissionType["Add"] = "add";
|
|
17
|
-
PermissionType["Edit"] = "edit";
|
|
18
|
-
PermissionType["Delete"] = "delete";
|
|
19
|
-
})(PermissionType = exports.PermissionType || (exports.PermissionType = {}));
|
|
20
|
-
var DepartmentPermissionTarget;
|
|
21
|
-
(function (DepartmentPermissionTarget) {
|
|
22
|
-
DepartmentPermissionTarget["DocumentsListView"] = "documents.list_view";
|
|
23
|
-
DepartmentPermissionTarget["DocumentsDetailView"] = "documents.detail_view";
|
|
24
|
-
DepartmentPermissionTarget["Activities"] = "activities";
|
|
25
|
-
DepartmentPermissionTarget["Tasks"] = "tasks";
|
|
26
|
-
DepartmentPermissionTarget["TasksAccessOthers"] = "tasks.access_others";
|
|
27
|
-
})(DepartmentPermissionTarget = exports.DepartmentPermissionTarget || (exports.DepartmentPermissionTarget = {}));
|
|
28
|
-
exports.DepartmentPermissionTargetTypes = (_a = {},
|
|
29
|
-
_a[DepartmentPermissionTarget.DocumentsListView] = [PermissionType.View],
|
|
30
|
-
_a[DepartmentPermissionTarget.DocumentsDetailView] = [
|
|
31
|
-
PermissionType.View,
|
|
32
|
-
PermissionType.Add,
|
|
33
|
-
PermissionType.Edit,
|
|
34
|
-
PermissionType.Delete,
|
|
35
|
-
],
|
|
36
|
-
_a[DepartmentPermissionTarget.Activities] = [
|
|
37
|
-
PermissionType.View,
|
|
38
|
-
PermissionType.Add,
|
|
39
|
-
PermissionType.Edit,
|
|
40
|
-
PermissionType.Delete,
|
|
41
|
-
],
|
|
42
|
-
_a[DepartmentPermissionTarget.Tasks] = [
|
|
43
|
-
PermissionType.View,
|
|
44
|
-
PermissionType.Add,
|
|
45
|
-
PermissionType.Edit,
|
|
46
|
-
PermissionType.Delete,
|
|
47
|
-
],
|
|
48
|
-
_a[DepartmentPermissionTarget.TasksAccessOthers] = [
|
|
49
|
-
PermissionType.View,
|
|
50
|
-
PermissionType.Edit,
|
|
51
|
-
PermissionType.Delete,
|
|
52
|
-
],
|
|
53
|
-
_a);
|
package/lib/helpers.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { DepartmentPermissionTarget, PermissionDetails, PermissionType, ProfilePermissionsDetails } from './constants';
|
|
2
|
-
export declare const checkIfProfileHasNeededPermissions: (profilePermissions: ProfilePermissionsDetails, permissionIds: number[]) => boolean;
|
|
3
|
-
export declare const getEnabledPermissionsForTarget: (permissions: PermissionDetails[], target: DepartmentPermissionTarget, type: PermissionType) => PermissionDetails[];
|
|
4
|
-
export declare const checkPermissionsForSubunits: (permissions: PermissionDetails[], target: DepartmentPermissionTarget, type: PermissionType, subunitIds: number[]) => boolean;
|
package/lib/helpers.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.checkPermissionsForSubunits = exports.getEnabledPermissionsForTarget = exports.checkIfProfileHasNeededPermissions = void 0;
|
|
4
|
-
var constants_1 = require("./constants");
|
|
5
|
-
var checkIfProfileHasNeededPermissions = function (profilePermissions, permissionIds) {
|
|
6
|
-
if (permissionIds.length === 0) {
|
|
7
|
-
throw new Error("Permission IDs can't be an empty array");
|
|
8
|
-
}
|
|
9
|
-
if (profilePermissions.type === constants_1.UserProfileType.Admin ||
|
|
10
|
-
profilePermissions.type === constants_1.UserProfileType.ApiKey) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return permissionIds.every(function (permissionId) {
|
|
14
|
-
return profilePermissions.enabledPermissionIds.includes(permissionId);
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.checkIfProfileHasNeededPermissions = checkIfProfileHasNeededPermissions;
|
|
18
|
-
var getEnabledPermissionsForTarget = function (permissions, target, type) {
|
|
19
|
-
return permissions.filter(function (permission) {
|
|
20
|
-
return permission.name.endsWith(target + "." + type);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.getEnabledPermissionsForTarget = getEnabledPermissionsForTarget;
|
|
24
|
-
var checkPermissionsForSubunits = function (permissions, target, type, subunitIds) {
|
|
25
|
-
var enabledPermissions = (0, exports.getEnabledPermissionsForTarget)(permissions, target, type);
|
|
26
|
-
return subunitIds.every(function (subunitId) {
|
|
27
|
-
return enabledPermissions.find(function (permission) { return permission.subunitId === subunitId; });
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
exports.checkPermissionsForSubunits = checkPermissionsForSubunits;
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
exports.__esModule = true;
|
|
13
|
-
__exportStar(require("./permissions"), exports);
|
|
14
|
-
__exportStar(require("./constants"), exports);
|
|
15
|
-
__exportStar(require("./helpers"), exports);
|