// 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);
};
import Injectable from "../../../core/injectable/Injectable";
import { QueryBus } from "../../../core/query/QueryBus";
import { LogError } from "../../../core/decorator/LogErrorDecorator";
import ValidatedRequest from "../../../core/validation/ValidatedArgs";
import { GetLatestKpiDataQuery } from "../../../app/usecase/query/interestRates/getLatestKpiData/GetLatestKpiDataQuery";
import GetLatestKpiDataRequest from "../request/kpis/GetLatestKpiDataRequest";
import { GetMinDateQuery } from "../../../app/usecase/query/kpis/getMinDate/GetMinDateQuery";
import GetMinDateRequest from "../request/kpis/GetMinDateRequest";
import { IsCheckPointDateQuery } from "../../../app/usecase/query/kpis/isCheckPointDate/IsCheckPointDateQuery";
import IsCheckPointDateRequest from "../request/kpis/IsCheckPointDateRequest";
class KpisInPort {
    queryBus;
    constructor(queryBus = Injectable.resolve(QueryBus)) {
        this.queryBus = queryBus;
    }
    async getLatestKpiData(request) {
        ValidatedRequest.handleValidation("GetLatestKpiDataRequest", request);
        const response = await this.queryBus.execute(new GetLatestKpiDataQuery(request.securityId, BigInt(request.from), BigInt(request.to), request.kpi));
        return { value: response.value, exists: response.exists };
    }
    async getMinDate(request) {
        ValidatedRequest.handleValidation("GetMinDateRequest", request);
        const result = await this.queryBus.execute(new GetMinDateQuery(request.securityId));
        return result.minDate;
    }
    async isCheckPointDate(request) {
        ValidatedRequest.handleValidation("IsCheckPointDateRequest", request);
        const result = await this.queryBus.execute(new IsCheckPointDateQuery(request.securityId, BigInt(request.date), request.project));
        return result.isCheckPoint;
    }
}
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetLatestKpiDataRequest]),
    __metadata("design:returntype", Promise)
], KpisInPort.prototype, "getLatestKpiData", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [GetMinDateRequest]),
    __metadata("design:returntype", Promise)
], KpisInPort.prototype, "getMinDate", null);
__decorate([
    LogError,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [IsCheckPointDateRequest]),
    __metadata("design:returntype", Promise)
], KpisInPort.prototype, "isCheckPointDate", null);
const Kpis = new KpisInPort();
export default Kpis;
