-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add consumption method * feat: add runtime usecase * feat: add delete to facade * test: add runtime tests * feat: add consumption tests * chore: rm todo * chore: negation
- Loading branch information
1 parent
b7b26d1
commit de7cd66
Showing
8 changed files
with
166 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/runtime/src/useCases/consumption/requests/DeleteIncomingRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Result } from "@js-soft/ts-utils"; | ||
import { IncomingRequestsController, LocalRequest } from "@nmshd/consumption"; | ||
import { CoreId } from "@nmshd/core-types"; | ||
import { AccountController } from "@nmshd/transport"; | ||
import { Inject } from "@nmshd/typescript-ioc"; | ||
import { RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; | ||
|
||
export interface DeleteIncomingRequestRequest { | ||
requestId: string; | ||
} | ||
|
||
class Validator extends SchemaValidator<DeleteIncomingRequestRequest> { | ||
public constructor(@Inject schemaRepository: SchemaRepository) { | ||
super(schemaRepository.getSchema("DeleteIncomingRequestRequest")); | ||
} | ||
} | ||
|
||
export class DeleteIncomingRequestUseCase extends UseCase<DeleteIncomingRequestRequest, void> { | ||
public constructor( | ||
@Inject private readonly incomingRequestsController: IncomingRequestsController, | ||
@Inject private readonly accountController: AccountController, | ||
@Inject validator: Validator | ||
) { | ||
super(validator); | ||
} | ||
|
||
protected async executeInternal(request: DeleteIncomingRequestRequest): Promise<Result<void>> { | ||
const localRequest = await this.incomingRequestsController.getIncomingRequest(CoreId.from(request.requestId)); | ||
if (!localRequest) { | ||
return Result.fail(RuntimeErrors.general.recordNotFound(LocalRequest)); | ||
} | ||
|
||
await this.incomingRequestsController.delete(localRequest); | ||
|
||
await this.accountController.syncDatawallet(); | ||
|
||
return Result.ok(undefined); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters