@ministryofjustice/hmpps-prison-permissions-lib
Version:
A library to centralise the process of determining whether a user should have access to create/read/update/delete a prison resource, for example, accessing a prisoner's Prisoner Profile.
30 lines (29 loc) • 1.44 kB
TypeScript
import type bunyan from 'bunyan';
import { ApiConfig, AuthenticationClient } from '@ministryofjustice/hmpps-rest-client';
import { TelemetryClient } from 'applicationinsights';
import Prisoner from '../../data/hmppsPrisonerSearch/interfaces/Prisoner';
import { HmppsUser } from '../../types/internal/user/HmppsUser';
import PermissionsLogger from './PermissionsLogger';
import { PrisonerPermission, PrisonerPermissions } from '../../types/public/permissions/prisoner/PrisonerPermissions';
export default class PermissionsService {
private readonly prisonerSearchClient;
readonly permissionsLogger: PermissionsLogger;
private readonly readOnly;
static create({ prisonerSearchConfig, authenticationClient, logger, telemetryClient, readOnly, }: {
prisonerSearchConfig: ApiConfig;
authenticationClient: AuthenticationClient;
logger?: bunyan | typeof console;
telemetryClient?: TelemetryClient;
readOnly?: boolean;
}): PermissionsService;
private constructor();
getPrisonerPermissions({ user, prisoner, requestDependentOn, duplicateRecords, }: {
user: HmppsUser;
prisoner: Prisoner;
requestDependentOn: PrisonerPermission[];
duplicateRecords?: Prisoner[];
}): PrisonerPermissions;
private calculatePrisonerPermissions;
private upgradePermissionsFromDuplicateRecords;
getPrisonerDetails(prisonerNumber: string): Promise<Prisoner>;
}