@superset-ui/connection
Advanced tools
Comparing version 0.11.5 to 0.11.10
@@ -5,2 +5,3 @@ function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}/* eslint compat/compat: 'off' */import"whatwg-fetch";import{CACHE_AVAILABLE,CACHE_KEY,HTTP_STATUS_NOT_MODIFIED,HTTP_STATUS_OK}from"../constants";// This function fetches an API response and returns the corresponding json | ||
var b=a.headers.get("Etag");r.headers=_extends({},r.headers,{"If-None-Match":b})}return fetch(q,r)}).then(function(b){return b.status===HTTP_STATUS_NOT_MODIFIED?a.match(q).then(function(a){if(a)return a.clone();throw new Error("Received 304 but no content is cached!")}):(b.status===HTTP_STATUS_OK&&b.headers.get("Etag")&&(a.delete(q),a.put(q,b.clone())),b)})});if(("POST"===i||"PATCH"===i||"PUT"===i)&&"object"==typeof l){// using FormData has the effect that Content-Type header is set to `multipart/form-data`, | ||
// not e.g., 'application/x-www-form-urlencoded' | ||
var s=new FormData;Object.keys(l).forEach(function(a){var b=l[a];"undefined"!=typeof b&&s.append(a,!(void 0!==p)||p?JSON.stringify(b):b)}),r.body=s}return fetch(q,r)} |
@@ -1,1 +0,1 @@ | ||
import SupersetClientClass from"./SupersetClientClass";var singletonClient;function getInstance(a){if(!a)throw new Error("You must call SupersetClient.configure(...) before calling other methods");return a}var SupersetClient={configure:function b(a){return singletonClient=new SupersetClientClass(a),singletonClient},delete:function b(a){return getInstance(singletonClient).delete(a)},get:function b(a){return getInstance(singletonClient).get(a)},getInstance:getInstance,init:function b(a){return getInstance(singletonClient).init(a)},isAuthenticated:function a(){return getInstance(singletonClient).isAuthenticated()},post:function b(a){return getInstance(singletonClient).post(a)},put:function b(a){return getInstance(singletonClient).put(a)},reAuthenticate:function a(){return getInstance(singletonClient).init(/* force = */!0)},request:function b(a){return getInstance(singletonClient).request(a)},reset:function a(){singletonClient=void 0}};export default SupersetClient; | ||
import SupersetClientClass from"./SupersetClientClass";var singletonClient;function getInstance(a){if(!a)throw new Error("You must call SupersetClient.configure(...) before calling other methods");return a}var SupersetClient={configure:function configure(a){return singletonClient=new SupersetClientClass(a),singletonClient},delete:function _delete(a){return getInstance(singletonClient).delete(a)},get:function get(a){return getInstance(singletonClient).get(a)},getInstance:getInstance,init:function init(a){return getInstance(singletonClient).init(a)},isAuthenticated:function isAuthenticated(){return getInstance(singletonClient).isAuthenticated()},post:function post(a){return getInstance(singletonClient).post(a)},put:function put(a){return getInstance(singletonClient).put(a)},reAuthenticate:function reAuthenticate(){return getInstance(singletonClient).init(/* force = */!0)},request:function request(a){return getInstance(singletonClient).request(a)},reset:function reset(){singletonClient=void 0}};export default SupersetClient; |
@@ -1,3 +0,3 @@ | ||
function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:/* force = */!0,configurable:!0,writable:!0}):a[b]=c,a}import callApi from"./callApi";var SupersetClientClass=/*#__PURE__*/function(){function a(a){var b=void 0===a?{}:a,c=b.protocol,d=void 0===c?"http:":c,e=b.host,f=void 0===e?"localhost":e,g=b.headers,h=void 0===g?{}:g,i=b.mode,j=void 0===i?"same-origin":i,k=b.timeout,l=b.credentials,m=void 0===l?void 0:l,n=b.csrfToken,o=void 0===n?void 0:n;_defineProperty(this,"credentials",void 0),_defineProperty(this,"csrfToken",void 0),_defineProperty(this,"csrfPromise",void 0),_defineProperty(this,"protocol",void 0),_defineProperty(this,"host",void 0),_defineProperty(this,"headers",void 0),_defineProperty(this,"mode",void 0),_defineProperty(this,"timeout",void 0),this.headers=_extends({},h),this.host=f,this.mode=j,this.timeout=k,this.protocol=d,this.credentials=m,this.csrfToken=o,this.csrfPromise=void 0,"string"==typeof this.csrfToken&&(this.headers=_extends({},this.headers,{"X-CSRFToken":this.csrfToken}),this.csrfPromise=Promise.resolve(this.csrfToken))}var b=a.prototype;return b.init=function b(a){return void 0===a&&(a=!1),this.isAuthenticated()&&!a?this.csrfPromise:this.getCSRFToken()},b.isAuthenticated=function a(){// if CSRF protection is disabled in the Superset app, the token may be an empty string | ||
return null!==this.csrfToken&&void 0!==this.csrfToken},b.get=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"GET"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.delete=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"DELETE"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.put=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"PUT"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.post=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"POST"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.request=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.body,d=b.credentials,e=b.endpoint,f=b.headers,g=b.host,h=b.method,i=b.mode,j=b.parseMethod,k=b.postPayload,l=b.signal,m=b.stringify,n=b.timeout,o=b.url,a.abrupt("return",this.ensureAuth().then(function(){return callApi({body:c,credentials:d||p.credentials,headers:_extends({},p.headers,f),method:h,mode:i||p.mode,parseMethod:j,postPayload:k,signal:l,stringify:m,timeout:n||p.timeout,url:p.getUrl({endpoint:e,host:g,url:o})})}));case 2:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.ensureAuth=function a(){return this.csrfPromise||Promise.reject({error:"SupersetClient has no CSRF token, ensure it is initialized or\n try logging into the Superset instance at "+this.getUrl({endpoint:"/login"})})},b.getCSRFToken=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(){var b=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return this.csrfToken=void 0,this.csrfPromise=callApi({credentials:this.credentials,headers:_extends({},this.headers),method:"GET",mode:this.mode,timeout:this.timeout,url:this.getUrl({endpoint:"superset/csrf_token/"})}).then(function(a){return"object"==typeof a.json&&(b.csrfToken=a.json.csrf_token,"string"==typeof b.csrfToken&&(b.headers=_extends({},b.headers,{"X-CSRFToken":b.csrfToken}))),b.isAuthenticated()?Promise.resolve(b.csrfToken):Promise.reject({error:"Failed to fetch CSRF token"})}),a.abrupt("return",this.csrfPromise);case 3:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.getUrl=function i(a){var b=void 0===a?{}:a,c=b.host,d=b.endpoint,e=void 0===d?"":d,f=b.url;if("string"==typeof f)return f;var g=c||this.host,h="/"===g.slice(-1)?g.slice(0,-1):g;// no backslash | ||
function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:/* force = */!0,configurable:!0,writable:!0}):a[b]=c,a}import callApi from"./callApi";var SupersetClientClass=/*#__PURE__*/function(){function a(a){var b=void 0===a?{}:a,c=b.protocol,d=void 0===c?"http:":c,e=b.host,f=void 0===e?"localhost":e,g=b.headers,h=void 0===g?{}:g,i=b.mode,j=void 0===i?"same-origin":i,k=b.timeout,l=b.credentials,m=void 0===l?void 0:l,n=b.csrfToken,o=void 0===n?void 0:n;_defineProperty(this,"credentials",void 0),_defineProperty(this,"csrfToken",void 0),_defineProperty(this,"csrfPromise",void 0),_defineProperty(this,"protocol",void 0),_defineProperty(this,"host",void 0),_defineProperty(this,"headers",void 0),_defineProperty(this,"mode",void 0),_defineProperty(this,"timeout",void 0),this.headers=_extends({},h),this.host=f,this.mode=j,this.timeout=k,this.protocol=d,this.credentials=m,this.csrfToken=o,this.csrfPromise=void 0,"string"==typeof this.csrfToken&&(this.headers=_extends({},this.headers,{"X-CSRFToken":this.csrfToken}),this.csrfPromise=Promise.resolve(this.csrfToken))}var b=a.prototype;return b.init=function init(a){return void 0===a&&(a=!1),this.isAuthenticated()&&!a?this.csrfPromise:this.getCSRFToken()},b.isAuthenticated=function isAuthenticated(){// if CSRF protection is disabled in the Superset app, the token may be an empty string | ||
return null!==this.csrfToken&&void 0!==this.csrfToken},b.get=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"GET"})));case 1:case"end":return a.stop();}},a,this)}));return function get(){return a.apply(this,arguments)}}(),b.delete=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"DELETE"})));case 1:case"end":return a.stop();}},a,this)}));return function _delete(){return a.apply(this,arguments)}}(),b.put=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"PUT"})));case 1:case"end":return a.stop();}},a,this)}));return function put(){return a.apply(this,arguments)}}(),b.post=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"POST"})));case 1:case"end":return a.stop();}},a,this)}));return function post(){return a.apply(this,arguments)}}(),b.request=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.body,d=b.credentials,e=b.endpoint,f=b.headers,g=b.host,h=b.method,i=b.mode,j=b.parseMethod,k=b.postPayload,l=b.signal,m=b.stringify,n=b.timeout,o=b.url,a.abrupt("return",this.ensureAuth().then(function(){return callApi({body:c,credentials:d||p.credentials,headers:_extends({},p.headers,f),method:h,mode:i||p.mode,parseMethod:j,postPayload:k,signal:l,stringify:m,timeout:n||p.timeout,url:p.getUrl({endpoint:e,host:g,url:o})})}));case 2:case"end":return a.stop();}},a,this)}));return function request(){return a.apply(this,arguments)}}(),b.ensureAuth=function ensureAuth(){return this.csrfPromise||Promise.reject({error:"SupersetClient has no CSRF token, ensure it is initialized or\n try logging into the Superset instance at "+this.getUrl({endpoint:"/login"})})},b.getCSRFToken=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(){var b=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return this.csrfToken=void 0,this.csrfPromise=callApi({credentials:this.credentials,headers:_extends({},this.headers),method:"GET",mode:this.mode,timeout:this.timeout,url:this.getUrl({endpoint:"superset/csrf_token/"})}).then(function(a){return"object"==typeof a.json&&(b.csrfToken=a.json.csrf_token,"string"==typeof b.csrfToken&&(b.headers=_extends({},b.headers,{"X-CSRFToken":b.csrfToken}))),b.isAuthenticated()?Promise.resolve(b.csrfToken):Promise.reject({error:"Failed to fetch CSRF token"})}),a.abrupt("return",this.csrfPromise);case 3:case"end":return a.stop();}},a,this)}));return function getCSRFToken(){return a.apply(this,arguments)}}(),b.getUrl=function getUrl(a){var b=void 0===a?{}:a,c=b.host,d=b.endpoint,e=void 0===d?"":d,f=b.url;if("string"==typeof f)return f;var g=c||this.host,h="/"===g.slice(-1)?g.slice(0,-1):g;// no backslash | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}();export{SupersetClientClass as default}; |
@@ -5,2 +5,3 @@ "use strict";var _constants=require("../constants");exports.__esModule=/* force = */!0,exports.default=callApi,require("whatwg-fetch");function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}// This function fetches an API response and returns the corresponding json | ||
var b=a.headers.get("Etag");r.headers=_extends({},r.headers,{"If-None-Match":b})}return fetch(q,r)}).then(function(b){return b.status===_constants.HTTP_STATUS_NOT_MODIFIED?a.match(q).then(function(a){if(a)return a.clone();throw new Error("Received 304 but no content is cached!")}):(b.status===_constants.HTTP_STATUS_OK&&b.headers.get("Etag")&&(a.delete(q),a.put(q,b.clone())),b)})});if(("POST"===i||"PATCH"===i||"PUT"===i)&&"object"==typeof l){// using FormData has the effect that Content-Type header is set to `multipart/form-data`, | ||
// not e.g., 'application/x-www-form-urlencoded' | ||
var s=new FormData;Object.keys(l).forEach(function(a){var b=l[a];"undefined"!=typeof b&&s.append(a,!(void 0!==p)||p?JSON.stringify(b):b)}),r.body=s}return fetch(q,r)} |
@@ -1,1 +0,1 @@ | ||
"use strict";var _SupersetClientClass=_interopRequireDefault(require("./SupersetClientClass"));exports.__esModule=/* force = */!0,exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var singletonClient;function getInstance(a){if(!a)throw new Error("You must call SupersetClient.configure(...) before calling other methods");return a}var SupersetClient={configure:function b(a){return singletonClient=new _SupersetClientClass.default(a),singletonClient},delete:function b(a){return getInstance(singletonClient).delete(a)},get:function b(a){return getInstance(singletonClient).get(a)},getInstance:getInstance,init:function b(a){return getInstance(singletonClient).init(a)},isAuthenticated:function a(){return getInstance(singletonClient).isAuthenticated()},post:function b(a){return getInstance(singletonClient).post(a)},put:function b(a){return getInstance(singletonClient).put(a)},reAuthenticate:function a(){return getInstance(singletonClient).init(!0)},request:function b(a){return getInstance(singletonClient).request(a)},reset:function a(){singletonClient=void 0}},_default=SupersetClient;exports.default=_default; | ||
"use strict";var _SupersetClientClass=_interopRequireDefault(require("./SupersetClientClass"));exports.__esModule=/* force = */!0,exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var singletonClient;function getInstance(a){if(!a)throw new Error("You must call SupersetClient.configure(...) before calling other methods");return a}var SupersetClient={configure:function configure(a){return singletonClient=new _SupersetClientClass.default(a),singletonClient},delete:function _delete(a){return getInstance(singletonClient).delete(a)},get:function get(a){return getInstance(singletonClient).get(a)},getInstance:getInstance,init:function init(a){return getInstance(singletonClient).init(a)},isAuthenticated:function isAuthenticated(){return getInstance(singletonClient).isAuthenticated()},post:function post(a){return getInstance(singletonClient).post(a)},put:function put(a){return getInstance(singletonClient).put(a)},reAuthenticate:function reAuthenticate(){return getInstance(singletonClient).init(!0)},request:function request(a){return getInstance(singletonClient).request(a)},reset:function reset(){singletonClient=void 0}},_default=SupersetClient;exports.default=_default; |
@@ -1,3 +0,3 @@ | ||
"use strict";var _callApi=_interopRequireDefault(require("./callApi"));exports.__esModule=/* force = */!0,exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var SupersetClientClass=/*#__PURE__*/function(){function a(a){var b=void 0===a?{}:a,c=b.protocol,d=void 0===c?"http:":c,e=b.host,f=void 0===e?"localhost":e,g=b.headers,h=void 0===g?{}:g,i=b.mode,j=void 0===i?"same-origin":i,k=b.timeout,l=b.credentials,m=void 0===l?void 0:l,n=b.csrfToken,o=void 0===n?void 0:n;_defineProperty(this,"credentials",void 0),_defineProperty(this,"csrfToken",void 0),_defineProperty(this,"csrfPromise",void 0),_defineProperty(this,"protocol",void 0),_defineProperty(this,"host",void 0),_defineProperty(this,"headers",void 0),_defineProperty(this,"mode",void 0),_defineProperty(this,"timeout",void 0),this.headers=_extends({},h),this.host=f,this.mode=j,this.timeout=k,this.protocol=d,this.credentials=m,this.csrfToken=o,this.csrfPromise=void 0,"string"==typeof this.csrfToken&&(this.headers=_extends({},this.headers,{"X-CSRFToken":this.csrfToken}),this.csrfPromise=Promise.resolve(this.csrfToken))}var b=a.prototype;return b.init=function b(a){return void 0===a&&(a=!1),this.isAuthenticated()&&!a?this.csrfPromise:this.getCSRFToken()},b.isAuthenticated=function a(){// if CSRF protection is disabled in the Superset app, the token may be an empty string | ||
return null!==this.csrfToken&&void 0!==this.csrfToken},b.get=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"GET"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.delete=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"DELETE"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.put=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"PUT"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.post=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"POST"})));case 1:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.request=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.body,d=b.credentials,e=b.endpoint,f=b.headers,g=b.host,h=b.method,i=b.mode,j=b.parseMethod,k=b.postPayload,l=b.signal,m=b.stringify,n=b.timeout,o=b.url,a.abrupt("return",this.ensureAuth().then(function(){return(0,_callApi.default)({body:c,credentials:d||p.credentials,headers:_extends({},p.headers,f),method:h,mode:i||p.mode,parseMethod:j,postPayload:k,signal:l,stringify:m,timeout:n||p.timeout,url:p.getUrl({endpoint:e,host:g,url:o})})}));case 2:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.ensureAuth=function a(){return this.csrfPromise||Promise.reject({error:"SupersetClient has no CSRF token, ensure it is initialized or\n try logging into the Superset instance at "+this.getUrl({endpoint:"/login"})})},b.getCSRFToken=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(){var b=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return this.csrfToken=void 0,this.csrfPromise=(0,_callApi.default)({credentials:this.credentials,headers:_extends({},this.headers),method:"GET",mode:this.mode,timeout:this.timeout,url:this.getUrl({endpoint:"superset/csrf_token/"})}).then(function(a){return"object"==typeof a.json&&(b.csrfToken=a.json.csrf_token,"string"==typeof b.csrfToken&&(b.headers=_extends({},b.headers,{"X-CSRFToken":b.csrfToken}))),b.isAuthenticated()?Promise.resolve(b.csrfToken):Promise.reject({error:"Failed to fetch CSRF token"})}),a.abrupt("return",this.csrfPromise);case 3:case"end":return a.stop();}},a,this)}));return function b(){return a.apply(this,arguments)}}(),b.getUrl=function i(a){var b=void 0===a?{}:a,c=b.host,d=b.endpoint,e=void 0===d?"":d,f=b.url;if("string"==typeof f)return f;var g=c||this.host,h="/"===g.slice(-1)?g.slice(0,-1):g;// no backslash | ||
"use strict";var _callApi=_interopRequireDefault(require("./callApi"));exports.__esModule=/* force = */!0,exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var SupersetClientClass=/*#__PURE__*/function(){function a(a){var b=void 0===a?{}:a,c=b.protocol,d=void 0===c?"http:":c,e=b.host,f=void 0===e?"localhost":e,g=b.headers,h=void 0===g?{}:g,i=b.mode,j=void 0===i?"same-origin":i,k=b.timeout,l=b.credentials,m=void 0===l?void 0:l,n=b.csrfToken,o=void 0===n?void 0:n;_defineProperty(this,"credentials",void 0),_defineProperty(this,"csrfToken",void 0),_defineProperty(this,"csrfPromise",void 0),_defineProperty(this,"protocol",void 0),_defineProperty(this,"host",void 0),_defineProperty(this,"headers",void 0),_defineProperty(this,"mode",void 0),_defineProperty(this,"timeout",void 0),this.headers=_extends({},h),this.host=f,this.mode=j,this.timeout=k,this.protocol=d,this.credentials=m,this.csrfToken=o,this.csrfPromise=void 0,"string"==typeof this.csrfToken&&(this.headers=_extends({},this.headers,{"X-CSRFToken":this.csrfToken}),this.csrfPromise=Promise.resolve(this.csrfToken))}var b=a.prototype;return b.init=function init(a){return void 0===a&&(a=!1),this.isAuthenticated()&&!a?this.csrfPromise:this.getCSRFToken()},b.isAuthenticated=function isAuthenticated(){// if CSRF protection is disabled in the Superset app, the token may be an empty string | ||
return null!==this.csrfToken&&void 0!==this.csrfToken},b.get=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"GET"})));case 1:case"end":return a.stop();}},a,this)}));return function get(){return a.apply(this,arguments)}}(),b.delete=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"DELETE"})));case 1:case"end":return a.stop();}},a,this)}));return function _delete(){return a.apply(this,arguments)}}(),b.put=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"PUT"})));case 1:case"end":return a.stop();}},a,this)}));return function put(){return a.apply(this,arguments)}}(),b.post=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.request(_extends({},b,{method:"POST"})));case 1:case"end":return a.stop();}},a,this)}));return function post(){return a.apply(this,arguments)}}(),b.request=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=b.body,d=b.credentials,e=b.endpoint,f=b.headers,g=b.host,h=b.method,i=b.mode,j=b.parseMethod,k=b.postPayload,l=b.signal,m=b.stringify,n=b.timeout,o=b.url,a.abrupt("return",this.ensureAuth().then(function(){return(0,_callApi.default)({body:c,credentials:d||p.credentials,headers:_extends({},p.headers,f),method:h,mode:i||p.mode,parseMethod:j,postPayload:k,signal:l,stringify:m,timeout:n||p.timeout,url:p.getUrl({endpoint:e,host:g,url:o})})}));case 2:case"end":return a.stop();}},a,this)}));return function request(){return a.apply(this,arguments)}}(),b.ensureAuth=function ensureAuth(){return this.csrfPromise||Promise.reject({error:"SupersetClient has no CSRF token, ensure it is initialized or\n try logging into the Superset instance at "+this.getUrl({endpoint:"/login"})})},b.getCSRFToken=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function a(){var b=this;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return this.csrfToken=void 0,this.csrfPromise=(0,_callApi.default)({credentials:this.credentials,headers:_extends({},this.headers),method:"GET",mode:this.mode,timeout:this.timeout,url:this.getUrl({endpoint:"superset/csrf_token/"})}).then(function(a){return"object"==typeof a.json&&(b.csrfToken=a.json.csrf_token,"string"==typeof b.csrfToken&&(b.headers=_extends({},b.headers,{"X-CSRFToken":b.csrfToken}))),b.isAuthenticated()?Promise.resolve(b.csrfToken):Promise.reject({error:"Failed to fetch CSRF token"})}),a.abrupt("return",this.csrfPromise);case 3:case"end":return a.stop();}},a,this)}));return function getCSRFToken(){return a.apply(this,arguments)}}(),b.getUrl=function getUrl(a){var b=void 0===a?{}:a,c=b.host,d=b.endpoint,e=void 0===d?"":d,f=b.url;if("string"==typeof f)return f;var g=c||this.host,h="/"===g.slice(-1)?g.slice(0,-1):g;// no backslash | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}();exports.default=SupersetClientClass; |
{ | ||
"name": "@superset-ui/connection", | ||
"version": "0.11.5", | ||
"version": "0.11.10", | ||
"description": "Superset UI connection", | ||
@@ -40,3 +40,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "c25a55ff4b484c139c4623d1ed2925acfb5a1d7f" | ||
"gitHead": "54849c153d6571352ec1caeb8138e9be568feecc" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
43062
207