Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@superset-ui/connection

Package Overview
Dependencies
Maintainers
8
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superset-ui/connection - npm Package Compare versions

Comparing version 0.10.10 to 0.11.0

3

esm/callApi/parseResponse.js

@@ -1,2 +0,1 @@

import JSONbig from"json-bigint";function rejectIfNotOkay(a){return a.ok?Promise.resolve(a):Promise.reject(a)}function parseJson(a){try{return JSONbig.parse(a)}catch(a){// if JSONbig.parse fails, it throws an object (not a proper Error), so let's re-wrap the message.
throw new Error(a.message)}}export default function parseResponse(a,b){void 0===b&&(b="json");var c=a.then(rejectIfNotOkay);if(null===b)return a.then(rejectIfNotOkay);if("text"===b)return c.then(function(a){return a.text().then(function(b){return{response:a,text:b}})});if("json"===b)return c.then(function(a){return a.text().then(function(b){return{json:parseJson(b),response:a}})});throw new Error("Expected parseResponse=null|json|text, got '"+b+"'.")}
function rejectIfNotOkay(a){return a.ok?Promise.resolve(a):Promise.reject(a)}export default function parseResponse(a,b){void 0===b&&(b="json");var c=a.then(rejectIfNotOkay);if(null===b)return a.then(rejectIfNotOkay);if("text"===b)return c.then(function(a){return a.text().then(function(b){return{response:a,text:b}})});if("json"===b)return c.then(function(a){return a.json().then(function(b){return{json:b,response:a}})});throw new Error("Expected parseResponse=null|json|text, got '"+b+"'.")}

@@ -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};

@@ -1,2 +0,1 @@

"use strict";var _jsonBigint=_interopRequireDefault(require("json-bigint"));exports.__esModule=/* force = */!0,exports.default=parseResponse;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function rejectIfNotOkay(a){return a.ok?Promise.resolve(a):Promise.reject(a)}function parseJson(a){try{return _jsonBigint.default.parse(a)}catch(a){// if JSONbig.parse fails, it throws an object (not a proper Error), so let's re-wrap the message.
throw new Error(a.message)}}function parseResponse(a,b){void 0===b&&(b="json");var c=a.then(rejectIfNotOkay);if(null===b)return a.then(rejectIfNotOkay);if("text"===b)return c.then(function(a){return a.text().then(function(b){return{response:a,text:b}})});if("json"===b)return c.then(function(a){return a.text().then(function(b){return{json:parseJson(b),response:a}})});throw new Error("Expected parseResponse=null|json|text, got '"+b+"'.")}
"use strict";exports.__esModule=/* force = */!0,exports.default=parseResponse;function rejectIfNotOkay(a){return a.ok?Promise.resolve(a):Promise.reject(a)}function parseResponse(a,b){void 0===b&&(b="json");var c=a.then(rejectIfNotOkay);if(null===b)return a.then(rejectIfNotOkay);if("text"===b)return c.then(function(a){return a.text().then(function(b){return{response:a,text:b}})});if("json"===b)return c.then(function(a){return a.json().then(function(b){return{json:b,response:a}})});throw new Error("Expected parseResponse=null|json|text, got '"+b+"'.")}

@@ -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.10.10",
"version": "0.11.0",
"description": "Superset UI connection",

@@ -35,3 +35,2 @@ "sideEffects": false,

"@babel/runtime": "^7.1.2",
"json-bigint": "^0.3.0",
"whatwg-fetch": "^2.0.4"

@@ -41,4 +40,3 @@ },

"access": "public"
},
"gitHead": "20cf61bc6e03a7fc2ed0845024a987bd40140d18"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc