import { ReportType, RequestStatus } from '../../../types/UserReports.js';
import localsHelper from '../../../utils/localsHelper.js';

const cancelRequest = async ({ req, res, services }) => {
    const { token, dprUser, definitionsPath } = localsHelper.getValues(res);
    const { reportId, id, executionId, type } = req.params;
    let service = services.reportingService;
    if (type === ReportType.REPORT)
        service = services.reportingService;
    if (type === ReportType.DASHBOARD)
        service = services.dashboardService;
    const response = await service.cancelAsyncRequest(token, reportId, id, executionId, definitionsPath);
    if (response && response['cancellationSucceeded']) {
        await services.requestedReportService.updateStatus(executionId, dprUser.id, RequestStatus.ABORTED);
    }
};

export { cancelRequest };
//# sourceMappingURL=utils.js.map
