"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Query = void 0;
const robotics_types_1 = require("../../../controllers/robotics-types");
const integration_base_1 = require("@things-factory/integration-base");
exports.Query = {
    async trackableObject(_, { name }, context) {
        const { domain } = context.state;
        var connection = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, name);
        if (!connection || connection.discriminator !== robotics_types_1.ROBOTICS_OBJECT_TYPES.OBJECT) {
            throw Error(`TrackableObject '${name}' Not Found`);
        }
        var { poiOffset } = connection.params || {};
        return Object.assign(Object.assign({}, connection), { poiOffset });
    },
    async trackableObjects(_, {}, context) {
        const { domain } = context.state;
        var items = Object.keys(integration_base_1.ConnectionManager.getConnectionInstances(domain))
            .map(name => integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, name))
            .filter(connection => connection.discriminator == robotics_types_1.ROBOTICS_OBJECT_TYPES.OBJECT)
            .map(connection => {
            var { poiOffset } = connection.params || {};
            return Object.assign(Object.assign({}, connection), { poiOffset });
        });
        return {
            items,
            total: items.length
        };
    }
};
//# sourceMappingURL=trackable-object-query.js.map