chore: fix getting vault method (#2547)
* chore: fix getting vault method * remove only attribute * fix checking for vaults * fix expected missing vaults
This commit is contained in:
@@ -85,22 +85,8 @@ export class VaultService
|
||||
return this._getVaults.execute().getValue()
|
||||
}
|
||||
|
||||
public getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined {
|
||||
const result = this._getVault.execute(dto)
|
||||
if (result.isFailed()) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.getValue()
|
||||
}
|
||||
|
||||
public getSureVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface {
|
||||
const vault = this.getVault(dto)
|
||||
if (!vault) {
|
||||
throw new Error('Vault not found')
|
||||
}
|
||||
|
||||
return vault
|
||||
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): Result<VaultListingInterface> {
|
||||
return this._getVault.execute(dto)
|
||||
}
|
||||
|
||||
async createRandomizedVault(dto: {
|
||||
@@ -293,7 +279,12 @@ export class VaultService
|
||||
return undefined
|
||||
}
|
||||
|
||||
return this.getVault({ keySystemIdentifier: latestItem.key_system_identifier })
|
||||
const vault = this.getVault({ keySystemIdentifier: latestItem.key_system_identifier })
|
||||
if (vault.isFailed()) {
|
||||
throw new Error('Cannot find vault for item')
|
||||
}
|
||||
|
||||
return vault.getValue()
|
||||
}
|
||||
|
||||
async changeVaultKeyOptions(dto: ChangeVaultKeyOptionsDTO): Promise<Result<void>> {
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface VaultServiceInterface
|
||||
}): Promise<VaultListingInterface>
|
||||
|
||||
getVaults(): VaultListingInterface[]
|
||||
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined
|
||||
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): Result<VaultListingInterface>
|
||||
authorizeVaultDeletion(vault: VaultListingInterface): Promise<Result<boolean>>
|
||||
deleteVault(vault: VaultListingInterface): Promise<boolean>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user