Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add delete methods to services and modules #447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/core/src/modules/connections/ConnectionsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ export class ConnectionsModule {
return this.connectionService.findById(connectionId)
}

/**
* Delete a connection record by id
*
* @param connectionId the connection record id
*/
public async deleteById(connectionId: string) {
return this.connectionService.deleteById(connectionId)
}

/**
* Find connection by verkey.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ export class ConnectionService {
return this.connectionRepository.findById(connectionId)
}

/**
* Delete a connection record by id
*
* @param connectionId the connection record id
*/
public async deleteById(connectionId: string) {
const connectionRecord = await this.getById(connectionId)
return this.connectionRepository.delete(connectionRecord)
}

/**
* Find connection by verkey.
*
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/modules/credentials/CredentialsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ export class CredentialsModule {
return this.credentialService.findById(connectionId)
}

/**
* Delete a credential record by id
*
* @param credentialId the credential record id
*/
public async deleteById(credentialId: string) {
return this.credentialService.deleteById(credentialId)
}

private registerHandlers(dispatcher: Dispatcher) {
dispatcher.registerHandler(
new ProposeCredentialHandler(this.credentialService, this.agentConfig, this.credentialResponseCoordinator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,16 @@ export class CredentialService {
return this.credentialRepository.findById(connectionId)
}

/**
* Delete a credential record by id
*
* @param credentialId the credential record id
*/
public async deleteById(credentialId: string) {
const credentialRecord = await this.getById(credentialId)
return this.credentialRepository.delete(credentialRecord)
}

/**
* Retrieve a credential record by connection id and thread id
*
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/modules/proofs/ProofsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ export class ProofsModule {
return this.proofService.findById(proofRecordId)
}

/**
* Delete a proof record by id
*
* @param proofId the proof record id
*/
public async deleteById(proofId: string) {
return this.proofService.deleteById(proofId)
}

private registerHandlers(dispatcher: Dispatcher) {
dispatcher.registerHandler(
new ProposePresentationHandler(this.proofService, this.agentConfig, this.proofResponseCoordinator)
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/modules/proofs/services/ProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,16 @@ export class ProofService {
return this.proofRepository.findById(proofRecordId)
}

/**
* Delete a proof record by id
*
* @param proofId the proof record id
*/
public async deleteById(proofId: string) {
const proofRecord = await this.getById(proofId)
return this.proofRepository.delete(proofRecord)
}

/**
* Retrieve a proof record by connection id and thread id
*
Expand Down