"use strict";
// 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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-unused-vars */
const LogErrorDecorator_1 = require("../../../core/decorator/LogErrorDecorator");
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
const QueryBus_1 = require("../../../core/query/QueryBus");
const Injectable_1 = __importDefault(require("../../../core/injectable/Injectable"));
const CommandBus_1 = require("../../../core/command/CommandBus");
const IsIssuerRequest_1 = __importDefault(require("../request/security/operations/issue/IsIssuerRequest"));
const IsIssuerQuery_1 = require("../../../app/usecase/query/security/ssi/isIssuer/IsIssuerQuery");
const AddIssuerCommand_1 = require("../../../app/usecase/command/security/ssi/addIssuer/AddIssuerCommand");
const SetRevocationRegistryAddressCommand_1 = require("../../../app/usecase/command/security/ssi/setRevocationRegistryAddress/SetRevocationRegistryAddressCommand");
const RemoveIssuerCommand_1 = require("../../../app/usecase/command/security/ssi/removeIssuer/RemoveIssuerCommand");
const SetRevocationRegistryAddressRequest_1 = __importDefault(require("../request/security/ssi/SetRevocationRegistryAddressRequest"));
const AddIssuerRequest_1 = __importDefault(require("../request/security/ssi/AddIssuerRequest"));
const RemoveIssuerRequest_1 = __importDefault(require("../request/security/operations/issue/RemoveIssuerRequest"));
const GetRevocationRegistryAddressRequest_1 = __importDefault(require("../request/security/ssi/GetRevocationRegistryAddressRequest"));
const GetIssuerListCountRequest_1 = __importDefault(require("../request/security/ssi/GetIssuerListCountRequest"));
const GetIssuerListMembersRequest_1 = __importDefault(require("../request/security/ssi/GetIssuerListMembersRequest"));
const GetRevocationRegistryAddressQuery_1 = require("../../../app/usecase/query/security/ssi/getRevocationRegistryAddress/GetRevocationRegistryAddressQuery");
const GetIssuerListCountQuery_1 = require("../../../app/usecase/query/security/ssi/getIssuerListCount/GetIssuerListCountQuery");
const GetIssuerListMembersQuery_1 = require("../../../app/usecase/query/security/ssi/getIssuerListMembers/GetIssuerListMembersQuery");
class SsiManagementInPort {
    commandBus;
    queryBus;
    constructor(commandBus = Injectable_1.default.resolve(CommandBus_1.CommandBus), queryBus = Injectable_1.default.resolve(QueryBus_1.QueryBus)) {
        this.commandBus = commandBus;
        this.queryBus = queryBus;
    }
    async addIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedArgs_1.default.handleValidation("AddIssuerRequest", request);
        return await this.commandBus.execute(new AddIssuerCommand_1.AddIssuerCommand(securityId, issuerId));
    }
    async setRevocationRegistryAddress(request) {
        const { securityId, revocationRegistryId } = request;
        ValidatedArgs_1.default.handleValidation("SetRevocationRegistryAddressRequest", request);
        return await this.commandBus.execute(new SetRevocationRegistryAddressCommand_1.SetRevocationRegistryAddressCommand(securityId, revocationRegistryId));
    }
    async removeIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedArgs_1.default.handleValidation("RemoveIssuerRequest", request);
        return await this.commandBus.execute(new RemoveIssuerCommand_1.RemoveIssuerCommand(securityId, issuerId));
    }
    async getRevocationRegistryAddress(request) {
        const { securityId } = request;
        ValidatedArgs_1.default.handleValidation("GetRevocationRegistryAddressRequest", request);
        return (await this.queryBus.execute(new GetRevocationRegistryAddressQuery_1.GetRevocationRegistryAddressQuery(securityId))).payload;
    }
    async getIssuerListCount(request) {
        const { securityId } = request;
        ValidatedArgs_1.default.handleValidation("GetIssuerListCountRequest", request);
        return (await this.queryBus.execute(new GetIssuerListCountQuery_1.GetIssuerListCountQuery(securityId))).payload;
    }
    async getIssuerListMembers(request) {
        const { securityId, start, end } = request;
        ValidatedArgs_1.default.handleValidation("GetIssuerListMembersRequest", request);
        return (await this.queryBus.execute(new GetIssuerListMembersQuery_1.GetIssuerListMembersQuery(securityId, start, end))).payload;
    }
    async isIssuer(request) {
        const { securityId, issuerId } = request;
        ValidatedArgs_1.default.handleValidation("IsIssuerRequest", request);
        return (await this.queryBus.execute(new IsIssuerQuery_1.IsIssuerQuery(securityId, issuerId))).payload;
    }
}
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [AddIssuerRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "addIssuer", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [SetRevocationRegistryAddressRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "setRevocationRegistryAddress", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [RemoveIssuerRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "removeIssuer", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetRevocationRegistryAddressRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getRevocationRegistryAddress", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetIssuerListCountRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getIssuerListCount", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetIssuerListMembersRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "getIssuerListMembers", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsIssuerRequest_1.default]),
    __metadata("design:returntype", Promise)
], SsiManagementInPort.prototype, "isIssuer", null);
const SsiManagement = new SsiManagementInPort();
exports.default = SsiManagement;
