UNPKG

@upv/ushi-shared

Version:

Shared DTOs, types, and utilities for the USHI platform (LMS, Trials, Social, Wallet).

43 lines (42 loc) 1.66 kB
import { PersonRole } from '../core/enums/PersonEnums'; import { IRoleAssignment } from '../types'; export declare function isAdmin(role: PersonRole): boolean; export declare function isTrialRole(role: PersonRole): boolean; /** * getActiveAssignmentsForPerson * * Filters role assignments to include only those that: * - belong to the specified user * - are currently active * - have not expired * * @param userId - The user ID to filter by * @param assignments - All role assignments in the system * @param now - Optional override for current time (defaults to Date.now()) * @returns Array of active, non-expired role assignments */ export declare function getActiveAssignmentsForPerson(userId: string, assignments: IRoleAssignment[], now?: number): IRoleAssignment[]; /** * isRoleStillValid * * Determines whether a single role assignment is still valid * (i.e., active and not expired). * * @param assignment - The assignment to check * @param now - Optional override for current time (defaults to Date.now()) * @returns True if the role is valid, otherwise false */ export declare function isRoleStillValid(assignment: IRoleAssignment, now?: number): boolean; /** * validateRoleAssignments * * Returns a new list of role assignments with any expired roles * marked as `status: 'expired'`. * * NOTE: This function is non-mutative. * * @param assignments - List of role assignments to validate * @param now - Optional override for current time (defaults to Date.now()) * @returns Updated list of role assignments */ export declare function validateRoleAssignments(assignments: IRoleAssignment[], now?: number): IRoleAssignment[];