@edular/permissions 8.12.0 → 9.0.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/lib/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DepartmentPermissionTarget, PermissionDetails, PermissionType, ProfilePermissionsDetails } from './constants';
2
- export declare const checkIfProfileHasNeededPermissions: (profilePermissions: ProfilePermissionsDetails, permissionIds: number[]) => boolean;
2
+ export declare const checkIfProfileHasNeededPermissions: (profilePermissions: ProfilePermissionsDetails, permissionIds?: number[]) => boolean;
3
3
  export declare const getEnabledPermissionsForTarget: (permissions: PermissionDetails[], target: DepartmentPermissionTarget, type: PermissionType) => PermissionDetails[];
4
4
  export declare const checkPermissionsForSubunits: (permissions: PermissionDetails[], target: DepartmentPermissionTarget, type: PermissionType, subunitIds: number[]) => boolean;
5
5
  export declare const checkPermissionsForDepartments: (permissions: PermissionDetails[], target: DepartmentPermissionTarget, type: PermissionType, departmentIds: number[]) => boolean;
package/lib/helpers.js CHANGED
@@ -3,13 +3,14 @@ exports.__esModule = true;
3
3
  exports.checkPermissionsForDepartments = exports.checkPermissionsForSubunits = exports.getEnabledPermissionsForTarget = exports.checkIfProfileHasNeededPermissions = void 0;
4
4
  var constants_1 = require("./constants");
5
5
  var checkIfProfileHasNeededPermissions = function (profilePermissions, permissionIds) {
6
- if (permissionIds.length === 0) {
7
- return false;
8
- }
6
+ if (permissionIds === void 0) { permissionIds = []; }
9
7
  if (profilePermissions.type === constants_1.UserProfileType.Admin ||
10
8
  profilePermissions.type === constants_1.UserProfileType.ApiKey) {
11
9
  return true;
12
10
  }
11
+ if (permissionIds.length === 0) {
12
+ return false;
13
+ }
13
14
  return permissionIds.every(function (permissionId) {
14
15
  return profilePermissions.enabledPermissionIds.includes(permissionId);
15
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edular/permissions",
3
- "version": "8.12.0",
3
+ "version": "9.0.0",
4
4
  "author": "Edular",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",