"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var TaskEntity_1 = __importDefault(require("./Entity/TaskEntity"));
var TaskHelpers_1 = require("./TaskHelpers");
var Tasks_consts_1 = require("./Tasks.consts");
var Tasks = /** @class */ (function () {
    function Tasks(session) {
        var _this = this;
        this.unsubscribe = function () {
            _this.taskEntity.store.unsubscribe();
        };
        this.onUpdate = function (callback) {
            return _this.taskEntity.registerOnUpdate(callback);
        };
        this.onCreate = function (callback) {
            return _this.taskEntity.registerOnCreate(callback);
        };
        this.onDelete = function (callback) {
            return _this.taskEntity.registerOnDelete(callback);
        };
        this.onWayPointUpdate = function (callback) {
            return _this.taskEntity.registerOnWayPointUpdate(callback);
        };
        this.onWayPointAdd = function (callback) {
            return _this.taskEntity.registerOnWayPointAdded(callback);
        };
        this.onWayPointDelete = function (callback) {
            return _this.taskEntity.registerOnWayPointDeleted(callback);
        };
        this.taskEntity = new TaskEntity_1.default(session);
    }
    Tasks.prototype.getOpenTasks = function (options) {
        return this.taskEntity.getOpenTasks(options);
    };
    Tasks.prototype.getHistoryTasks = function (query, page, limit) {
        return this.taskEntity.getHistoryTasks(query, page, limit);
    };
    Tasks.prototype.getHistoryTasksMetadata = function (query) {
        return this.taskEntity.getHistoryTasksMetadata(query);
    };
    Tasks.prototype.getOpenTasksKeySetPagination = function (options) {
        return this.taskEntity.getOpenTasksKeySetPagination(options);
    };
    Tasks.prototype.getInvalidTasks = function () {
        return this.taskEntity.getInvalidTasks();
    };
    Tasks.prototype.updatePriorities = function (taskPriorities) {
        return this.taskEntity.updatePriorities(taskPriorities);
    };
    Tasks.prototype.getPlanningTasks = function (options) {
        return this.taskEntity.getPlanningTasks(options);
    };
    Tasks.prototype.update = function (id, diff) {
        return this.taskEntity.update(id, diff, Tasks_consts_1.defaultExtractor, Tasks_consts_1.taskExtractor);
    };
    Tasks.prototype.finish = function (id) {
        return this.taskEntity.finish(id);
    };
    Tasks.prototype.cancel = function (id) {
        return this.taskEntity.cancel(id);
    };
    Tasks.prototype.acknowledge = function (id) {
        return this.taskEntity.acknowledge(id);
    };
    Tasks.prototype.get = function (id) {
        return this.taskEntity.get(id);
    };
    Tasks.prototype.forceGet = function (id) {
        return this.taskEntity.forceGet(id);
    };
    Tasks.prototype.batchGet = function (ids) {
        return this.taskEntity.batchGet(ids);
    };
    Tasks.prototype.massAssign = function (userId, taskIds, options, targetRun) {
        return this.taskEntity.massAssign(userId, taskIds, options, targetRun);
    };
    Tasks.prototype.getChildTasks = function (taskId) {
        return this.taskEntity.getChildTasks(taskId);
    };
    Tasks.prototype.massUnassign = function (taskIds, options) {
        return this.taskEntity.massUnassign(taskIds, options);
    };
    Tasks.prototype.moveToPlanning = function (taskIds) {
        return this.taskEntity.moveToPlanning(taskIds);
    };
    Tasks.prototype.releaseToDrivers = function (taskIds) {
        return this.taskEntity.releaseToDrivers(taskIds);
    };
    /**
     * `/tasks` API accepting task wrapped in `{task: {...}}` or as plain task object.
     * The proper way to create task via API is with wrapped into `{task: {...}}` because this type of payload
     * support more properties for task creation(backend logic).
     * DO NOT use plain task object as payload for task creation, it is here only to support places where method was used before
     */
    Tasks.prototype.create = function (payload) {
        return this.taskEntity.create(payload);
    };
    Tasks.prototype.massCancel = function (taskIds, reasonId, text, automaticallyCancelled) {
        return this.taskEntity.massCancel(taskIds, reasonId, text, automaticallyCancelled);
    };
    Tasks.prototype.updatePreparationStatus = function (taskId, preparationStatus) {
        return this.taskEntity.updatePreparationStatus(taskId, preparationStatus);
    };
    Tasks.prototype.cancelAllOpen = function () {
        return this.taskEntity.cancelAllOpen();
    };
    Tasks.prototype.closedTaskByQuery = function (query, page, limit) {
        // used to search/filter closed tasks
        return this.taskEntity.closedTaskByQuery(query, page, limit);
    };
    Tasks.prototype.activityLog = function (taskId) {
        return this.taskEntity.activityLog(taskId);
    };
    Tasks.prototype.changeTeam = function (taskId, teamId) {
        return this.taskEntity.changeTeam(taskId, teamId);
    };
    Tasks.prototype.getLocations = function (taskId) {
        return this.taskEntity.getLocations(taskId);
    };
    Tasks.prototype.submitForm = function (form) {
        return this.taskEntity.submitForm(form);
    };
    Tasks.prototype.lock = function (taskIds) {
        return this.taskEntity.lock(taskIds);
    };
    Tasks.prototype.unlock = function (taskIds) {
        return this.taskEntity.unlock(taskIds);
    };
    Tasks.prototype.duplicate = function (taskId) {
        return this.taskEntity.duplicate(taskId);
    };
    Tasks.prototype.rescheduleCancelled = function (taskId) {
        return this.taskEntity.rescheduleCancelled(taskId);
    };
    Tasks.prototype.rescheduleVirtualTasks = function (taskIds, noLaterThan, noEarlierThan) {
        return this.taskEntity.rescheduleVirtualTasks(taskIds, noLaterThan, noEarlierThan);
    };
    Tasks.prototype.getPickupQRCode = function (taskId) {
        return this.taskEntity.getPickupQRCode(taskId);
    };
    Tasks.prototype.getTaskNotesByWayPoint = function (taskId, waypointId) {
        return this.taskEntity.getTaskNotesByWayPoint(taskId, waypointId);
    };
    Tasks.prototype.getTaskInventoriesByWayPoint = function (taskId, waypointId) {
        return this.taskEntity.getTaskInventoriesByWayPoint(taskId, waypointId);
    };
    Tasks.prototype.importTasksCsv = function (file) {
        return this.taskEntity.importTasksCsv(file);
    };
    Tasks.prototype.broadcastToDrivers = function (taskId, userIds, message) {
        return this.taskEntity.broadcastToDrivers(taskId, userIds, message);
    };
    Tasks.prototype.addTaskNote = function (taskId, wayPointId, note, type, image, hiddenFromDrivers) {
        return this.taskEntity.addTaskNote(taskId, wayPointId, note, type, image, hiddenFromDrivers);
    };
    Tasks.prototype.deleteWayPoint = function (taskId, wayPointId) {
        return this.taskEntity.deleteWayPoint(taskId, wayPointId);
    };
    Tasks.prototype.attachSubscriptions = function () {
        this.taskEntity.attachSubscriptions();
    };
    Tasks.prototype.subscribeToGroupUpdates = function (fn) {
        this.taskEntity.subscribeToGroupUpdates(fn);
    };
    /*
     * get grouped values ids
     * */
    Tasks.prototype.getOpenTasksIds = function () {
        return this.taskEntity.getOpenTasksIds();
    };
    Tasks.prototype.getPlanningTasksIds = function () {
        return this.taskEntity.getPlanningTasksIds();
    };
    Tasks.prototype.getGeneralTasksIds = function () {
        return this.taskEntity.getGeneralTasksIds();
    };
    Tasks.prototype.getInvalidTasksIds = function () {
        return this.taskEntity.getInvalidTasksIds();
    };
    Tasks.prototype.getWayPointAnswers = function (taskId, wayPointId) {
        return this.taskEntity.getWayPointAnswers(taskId, wayPointId);
    };
    /**
     * task methods
     */
    Tasks.isReadyToExecute = TaskHelpers_1.TaskHelpers.isReadyToExecute;
    Tasks.isActive = TaskHelpers_1.TaskHelpers.isTaskInOpenState;
    Tasks.isDone = TaskHelpers_1.TaskHelpers.isDone;
    Tasks.isGroupFollower = TaskHelpers_1.TaskHelpers.isGroupFollower;
    Tasks.isUnacknowledged = TaskHelpers_1.TaskHelpers.isUnacknowledged;
    Tasks.isLate = TaskHelpers_1.TaskHelpers.isLate;
    Tasks.isInOpenState = TaskHelpers_1.TaskHelpers.isInOpenState;
    Tasks.isInPlanningState = TaskHelpers_1.TaskHelpers.isInPlanningState;
    Tasks.isInClosedState = TaskHelpers_1.TaskHelpers.isInClosedState;
    Tasks.isInvalid = TaskHelpers_1.TaskHelpers.isInvalid;
    return Tasks;
}());
exports.default = Tasks;
//# sourceMappingURL=TaskApi.js.map