@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
28 lines (27 loc) • 1.01 kB
TypeScript
/**
* Permission checking functionality
*
* Provides utilities for checking permissions against a defined permission set.
*
* @module @jay-js/system/guard/core/permissions
*/
import type { THasPermission, TPermission } from "../types";
/**
* Checks if a role has permission to perform an action on a subject
*
* @param permissions - Array of permission objects to check against
* @param role - The role to check permissions for
* @param subject - The subject to check permissions on
* @param action - The action to check permission for
* @param attribute - Optional attribute to check permission for
* @returns Object with granted status and available attributes
*
* @example
* ```ts
* const result = hasPermission(userPermissions, 'editor', 'articles', 'edit');
* if (result.granted) {
* // Allow the user to edit articles
* }
* ```
*/
export declare function hasPermission(permissions: TPermission[], role: string, subject: string, action: string, attribute?: string): THasPermission;