From b14ad689d360d760d866a99c5b8bab25a6684767 Mon Sep 17 00:00:00 2001 From: Alejo Villegas Date: Sun, 14 Mar 2021 21:25:11 -0500 Subject: [PATCH 1/2] View Data preview --- dist/mindsdb-sdk.js | 90 ++-- dist/mindsdb-sdk.min.js | 2 +- es/mindsdb-sdk.js | 90 ++-- es/mindsdb-sdk.mjs | 2 +- lib/mindsdb-sdk.js | 90 ++-- src/index.js | 897 ++++++++++++++++++++++------------------ 6 files changed, 631 insertions(+), 540 deletions(-) diff --git a/dist/mindsdb-sdk.js b/dist/mindsdb-sdk.js index 94dcae8..4ac0b66 100644 --- a/dist/mindsdb-sdk.js +++ b/dist/mindsdb-sdk.js @@ -2353,7 +2353,7 @@ var connection = { url: null, api: null, token: { - key: 'apikey', + key: "apikey", value: null }, version: 0.2 @@ -2361,7 +2361,7 @@ var connection = { var connect = function connect(url, params) { connection.token.value = params.find(function (param) { - return param.key === 'apikey'; + return param.key === "apikey"; }).value; connection.url = setQueryParams([connection.token], url); connection.api = axios$1.create({ @@ -2372,7 +2372,7 @@ var connect = function connect(url, params) { var disconnect = function disconnect() { connection.url = null; connection.token = { - key: 'apikey', + key: "apikey", value: null }; connection.api = null; @@ -2385,14 +2385,14 @@ var ping = /*#__PURE__*/function () { while (1) { switch (_context.prev = _context.next) { case 0: - request = setQueryParams([connection.token], '/util/ping'); + request = setQueryParams([connection.token], "/util/ping"); _context.next = 3; return connection.api.get(request); case 3: response = _context.sent; - if (!(response.status === 200 && _typeof(response.data) === 'object' && response.data.status === 'ok')) { + if (!(response.status === 200 && _typeof(response.data) === "object" && response.data.status === "ok")) { _context.next = 6; break; } @@ -2422,7 +2422,7 @@ var logs = /*#__PURE__*/function () { while (1) { switch (_context2.prev = _context2.next) { case 0: - request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), '/config/logs'); + request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), "/config/logs"); _context2.next = 3; return connection.api.get(request); @@ -2450,7 +2450,7 @@ var dependencies = /*#__PURE__*/function () { while (1) { switch (_context3.prev = _context3.next) { case 0: - request = setQueryParams([connection.token], '/config/install_options'); + request = setQueryParams([connection.token], "/config/install_options"); _context3.next = 3; return connection.api.get(request); @@ -2478,7 +2478,7 @@ var getEnvs = /*#__PURE__*/function () { while (1) { switch (_context4.prev = _context4.next) { case 0: - request = setQueryParams([connection.token], '/config/vars'); + request = setQueryParams([connection.token], "/config/vars"); _context4.next = 3; return connection.api.get(request); @@ -2547,7 +2547,7 @@ var predictors = /*#__PURE__*/function () { switch (_context6.prev = _context6.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/predictors/'); + request = setQueryParams(mergeParams, "/predictors/"); _context6.next = 4; return connection.api.get(request); @@ -2578,7 +2578,7 @@ var dataSources = /*#__PURE__*/function () { switch (_context7.prev = _context7.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/datasources/'); + request = setQueryParams(mergeParams, "/datasources/"); _context7.next = 4; return connection.api.get(request); @@ -2603,9 +2603,9 @@ var dataSources = /*#__PURE__*/function () { var saveFile = function saveFile(response, source) { var url = window.URL.createObjectURL(new Blob([response.data])); - var link = document.createElement('a'); + var link = document.createElement("a"); link.href = url; - var contentDisposition = response.headers['content-disposition']; + var contentDisposition = response.headers["content-disposition"]; var fileName = null; if (contentDisposition) { @@ -2617,15 +2617,15 @@ var saveFile = function saveFile(response, source) { } if (!fileName && source) { - var parts = source.split('/'); + var parts = source.split("/"); var end = parts[parts.length - 1]; - parts = end.split('\\'); + parts = end.split("\\"); end = parts[parts.length - 1]; fileName = end; } - fileName = fileName || 'unknown'; - link.setAttribute('download', fileName); + fileName = fileName || "unknown"; + link.setAttribute("download", fileName); document.body.appendChild(link); link.click(); link.remove(); @@ -2639,19 +2639,19 @@ var Predictor = function Predictor(_data) { _defineProperty(this, "loaded", false); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "version", ''); + _defineProperty(this, "version", ""); _defineProperty(this, "is_active", false); - _defineProperty(this, "data_source", ''); + _defineProperty(this, "data_source", ""); _defineProperty(this, "predict", null); _defineProperty(this, "accuracy", 0); - _defineProperty(this, "status", ''); + _defineProperty(this, "status", ""); _defineProperty(this, "train_end_at", null); @@ -2677,7 +2677,7 @@ var Predictor = function Predictor(_data) { mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; url_path = "/predictors/"; - if (_this.name !== undefined && _this.name !== '') { + if (_this.name !== undefined && _this.name !== "") { url_path += "".concat(_this.name); } @@ -2872,7 +2872,7 @@ var Predictor = function Predictor(_data) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('file', file); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -2881,7 +2881,7 @@ var Predictor = function Predictor(_data) { } } }; - request = setQueryParams(mergeParams, '/predictors/upload'); + request = setQueryParams(mergeParams, "/predictors/upload"); _context14.next = 7; return connection.api.post(request, fd, config); @@ -2909,7 +2909,7 @@ var Predictor = function Predictor(_data) { request = setQueryParams(mergeParams, "/predictors/".concat(_this.name, "/download")); _context15.next = 4; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 4: @@ -2944,11 +2944,11 @@ var DataSource = function DataSource(_data2) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "source", ''); + _defineProperty(this, "source", ""); _defineProperty(this, "missed_files", false); @@ -3001,14 +3001,14 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context17.prev = _context17.next) { case 0: - _this2.source_type = 'file'; + _this2.source_type = "file"; _this2.source = file.name; mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('name', _this2.name); - fd.append('source_type', _this2.source_type); - fd.append('source', _this2.source); - fd.append('file', file); + fd.append("name", _this2.name); + fd.append("source_type", _this2.source_type); + fd.append("source", _this2.source); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -3042,7 +3042,7 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context18.prev = _context18.next) { case 0: - _this2.source_type = 'url'; + _this2.source_type = "url"; _this2.source = url; data = { name: _this2.name, @@ -3079,7 +3079,7 @@ var DataSource = function DataSource(_data2) { request = setQueryParams(mergeParams, url); _context19.next = 5; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 5: @@ -3101,7 +3101,7 @@ var DataSource = function DataSource(_data2) { }()); _defineProperty(this, "getDownloadUrl", function () { - return _this2.source_type === 'url' ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); + return _this2.source_type === "url" ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); }); _defineProperty(this, "delete", /*#__PURE__*/function () { @@ -3137,7 +3137,7 @@ var DataSource = function DataSource(_data2) { switch (_context21.prev = _context21.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data")); + request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data/")); _context21.next = 4; return connection.api.get(request); @@ -3175,11 +3175,11 @@ var DataSource = function DataSource(_data2) { case 5: response = _context22.sent; data = { - data_preparation: response.data['data_preparation'], - data_analysis_v2: response.data['data_analysis_v2'], - useable_input_columns: response.data['useable_input_columns'], - current_phase: response.data['current_phase'], - versionNative: response.data['version'], + data_preparation: response.data["data_preparation"], + data_analysis_v2: response.data["data_analysis_v2"], + useable_input_columns: response.data["useable_input_columns"], + current_phase: response.data["current_phase"], + versionNative: response.data["version"], status: response.data && response.data.status }; _context22.next = 13; @@ -3249,8 +3249,8 @@ var DataSource = function DataSource(_data2) { case 0: column = _ref25.column, rowIndex = _ref25.rowIndex, extension = _ref25.extension, file = _ref25.file; fd = new FormData(); - fd.append('file', file); - fd.append('extension', extension); + fd.append("file", file); + fd.append("extension", extension); mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/files/").concat(column, ":").concat(rowIndex)); _context24.next = 8; @@ -3283,7 +3283,7 @@ var DataBase = function DataBase(_data3) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); _defineProperty(this, "integration", []); @@ -3296,7 +3296,7 @@ var DataBase = function DataBase(_data3) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; _context25.prev = 1; - deRequest = setQueryParams(mergeParams, 'config/all_integrations'); + deRequest = setQueryParams(mergeParams, "config/all_integrations"); _context25.next = 5; return connection.api.get(deRequest); diff --git a/dist/mindsdb-sdk.min.js b/dist/mindsdb-sdk.min.js index 7f36fd2..7b938e2 100644 --- a/dist/mindsdb-sdk.min.js +++ b/dist/mindsdb-sdk.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MindsDB=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=t(e((function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0}))),r=t(e((function(t){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0}))),o=e((function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r},t.exports.default=t.exports,t.exports.__esModule=!0}));t(o);var a=e((function(t){t.exports=function(t){if(Array.isArray(t))return o(t)},t.exports.default=t.exports,t.exports.__esModule=!0}));t(a);var i=e((function(t){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0}));t(i);var s=e((function(t){t.exports=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0}));t(s);var u=e((function(t){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0}));t(u);var c=t(e((function(t){t.exports=function(t){return a(t)||i(t)||s(t)||u()},t.exports.default=t.exports,t.exports.__esModule=!0}))),f=e((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new _(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return j()}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var s=x(i,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function p(){}function l(){}function d(){}var h={};h[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(E([])));v&&v!==e&&n.call(v,o)&&(h=v);var y=d.prototype=p.prototype=Object.create(h);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var r;this._invoke=function(o,a){function i(){return new e((function(r,i){!function r(o,a,i,s){var u=c(t[o],t,a);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,i,s)}),(function(t){r("throw",t,i,s)})):e.resolve(p).then((function(t){f.value=t,i(f)}),(function(t){return r("throw",t,i,s)}))}s(u.arg)}(o,a,r,i)}))}return r=r?r.then(i,i):i()}}function x(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=c(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,f;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(this.prev>=a.tryLoc){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(a.catchLoc>this.prev)return r(a.catchLoc,!0);if(a.finallyLoc>this.prev)return r(a.finallyLoc)}else if(s){if(a.catchLoc>this.prev)return r(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var a=o;break}}!a||"break"!==t&&"continue"!==t||a.tryLoc>e||e>a.finallyLoc||(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:E(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),p=t(e((function(t){function e(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=e=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),e(n)}t.exports=e,t.exports.default=t.exports,t.exports.__esModule=!0}))),l=t(e((function(t){function e(t,e,n,r,o,a,i){try{var s=t[a](i),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}t.exports=function(t){return function(){var n=this,r=arguments;return new Promise((function(o,a){var i=t.apply(n,r);function s(t){e(i,o,a,s,u,"next",t)}function u(t){e(i,o,a,s,u,"throw",t)}s(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0}))),d=function(t,e){return function(){for(var n=Array(arguments.length),r=0;n.length>r;r++)n[r]=arguments[r];return t.apply(e,n)}},h=Object.prototype.toString;function m(t){return"[object Array]"===h.call(t)}function v(t){return void 0===t}function y(t){return null!==t&&"object"==typeof t}function g(t){if("[object Object]"!==h.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function w(t){return"[object Function]"===h.call(t)}function x(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),m(t))for(var n=0,r=t.length;r>n;n++)e.call(null,t[n],n,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}var b={isArray:m,isArrayBuffer:function(t){return"[object ArrayBuffer]"===h.call(t)},isBuffer:function(t){return null!==t&&!v(t)&&null!==t.constructor&&!v(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:y,isPlainObject:g,isUndefined:v,isDate:function(t){return"[object Date]"===h.call(t)},isFile:function(t){return"[object File]"===h.call(t)},isBlob:function(t){return"[object Blob]"===h.call(t)},isFunction:w,isStream:function(t){return y(t)&&w(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:x,merge:function t(){var e={};function n(n,r){e[r]=g(e[r])&&g(n)?t(e[r],n):g(n)?t({},n):m(n)?n.slice():n}for(var r=0,o=arguments.length;o>r;r++)x(arguments[r],n);return e},extend:function(t,e,n){return x(e,(function(e,r){t[r]=n&&"function"==typeof e?d(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}};function k(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var _=function(t,e,n){if(!e)return t;var r;if(n)r=n(e);else if(b.isURLSearchParams(e))r=""+e;else{var o=[];b.forEach(e,(function(t,e){null!=t&&(b.isArray(t)?e+="[]":t=[t],b.forEach(t,(function(t){b.isDate(t)?t=t.toISOString():b.isObject(t)&&(t=JSON.stringify(t)),o.push(k(e)+"="+k(t))})))})),r=o.join("&")}if(r){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t};function E(){this.handlers=[]}E.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},E.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},E.prototype.forEach=function(t){b.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var j=E,O=function(t,e,n){return b.forEach(n,(function(n){t=n(t,e)})),t},L=function(t){return!(!t||!t.__CANCEL__)},S=function(t,e){b.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))},R=function(t,e,n,r,o){return function(t,e,n,r,o){return t.config=e,n&&(t.code=n),t.request=r,t.response=o,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}(Error(t),e,n,r,o)},C=b.isStandardBrowserEnv()?{write:function(t,e,n,r,o,a){var i=[];i.push(t+"="+encodeURIComponent(e)),b.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),b.isString(r)&&i.push("path="+r),b.isString(o)&&i.push("domain="+o),!0===a&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},A=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],U=b.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=r(window.location.href),function(e){var n=b.isString(e)?r(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0},N=function(t){return new Promise((function(e,n){var r=t.data,o=t.headers;b.isFormData(r)&&delete o["Content-Type"];var a=new XMLHttpRequest;t.auth&&(o.Authorization="Basic "+btoa((t.auth.username||"")+":"+(t.auth.password?unescape(encodeURIComponent(t.auth.password)):"")));var i,s,u=(s=t.url,(i=t.baseURL)&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(s)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(i,s):s);if(a.open(t.method.toUpperCase(),_(u,t.params,t.paramsSerializer),!0),a.timeout=t.timeout,a.onreadystatechange=function(){if(a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))){var r,o,i,s,u,c="getAllResponseHeaders"in a?(r=a.getAllResponseHeaders(),u={},r?(b.forEach(r.split("\n"),(function(t){if(s=t.indexOf(":"),o=b.trim(t.substr(0,s)).toLowerCase(),i=b.trim(t.substr(s+1)),o){if(u[o]&&A.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([i]):u[o]?u[o]+", "+i:i}})),u):u):null;!function(t,e,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?e(R("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}(e,n,{data:t.responseType&&"text"!==t.responseType?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:c,config:t,request:a}),a=null}},a.onabort=function(){a&&(n(R("Request aborted",t,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(R("Network Error",t,null,a)),a=null},a.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(R(e,t,"ECONNABORTED",a)),a=null},b.isStandardBrowserEnv()){var c=(t.withCredentials||U(u))&&t.xsrfCookieName?C.read(t.xsrfCookieName):void 0;c&&(o[t.xsrfHeaderName]=c)}if("setRequestHeader"in a&&b.forEach(o,(function(t,e){void 0===r&&"content-type"===e.toLowerCase()?delete o[e]:a.setRequestHeader(e,t)})),b.isUndefined(t.withCredentials)||(a.withCredentials=!!t.withCredentials),t.responseType)try{a.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&a.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){a&&(a.abort(),n(t),a=null)})),r||(r=null),a.send(r)}))},P={"Content-Type":"application/x-www-form-urlencoded"};function T(t,e){!b.isUndefined(t)&&b.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var B,D={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(B=N),B),transformRequest:[function(t,e){return S(e,"Accept"),S(e,"Content-Type"),b.isFormData(t)||b.isArrayBuffer(t)||b.isBuffer(t)||b.isStream(t)||b.isFile(t)||b.isBlob(t)?t:b.isArrayBufferView(t)?t.buffer:b.isURLSearchParams(t)?(T(e,"application/x-www-form-urlencoded;charset=utf-8"),""+t):b.isObject(t)?(T(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&300>t}};D.headers={common:{Accept:"application/json, text/plain, */*"}},b.forEach(["delete","get","head"],(function(t){D.headers[t]={}})),b.forEach(["post","put","patch"],(function(t){D.headers[t]=b.merge(P)}));var F=D;function M(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var q=function(t){return M(t),t.headers=t.headers||{},t.data=O(t.data,t.headers,t.transformRequest),t.headers=b.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),b.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||F.adapter)(t).then((function(e){return M(t),e.data=O(e.data,e.headers,t.transformResponse),e}),(function(e){return L(e)||(M(t),e&&e.response&&(e.response.data=O(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},I=function(t,e){e=e||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function s(t,e){return b.isPlainObject(t)&&b.isPlainObject(e)?b.merge(t,e):b.isPlainObject(e)?b.merge({},e):b.isArray(e)?e.slice():e}function u(r){b.isUndefined(e[r])?b.isUndefined(t[r])||(n[r]=s(void 0,t[r])):n[r]=s(t[r],e[r])}b.forEach(r,(function(t){b.isUndefined(e[t])||(n[t]=s(void 0,e[t]))})),b.forEach(o,u),b.forEach(a,(function(r){b.isUndefined(e[r])?b.isUndefined(t[r])||(n[r]=s(void 0,t[r])):n[r]=s(void 0,e[r])})),b.forEach(i,(function(r){r in e?n[r]=s(t[r],e[r]):r in t&&(n[r]=s(void 0,t[r]))}));var c=r.concat(o).concat(a).concat(i),f=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===c.indexOf(t)}));return b.forEach(f,u),n};function z(t){this.defaults=t,this.interceptors={request:new j,response:new j}}z.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=I(this.defaults,t)).method=t.method?t.method.toLowerCase():this.defaults.method?this.defaults.method.toLowerCase():"get";var e=[q,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)n=n.then(e.shift(),e.shift());return n},z.prototype.getUri=function(t){return t=I(this.defaults,t),_(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},b.forEach(["delete","get","head","options"],(function(t){z.prototype[t]=function(e,n){return this.request(I(n||{},{method:t,url:e,data:(n||{}).data}))}})),b.forEach(["post","put","patch"],(function(t){z.prototype[t]=function(e,n,r){return this.request(I(r||{},{method:t,url:e,data:n}))}}));var G=z;function H(t){this.message=t}H.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},H.prototype.__CANCEL__=!0;var X=H;function $(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;t((function(t){n.reason||(n.reason=new X(t),e(n.reason))}))}$.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},$.source=function(){var t;return{token:new $((function(e){t=e})),cancel:t}};var J=$;function V(t){var e=new G(t),n=d(G.prototype.request,e);return b.extend(n,G.prototype,e),b.extend(n,e),n}var K=V(F);K.Axios=G,K.create=function(t){return V(I(K.defaults,t))},K.Cancel=X,K.CancelToken=J,K.isCancel=L,K.all=function(t){return Promise.all(t)},K.spread=function(t){return function(e){return t.apply(null,e)}},K.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var Q=K;Q.default=K;var Y=Q,W=function(t,e){var n="";return t?(t.forEach((function(t,e){if(t.value){var r=encodeURIComponent(t.key)+"="+(t.noEncodeURIComponent?t.value:encodeURIComponent(t.value));n=n.concat(e>0?"&".concat(r):r)}})),n.length>0?e+"?"+n:e):e},Z={url:null,api:null,token:{key:"apikey",value:null},version:.2},tt=function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([Z.token],"/util/ping"),t.next=3,Z.api.get(n);case 3:if(200!==(r=t.sent).status||"object"!==p(r.data)||"ok"!==r.data.status){t.next=6;break}return t.abrupt("return",!0);case 6:return t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),et=function(){var t=l(f.mark((function t(e){var n;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([].concat(c(e),[Z.token]),"/config/logs"),t.next=3,Z.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),nt=function(){var t=l(f.mark((function t(){var e;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=W([Z.token],"/config/install_options"),t.next=3,Z.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),rt=function(){var t=l(f.mark((function t(){var e;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=W([Z.token],"/config/vars"),t.next=3,Z.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),ot=function(t){return new st(t)},at=function(t){return new ut(t)},it=function(t,e){var n=window.URL.createObjectURL(new Blob([t.data])),r=document.createElement("a");r.href=n;var o=t.headers["content-disposition"],a=null;if(o){var i=o.match(/filename="?(.+)"?/);2===i.length&&(a=i[1])}if(!a&&e){var s=e.split("/"),u=s[s.length-1];s=u.split("\\"),a=u=s[s.length-1]}r.setAttribute("download",a=a||"unknown"),document.body.appendChild(r),r.click(),r.remove(),window.URL.revokeObjectURL(n)},st=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"name",""),r(this,"version",""),r(this,"is_active",!1),r(this,"data_source",""),r(this,"predict",null),r(this,"accuracy",0),r(this,"status",""),r(this,"train_end_at",null),r(this,"updated_at",null),r(this,"created_at",null),r(this,"data_preparation",null),r(this,"data_analysis",null),r(this,"model_analysis",null),r(this,"columns",null),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r,a;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r="/predictors/",void 0!==o.name&&""!==o.name&&(r+="".concat(o.name)),a=W(n,r),t.next=6,Z.api.get(a);case 6:return Object.assign(o,t.sent.data),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"rename",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(e.oldName,"/rename?new_name=").concat(e.newName)),t.next=4,Z.api.get(r);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadColumns",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name,"/columns")),t.next=4,Z.api.get(r);case 4:return o.columns=t.sent.data,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"learn",function(){var t=l(f.mark((function t(e,n){var r,a,i,s,u,p;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.dataSourceName,a=e.fromData,s={to_predict:e.toPredict},(i=e.kwargs)&&(s.kwargs=i),r?s.data_source_name=r:a&&(s.from_data=a),u=n?[].concat(c(n),[Z.token]):[Z.token],p=W(u,"/predictors/".concat(o.name)),t.next=8,Z.api.put(p,s);case 8:return t.abrupt("return",t.sent.data);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"queryPredict",function(){var t=l(f.mark((function t(e,n,r){var a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=n?[].concat(c(n),[Z.token]):[Z.token],i=W(a,"/predictors/".concat(o.name,"/predict")),t.next=4,Z.api.post(i,{when:e,format_flag:r});case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"delete",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name)),t.next=4,Z.api.delete(r);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"upload",function(){var t=l(f.mark((function t(e,n,r){var o,a,i,s;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r?[].concat(c(r),[Z.token]):[Z.token],(a=new FormData).append("file",e),i={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))}},s=W(o,"/predictors/upload"),t.next=7,Z.api.post(s,a,i);case 7:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"download",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name,"/download")),t.next=4,Z.api.get(r,{responseType:"blob"});case 4:return it(t.sent),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"getDownloadUrl",(function(){return"".concat(Z.url,"/predictors/").concat(o.name,"/download")})),Object.assign(this,e)},ut=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"source_type","url"),r(this,"name",""),r(this,"source",""),r(this,"missed_files",!1),r(this,"created_at",null),r(this,"updated_at",null),r(this,"row_count",0),r(this,"columns",null),r(this,"data",null),r(this,"missedFileList",null),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name)),t.next=4,Z.api.get(r);case 4:return Object.assign(o,t.sent.data),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"upload",function(){var t=l(f.mark((function t(e,n,r){var a,i,s,u;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.source_type="file",o.source=e.name,a=r?[].concat(c(r),[Z.token]):[Z.token],(i=new FormData).append("name",o.name),i.append("source_type",o.source_type),i.append("source",o.source),i.append("file",e),s={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))},timeout:6e5},u=W(a,"/datasources/".concat(o.name)),t.next=12,Z.api.put(u,i,s);case 12:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"uploadFromUrl",function(){var t=l(f.mark((function t(e,n){var r,a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.source_type="url",o.source=e,r={name:o.name,source_type:o.source_type,source:o.source},a=n?[].concat(c(n),[Z.token]):[Z.token],i=W(a,"/datasources/".concat(o.name)),t.next=7,Z.api.put(i,r);case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"download",function(){var t=l(f.mark((function t(e){var n,r,a;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.getDownloadUrl(),r=e?[].concat(c(e),[Z.token]):[Z.token],a=W(r,n),t.next=5,Z.api.get(a,{responseType:"blob"});case 5:return it(t.sent,o.source),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"getDownloadUrl",(function(){return"url"===o.source_type?o.source:"".concat(Z.url,"/datasources/").concat(o.name,"/download")})),r(this,"delete",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name)),t.next=4,Z.api.delete(r);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadData",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/data")),t.next=4,Z.api.get(r);case 4:return o.data=t.sent.data,t.abrupt("return",o.data);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadDataQuality",function(){var t=l(f.mark((function t(e){var n,r,a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/analyze")),t.prev=2,t.next=5,Z.api.get(r);case 5:a={data_preparation:(i=t.sent).data.data_preparation,data_analysis_v2:i.data.data_analysis_v2,useable_input_columns:i.data.useable_input_columns,current_phase:i.data.current_phase,versionNative:i.data.version,status:i.data&&i.data.status},t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),Object.assign(o,{error:t.t0}),console.error(t.t0);case 13:return o.dataQuality=a,t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadMissedFileList",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/missed_files")),t.next=4,Z.api.get(r);case 4:return o.missedFileList=t.sent.data,t.abrupt("return",o.missedFileList);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"uploadFile",function(){var t=l(f.mark((function t(e,n){var r,a,i,s,u,p,l;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.column,a=e.rowIndex,i=e.extension,s=e.file,(u=new FormData).append("file",s),u.append("extension",i),p=n?[].concat(c(n),[Z.token]):[Z.token],l=W(p,"/datasources/".concat(o.name,"/files/").concat(r,":").concat(a)),t.next=8,Z.api.put(l,u);case 8:return t.abrupt("return",200===t.sent.status);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},ct=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"source_type","url"),r(this,"integration",[]),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],t.prev=1,r=W(n,"config/all_integrations"),t.next=5,Z.api.get(r);case 5:return Object.assign(o,t.sent),t.abrupt("return",o);case 10:t.prev=10,t.t0=t.catch(1),Object.assign(o,{error:t.t0}),console.error(t.t0);case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e){return t.apply(this,arguments)}}()),r(this,"delete",function(){var t=l(f.mark((function t(e){return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z.api.delete("/config/integrations/".concat(e.db_name));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"check",function(){var t=l(f.mark((function t(e){return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z.api.get("/config/integrations/".concat(e.database_name,"/check"));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"edit",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],o=W(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,Z.api.post(o,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"create",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],o=W(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,Z.api.put(o,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"newDataset",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],t.prev=1,o=W(r,"/datasources/".concat(e.name)),t.next=5,Z.api.put(o,e);case 5:return t.abrupt("return",t.sent);case 8:return t.prev=8,t.t0=t.catch(1),t.abrupt("return",t.t0);case 11:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)};return{connect:function(t,e){Z.token.value=e.find((function(t){return"apikey"===t.key})).value,Z.url=W([Z.token],t),Z.api=Y.create({baseURL:t})},disconnect:function(){Z.url=null,Z.token={key:"apikey",value:null},Z.api=null},ping:tt,logs:et,dependencies:nt,installDependencies:function(){var t=l(f.mark((function t(e){var n;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([Z.token],"/config/install/".concat(e)),t.next=3,Z.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),getEnvs:rt,predictors:function(){var t=l(f.mark((function t(e){var n,r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/"),t.next=4,Z.api.get(r);case 4:return o=(t.sent.data||[]).map(ot),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),dataSources:function(){var t=l(f.mark((function t(e){var n,r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/"),t.next=4,Z.api.get(r);case 4:return o=(t.sent.data||[]).map(at),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),DataSource:at,Predictor:ot,DataBase:function(t){return new ct(t)}}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MindsDB=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=t(e((function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0}))),r=t(e((function(t){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0}))),o=e((function(t){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r},t.exports.default=t.exports,t.exports.__esModule=!0}));t(o);var a=e((function(t){t.exports=function(t){if(Array.isArray(t))return o(t)},t.exports.default=t.exports,t.exports.__esModule=!0}));t(a);var i=e((function(t){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0}));t(i);var s=e((function(t){t.exports=function(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0}));t(s);var u=e((function(t){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0}));t(u);var c=t(e((function(t){t.exports=function(t){return a(t)||i(t)||s(t)||u()},t.exports.default=t.exports,t.exports.__esModule=!0}))),f=e((function(t){var e=function(t){var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",i=r.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function u(t,e,n,r){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new _(r||[]);return o._invoke=function(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return j()}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var s=x(i,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=c(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}(t,n,a),o}function c(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function p(){}function l(){}function d(){}var h={};h[o]=function(){return this};var m=Object.getPrototypeOf,v=m&&m(m(E([])));v&&v!==e&&n.call(v,o)&&(h=v);var y=d.prototype=p.prototype=Object.create(h);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var r;this._invoke=function(o,a){function i(){return new e((function(r,i){!function r(o,a,i,s){var u=c(t[o],t,a);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,i,s)}),(function(t){r("throw",t,i,s)})):e.resolve(p).then((function(t){f.value=t,i(f)}),(function(t){return r("throw",t,i,s)}))}s(u.arg)}(o,a,r,i)}))}return r=r?r.then(i,i):i()}}function x(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=c(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,f;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,a=function e(){for(;++r=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(this.prev>=a.tryLoc){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(a.catchLoc>this.prev)return r(a.catchLoc,!0);if(a.finallyLoc>this.prev)return r(a.finallyLoc)}else if(s){if(a.catchLoc>this.prev)return r(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(a.finallyLoc>this.prev)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var a=o;break}}!a||"break"!==t&&"continue"!==t||a.tryLoc>e||e>a.finallyLoc||(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:E(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),p=t(e((function(t){function e(n){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=e=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),e(n)}t.exports=e,t.exports.default=t.exports,t.exports.__esModule=!0}))),l=t(e((function(t){function e(t,e,n,r,o,a,i){try{var s=t[a](i),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}t.exports=function(t){return function(){var n=this,r=arguments;return new Promise((function(o,a){var i=t.apply(n,r);function s(t){e(i,o,a,s,u,"next",t)}function u(t){e(i,o,a,s,u,"throw",t)}s(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0}))),d=function(t,e){return function(){for(var n=Array(arguments.length),r=0;n.length>r;r++)n[r]=arguments[r];return t.apply(e,n)}},h=Object.prototype.toString;function m(t){return"[object Array]"===h.call(t)}function v(t){return void 0===t}function y(t){return null!==t&&"object"==typeof t}function g(t){if("[object Object]"!==h.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function w(t){return"[object Function]"===h.call(t)}function x(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),m(t))for(var n=0,r=t.length;r>n;n++)e.call(null,t[n],n,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}var b={isArray:m,isArrayBuffer:function(t){return"[object ArrayBuffer]"===h.call(t)},isBuffer:function(t){return null!==t&&!v(t)&&null!==t.constructor&&!v(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:y,isPlainObject:g,isUndefined:v,isDate:function(t){return"[object Date]"===h.call(t)},isFile:function(t){return"[object File]"===h.call(t)},isBlob:function(t){return"[object Blob]"===h.call(t)},isFunction:w,isStream:function(t){return y(t)&&w(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:x,merge:function t(){var e={};function n(n,r){e[r]=g(e[r])&&g(n)?t(e[r],n):g(n)?t({},n):m(n)?n.slice():n}for(var r=0,o=arguments.length;o>r;r++)x(arguments[r],n);return e},extend:function(t,e,n){return x(e,(function(e,r){t[r]=n&&"function"==typeof e?d(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}};function k(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var _=function(t,e,n){if(!e)return t;var r;if(n)r=n(e);else if(b.isURLSearchParams(e))r=""+e;else{var o=[];b.forEach(e,(function(t,e){null!=t&&(b.isArray(t)?e+="[]":t=[t],b.forEach(t,(function(t){b.isDate(t)?t=t.toISOString():b.isObject(t)&&(t=JSON.stringify(t)),o.push(k(e)+"="+k(t))})))})),r=o.join("&")}if(r){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t};function E(){this.handlers=[]}E.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},E.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},E.prototype.forEach=function(t){b.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var j=E,O=function(t,e,n){return b.forEach(n,(function(n){t=n(t,e)})),t},L=function(t){return!(!t||!t.__CANCEL__)},S=function(t,e){b.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))},R=function(t,e,n,r,o){return function(t,e,n,r,o){return t.config=e,n&&(t.code=n),t.request=r,t.response=o,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}(Error(t),e,n,r,o)},C=b.isStandardBrowserEnv()?{write:function(t,e,n,r,o,a){var i=[];i.push(t+"="+encodeURIComponent(e)),b.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),b.isString(r)&&i.push("path="+r),b.isString(o)&&i.push("domain="+o),!0===a&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},A=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],U=b.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=r(window.location.href),function(e){var n=b.isString(e)?r(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0},N=function(t){return new Promise((function(e,n){var r=t.data,o=t.headers;b.isFormData(r)&&delete o["Content-Type"];var a=new XMLHttpRequest;t.auth&&(o.Authorization="Basic "+btoa((t.auth.username||"")+":"+(t.auth.password?unescape(encodeURIComponent(t.auth.password)):"")));var i,s,u=(s=t.url,(i=t.baseURL)&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(s)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(i,s):s);if(a.open(t.method.toUpperCase(),_(u,t.params,t.paramsSerializer),!0),a.timeout=t.timeout,a.onreadystatechange=function(){if(a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))){var r,o,i,s,u,c="getAllResponseHeaders"in a?(r=a.getAllResponseHeaders(),u={},r?(b.forEach(r.split("\n"),(function(t){if(s=t.indexOf(":"),o=b.trim(t.substr(0,s)).toLowerCase(),i=b.trim(t.substr(s+1)),o){if(u[o]&&A.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([i]):u[o]?u[o]+", "+i:i}})),u):u):null;!function(t,e,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?e(R("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}(e,n,{data:t.responseType&&"text"!==t.responseType?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:c,config:t,request:a}),a=null}},a.onabort=function(){a&&(n(R("Request aborted",t,"ECONNABORTED",a)),a=null)},a.onerror=function(){n(R("Network Error",t,null,a)),a=null},a.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(R(e,t,"ECONNABORTED",a)),a=null},b.isStandardBrowserEnv()){var c=(t.withCredentials||U(u))&&t.xsrfCookieName?C.read(t.xsrfCookieName):void 0;c&&(o[t.xsrfHeaderName]=c)}if("setRequestHeader"in a&&b.forEach(o,(function(t,e){void 0===r&&"content-type"===e.toLowerCase()?delete o[e]:a.setRequestHeader(e,t)})),b.isUndefined(t.withCredentials)||(a.withCredentials=!!t.withCredentials),t.responseType)try{a.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&a.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){a&&(a.abort(),n(t),a=null)})),r||(r=null),a.send(r)}))},P={"Content-Type":"application/x-www-form-urlencoded"};function T(t,e){!b.isUndefined(t)&&b.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var B,D={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(B=N),B),transformRequest:[function(t,e){return S(e,"Accept"),S(e,"Content-Type"),b.isFormData(t)||b.isArrayBuffer(t)||b.isBuffer(t)||b.isStream(t)||b.isFile(t)||b.isBlob(t)?t:b.isArrayBufferView(t)?t.buffer:b.isURLSearchParams(t)?(T(e,"application/x-www-form-urlencoded;charset=utf-8"),""+t):b.isObject(t)?(T(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&300>t}};D.headers={common:{Accept:"application/json, text/plain, */*"}},b.forEach(["delete","get","head"],(function(t){D.headers[t]={}})),b.forEach(["post","put","patch"],(function(t){D.headers[t]=b.merge(P)}));var F=D;function M(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var q=function(t){return M(t),t.headers=t.headers||{},t.data=O(t.data,t.headers,t.transformRequest),t.headers=b.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),b.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||F.adapter)(t).then((function(e){return M(t),e.data=O(e.data,e.headers,t.transformResponse),e}),(function(e){return L(e)||(M(t),e&&e.response&&(e.response.data=O(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},I=function(t,e){e=e||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function s(t,e){return b.isPlainObject(t)&&b.isPlainObject(e)?b.merge(t,e):b.isPlainObject(e)?b.merge({},e):b.isArray(e)?e.slice():e}function u(r){b.isUndefined(e[r])?b.isUndefined(t[r])||(n[r]=s(void 0,t[r])):n[r]=s(t[r],e[r])}b.forEach(r,(function(t){b.isUndefined(e[t])||(n[t]=s(void 0,e[t]))})),b.forEach(o,u),b.forEach(a,(function(r){b.isUndefined(e[r])?b.isUndefined(t[r])||(n[r]=s(void 0,t[r])):n[r]=s(void 0,e[r])})),b.forEach(i,(function(r){r in e?n[r]=s(t[r],e[r]):r in t&&(n[r]=s(void 0,t[r]))}));var c=r.concat(o).concat(a).concat(i),f=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===c.indexOf(t)}));return b.forEach(f,u),n};function z(t){this.defaults=t,this.interceptors={request:new j,response:new j}}z.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=I(this.defaults,t)).method=t.method?t.method.toLowerCase():this.defaults.method?this.defaults.method.toLowerCase():"get";var e=[q,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)n=n.then(e.shift(),e.shift());return n},z.prototype.getUri=function(t){return t=I(this.defaults,t),_(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},b.forEach(["delete","get","head","options"],(function(t){z.prototype[t]=function(e,n){return this.request(I(n||{},{method:t,url:e,data:(n||{}).data}))}})),b.forEach(["post","put","patch"],(function(t){z.prototype[t]=function(e,n,r){return this.request(I(r||{},{method:t,url:e,data:n}))}}));var G=z;function H(t){this.message=t}H.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},H.prototype.__CANCEL__=!0;var X=H;function $(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;t((function(t){n.reason||(n.reason=new X(t),e(n.reason))}))}$.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},$.source=function(){var t;return{token:new $((function(e){t=e})),cancel:t}};var J=$;function V(t){var e=new G(t),n=d(G.prototype.request,e);return b.extend(n,G.prototype,e),b.extend(n,e),n}var K=V(F);K.Axios=G,K.create=function(t){return V(I(K.defaults,t))},K.Cancel=X,K.CancelToken=J,K.isCancel=L,K.all=function(t){return Promise.all(t)},K.spread=function(t){return function(e){return t.apply(null,e)}},K.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var Q=K;Q.default=K;var Y=Q,W=function(t,e){var n="";return t?(t.forEach((function(t,e){if(t.value){var r=encodeURIComponent(t.key)+"="+(t.noEncodeURIComponent?t.value:encodeURIComponent(t.value));n=n.concat(e>0?"&".concat(r):r)}})),n.length>0?e+"?"+n:e):e},Z={url:null,api:null,token:{key:"apikey",value:null},version:.2},tt=function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([Z.token],"/util/ping"),t.next=3,Z.api.get(n);case 3:if(200!==(r=t.sent).status||"object"!==p(r.data)||"ok"!==r.data.status){t.next=6;break}return t.abrupt("return",!0);case 6:return t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),et=function(){var t=l(f.mark((function t(e){var n;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([].concat(c(e),[Z.token]),"/config/logs"),t.next=3,Z.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),nt=function(){var t=l(f.mark((function t(){var e;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=W([Z.token],"/config/install_options"),t.next=3,Z.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),rt=function(){var t=l(f.mark((function t(){var e;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=W([Z.token],"/config/vars"),t.next=3,Z.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),ot=function(t){return new st(t)},at=function(t){return new ut(t)},it=function(t,e){var n=window.URL.createObjectURL(new Blob([t.data])),r=document.createElement("a");r.href=n;var o=t.headers["content-disposition"],a=null;if(o){var i=o.match(/filename="?(.+)"?/);2===i.length&&(a=i[1])}if(!a&&e){var s=e.split("/"),u=s[s.length-1];s=u.split("\\"),a=u=s[s.length-1]}r.setAttribute("download",a=a||"unknown"),document.body.appendChild(r),r.click(),r.remove(),window.URL.revokeObjectURL(n)},st=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"name",""),r(this,"version",""),r(this,"is_active",!1),r(this,"data_source",""),r(this,"predict",null),r(this,"accuracy",0),r(this,"status",""),r(this,"train_end_at",null),r(this,"updated_at",null),r(this,"created_at",null),r(this,"data_preparation",null),r(this,"data_analysis",null),r(this,"model_analysis",null),r(this,"columns",null),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r,a;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r="/predictors/",void 0!==o.name&&""!==o.name&&(r+="".concat(o.name)),a=W(n,r),t.next=6,Z.api.get(a);case 6:return Object.assign(o,t.sent.data),t.abrupt("return",o);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"rename",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(e.oldName,"/rename?new_name=").concat(e.newName)),t.next=4,Z.api.get(r);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadColumns",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name,"/columns")),t.next=4,Z.api.get(r);case 4:return o.columns=t.sent.data,t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"learn",function(){var t=l(f.mark((function t(e,n){var r,a,i,s,u,p;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.dataSourceName,a=e.fromData,s={to_predict:e.toPredict},(i=e.kwargs)&&(s.kwargs=i),r?s.data_source_name=r:a&&(s.from_data=a),u=n?[].concat(c(n),[Z.token]):[Z.token],p=W(u,"/predictors/".concat(o.name)),t.next=8,Z.api.put(p,s);case 8:return t.abrupt("return",t.sent.data);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"queryPredict",function(){var t=l(f.mark((function t(e,n,r){var a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=n?[].concat(c(n),[Z.token]):[Z.token],i=W(a,"/predictors/".concat(o.name,"/predict")),t.next=4,Z.api.post(i,{when:e,format_flag:r});case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"delete",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name)),t.next=4,Z.api.delete(r);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"upload",function(){var t=l(f.mark((function t(e,n,r){var o,a,i,s;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r?[].concat(c(r),[Z.token]):[Z.token],(a=new FormData).append("file",e),i={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))}},s=W(o,"/predictors/upload"),t.next=7,Z.api.post(s,a,i);case 7:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"download",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/".concat(o.name,"/download")),t.next=4,Z.api.get(r,{responseType:"blob"});case 4:return it(t.sent),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"getDownloadUrl",(function(){return"".concat(Z.url,"/predictors/").concat(o.name,"/download")})),Object.assign(this,e)},ut=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"source_type","url"),r(this,"name",""),r(this,"source",""),r(this,"missed_files",!1),r(this,"created_at",null),r(this,"updated_at",null),r(this,"row_count",0),r(this,"columns",null),r(this,"data",null),r(this,"missedFileList",null),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name)),t.next=4,Z.api.get(r);case 4:return Object.assign(o,t.sent.data),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"upload",function(){var t=l(f.mark((function t(e,n,r){var a,i,s,u;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.source_type="file",o.source=e.name,a=r?[].concat(c(r),[Z.token]):[Z.token],(i=new FormData).append("name",o.name),i.append("source_type",o.source_type),i.append("source",o.source),i.append("file",e),s={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))},timeout:6e5},u=W(a,"/datasources/".concat(o.name)),t.next=12,Z.api.put(u,i,s);case 12:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),r(this,"uploadFromUrl",function(){var t=l(f.mark((function t(e,n){var r,a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o.source_type="url",o.source=e,r={name:o.name,source_type:o.source_type,source:o.source},a=n?[].concat(c(n),[Z.token]):[Z.token],i=W(a,"/datasources/".concat(o.name)),t.next=7,Z.api.put(i,r);case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"download",function(){var t=l(f.mark((function t(e){var n,r,a;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.getDownloadUrl(),r=e?[].concat(c(e),[Z.token]):[Z.token],a=W(r,n),t.next=5,Z.api.get(a,{responseType:"blob"});case 5:return it(t.sent,o.source),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"getDownloadUrl",(function(){return"url"===o.source_type?o.source:"".concat(Z.url,"/datasources/").concat(o.name,"/download")})),r(this,"delete",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name)),t.next=4,Z.api.delete(r);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadData",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/data/")),t.next=4,Z.api.get(r);case 4:return o.data=t.sent.data,t.abrupt("return",o.data);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadDataQuality",function(){var t=l(f.mark((function t(e){var n,r,a,i;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/analyze")),t.prev=2,t.next=5,Z.api.get(r);case 5:a={data_preparation:(i=t.sent).data.data_preparation,data_analysis_v2:i.data.data_analysis_v2,useable_input_columns:i.data.useable_input_columns,current_phase:i.data.current_phase,versionNative:i.data.version,status:i.data&&i.data.status},t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),Object.assign(o,{error:t.t0}),console.error(t.t0);case 13:return o.dataQuality=a,t.abrupt("return",a);case 15:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e){return t.apply(this,arguments)}}()),r(this,"loadMissedFileList",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/".concat(o.name,"/missed_files")),t.next=4,Z.api.get(r);case 4:return o.missedFileList=t.sent.data,t.abrupt("return",o.missedFileList);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"uploadFile",function(){var t=l(f.mark((function t(e,n){var r,a,i,s,u,p,l;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.column,a=e.rowIndex,i=e.extension,s=e.file,(u=new FormData).append("file",s),u.append("extension",i),p=n?[].concat(c(n),[Z.token]):[Z.token],l=W(p,"/datasources/".concat(o.name,"/files/").concat(r,":").concat(a)),t.next=8,Z.api.put(l,u);case 8:return t.abrupt("return",200===t.sent.status);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},ct=function t(e){var o=this;n(this,t),r(this,"loaded",!1),r(this,"source_type","url"),r(this,"integration",[]),r(this,"load",function(){var t=l(f.mark((function t(e){var n,r;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],t.prev=1,r=W(n,"config/all_integrations"),t.next=5,Z.api.get(r);case 5:return Object.assign(o,t.sent),t.abrupt("return",o);case 10:t.prev=10,t.t0=t.catch(1),Object.assign(o,{error:t.t0}),console.error(t.t0);case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e){return t.apply(this,arguments)}}()),r(this,"delete",function(){var t=l(f.mark((function t(e){return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z.api.delete("/config/integrations/".concat(e.db_name));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"check",function(){var t=l(f.mark((function t(e){return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z.api.get("/config/integrations/".concat(e.database_name,"/check"));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),r(this,"edit",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],o=W(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,Z.api.post(o,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"create",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],o=W(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,Z.api.put(o,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),r(this,"newDataset",function(){var t=l(f.mark((function t(e,n){var r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(c(n),[Z.token]):[Z.token],t.prev=1,o=W(r,"/datasources/".concat(e.name)),t.next=5,Z.api.put(o,e);case 5:return t.abrupt("return",t.sent);case 8:return t.prev=8,t.t0=t.catch(1),t.abrupt("return",t.t0);case 11:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)};return{connect:function(t,e){Z.token.value=e.find((function(t){return"apikey"===t.key})).value,Z.url=W([Z.token],t),Z.api=Y.create({baseURL:t})},disconnect:function(){Z.url=null,Z.token={key:"apikey",value:null},Z.api=null},ping:tt,logs:et,dependencies:nt,installDependencies:function(){var t=l(f.mark((function t(e){var n;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=W([Z.token],"/config/install/".concat(e)),t.next=3,Z.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),getEnvs:rt,predictors:function(){var t=l(f.mark((function t(e){var n,r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/predictors/"),t.next=4,Z.api.get(r);case 4:return o=(t.sent.data||[]).map(ot),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),dataSources:function(){var t=l(f.mark((function t(e){var n,r,o;return f.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(c(e),[Z.token]):[Z.token],r=W(n,"/datasources/"),t.next=4,Z.api.get(r);case 4:return o=(t.sent.data||[]).map(at),t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),DataSource:at,Predictor:ot,DataBase:function(t){return new ct(t)}}})); diff --git a/es/mindsdb-sdk.js b/es/mindsdb-sdk.js index 3f139dd..c4f802d 100644 --- a/es/mindsdb-sdk.js +++ b/es/mindsdb-sdk.js @@ -128,7 +128,7 @@ var connection = { url: null, api: null, token: { - key: 'apikey', + key: "apikey", value: null }, version: 0.2 @@ -136,7 +136,7 @@ var connection = { var connect = function connect(url, params) { connection.token.value = params.find(function (param) { - return param.key === 'apikey'; + return param.key === "apikey"; }).value; connection.url = setQueryParams([connection.token], url); connection.api = axios.create({ @@ -147,7 +147,7 @@ var connect = function connect(url, params) { var disconnect = function disconnect() { connection.url = null; connection.token = { - key: 'apikey', + key: "apikey", value: null }; connection.api = null; @@ -160,14 +160,14 @@ var ping = /*#__PURE__*/function () { while (1) { switch (_context.prev = _context.next) { case 0: - request = setQueryParams([connection.token], '/util/ping'); + request = setQueryParams([connection.token], "/util/ping"); _context.next = 3; return connection.api.get(request); case 3: response = _context.sent; - if (!(response.status === 200 && _typeof(response.data) === 'object' && response.data.status === 'ok')) { + if (!(response.status === 200 && _typeof(response.data) === "object" && response.data.status === "ok")) { _context.next = 6; break; } @@ -197,7 +197,7 @@ var logs = /*#__PURE__*/function () { while (1) { switch (_context2.prev = _context2.next) { case 0: - request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), '/config/logs'); + request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), "/config/logs"); _context2.next = 3; return connection.api.get(request); @@ -225,7 +225,7 @@ var dependencies = /*#__PURE__*/function () { while (1) { switch (_context3.prev = _context3.next) { case 0: - request = setQueryParams([connection.token], '/config/install_options'); + request = setQueryParams([connection.token], "/config/install_options"); _context3.next = 3; return connection.api.get(request); @@ -253,7 +253,7 @@ var getEnvs = /*#__PURE__*/function () { while (1) { switch (_context4.prev = _context4.next) { case 0: - request = setQueryParams([connection.token], '/config/vars'); + request = setQueryParams([connection.token], "/config/vars"); _context4.next = 3; return connection.api.get(request); @@ -322,7 +322,7 @@ var predictors = /*#__PURE__*/function () { switch (_context6.prev = _context6.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/predictors/'); + request = setQueryParams(mergeParams, "/predictors/"); _context6.next = 4; return connection.api.get(request); @@ -353,7 +353,7 @@ var dataSources = /*#__PURE__*/function () { switch (_context7.prev = _context7.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/datasources/'); + request = setQueryParams(mergeParams, "/datasources/"); _context7.next = 4; return connection.api.get(request); @@ -378,9 +378,9 @@ var dataSources = /*#__PURE__*/function () { var saveFile = function saveFile(response, source) { var url = window.URL.createObjectURL(new Blob([response.data])); - var link = document.createElement('a'); + var link = document.createElement("a"); link.href = url; - var contentDisposition = response.headers['content-disposition']; + var contentDisposition = response.headers["content-disposition"]; var fileName = null; if (contentDisposition) { @@ -392,15 +392,15 @@ var saveFile = function saveFile(response, source) { } if (!fileName && source) { - var parts = source.split('/'); + var parts = source.split("/"); var end = parts[parts.length - 1]; - parts = end.split('\\'); + parts = end.split("\\"); end = parts[parts.length - 1]; fileName = end; } - fileName = fileName || 'unknown'; - link.setAttribute('download', fileName); + fileName = fileName || "unknown"; + link.setAttribute("download", fileName); document.body.appendChild(link); link.click(); link.remove(); @@ -414,19 +414,19 @@ var Predictor = function Predictor(_data) { _defineProperty(this, "loaded", false); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "version", ''); + _defineProperty(this, "version", ""); _defineProperty(this, "is_active", false); - _defineProperty(this, "data_source", ''); + _defineProperty(this, "data_source", ""); _defineProperty(this, "predict", null); _defineProperty(this, "accuracy", 0); - _defineProperty(this, "status", ''); + _defineProperty(this, "status", ""); _defineProperty(this, "train_end_at", null); @@ -452,7 +452,7 @@ var Predictor = function Predictor(_data) { mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; url_path = "/predictors/"; - if (_this.name !== undefined && _this.name !== '') { + if (_this.name !== undefined && _this.name !== "") { url_path += "".concat(_this.name); } @@ -647,7 +647,7 @@ var Predictor = function Predictor(_data) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('file', file); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -656,7 +656,7 @@ var Predictor = function Predictor(_data) { } } }; - request = setQueryParams(mergeParams, '/predictors/upload'); + request = setQueryParams(mergeParams, "/predictors/upload"); _context14.next = 7; return connection.api.post(request, fd, config); @@ -684,7 +684,7 @@ var Predictor = function Predictor(_data) { request = setQueryParams(mergeParams, "/predictors/".concat(_this.name, "/download")); _context15.next = 4; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 4: @@ -719,11 +719,11 @@ var DataSource = function DataSource(_data2) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "source", ''); + _defineProperty(this, "source", ""); _defineProperty(this, "missed_files", false); @@ -776,14 +776,14 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context17.prev = _context17.next) { case 0: - _this2.source_type = 'file'; + _this2.source_type = "file"; _this2.source = file.name; mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('name', _this2.name); - fd.append('source_type', _this2.source_type); - fd.append('source', _this2.source); - fd.append('file', file); + fd.append("name", _this2.name); + fd.append("source_type", _this2.source_type); + fd.append("source", _this2.source); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -817,7 +817,7 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context18.prev = _context18.next) { case 0: - _this2.source_type = 'url'; + _this2.source_type = "url"; _this2.source = url; data = { name: _this2.name, @@ -854,7 +854,7 @@ var DataSource = function DataSource(_data2) { request = setQueryParams(mergeParams, url); _context19.next = 5; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 5: @@ -876,7 +876,7 @@ var DataSource = function DataSource(_data2) { }()); _defineProperty(this, "getDownloadUrl", function () { - return _this2.source_type === 'url' ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); + return _this2.source_type === "url" ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); }); _defineProperty(this, "delete", /*#__PURE__*/function () { @@ -912,7 +912,7 @@ var DataSource = function DataSource(_data2) { switch (_context21.prev = _context21.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data")); + request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data/")); _context21.next = 4; return connection.api.get(request); @@ -950,11 +950,11 @@ var DataSource = function DataSource(_data2) { case 5: response = _context22.sent; data = { - data_preparation: response.data['data_preparation'], - data_analysis_v2: response.data['data_analysis_v2'], - useable_input_columns: response.data['useable_input_columns'], - current_phase: response.data['current_phase'], - versionNative: response.data['version'], + data_preparation: response.data["data_preparation"], + data_analysis_v2: response.data["data_analysis_v2"], + useable_input_columns: response.data["useable_input_columns"], + current_phase: response.data["current_phase"], + versionNative: response.data["version"], status: response.data && response.data.status }; _context22.next = 13; @@ -1024,8 +1024,8 @@ var DataSource = function DataSource(_data2) { case 0: column = _ref25.column, rowIndex = _ref25.rowIndex, extension = _ref25.extension, file = _ref25.file; fd = new FormData(); - fd.append('file', file); - fd.append('extension', extension); + fd.append("file", file); + fd.append("extension", extension); mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/files/").concat(column, ":").concat(rowIndex)); _context24.next = 8; @@ -1058,7 +1058,7 @@ var DataBase = function DataBase(_data3) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); _defineProperty(this, "integration", []); @@ -1071,7 +1071,7 @@ var DataBase = function DataBase(_data3) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; _context25.prev = 1; - deRequest = setQueryParams(mergeParams, 'config/all_integrations'); + deRequest = setQueryParams(mergeParams, "config/all_integrations"); _context25.next = 5; return connection.api.get(deRequest); diff --git a/es/mindsdb-sdk.mjs b/es/mindsdb-sdk.mjs index aa9c29c..a0f80e3 100644 --- a/es/mindsdb-sdk.mjs +++ b/es/mindsdb-sdk.mjs @@ -1 +1 @@ -import t from"axios";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,n,r,a,o,u){try{var c=t[o](u),i=c.value}catch(t){return void n(t)}c.done?e(i):Promise.resolve(i).then(r,a)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(a,o){var u=t.apply(e,r);function c(t){n(u,a,o,c,i,"next",t)}function i(t){n(u,a,o,c,i,"throw",t)}c(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}var i=function(t,e){var n="";return t?(t.forEach((function(t,e){if(t.value){var r=encodeURIComponent(t.key)+"="+(t.noEncodeURIComponent?t.value:encodeURIComponent(t.value));n=n.concat(e>0?"&".concat(r):r)}})),n.length>0?e+"?"+n:e):e},s={url:null,api:null,token:{key:"apikey",value:null},version:.2},p=function(){var t=r(regeneratorRuntime.mark((function t(n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=i([s.token],"/util/ping"),t.next=3,s.api.get(r);case 3:if(200!==(a=t.sent).status||"object"!==e(a.data)||"ok"!==a.data.status){t.next=6;break}return t.abrupt("return",!0);case 6:return t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),f=function(){var t=r(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i([].concat(u(e),[s.token]),"/config/logs"),t.next=3,s.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l=function(){var t=r(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i([s.token],"/config/install_options"),t.next=3,s.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),d=function(){var t=r(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i([s.token],"/config/vars"),t.next=3,s.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),m=function(t){return new g(t)},h=function(t){return new k(t)},v=function(t,e){var n=window.URL.createObjectURL(new Blob([t.data])),r=document.createElement("a");r.href=n;var a=t.headers["content-disposition"],o=null;if(a){var u=a.match(/filename="?(.+)"?/);2===u.length&&(o=u[1])}if(!o&&e){var c=e.split("/"),i=c[c.length-1];c=i.split("\\"),o=i=c[c.length-1]}r.setAttribute("download",o=o||"unknown"),document.body.appendChild(r),r.click(),r.remove(),window.URL.revokeObjectURL(n)},g=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"name",""),o(this,"version",""),o(this,"is_active",!1),o(this,"data_source",""),o(this,"predict",null),o(this,"accuracy",0),o(this,"status",""),o(this,"train_end_at",null),o(this,"updated_at",null),o(this,"created_at",null),o(this,"data_preparation",null),o(this,"data_analysis",null),o(this,"model_analysis",null),o(this,"columns",null),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a="/predictors/",void 0!==n.name&&""!==n.name&&(a+="".concat(n.name)),o=i(r,a),t.next=6,s.api.get(o);case 6:return Object.assign(n,t.sent.data),t.abrupt("return",n);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"rename",function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/predictors/".concat(e.oldName,"/rename?new_name=").concat(e.newName)),t.next=4,s.api.get(r);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadColumns",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name,"/columns")),t.next=4,s.api.get(a);case 4:return n.columns=t.sent.data,t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"learn",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c,p,f,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.dataSourceName,o=e.fromData,p={to_predict:e.toPredict},(c=e.kwargs)&&(p.kwargs=c),a?p.data_source_name=a:o&&(p.from_data=o),f=r?[].concat(u(r),[s.token]):[s.token],l=i(f,"/predictors/".concat(n.name)),t.next=8,s.api.put(l,p);case 8:return t.abrupt("return",t.sent.data);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"queryPredict",function(){var t=r(regeneratorRuntime.mark((function t(e,r,a){var o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r?[].concat(u(r),[s.token]):[s.token],c=i(o,"/predictors/".concat(n.name,"/predict")),t.next=4,s.api.post(c,{when:e,format_flag:a});case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name)),t.next=4,s.api.delete(a);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"upload",function(){var t=r(regeneratorRuntime.mark((function t(e,n,r){var a,o,c,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=r?[].concat(u(r),[s.token]):[s.token],(o=new FormData).append("file",e),c={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))}},p=i(a,"/predictors/upload"),t.next=7,s.api.post(p,o,c);case 7:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"download",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name,"/download")),t.next=4,s.api.get(a,{responseType:"blob"});case 4:return v(t.sent),t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"getDownloadUrl",(function(){return"".concat(s.url,"/predictors/").concat(n.name,"/download")})),Object.assign(this,e)},k=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"source_type","url"),o(this,"name",""),o(this,"source",""),o(this,"missed_files",!1),o(this,"created_at",null),o(this,"updated_at",null),o(this,"row_count",0),o(this,"columns",null),o(this,"data",null),o(this,"missedFileList",null),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name)),t.next=4,s.api.get(a);case 4:return Object.assign(n,t.sent.data),t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"upload",function(){var t=r(regeneratorRuntime.mark((function t(e,r,a){var o,c,p,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.source_type="file",n.source=e.name,o=a?[].concat(u(a),[s.token]):[s.token],(c=new FormData).append("name",n.name),c.append("source_type",n.source_type),c.append("source",n.source),c.append("file",e),p={onUploadProgress:function(t){r&&r(Math.round(100*t.loaded/t.total))},timeout:6e5},f=i(o,"/datasources/".concat(n.name)),t.next=12,s.api.put(f,c,p);case 12:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"uploadFromUrl",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.source_type="url",n.source=e,a={name:n.name,source_type:n.source_type,source:n.source},o=r?[].concat(u(r),[s.token]):[s.token],c=i(o,"/datasources/".concat(n.name)),t.next=7,s.api.put(c,a);case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"download",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.getDownloadUrl(),a=e?[].concat(u(e),[s.token]):[s.token],o=i(a,r),t.next=5,s.api.get(o,{responseType:"blob"});case 5:return v(t.sent,n.source),t.abrupt("return",n);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"getDownloadUrl",(function(){return"url"===n.source_type?n.source:"".concat(s.url,"/datasources/").concat(n.name,"/download")})),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name)),t.next=4,s.api.delete(a);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadData",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/data")),t.next=4,s.api.get(a);case 4:return n.data=t.sent.data,t.abrupt("return",n.data);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadDataQuality",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/analyze")),t.prev=2,t.next=5,s.api.get(a);case 5:o={data_preparation:(c=t.sent).data.data_preparation,data_analysis_v2:c.data.data_analysis_v2,useable_input_columns:c.data.useable_input_columns,current_phase:c.data.current_phase,versionNative:c.data.version,status:c.data&&c.data.status},t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),Object.assign(n,{error:t.t0}),console.error(t.t0);case 13:return n.dataQuality=o,t.abrupt("return",o);case 15:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadMissedFileList",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/missed_files")),t.next=4,s.api.get(a);case 4:return n.missedFileList=t.sent.data,t.abrupt("return",n.missedFileList);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"uploadFile",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c,p,f,l,d;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.column,o=e.rowIndex,c=e.extension,p=e.file,(f=new FormData).append("file",p),f.append("extension",c),l=r?[].concat(u(r),[s.token]):[s.token],d=i(l,"/datasources/".concat(n.name,"/files/").concat(a,":").concat(o)),t.next=8,s.api.put(d,f);case 8:return t.abrupt("return",200===t.sent.status);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},w=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"source_type","url"),o(this,"integration",[]),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],t.prev=1,a=i(r,"config/all_integrations"),t.next=5,s.api.get(a);case 5:return Object.assign(n,t.sent),t.abrupt("return",n);case 10:t.prev=10,t.t0=t.catch(1),Object.assign(n,{error:t.t0}),console.error(t.t0);case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e){return t.apply(this,arguments)}}()),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.api.delete("/config/integrations/".concat(e.db_name));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"check",function(){var t=r(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.api.get("/config/integrations/".concat(e.database_name,"/check"));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"edit",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],a=i(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,s.api.post(a,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"create",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],a=i(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,s.api.put(a,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"newDataset",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],t.prev=1,a=i(r,"/datasources/".concat(e.name)),t.next=5,s.api.put(a,e);case 5:return t.abrupt("return",t.sent);case 8:return t.prev=8,t.t0=t.catch(1),t.abrupt("return",t.t0);case 11:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},y={connect:function(e,n){s.token.value=n.find((function(t){return"apikey"===t.key})).value,s.url=i([s.token],e),s.api=t.create({baseURL:e})},disconnect:function(){s.url=null,s.token={key:"apikey",value:null},s.api=null},ping:p,logs:f,dependencies:l,installDependencies:function(){var t=r(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i([s.token],"/config/install/".concat(e)),t.next=3,s.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),getEnvs:d,predictors:function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/predictors/"),t.next=4,s.api.get(r);case 4:return a=(t.sent.data||[]).map(m),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),dataSources:function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/datasources/"),t.next=4,s.api.get(r);case 4:return a=(t.sent.data||[]).map(h),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),DataSource:h,Predictor:m,DataBase:function(t){return new w(t)}};export default y; +import t from"axios";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,n,r,a,o,u){try{var c=t[o](u),i=c.value}catch(t){return void n(t)}c.done?e(i):Promise.resolve(i).then(r,a)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(a,o){var u=t.apply(e,r);function c(t){n(u,a,o,c,i,"next",t)}function i(t){n(u,a,o,c,i,"throw",t)}c(void 0)}))}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);e>n;n++)r[n]=t[n];return r}var i=function(t,e){var n="";return t?(t.forEach((function(t,e){if(t.value){var r=encodeURIComponent(t.key)+"="+(t.noEncodeURIComponent?t.value:encodeURIComponent(t.value));n=n.concat(e>0?"&".concat(r):r)}})),n.length>0?e+"?"+n:e):e},s={url:null,api:null,token:{key:"apikey",value:null},version:.2},p=function(){var t=r(regeneratorRuntime.mark((function t(n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=i([s.token],"/util/ping"),t.next=3,s.api.get(r);case 3:if(200!==(a=t.sent).status||"object"!==e(a.data)||"ok"!==a.data.status){t.next=6;break}return t.abrupt("return",!0);case 6:return t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),f=function(){var t=r(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i([].concat(u(e),[s.token]),"/config/logs"),t.next=3,s.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l=function(){var t=r(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i([s.token],"/config/install_options"),t.next=3,s.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),d=function(){var t=r(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i([s.token],"/config/vars"),t.next=3,s.api.get(e);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),m=function(t){return new g(t)},h=function(t){return new k(t)},v=function(t,e){var n=window.URL.createObjectURL(new Blob([t.data])),r=document.createElement("a");r.href=n;var a=t.headers["content-disposition"],o=null;if(a){var u=a.match(/filename="?(.+)"?/);2===u.length&&(o=u[1])}if(!o&&e){var c=e.split("/"),i=c[c.length-1];c=i.split("\\"),o=i=c[c.length-1]}r.setAttribute("download",o=o||"unknown"),document.body.appendChild(r),r.click(),r.remove(),window.URL.revokeObjectURL(n)},g=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"name",""),o(this,"version",""),o(this,"is_active",!1),o(this,"data_source",""),o(this,"predict",null),o(this,"accuracy",0),o(this,"status",""),o(this,"train_end_at",null),o(this,"updated_at",null),o(this,"created_at",null),o(this,"data_preparation",null),o(this,"data_analysis",null),o(this,"model_analysis",null),o(this,"columns",null),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a="/predictors/",void 0!==n.name&&""!==n.name&&(a+="".concat(n.name)),o=i(r,a),t.next=6,s.api.get(o);case 6:return Object.assign(n,t.sent.data),t.abrupt("return",n);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"rename",function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/predictors/".concat(e.oldName,"/rename?new_name=").concat(e.newName)),t.next=4,s.api.get(r);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadColumns",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name,"/columns")),t.next=4,s.api.get(a);case 4:return n.columns=t.sent.data,t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"learn",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c,p,f,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.dataSourceName,o=e.fromData,p={to_predict:e.toPredict},(c=e.kwargs)&&(p.kwargs=c),a?p.data_source_name=a:o&&(p.from_data=o),f=r?[].concat(u(r),[s.token]):[s.token],l=i(f,"/predictors/".concat(n.name)),t.next=8,s.api.put(l,p);case 8:return t.abrupt("return",t.sent.data);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"queryPredict",function(){var t=r(regeneratorRuntime.mark((function t(e,r,a){var o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=r?[].concat(u(r),[s.token]):[s.token],c=i(o,"/predictors/".concat(n.name,"/predict")),t.next=4,s.api.post(c,{when:e,format_flag:a});case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name)),t.next=4,s.api.delete(a);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"upload",function(){var t=r(regeneratorRuntime.mark((function t(e,n,r){var a,o,c,p;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=r?[].concat(u(r),[s.token]):[s.token],(o=new FormData).append("file",e),c={onUploadProgress:function(t){n&&n(Math.round(100*t.loaded/t.total))}},p=i(a,"/predictors/upload"),t.next=7,s.api.post(p,o,c);case 7:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"download",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/predictors/".concat(n.name,"/download")),t.next=4,s.api.get(a,{responseType:"blob"});case 4:return v(t.sent),t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"getDownloadUrl",(function(){return"".concat(s.url,"/predictors/").concat(n.name,"/download")})),Object.assign(this,e)},k=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"source_type","url"),o(this,"name",""),o(this,"source",""),o(this,"missed_files",!1),o(this,"created_at",null),o(this,"updated_at",null),o(this,"row_count",0),o(this,"columns",null),o(this,"data",null),o(this,"missedFileList",null),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name)),t.next=4,s.api.get(a);case 4:return Object.assign(n,t.sent.data),t.abrupt("return",n);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"upload",function(){var t=r(regeneratorRuntime.mark((function t(e,r,a){var o,c,p,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.source_type="file",n.source=e.name,o=a?[].concat(u(a),[s.token]):[s.token],(c=new FormData).append("name",n.name),c.append("source_type",n.source_type),c.append("source",n.source),c.append("file",e),p={onUploadProgress:function(t){r&&r(Math.round(100*t.loaded/t.total))},timeout:6e5},f=i(o,"/datasources/".concat(n.name)),t.next=12,s.api.put(f,c,p);case 12:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()),o(this,"uploadFromUrl",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.source_type="url",n.source=e,a={name:n.name,source_type:n.source_type,source:n.source},o=r?[].concat(u(r),[s.token]):[s.token],c=i(o,"/datasources/".concat(n.name)),t.next=7,s.api.put(c,a);case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"download",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.getDownloadUrl(),a=e?[].concat(u(e),[s.token]):[s.token],o=i(a,r),t.next=5,s.api.get(o,{responseType:"blob"});case 5:return v(t.sent,n.source),t.abrupt("return",n);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"getDownloadUrl",(function(){return"url"===n.source_type?n.source:"".concat(s.url,"/datasources/").concat(n.name,"/download")})),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name)),t.next=4,s.api.delete(a);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadData",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/data/")),t.next=4,s.api.get(a);case 4:return n.data=t.sent.data,t.abrupt("return",n.data);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadDataQuality",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a,o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/analyze")),t.prev=2,t.next=5,s.api.get(a);case 5:o={data_preparation:(c=t.sent).data.data_preparation,data_analysis_v2:c.data.data_analysis_v2,useable_input_columns:c.data.useable_input_columns,current_phase:c.data.current_phase,versionNative:c.data.version,status:c.data&&c.data.status},t.next=13;break;case 9:t.prev=9,t.t0=t.catch(2),Object.assign(n,{error:t.t0}),console.error(t.t0);case 13:return n.dataQuality=o,t.abrupt("return",o);case 15:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e){return t.apply(this,arguments)}}()),o(this,"loadMissedFileList",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],a=i(r,"/datasources/".concat(n.name,"/missed_files")),t.next=4,s.api.get(a);case 4:return n.missedFileList=t.sent.data,t.abrupt("return",n.missedFileList);case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"uploadFile",function(){var t=r(regeneratorRuntime.mark((function t(e,r){var a,o,c,p,f,l,d;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.column,o=e.rowIndex,c=e.extension,p=e.file,(f=new FormData).append("file",p),f.append("extension",c),l=r?[].concat(u(r),[s.token]):[s.token],d=i(l,"/datasources/".concat(n.name,"/files/").concat(a,":").concat(o)),t.next=8,s.api.put(d,f);case 8:return t.abrupt("return",200===t.sent.status);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},w=function t(e){var n=this;a(this,t),o(this,"loaded",!1),o(this,"source_type","url"),o(this,"integration",[]),o(this,"load",function(){var t=r(regeneratorRuntime.mark((function t(e){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e?[].concat(u(e),[s.token]):[s.token],t.prev=1,a=i(r,"config/all_integrations"),t.next=5,s.api.get(a);case 5:return Object.assign(n,t.sent),t.abrupt("return",n);case 10:t.prev=10,t.t0=t.catch(1),Object.assign(n,{error:t.t0}),console.error(t.t0);case 14:case"end":return t.stop()}}),t,null,[[1,10]])})));return function(e){return t.apply(this,arguments)}}()),o(this,"delete",function(){var t=r(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.api.delete("/config/integrations/".concat(e.db_name));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"check",function(){var t=r(regeneratorRuntime.mark((function t(e){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.api.get("/config/integrations/".concat(e.database_name,"/check"));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),o(this,"edit",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],a=i(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,s.api.post(a,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"create",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],a=i(r,"/config/integrations/".concat(e.params.database_name)),t.next=4,s.api.put(a,e);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),o(this,"newDataset",function(){var t=r(regeneratorRuntime.mark((function t(e,n){var r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n?[].concat(u(n),[s.token]):[s.token],t.prev=1,a=i(r,"/datasources/".concat(e.name)),t.next=5,s.api.put(a,e);case 5:return t.abrupt("return",t.sent);case 8:return t.prev=8,t.t0=t.catch(1),t.abrupt("return",t.t0);case 11:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(e,n){return t.apply(this,arguments)}}()),Object.assign(this,e)},y={connect:function(e,n){s.token.value=n.find((function(t){return"apikey"===t.key})).value,s.url=i([s.token],e),s.api=t.create({baseURL:e})},disconnect:function(){s.url=null,s.token={key:"apikey",value:null},s.api=null},ping:p,logs:f,dependencies:l,installDependencies:function(){var t=r(regeneratorRuntime.mark((function t(e){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i([s.token],"/config/install/".concat(e)),t.next=3,s.api.get(n);case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),getEnvs:d,predictors:function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/predictors/"),t.next=4,s.api.get(r);case 4:return a=(t.sent.data||[]).map(m),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),dataSources:function(){var t=r(regeneratorRuntime.mark((function t(e){var n,r,a;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e?[].concat(u(e),[s.token]):[s.token],r=i(n,"/datasources/"),t.next=4,s.api.get(r);case 4:return a=(t.sent.data||[]).map(h),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),DataSource:h,Predictor:m,DataBase:function(t){return new w(t)}};export default y; diff --git a/lib/mindsdb-sdk.js b/lib/mindsdb-sdk.js index 6e79d5a..52cac1a 100644 --- a/lib/mindsdb-sdk.js +++ b/lib/mindsdb-sdk.js @@ -32,7 +32,7 @@ var connection = { url: null, api: null, token: { - key: 'apikey', + key: "apikey", value: null }, version: 0.2 @@ -40,7 +40,7 @@ var connection = { var connect = function connect(url, params) { connection.token.value = params.find(function (param) { - return param.key === 'apikey'; + return param.key === "apikey"; }).value; connection.url = setQueryParams([connection.token], url); connection.api = axios.create({ @@ -51,7 +51,7 @@ var connect = function connect(url, params) { var disconnect = function disconnect() { connection.url = null; connection.token = { - key: 'apikey', + key: "apikey", value: null }; connection.api = null; @@ -64,14 +64,14 @@ var ping = /*#__PURE__*/function () { while (1) { switch (_context.prev = _context.next) { case 0: - request = setQueryParams([connection.token], '/util/ping'); + request = setQueryParams([connection.token], "/util/ping"); _context.next = 3; return connection.api.get(request); case 3: response = _context.sent; - if (!(response.status === 200 && _typeof(response.data) === 'object' && response.data.status === 'ok')) { + if (!(response.status === 200 && _typeof(response.data) === "object" && response.data.status === "ok")) { _context.next = 6; break; } @@ -101,7 +101,7 @@ var logs = /*#__PURE__*/function () { while (1) { switch (_context2.prev = _context2.next) { case 0: - request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), '/config/logs'); + request = setQueryParams([].concat(_toConsumableArray(params), [connection.token]), "/config/logs"); _context2.next = 3; return connection.api.get(request); @@ -129,7 +129,7 @@ var dependencies = /*#__PURE__*/function () { while (1) { switch (_context3.prev = _context3.next) { case 0: - request = setQueryParams([connection.token], '/config/install_options'); + request = setQueryParams([connection.token], "/config/install_options"); _context3.next = 3; return connection.api.get(request); @@ -157,7 +157,7 @@ var getEnvs = /*#__PURE__*/function () { while (1) { switch (_context4.prev = _context4.next) { case 0: - request = setQueryParams([connection.token], '/config/vars'); + request = setQueryParams([connection.token], "/config/vars"); _context4.next = 3; return connection.api.get(request); @@ -226,7 +226,7 @@ var predictors = /*#__PURE__*/function () { switch (_context6.prev = _context6.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/predictors/'); + request = setQueryParams(mergeParams, "/predictors/"); _context6.next = 4; return connection.api.get(request); @@ -257,7 +257,7 @@ var dataSources = /*#__PURE__*/function () { switch (_context7.prev = _context7.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, '/datasources/'); + request = setQueryParams(mergeParams, "/datasources/"); _context7.next = 4; return connection.api.get(request); @@ -282,9 +282,9 @@ var dataSources = /*#__PURE__*/function () { var saveFile = function saveFile(response, source) { var url = window.URL.createObjectURL(new Blob([response.data])); - var link = document.createElement('a'); + var link = document.createElement("a"); link.href = url; - var contentDisposition = response.headers['content-disposition']; + var contentDisposition = response.headers["content-disposition"]; var fileName = null; if (contentDisposition) { @@ -296,15 +296,15 @@ var saveFile = function saveFile(response, source) { } if (!fileName && source) { - var parts = source.split('/'); + var parts = source.split("/"); var end = parts[parts.length - 1]; - parts = end.split('\\'); + parts = end.split("\\"); end = parts[parts.length - 1]; fileName = end; } - fileName = fileName || 'unknown'; - link.setAttribute('download', fileName); + fileName = fileName || "unknown"; + link.setAttribute("download", fileName); document.body.appendChild(link); link.click(); link.remove(); @@ -318,19 +318,19 @@ var Predictor = function Predictor(_data) { _defineProperty(this, "loaded", false); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "version", ''); + _defineProperty(this, "version", ""); _defineProperty(this, "is_active", false); - _defineProperty(this, "data_source", ''); + _defineProperty(this, "data_source", ""); _defineProperty(this, "predict", null); _defineProperty(this, "accuracy", 0); - _defineProperty(this, "status", ''); + _defineProperty(this, "status", ""); _defineProperty(this, "train_end_at", null); @@ -356,7 +356,7 @@ var Predictor = function Predictor(_data) { mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; url_path = "/predictors/"; - if (_this.name !== undefined && _this.name !== '') { + if (_this.name !== undefined && _this.name !== "") { url_path += "".concat(_this.name); } @@ -551,7 +551,7 @@ var Predictor = function Predictor(_data) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('file', file); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -560,7 +560,7 @@ var Predictor = function Predictor(_data) { } } }; - request = setQueryParams(mergeParams, '/predictors/upload'); + request = setQueryParams(mergeParams, "/predictors/upload"); _context14.next = 7; return connection.api.post(request, fd, config); @@ -588,7 +588,7 @@ var Predictor = function Predictor(_data) { request = setQueryParams(mergeParams, "/predictors/".concat(_this.name, "/download")); _context15.next = 4; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 4: @@ -623,11 +623,11 @@ var DataSource = function DataSource(_data2) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); - _defineProperty(this, "name", ''); + _defineProperty(this, "name", ""); - _defineProperty(this, "source", ''); + _defineProperty(this, "source", ""); _defineProperty(this, "missed_files", false); @@ -680,14 +680,14 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context17.prev = _context17.next) { case 0: - _this2.source_type = 'file'; + _this2.source_type = "file"; _this2.source = file.name; mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; fd = new FormData(); - fd.append('name', _this2.name); - fd.append('source_type', _this2.source_type); - fd.append('source', _this2.source); - fd.append('file', file); + fd.append("name", _this2.name); + fd.append("source_type", _this2.source_type); + fd.append("source", _this2.source); + fd.append("file", file); config = { onUploadProgress: function onUploadProgress(progressEvent) { if (onProgress) { @@ -721,7 +721,7 @@ var DataSource = function DataSource(_data2) { while (1) { switch (_context18.prev = _context18.next) { case 0: - _this2.source_type = 'url'; + _this2.source_type = "url"; _this2.source = url; data = { name: _this2.name, @@ -758,7 +758,7 @@ var DataSource = function DataSource(_data2) { request = setQueryParams(mergeParams, url); _context19.next = 5; return connection.api.get(request, { - responseType: 'blob' + responseType: "blob" }); case 5: @@ -780,7 +780,7 @@ var DataSource = function DataSource(_data2) { }()); _defineProperty(this, "getDownloadUrl", function () { - return _this2.source_type === 'url' ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); + return _this2.source_type === "url" ? _this2.source : "".concat(connection.url, "/datasources/").concat(_this2.name, "/download"); }); _defineProperty(this, "delete", /*#__PURE__*/function () { @@ -816,7 +816,7 @@ var DataSource = function DataSource(_data2) { switch (_context21.prev = _context21.next) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; - request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data")); + request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/data/")); _context21.next = 4; return connection.api.get(request); @@ -854,11 +854,11 @@ var DataSource = function DataSource(_data2) { case 5: response = _context22.sent; data = { - data_preparation: response.data['data_preparation'], - data_analysis_v2: response.data['data_analysis_v2'], - useable_input_columns: response.data['useable_input_columns'], - current_phase: response.data['current_phase'], - versionNative: response.data['version'], + data_preparation: response.data["data_preparation"], + data_analysis_v2: response.data["data_analysis_v2"], + useable_input_columns: response.data["useable_input_columns"], + current_phase: response.data["current_phase"], + versionNative: response.data["version"], status: response.data && response.data.status }; _context22.next = 13; @@ -928,8 +928,8 @@ var DataSource = function DataSource(_data2) { case 0: column = _ref25.column, rowIndex = _ref25.rowIndex, extension = _ref25.extension, file = _ref25.file; fd = new FormData(); - fd.append('file', file); - fd.append('extension', extension); + fd.append("file", file); + fd.append("extension", extension); mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; request = setQueryParams(mergeParams, "/datasources/".concat(_this2.name, "/files/").concat(column, ":").concat(rowIndex)); _context24.next = 8; @@ -962,7 +962,7 @@ var DataBase = function DataBase(_data3) { _defineProperty(this, "loaded", false); - _defineProperty(this, "source_type", 'url'); + _defineProperty(this, "source_type", "url"); _defineProperty(this, "integration", []); @@ -975,7 +975,7 @@ var DataBase = function DataBase(_data3) { case 0: mergeParams = params ? [].concat(_toConsumableArray(params), [connection.token]) : [connection.token]; _context25.prev = 1; - deRequest = setQueryParams(mergeParams, 'config/all_integrations'); + deRequest = setQueryParams(mergeParams, "config/all_integrations"); _context25.next = 5; return connection.api.get(deRequest); diff --git a/src/index.js b/src/index.js index 38e90af..1ee5afd 100644 --- a/src/index.js +++ b/src/index.js @@ -1,64 +1,68 @@ /* eslint-disable */ -import axios from 'axios'; -import { setQueryParams } from './utils'; +import axios from "axios"; +import { setQueryParams } from "./utils"; const connection = { - url: null, - api: null, - token: { key: 'apikey', value: null }, - version: 0.2, + url: null, + api: null, + token: { key: "apikey", value: null }, + version: 0.2, }; const connect = (url, params) => { - connection.token.value = params.find((param) => param.key === 'apikey').value; - connection.url = setQueryParams([connection.token], url); - connection.api = axios.create({ - baseURL: url, - }); + connection.token.value = params.find((param) => param.key === "apikey").value; + connection.url = setQueryParams([connection.token], url); + connection.api = axios.create({ + baseURL: url, + }); }; const disconnect = () => { - connection.url = null; - connection.token = { key: 'apikey', value: null }; - connection.api = null; + connection.url = null; + connection.token = { key: "apikey", value: null }; + connection.api = null; }; const ping = async (params) => { - const request = setQueryParams([connection.token], '/util/ping'); - const response = await connection.api.get(request); - - if (response.status === 200 && typeof response.data === 'object' && response.data.status === 'ok') { - return true; - } - return false; + const request = setQueryParams([connection.token], "/util/ping"); + const response = await connection.api.get(request); + + if ( + response.status === 200 && + typeof response.data === "object" && + response.data.status === "ok" + ) { + return true; + } + return false; }; const logs = async (params) => { - const request = setQueryParams([...params, connection.token], '/config/logs'); - const response = await connection.api.get(request); + const request = setQueryParams([...params, connection.token], "/config/logs"); + const response = await connection.api.get(request); - return response.data; + return response.data; }; const dependencies = async () => { - const request = setQueryParams([connection.token], '/config/install_options'); - const response = await connection.api.get(request); + const request = setQueryParams([connection.token], "/config/install_options"); + const response = await connection.api.get(request); - return response.data; + return response.data; }; const getEnvs = async () => { - const request = setQueryParams([connection.token], '/config/vars'); - const response = await connection.api.get(request); + const request = setQueryParams([connection.token], "/config/vars"); + const response = await connection.api.get(request); - return response.data; + return response.data; }; const installDependencies = async (name) => { - const request = setQueryParams([connection.token], `/config/install/${name}`); - const response = await connection.api.get(request); + const request = setQueryParams([connection.token], `/config/install/${name}`); + const response = await connection.api.get(request); - return response.data; + return response.data; }; const predictor = (opts) => new Predictor(opts); @@ -66,398 +70,485 @@ const dataSource = (opts) => new DataSource(opts); const database = (opts) => new DataBase(opts); const predictors = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; - const request = setQueryParams(mergeParams, '/predictors/'); - const response = await connection.api.get(request); + const request = setQueryParams(mergeParams, "/predictors/"); + const response = await connection.api.get(request); - const rawData = response.data || []; - const predictorList = rawData.map(predictor); - return predictorList; + const rawData = response.data || []; + const predictorList = rawData.map(predictor); + return predictorList; }; const dataSources = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; - const request = setQueryParams(mergeParams, '/datasources/'); - const response = await connection.api.get(request); + const request = setQueryParams(mergeParams, "/datasources/"); + const response = await connection.api.get(request); - const rawData = response.data || []; - const dataSourceList = rawData.map(dataSource); - return dataSourceList; + const rawData = response.data || []; + const dataSourceList = rawData.map(dataSource); + return dataSourceList; }; const saveFile = (response, source) => { - const url = window.URL.createObjectURL(new Blob([response.data])); - const link = document.createElement('a'); - link.href = url; - const contentDisposition = response.headers['content-disposition']; - let fileName = null; - if (contentDisposition) { - const fileNameMatch = contentDisposition.match(/filename="?(.+)"?/); - if (fileNameMatch.length === 2) { - fileName = fileNameMatch[1]; - } - } - if (!fileName && source) { - let parts = source.split('/'); - let end = parts[parts.length - 1]; - parts = end.split('\\'); - end = parts[parts.length - 1]; - fileName = end; - } - fileName = fileName || 'unknown'; - link.setAttribute('download', fileName); - document.body.appendChild(link); - link.click(); - link.remove(); - window.URL.revokeObjectURL(url); + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement("a"); + link.href = url; + const contentDisposition = response.headers["content-disposition"]; + let fileName = null; + if (contentDisposition) { + const fileNameMatch = contentDisposition.match(/filename="?(.+)"?/); + if (fileNameMatch.length === 2) { + fileName = fileNameMatch[1]; + } + } + if (!fileName && source) { + let parts = source.split("/"); + let end = parts[parts.length - 1]; + parts = end.split("\\"); + end = parts[parts.length - 1]; + fileName = end; + } + fileName = fileName || "unknown"; + link.setAttribute("download", fileName); + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); }; class Predictor { - loaded = false; - name = ''; - version = ''; - is_active = false; - data_source = ''; - predict = null; - accuracy = 0; - status = ''; - train_end_at = null; - updated_at = null; - created_at = null; - - data_preparation = null; - data_analysis = null; - model_analysis = null; - - columns = null; - - constructor(data) { - Object.assign(this, data); - } - - load = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - let url_path = `/predictors/`; - if (this.name !== undefined && this.name !== '') { - url_path += `${this.name}`; - } - - const request = setQueryParams(mergeParams, url_path); - const response = await connection.api.get(request); - - Object.assign(this, response.data); - return this; - }; - - rename = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/predictors/${params.oldName}/rename?new_name=${params.newName}`); - const response = await connection.api.get(request); - - return response.data; - }; - - loadColumns = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/predictors/${this.name}/columns`); - const response = await connection.api.get(request); - - this.columns = response.data; - return this; - }; - - learn = async ({ dataSourceName, fromData, toPredict, kwargs }, params) => { - const data = { - to_predict: toPredict, - }; - - if (kwargs) { - data.kwargs = kwargs; - } - - if (dataSourceName) { - data.data_source_name = dataSourceName; - } else if (fromData) { - data.from_data = fromData; - } - - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/predictors/${this.name}`); - const response = await connection.api.put(request, data); - - return response.data; - }; - - queryPredict = async (when, params, format_flag_value) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/predictors/${this.name}/predict`); - const response = await connection.api.post(request, { when, format_flag: format_flag_value }); - - return response.data; - }; - - delete = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/predictors/${this.name}`); - await connection.api.delete(request); - }; - - upload = async (file, onProgress, params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const fd = new FormData(); - fd.append('file', file); - - const config = { - onUploadProgress: (progressEvent) => { - if (onProgress) { - const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total); - onProgress(percentCompleted); - } - }, - }; - - const request = setQueryParams(mergeParams, '/predictors/upload'); - await connection.api.post(request, fd, config); - }; - - download = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/predictors/${this.name}/download`); - const response = await connection.api.get(request, { - responseType: 'blob', - }); - saveFile(response); - return this; - }; - - getDownloadUrl = () => `${connection.url}/predictors/${this.name}/download`; + loaded = false; + name = ""; + version = ""; + is_active = false; + data_source = ""; + predict = null; + accuracy = 0; + status = ""; + train_end_at = null; + updated_at = null; + created_at = null; + + data_preparation = null; + data_analysis = null; + model_analysis = null; + + columns = null; + + constructor(data) { + Object.assign(this, data); + } + + load = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + let url_path = `/predictors/`; + if (this.name !== undefined && this.name !== "") { + url_path += `${this.name}`; + } + + const request = setQueryParams(mergeParams, url_path); + const response = await connection.api.get(request); + + Object.assign(this, response.data); + return this; + }; + + rename = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams( + mergeParams, + `/predictors/${params.oldName}/rename?new_name=${params.newName}` + ); + const response = await connection.api.get(request); + + return response.data; + }; + + loadColumns = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams( + mergeParams, + `/predictors/${this.name}/columns` + ); + const response = await connection.api.get(request); + + this.columns = response.data; + return this; + }; + + learn = async ({ dataSourceName, fromData, toPredict, kwargs }, params) => { + const data = { + to_predict: toPredict, + }; + + if (kwargs) { + data.kwargs = kwargs; + } + + if (dataSourceName) { + data.data_source_name = dataSourceName; + } else if (fromData) { + data.from_data = fromData; + } + + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams(mergeParams, `/predictors/${this.name}`); + const response = await connection.api.put(request, data); + + return response.data; + }; + + queryPredict = async (when, params, format_flag_value) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams( + mergeParams, + `/predictors/${this.name}/predict` + ); + const response = await connection.api.post(request, { + when, + format_flag: format_flag_value, + }); + + return response.data; + }; + + delete = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams(mergeParams, `/predictors/${this.name}`); + await connection.api.delete(request); + }; + + upload = async (file, onProgress, params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const fd = new FormData(); + fd.append("file", file); + + const config = { + onUploadProgress: (progressEvent) => { + if (onProgress) { + const percentCompleted = Math.round( + (progressEvent.loaded * 100) / progressEvent.total + ); + onProgress(percentCompleted); + } + }, + }; + + const request = setQueryParams(mergeParams, "/predictors/upload"); + await connection.api.post(request, fd, config); + }; + + download = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams( + mergeParams, + `/predictors/${this.name}/download` + ); + const response = await connection.api.get(request, { + responseType: "blob", + }); + saveFile(response); + return this; + }; + + getDownloadUrl = () => `${connection.url}/predictors/${this.name}/download`; } class DataSource { - loaded = false; - - source_type = 'url'; - - name = ''; - source = ''; - missed_files = false; - created_at = null; - updated_at = null; - row_count = 0; - columns = null; - - data = null; - missedFileList = null; - - constructor(data) { - Object.assign(this, data); - } - - load = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const request = setQueryParams(mergeParams, `/datasources/${this.name}`); - const response = await connection.api.get(request); - Object.assign(this, response.data); - return this; - }; - - // setSource = () => {}; - - upload = async (file, onProgress, params) => { - this.source_type = 'file'; - this.source = file.name; - const mergeParams = params ? [...params, connection.token] : [connection.token]; - - const fd = new FormData(); - fd.append('name', this.name); - fd.append('source_type', this.source_type); - fd.append('source', this.source); - fd.append('file', file); - - const config = { - onUploadProgress: (progressEvent) => { - if (onProgress) { - const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total); - onProgress(percentCompleted); - } - }, - timeout: 600000, - }; - - const request = setQueryParams(mergeParams, `/datasources/${this.name}`); - await connection.api.put(request, fd, config); - }; - - uploadFromUrl = async (url, params) => { - this.source_type = 'url'; - this.source = url; - const data = { - name: this.name, - source_type: this.source_type, - source: this.source, - }; - - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}`); - - await connection.api.put(request, data); - }; - - download = async (params) => { - const url = this.getDownloadUrl(); - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, url); - - const response = await connection.api.get(request, { - responseType: 'blob', - }); - saveFile(response, this.source); - return this; - }; - - getDownloadUrl = () => - this.source_type === 'url' ? this.source : `${connection.url}/datasources/${this.name}/download`; - - delete = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}`); - await connection.api.delete(request); - }; - - loadData = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}/data`); - const response = await connection.api.get(request); - - this.data = response.data; - return this.data; - }; - - loadDataQuality = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}/analyze`); - let data; - try { - const response = await connection.api.get(request); - data = { - data_preparation: response.data['data_preparation'], - data_analysis_v2: response.data['data_analysis_v2'], - useable_input_columns: response.data['useable_input_columns'], - current_phase: response.data['current_phase'], - versionNative: response.data['version'], - status: response.data && response.data.status, - }; - } catch (error) { - Object.assign(this, { error: error }); - console.error(error); - } - this.dataQuality = data; - return data; - }; - - loadMissedFileList = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}/missed_files`); - const response = await connection.api.get(request); - - this.missedFileList = response.data; - return this.missedFileList; - }; - - uploadFile = async ({ column, rowIndex, extension, file }, params) => { - const fd = new FormData(); - - fd.append('file', file); - fd.append('extension', extension); - - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/datasources/${this.name}/files/${column}:${rowIndex}`); - const response = await connection.api.put(request, fd); - - return response.status === 200; - }; + loaded = false; + + source_type = "url"; + + name = ""; + source = ""; + missed_files = false; + created_at = null; + updated_at = null; + row_count = 0; + columns = null; + + data = null; + missedFileList = null; + + constructor(data) { + Object.assign(this, data); + } + + load = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const request = setQueryParams(mergeParams, `/datasources/${this.name}`); + const response = await connection.api.get(request); + Object.assign(this, response.data); + return this; + }; + + // setSource = () => {}; + + upload = async (file, onProgress, params) => { + this.source_type = "file"; + this.source = file.name; + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + + const fd = new FormData(); + fd.append("name", this.name); + fd.append("source_type", this.source_type); + fd.append("source", this.source); + fd.append("file", file); + + const config = { + onUploadProgress: (progressEvent) => { + if (onProgress) { + const percentCompleted = Math.round( + (progressEvent.loaded * 100) / progressEvent.total + ); + onProgress(percentCompleted); + } + }, + timeout: 600000, + }; + + const request = setQueryParams(mergeParams, `/datasources/${this.name}`); + await connection.api.put(request, fd, config); + }; + + uploadFromUrl = async (url, params) => { + this.source_type = "url"; + this.source = url; + const data = { + name: this.name, + source_type: this.source_type, + source: this.source, + }; + + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams(mergeParams, `/datasources/${this.name}`); + + await connection.api.put(request, data); + }; + + download = async (params) => { + const url = this.getDownloadUrl(); + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams(mergeParams, url); + + const response = await connection.api.get(request, { + responseType: "blob", + }); + saveFile(response, this.source); + return this; + }; + + getDownloadUrl = () => + this.source_type === "url" + ? this.source + : `${connection.url}/datasources/${this.name}/download`; + + delete = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams(mergeParams, `/datasources/${this.name}`); + await connection.api.delete(request); + }; + + loadData = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/datasources/${this.name}/data/` + ); + const response = await connection.api.get(request); + + this.data = response.data; + return this.data; + }; + + loadDataQuality = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/datasources/${this.name}/analyze` + ); + let data; + try { + const response = await connection.api.get(request); + data = { + data_preparation: response.data["data_preparation"], + data_analysis_v2: response.data["data_analysis_v2"], + useable_input_columns: response.data["useable_input_columns"], + current_phase: response.data["current_phase"], + versionNative: response.data["version"], + status: response.data && response.data.status, + }; + } catch (error) { + Object.assign(this, { error: error }); + console.error(error); + } + this.dataQuality = data; + return data; + }; + + loadMissedFileList = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/datasources/${this.name}/missed_files` + ); + const response = await connection.api.get(request); + + this.missedFileList = response.data; + return this.missedFileList; + }; + + uploadFile = async ({ column, rowIndex, extension, file }, params) => { + const fd = new FormData(); + + fd.append("file", file); + fd.append("extension", extension); + + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/datasources/${this.name}/files/${column}:${rowIndex}` + ); + const response = await connection.api.put(request, fd); + + return response.status === 200; + }; } class DataBase { - loaded = false; - source_type = 'url'; - integration = []; - - constructor(data) { - Object.assign(this, data); - } - - load = async (params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - try { - const deRequest = setQueryParams(mergeParams, 'config/all_integrations'); - const response = await connection.api.get(deRequest); - Object.assign(this, response); - return this; - } catch (error) { - Object.assign(this, { error: error }); - console.error(error); - } - }; - - delete = async (params) => { - await connection.api.delete(`/config/integrations/${params.db_name}`); - }; - - check = async (params) => { - return await connection.api.get(`/config/integrations/${params.database_name}/check`); - }; - - edit = async (data, params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/config/integrations/${data.params.database_name}`); - const response = await connection.api.post(request, data); - - return response.data; - }; - - create = async (data, params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - const request = setQueryParams(mergeParams, `/config/integrations/${data.params.database_name}`); - const response = await connection.api.put(request, data); - - return response.data; - }; - - newDataset = async (data, params) => { - const mergeParams = params ? [...params, connection.token] : [connection.token]; - try { - const request = setQueryParams(mergeParams, `/datasources/${data.name}`); - return await connection.api.put(request, data); - } catch (error) { - return error; - } - }; + loaded = false; + source_type = "url"; + integration = []; + + constructor(data) { + Object.assign(this, data); + } + + load = async (params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + try { + const deRequest = setQueryParams(mergeParams, "config/all_integrations"); + const response = await connection.api.get(deRequest); + Object.assign(this, response); + return this; + } catch (error) { + Object.assign(this, { error: error }); + console.error(error); + } + }; + + delete = async (params) => { + await connection.api.delete(`/config/integrations/${params.db_name}`); + }; + + check = async (params) => { + return await connection.api.get( + `/config/integrations/${params.database_name}/check` + ); + }; + + edit = async (data, params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/config/integrations/${data.params.database_name}` + ); + const response = await connection.api.post(request, data); + + return response.data; + }; + + create = async (data, params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + const request = setQueryParams( + mergeParams, + `/config/integrations/${data.params.database_name}` + ); + const response = await connection.api.put(request, data); + + return response.data; + }; + + newDataset = async (data, params) => { + const mergeParams = params + ? [...params, connection.token] + : [connection.token]; + try { + const request = setQueryParams(mergeParams, `/datasources/${data.name}`); + return await connection.api.put(request, data); + } catch (error) { + return error; + } + }; } const MindsDB = { - connect, - disconnect, - ping, - logs, - dependencies, - installDependencies, - getEnvs, - predictors, - dataSources, - DataSource: dataSource, - Predictor: predictor, - DataBase: database, + connect, + disconnect, + ping, + logs, + dependencies, + installDependencies, + getEnvs, + predictors, + dataSources, + DataSource: dataSource, + Predictor: predictor, + DataBase: database, }; /* eslint-enable */ From f3fb7373b771b33a60d6378848c2ba2e3669ecc6 Mon Sep 17 00:00:00 2001 From: Alejo Villegas Date: Sun, 14 Mar 2021 21:31:40 -0500 Subject: [PATCH 2/2] update packaje json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a2c2cf..7171c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mindsdb-js-sdk", - "version": "0.5.10", + "version": "0.5.11", "license": "MIT", "homepage": "https://github.com/mindsdb/mindsdb_js_sdk#readme", "repository": {