@contember/schema-utils
Advanced tools
Comparing version 0.11.1 to 0.11.2
@@ -43,3 +43,3 @@ "use strict"; | ||
// } | ||
const rolePermissions = this.validateRolePermissions(roles[role], validRoles, errorBuilder.for(role)); | ||
const rolePermissions = this.validateRolePermissions(roles[role], Object.keys(roles), errorBuilder.for(role)); | ||
if (rolePermissions !== undefined) { | ||
@@ -79,6 +79,5 @@ validRoles[role] = rolePermissions; | ||
for (const inheritsFrom of inherits) { | ||
if (!roles[inheritsFrom]) { | ||
errorBuilder | ||
.for(inheritsFrom) | ||
.add('Referenced role not exists. Make sure you are defining roles in a right order'); | ||
if (!roles.includes(inheritsFrom)) { | ||
// todo: check recursion | ||
errorBuilder.for(inheritsFrom).add('Referenced role not exists.'); | ||
} | ||
@@ -85,0 +84,0 @@ else { |
{ | ||
"name": "@contember/schema-utils", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"license": "Apache-2.0", | ||
@@ -11,3 +11,3 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@contember/schema": "^0.11.1" | ||
"@contember/schema": "^0.11.2" | ||
}, | ||
@@ -14,0 +14,0 @@ "devDependencies": { |
@@ -39,3 +39,3 @@ import { Acl, Model } from '@contember/schema' | ||
// } | ||
const rolePermissions = this.validateRolePermissions(roles[role], validRoles, errorBuilder.for(role)) | ||
const rolePermissions = this.validateRolePermissions(roles[role], Object.keys(roles), errorBuilder.for(role)) | ||
if (rolePermissions !== undefined) { | ||
@@ -50,3 +50,3 @@ validRoles[role] = rolePermissions | ||
permissions: unknown, | ||
roles: Acl.Schema['roles'], | ||
roles: string[], | ||
errorBuilder: ErrorBuilder, | ||
@@ -85,7 +85,3 @@ ): Acl.RolePermissions | undefined { | ||
private validateInherits( | ||
inherits: unknown, | ||
roles: Acl.Schema['roles'], | ||
errorBuilder: ErrorBuilder, | ||
): string[] | undefined { | ||
private validateInherits(inherits: unknown, roles: string[], errorBuilder: ErrorBuilder): string[] | undefined { | ||
if (inherits === undefined) { | ||
@@ -100,6 +96,5 @@ return undefined | ||
for (const inheritsFrom of inherits) { | ||
if (!roles[inheritsFrom]) { | ||
errorBuilder | ||
.for(inheritsFrom) | ||
.add('Referenced role not exists. Make sure you are defining roles in a right order') | ||
if (!roles.includes(inheritsFrom)) { | ||
// todo: check recursion | ||
errorBuilder.for(inheritsFrom).add('Referenced role not exists.') | ||
} else { | ||
@@ -106,0 +101,0 @@ validRoles.push(inheritsFrom) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
427124
3637
Updated@contember/schema@^0.11.2