import Vault from "./Vault" ; import { VaultPermission } from "../types" ; /**
 * Base vault member class (for Entry, Group etc.)
 */ export default class VaultItem { _boundUpdateRefs : ( ) => void ; _source : any ; protected memberof _vault : Vault = null ; param { Vault } vault param { Object } source constructor ( vault , source ) { this . _vault = vault ; this . _source = source ; this . _source . permissions = this . _source . permissions || [ VaultPermission . Manage , VaultPermission . Read , VaultPermission . Write ] ; } readonly memberof get id ( ) : string { return this . _vault . format . getItemID ( this . _source ) ; } memberof get permissions ( ) : Array < string > { return [ ... this . _source . permissions ] ; } readonly memberof get vault ( ) : Vault { return this . _vault ; } param perm memberof grantPermission ( perm ) { if ( ! this . hasPermission ( perm ) ) { this . _source . permissions . push ( perm ) ; } } param perm memberof hasPermission ( perm ) { return this . _source . permissions . includes ( perm ) ; } memberof revokeAllPermissions ( ) { this . _source . permissions = [ ] ; } param perm memberof revokePermission ( perm ) { this . _source . permissions = this . _source . permissions . filter ( current => current !== perm ) ; } protected memberof _cleanUp ( ) { this . _vault = null ; this . _source = null ; } protected memberof _updateRefs ( ) { } }