import { Scope } from '../../types'; /** * Options for the useGrant hook */ export interface UseGrantOptions { /** Scope to check the permission in. If provided but null/undefined, hook waits for it to become valid. */ scope?: Scope | null; /** Whether to skip the permission check */ enabled?: boolean; /** Whether to use cached results (default: true) */ useCache?: boolean; /** Whether to return loading state (default: false) */ returnLoading?: boolean; /** Context to check permissions for */ context?: { resource?: Record | null; }; } /** * Result when returnLoading is true */ export interface UseGrantResult { /** Whether the user is granted permission */ isGranted: boolean; /** Whether the permission check is loading */ isLoading: boolean; } /** * Hook to check if a user is granted permission for a specific resource and action * * By default, returns a simple boolean, defaulting to false while loading. * Set `returnLoading: true` to get an object with `isGranted` and `isLoading`. * * @param resource - The resource slug to check * @param action - The action to check * @param options - Additional options * * @example * ```tsx * // Simple boolean (default) * const canEdit = useGrant('document', 'update'); * * return ( *
* {canEdit && } *
* ); * * // With loading state * const { isGranted, isLoading } = useGrant('document', 'update', { * returnLoading: true, * }); * * if (isLoading) return ; * if (!isGranted) return null; * * return ; * ``` */ export declare function useGrant(resource: string, action: string, options?: UseGrantOptions): boolean | UseGrantResult; //# sourceMappingURL=useGrant.d.ts.map