@superset-ui/connection
Advanced tools
Comparing version 0.9.3 to 0.9.5
@@ -1,1 +0,1 @@ | ||
export{default as callApi}from"./callApi";export{default as SupersetClient,SupersetClientInterface}from"./SupersetClient";export{SupersetClientClass}from"./SupersetClientClass";export*from"./types"; | ||
export{default as callApi}from"./callApi";export{default as SupersetClient}from"./SupersetClient";export{default as SupersetClientClass}from"./SupersetClientClass";export*from"./types"; |
@@ -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(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){return getInstance(singletonClient).get(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 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).get(a)},reset:function a(){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";export 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 | ||
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 | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}(); | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}();export{SupersetClientClass as default}; |
export { default as callApi } from './callApi'; | ||
export { default as SupersetClient, SupersetClientInterface } from './SupersetClient'; | ||
export { SupersetClientClass } from './SupersetClientClass'; | ||
export { default as SupersetClient } from './SupersetClient'; | ||
export { default as SupersetClientClass } from './SupersetClientClass'; | ||
export * from './types'; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _exportNames={callApi:/* force = */!0,SupersetClient:!0,SupersetClientInterface:!0,SupersetClientClass:!0};var _callApi=_interopRequireDefault(require("./callApi"));var _SupersetClient=_interopRequireWildcard(require("./SupersetClient"));var _SupersetClientClass=require("./SupersetClientClass");var _types=require("./types");exports.__esModule=!0;exports.SupersetClientClass=exports.SupersetClientInterface=exports.SupersetClient=exports.callApi=void 0;exports.callApi=_callApi.default;exports.SupersetClient=_SupersetClient.default,exports.SupersetClientInterface=_SupersetClient.SupersetClientInterface;exports.SupersetClientClass=_SupersetClientClass.SupersetClientClass;Object.keys(_types).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||(exports[a]=_types[a])});function _interopRequireWildcard(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};d.get||d.set?Object.defineProperty(b,c,d):b[c]=a[c]}return b.default=a,b}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
"use strict";var _exportNames={callApi:/* force = */!0,SupersetClient:!0,SupersetClientClass:!0};var _callApi=_interopRequireDefault(require("./callApi"));var _SupersetClient=_interopRequireDefault(require("./SupersetClient"));var _SupersetClientClass=_interopRequireDefault(require("./SupersetClientClass"));var _types=require("./types");exports.__esModule=!0;exports.SupersetClientClass=exports.SupersetClient=exports.callApi=void 0;exports.callApi=_callApi.default;exports.SupersetClient=_SupersetClient.default;exports.SupersetClientClass=_SupersetClientClass.default;Object.keys(_types).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||(exports[a]=_types[a])});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} |
@@ -1,17 +0,3 @@ | ||
import { ClientConfig, SupersetClientClass } from './SupersetClientClass'; | ||
import { RequestConfig, SupersetClientResponse } from './types'; | ||
export interface SupersetClientInterface { | ||
configure: (config?: ClientConfig) => SupersetClientClass; | ||
delete: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
get: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
getInstance: (maybeClient?: SupersetClientClass) => SupersetClientClass; | ||
init: (force?: boolean) => Promise<string | undefined>; | ||
isAuthenticated: () => boolean; | ||
post: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
put: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
reAuthenticate: () => Promise<string | undefined>; | ||
request: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
reset: () => void; | ||
} | ||
import { SupersetClientInterface } from './types'; | ||
declare const SupersetClient: SupersetClientInterface; | ||
export default SupersetClient; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=/* force = */!0,exports.default=void 0;var singletonClient,_SupersetClientClass=require("./SupersetClientClass");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.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(!0)},request:function(a){function b(){return a.apply(this,arguments)}return b.toString=function(){return a.toString()},b}(function(a){return getInstance(singletonClient).get(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 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).get(a)},reset:function a(){singletonClient=void 0}},_default=SupersetClient;exports.default=_default; |
@@ -1,15 +0,3 @@ | ||
import { ClientTimeout, Credentials, Headers, Host, Mode, SupersetClientResponse, RequestConfig } from './types'; | ||
declare type CsrfToken = string; | ||
declare type CsrfPromise = Promise<string | undefined>; | ||
declare type Protocol = 'http:' | 'https:'; | ||
export interface ClientConfig { | ||
credentials?: Credentials; | ||
csrfToken?: CsrfToken; | ||
headers?: Headers; | ||
host?: Host; | ||
protocol?: Protocol; | ||
mode?: Mode; | ||
timeout?: ClientTimeout; | ||
} | ||
export declare class SupersetClientClass { | ||
import { ClientConfig, ClientTimeout, Credentials, CsrfPromise, CsrfToken, Headers, Host, Mode, Protocol, RequestConfig, SupersetClientResponse } from './types'; | ||
export default class SupersetClientClass { | ||
credentials: Credentials; | ||
@@ -39,2 +27,1 @@ csrfToken?: CsrfToken; | ||
} | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
"use strict";var _callApi=_interopRequireDefault(require("./callApi"));exports.__esModule=/* force = */!0,exports.SupersetClientClass=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 | ||
"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 | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}();exports.SupersetClientClass=SupersetClientClass; | ||
return this.protocol+"//"+h+"/"+("/"===e[0]?e.slice(1):e)},a}();exports.default=SupersetClientClass; |
@@ -0,1 +1,2 @@ | ||
import SupersetClientClass from './SupersetClientClass'; | ||
export declare type Body = RequestInit['body']; | ||
@@ -63,2 +64,27 @@ export declare type Cache = RequestInit['cache']; | ||
} | ||
export declare type CsrfToken = string; | ||
export declare type CsrfPromise = Promise<string | undefined>; | ||
export declare type Protocol = 'http:' | 'https:'; | ||
export interface ClientConfig { | ||
credentials?: Credentials; | ||
csrfToken?: CsrfToken; | ||
headers?: Headers; | ||
host?: Host; | ||
protocol?: Protocol; | ||
mode?: Mode; | ||
timeout?: ClientTimeout; | ||
} | ||
export interface SupersetClientInterface { | ||
configure: (config?: ClientConfig) => SupersetClientClass; | ||
delete: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
get: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
getInstance: (maybeClient?: SupersetClientClass) => SupersetClientClass; | ||
init: (force?: boolean) => Promise<string | undefined>; | ||
isAuthenticated: () => boolean; | ||
post: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
put: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
reAuthenticate: () => Promise<string | undefined>; | ||
request: (request: RequestConfig) => Promise<SupersetClientResponse>; | ||
reset: () => void; | ||
} | ||
export declare type SupersetClientResponse = Response | JsonTextResponse; |
{ | ||
"name": "@superset-ui/connection", | ||
"version": "0.9.3", | ||
"version": "0.9.5", | ||
"description": "Superset UI connection", | ||
@@ -41,3 +41,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "ad9d288d7a1f2a6714ebd8cc332428b5b94c868e" | ||
"gitHead": "91768b5515b3a70f2d86b5abb98dfba82ecc529b" | ||
} |
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
40529
191