'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../widgets/livewidget/query/ServiceBase', './api/SmartsServiceAPI', 'underscore'], function (APIFactory, ServiceBase, SmartsServiceAPI, _) { 'use strict'; var SmartsService = function (_ServiceBase) { _inherits(SmartsService, _ServiceBase); function SmartsService(options) { _classCallCheck(this, SmartsService); var _this = _possibleConstructorReturn(this, _ServiceBase.call(this)); _this.ajaxSvc = options.features['API'].getGlassCoreSvc('.Ajax'); _this.logger = options.features['API'].getGlassCoreSvc('.Logger'); return _this; } SmartsService.prototype.getAPI = function getAPI() { return APIFactory.createAPI(this, [SmartsServiceAPI]); }; SmartsService.prototype.runQuery = function runQuery(options) { return this._runQuery(options); }; /** * @public api to excute query against Smart service. * * @param {Object} options.querySpec Mandatory: the query specification to be sent to annotation service * @returns a promise. */ SmartsService.prototype._runQuery = function _runQuery(options) { var _this2 = this; var requestId = this.getRequestId(options.sender); return new Promise(function (resolve, reject) { _this2.ajaxSvc.ajax({ type: 'post', url: options.url, contentType: 'application/json', data: JSON.stringify(options.querySpec) }).then(function (data) { if (_this2.isActiveRequest(requestId, options.sender)) { resolve(data); } else { reject(_.extend(new Error(), { reason: 'staleRequest' })); } }, function (err) { reject(err); }); }); }; return SmartsService; }(ServiceBase); return SmartsService; }); //# sourceMappingURL=SmartsService.js.map