"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 Injectable_1 = __importDefault(require("../../../core/injectable/Injectable"));
const CommandBus_1 = require("../../../core/command/CommandBus");
const index_1 = require("../request/index");
const UpdateExternalControlListsCommand_1 = require("../../../app/usecase/command/security/externalControlLists/updateExternalControlLists/UpdateExternalControlListsCommand");
const AddExternalControlListCommand_1 = require("../../../app/usecase/command/security/externalControlLists/addExternalControlList/AddExternalControlListCommand");
const RemoveExternalControlListCommand_1 = require("../../../app/usecase/command/security/externalControlLists/removeExternalControlList/RemoveExternalControlListCommand");
const QueryBus_1 = require("../../../core/query/QueryBus");
const IsExternalControlListQuery_1 = require("../../../app/usecase/query/security/externalControlLists/isExternalControlList/IsExternalControlListQuery");
const GetExternalControlListsCountQuery_1 = require("../../../app/usecase/query/security/externalControlLists/getExternalControlListsCount/GetExternalControlListsCountQuery");
const GetExternalControlListsMembersQuery_1 = require("../../../app/usecase/query/security/externalControlLists/getExternalControlListsMembers/GetExternalControlListsMembersQuery");
const AddToBlackListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/addToBlackListMock/AddToBlackListMockCommand");
const AddToWhiteListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/addToWhiteListMock/AddToWhiteListMockCommand");
const RemoveFromBlackListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/removeFromBlackListMock/RemoveFromBlackListMockCommand");
const RemoveFromWhiteListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/removeFromWhiteListMock/RemoveFromWhiteListMockCommand");
const CreateExternalBlackListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/createExternalBlackListMock/CreateExternalBlackListMockCommand");
const CreateExternalWhiteListMockCommand_1 = require("../../../app/usecase/command/security/externalControlLists/mock/createExternalWhiteListMock/CreateExternalWhiteListMockCommand");
const IsAuthorizedBlackListMockQuery_1 = require("../../../app/usecase/query/security/externalControlLists/mock/isAuthorizedBlackListMock/IsAuthorizedBlackListMockQuery");
const IsAuthorizedWhiteListMockQuery_1 = require("../../../app/usecase/query/security/externalControlLists/mock/isAuthorizedWhiteListMock/IsAuthorizedWhiteListMockQuery");
const ValidatedArgs_1 = __importDefault(require("../../../core/validation/ValidatedArgs"));
class ExternalControlListsInPort {
    queryBus;
    commandBus;
    constructor(queryBus = Injectable_1.default.resolve(QueryBus_1.QueryBus), commandBus = Injectable_1.default.resolve(CommandBus_1.CommandBus)) {
        this.queryBus = queryBus;
        this.commandBus = commandBus;
    }
    async updateExternalControlLists(request) {
        const { securityId, externalControlListsAddresses, actives } = request;
        ValidatedArgs_1.default.handleValidation("UpdateExternalControlListsRequest", request);
        return await this.commandBus.execute(new UpdateExternalControlListsCommand_1.UpdateExternalControlListsCommand(securityId, externalControlListsAddresses, actives));
    }
    async addExternalControlList(request) {
        const { securityId, externalControlListAddress } = request;
        ValidatedArgs_1.default.handleValidation("AddExternalControlListRequest", request);
        return await this.commandBus.execute(new AddExternalControlListCommand_1.AddExternalControlListCommand(securityId, externalControlListAddress));
    }
    async removeExternalControlList(request) {
        const { securityId, externalControlListAddress } = request;
        ValidatedArgs_1.default.handleValidation("RemoveExternalControlListRequest", request);
        return await this.commandBus.execute(new RemoveExternalControlListCommand_1.RemoveExternalControlListCommand(securityId, externalControlListAddress));
    }
    async isExternalControlList(request) {
        const { securityId, externalControlListAddress } = request;
        ValidatedArgs_1.default.handleValidation("IsExternalControlListRequest", request);
        return (await this.queryBus.execute(new IsExternalControlListQuery_1.IsExternalControlListQuery(securityId, externalControlListAddress)))
            .payload;
    }
    async getExternalControlListsCount(request) {
        const { securityId } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalControlListsCountRequest", request);
        return (await this.queryBus.execute(new GetExternalControlListsCountQuery_1.GetExternalControlListsCountQuery(securityId))).payload;
    }
    async getExternalControlListsMembers(request) {
        const { securityId, start, end } = request;
        ValidatedArgs_1.default.handleValidation("GetExternalControlListsMembersRequest", request);
        return (await this.queryBus.execute(new GetExternalControlListsMembersQuery_1.GetExternalControlListsMembersQuery(securityId, start, end))).payload;
    }
    async addToBlackListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("AddToBlackListMockRequest", request);
        return await this.commandBus.execute(new AddToBlackListMockCommand_1.AddToBlackListMockCommand(contractId, targetId));
    }
    async addToWhiteListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("AddToWhiteListMockRequest", request);
        return await this.commandBus.execute(new AddToWhiteListMockCommand_1.AddToWhiteListMockCommand(contractId, targetId));
    }
    async removeFromBlackListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("RemoveFromBlackListMockRequest", request);
        return await this.commandBus.execute(new RemoveFromBlackListMockCommand_1.RemoveFromBlackListMockCommand(contractId, targetId));
    }
    async removeFromWhiteListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("RemoveFromWhiteListMockRequest", request);
        return await this.commandBus.execute(new RemoveFromWhiteListMockCommand_1.RemoveFromWhiteListMockCommand(contractId, targetId));
    }
    async createExternalBlackListMock() {
        return (await this.commandBus.execute(new CreateExternalBlackListMockCommand_1.CreateExternalBlackListMockCommand())).payload;
    }
    async createExternalWhiteListMock() {
        return (await this.commandBus.execute(new CreateExternalWhiteListMockCommand_1.CreateExternalWhiteListMockCommand())).payload;
    }
    async isAuthorizedBlackListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("IsAuthorizedBlackListMockRequest", request);
        return (await this.queryBus.execute(new IsAuthorizedBlackListMockQuery_1.IsAuthorizedBlackListMockQuery(contractId, targetId))).payload;
    }
    async isAuthorizedWhiteListMock(request) {
        const { contractId, targetId } = request;
        ValidatedArgs_1.default.handleValidation("IsAuthorizedWhiteListMockRequest", request);
        return (await this.queryBus.execute(new IsAuthorizedWhiteListMockQuery_1.IsAuthorizedWhiteListMockQuery(contractId, targetId))).payload;
    }
}
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.UpdateExternalControlListsRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "updateExternalControlLists", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.AddExternalControlListRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "addExternalControlList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RemoveExternalControlListRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "removeExternalControlList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsExternalControlListRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "isExternalControlList", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalControlListsCountRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "getExternalControlListsCount", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.GetExternalControlListsMembersRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "getExternalControlListsMembers", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.AddToBlackListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "addToBlackListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.AddToWhiteListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "addToWhiteListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RemoveFromBlackListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "removeFromBlackListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.RemoveFromWhiteListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "removeFromWhiteListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "createExternalBlackListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "createExternalWhiteListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsAuthorizedBlackListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "isAuthorizedBlackListMock", null);
__decorate([
    LogErrorDecorator_1.LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [index_1.IsAuthorizedWhiteListMockRequest]),
    __metadata("design:returntype", Promise)
], ExternalControlListsInPort.prototype, "isAuthorizedWhiteListMock", null);
const ExternalControlListsManagement = new ExternalControlListsInPort();
exports.default = ExternalControlListsManagement;
