// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
/* eslint-disable @typescript-eslint/no-unused-vars */
import { LogError } from "../../../core/decorator/LogErrorDecorator";
import ValidatedRequest from "../../../core/validation/ValidatedArgs";
import { QueryBus } from "../../../core/query/QueryBus";
import Injectable from "../../../core/injectable/Injectable";
import { CommandBus } from "../../../core/command/CommandBus";
import IsIssuerRequest from "../request/security/operations/issue/IsIssuerRequest";
import { IsIssuerQuery } from "../../../app/usecase/query/security/ssi/isIssuer/IsIssuerQuery";
import { AddIssuerCommand } from "../../../app/usecase/command/security/ssi/addIssuer/AddIssuerCommand";
import { SetRevocationRegistryAddressCommand } from "../../../app/usecase/command/security/ssi/setRevocationRegistryAddress/SetRevocationRegistryAddressCommand";
import { RemoveIssuerCommand } from "../../../app/usecase/command/security/ssi/removeIssuer/RemoveIssuerCommand";
import SetRevocationRegistryAddressRequest from "../request/security/ssi/SetRevocationRegistryAddressRequest";
import AddIssuerRequest from "../request/security/ssi/AddIssuerRequest";
import RemoveIssuerRequest from "../request/security/operations/issue/RemoveIssuerRequest";
import GetRevocationRegistryAddressRequest from "../request/security/ssi/GetRevocationRegistryAddressRequest";
import GetIssuerListCountRequest from "../request/security/ssi/GetIssuerListCountRequest";
import GetIssuerListMembersRequest from "../request/security/ssi/GetIssuerListMembersRequest";
import { GetRevocationRegistryAddressQuery } from "../../../app/usecase/query/security/ssi/getRevocationRegistryAddress/GetRevocationRegistryAddressQuery";
import { GetIssuerListCountQuery } from "../../../app/usecase/query/security/ssi/getIssuerListCount/GetIssuerListCountQuery";
import { GetIssuerListMembersQuery } from "../../../app/usecase/query/security/ssi/getIssuerListMembers/GetIssuerListMembersQuery";
class SsiManagementInPort {
    commandBus;
    queryBus;
    constructor(commandBus = Injectable.resolve(CommandBus), queryBus = Injectable.resolve(QueryBus)) {
        this.commandBus = commandBus;
        this.queryBus = queryBus;
    }
    async addIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedRequest.handleValidation("AddIssuerRequest", request);
        return await this.commandBus.execute(new AddIssuerCommand(securityId, issuerId));
    }
    async setRevocationRegistryAddress(request) {
        const { securityId, revocationRegistryId } = request;
        ValidatedRequest.handleValidation("SetRevocationRegistryAddressRequest", request);
        return await this.commandBus.execute(new SetRevocationRegistryAddressCommand(securityId, revocationRegistryId));
    }
    async removeIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedRequest.handleValidation("RemoveIssuerRequest", request);
        return await this.commandBus.execute(new RemoveIssuerCommand(securityId, issuerId));
    }
    async getRevocationRegistryAddress(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation("GetRevocationRegistryAddressRequest", request);
        return (await this.queryBus.execute(new GetRevocationRegistryAddressQuery(securityId))).payload;
    }
    async getIssuerListCount(request) {
        const { securityId } = request;
        ValidatedRequest.handleValidation("GetIssuerListCountRequest", request);
        return (await this.queryBus.execute(new GetIssuerListCountQuery(securityId))).payload;
    }
    async getIssuerListMembers(request) {
        const { securityId, start, end } = request;
        ValidatedRequest.handleValidation("GetIssuerListMembersRequest", request);
        return (await this.queryBus.execute(new GetIssuerListMembersQuery(securityId, start, end))).payload;
    }
    async isIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedRequest.handleValidation("IsIssuerRequest", request);
        return (await this.queryBus.execute(new IsIssuerQuery(securityId, issuerId))).payload;
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [AddIssuerRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "addIssuer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [SetRevocationRegistryAddressRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "setRevocationRegistryAddress", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RemoveIssuerRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "removeIssuer", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetRevocationRegistryAddressRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getRevocationRegistryAddress", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetIssuerListCountRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getIssuerListCount", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetIssuerListMembersRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getIssuerListMembers", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsIssuerRequest]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "isIssuer", null);
const SsiManagement = new SsiManagementInPort();
export default SsiManagement;
