@urbanos/react-discovery-ui 2.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +118 -0
- package/lib/ReactDiscoveryUI.js +103 -0
- package/lib/ReactDiscoveryUI.scss +13 -0
- package/lib/assets/arrow.svg +6 -0
- package/lib/assets/blk-database.svg +48 -0
- package/lib/assets/chart.svg +1 -0
- package/lib/assets/down.png +0 -0
- package/lib/assets/down.svg +1 -0
- package/lib/assets/folder_icon.png +0 -0
- package/lib/assets/folder_icon.svg +1 -0
- package/lib/assets/ic_arrow.svg +15 -0
- package/lib/assets/loadingicon.svg +57 -0
- package/lib/assets/no_image.png +0 -0
- package/lib/assets/plus.png +0 -0
- package/lib/assets/plus.svg +1 -0
- package/lib/assets/user.svg +1 -0
- package/lib/auth/auth0-client-provider.js +37 -0
- package/lib/auth/auth0-client-provider.test.js +33 -0
- package/lib/auth/auth0-wrapper.js +155 -0
- package/lib/auth/auth0-wrapper.test.js +100 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.js +147 -0
- package/lib/components/auth0-login-zone/auth0-login-zone.test.js +177 -0
- package/lib/components/auth0-login-zone/index.js +9 -0
- package/lib/components/code-editor/code-editor.css +173 -0
- package/lib/components/code-editor/code-editor.js +64 -0
- package/lib/components/code-editor/index.js +9 -0
- package/lib/components/collapsable-box/collapsable-box.js +81 -0
- package/lib/components/collapsable-box/collapsable-box.scss +39 -0
- package/lib/components/collapsable-box/collapsable-box.test.js +87 -0
- package/lib/components/collapsable-box/index.js +9 -0
- package/lib/components/data-card/data-card.js +63 -0
- package/lib/components/data-card/data-card.scss +93 -0
- package/lib/components/data-card/data-card.test.js +74 -0
- package/lib/components/data-card/index.js +9 -0
- package/lib/components/data-view/data-view.js +194 -0
- package/lib/components/data-view/data-view.scss +39 -0
- package/lib/components/data-view/data-view.test.js +155 -0
- package/lib/components/data-view/index.js +9 -0
- package/lib/components/dataset-api-doc/api-example.js +120 -0
- package/lib/components/dataset-api-doc/api-example.scss +84 -0
- package/lib/components/dataset-api-doc/api-example.test.js +88 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.js +117 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.scss +8 -0
- package/lib/components/dataset-api-doc/dataset-api-doc.test.js +42 -0
- package/lib/components/dataset-api-doc/index.js +9 -0
- package/lib/components/dataset-details/dataset-details.js +64 -0
- package/lib/components/dataset-details/dataset-details.scss +58 -0
- package/lib/components/dataset-details/dataset-details.test.js +38 -0
- package/lib/components/dataset-details/index.js +9 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.js +127 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.scss +42 -0
- package/lib/components/dataset-dictionary/dataset-dictionary.test.js +286 -0
- package/lib/components/dataset-dictionary/index.js +9 -0
- package/lib/components/dataset-list/dataset-list.js +22 -0
- package/lib/components/dataset-list/dataset-list.scss +9 -0
- package/lib/components/dataset-list/dataset-list.test.js +16 -0
- package/lib/components/dataset-list/index.js +9 -0
- package/lib/components/dataset-metadata/dataset-metadata.js +169 -0
- package/lib/components/dataset-metadata/dataset-metadata.scss +34 -0
- package/lib/components/dataset-metadata/dataset-metadata.test.js +24 -0
- package/lib/components/dataset-metadata/index.js +9 -0
- package/lib/components/dataset-preview/connector.js +26 -0
- package/lib/components/dataset-preview/dataset-preview.js +58 -0
- package/lib/components/dataset-preview/dataset-preview.scss +24 -0
- package/lib/components/dataset-preview/dataset-preview.test.js +34 -0
- package/lib/components/dataset-preview/index.js +9 -0
- package/lib/components/dataset-quality/dataset-quality.js +56 -0
- package/lib/components/dataset-quality/dataset-quality.scss +24 -0
- package/lib/components/dataset-quality/dataset-quality.test.js +34 -0
- package/lib/components/dataset-quality/index.js +9 -0
- package/lib/components/dataset-recommendations/connector.js +24 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.js +47 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.scss +17 -0
- package/lib/components/dataset-recommendations/dataset-recommendations.test.js +37 -0
- package/lib/components/dataset-recommendations/index.js +9 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.js +41 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.scss +13 -0
- package/lib/components/detail-toggle-icon/detail-toggle-icon.test.js +20 -0
- package/lib/components/detail-toggle-icon/index.js +9 -0
- package/lib/components/facet-list/facet-list.js +47 -0
- package/lib/components/facet-list/facet-list.scss +19 -0
- package/lib/components/facet-list/facet-list.test.js +94 -0
- package/lib/components/facet-list/index.js +9 -0
- package/lib/components/facet-sidebar/facet-sidebar.js +101 -0
- package/lib/components/facet-sidebar/facet-sidebar.scss +129 -0
- package/lib/components/facet-sidebar/facet-sidebar.test.js +93 -0
- package/lib/components/facet-sidebar/index.js +9 -0
- package/lib/components/generic-elements/alert-component/alert-component.js +51 -0
- package/lib/components/generic-elements/alert-component/alert-component.scss +26 -0
- package/lib/components/generic-elements/alert-component/alert-component.test.js +26 -0
- package/lib/components/generic-elements/alert-component/index.js +9 -0
- package/lib/components/generic-elements/arrow-button/arrow-button.js +30 -0
- package/lib/components/generic-elements/arrow-button/index.js +9 -0
- package/lib/components/generic-elements/auto-anchoring-popover/index.js +61 -0
- package/lib/components/generic-elements/back-button/back-button.js +14 -0
- package/lib/components/generic-elements/back-button/back-button.scss +14 -0
- package/lib/components/generic-elements/back-button/index.js +9 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.js +118 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.scss +19 -0
- package/lib/components/generic-elements/call-to-action-button/call-to-action-button.test.js +68 -0
- package/lib/components/generic-elements/call-to-action-button/index.js +9 -0
- package/lib/components/generic-elements/chart-icon/index.js +23 -0
- package/lib/components/generic-elements/checkbox/checkbox.js +50 -0
- package/lib/components/generic-elements/checkbox/checkbox.scss +44 -0
- package/lib/components/generic-elements/checkbox/checkbox.test.js +71 -0
- package/lib/components/generic-elements/checkbox/index.js +9 -0
- package/lib/components/generic-elements/error-component/error-component.js +21 -0
- package/lib/components/generic-elements/error-component/error-component.scss +16 -0
- package/lib/components/generic-elements/error-component/error-component.test.js +12 -0
- package/lib/components/generic-elements/error-component/index.js +9 -0
- package/lib/components/generic-elements/folder-icon/index.js +23 -0
- package/lib/components/generic-elements/generated-link/generated-link.js +25 -0
- package/lib/components/generic-elements/generated-link/index.js +13 -0
- package/lib/components/generic-elements/loading-element/index.js +9 -0
- package/lib/components/generic-elements/loading-element/loading-element.js +22 -0
- package/lib/components/generic-elements/loading-element/loading-element.scss +6 -0
- package/lib/components/generic-elements/loading-element/loading-element.test.js +11 -0
- package/lib/components/generic-elements/paginator/index.js +9 -0
- package/lib/components/generic-elements/paginator/paginator.js +84 -0
- package/lib/components/generic-elements/paginator/paginator.scss +38 -0
- package/lib/components/generic-elements/paginator/paginator.test.js +140 -0
- package/lib/components/generic-elements/plus-icon/index.js +21 -0
- package/lib/components/generic-elements/save-indicator/index.js +9 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.js +39 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.scss +31 -0
- package/lib/components/generic-elements/save-indicator/save-indicator.test.js +89 -0
- package/lib/components/generic-elements/search/index.js +9 -0
- package/lib/components/generic-elements/search/search.js +93 -0
- package/lib/components/generic-elements/search/search.scss +90 -0
- package/lib/components/generic-elements/search/search.test.js +41 -0
- package/lib/components/generic-elements/select/index.js +9 -0
- package/lib/components/generic-elements/select/select.js +44 -0
- package/lib/components/generic-elements/select/select.scss +22 -0
- package/lib/components/generic-elements/select/select.test.js +34 -0
- package/lib/components/generic-elements/share-link/index.js +9 -0
- package/lib/components/generic-elements/share-link/share-link.js +23 -0
- package/lib/components/generic-elements/share-link/share-link.scss +17 -0
- package/lib/components/generic-elements/share-link/share-link.test.js +28 -0
- package/lib/components/generic-elements/sql-icon/index.js +20 -0
- package/lib/components/generic-elements/tab-button/index.js +9 -0
- package/lib/components/generic-elements/tab-button/tab-button.js +25 -0
- package/lib/components/generic-elements/tab-button/tab-button.scss +27 -0
- package/lib/components/generic-elements/visualize-button/index.js +9 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.js +37 -0
- package/lib/components/generic-elements/visualize-button/visualize-button.scss +14 -0
- package/lib/components/login-zone/connector.js +25 -0
- package/lib/components/login-zone/index.js +9 -0
- package/lib/components/login-zone/login-svgs-and-text.js +39 -0
- package/lib/components/login-zone/login-zone.js +21 -0
- package/lib/components/login-zone/login-zone.scss +115 -0
- package/lib/components/login-zone/login-zone.test.js +17 -0
- package/lib/components/login-zone/login.js +48 -0
- package/lib/components/login-zone/logout.js +39 -0
- package/lib/components/network-loading-element/connector.js +17 -0
- package/lib/components/network-loading-element/index.js +9 -0
- package/lib/components/network-loading-element/network-loading-element.js +23 -0
- package/lib/components/network-loading-element/network-loading-element.scss +21 -0
- package/lib/components/network-loading-element/network-loading-element.test.js +34 -0
- package/lib/components/organization/index.js +9 -0
- package/lib/components/organization/organization.js +27 -0
- package/lib/components/organization/organization.scss +32 -0
- package/lib/components/protected-route/protected-route.js +101 -0
- package/lib/components/protected-route/protected-route.scss +4 -0
- package/lib/components/protected-route/protected-route.test.js +63 -0
- package/lib/components/query-form/index.js +9 -0
- package/lib/components/query-form/query-form.js +262 -0
- package/lib/components/query-form/query-form.scss +167 -0
- package/lib/components/query-form/query-form.test.js +248 -0
- package/lib/components/recommendation-list/index.js +9 -0
- package/lib/components/recommendation-list/recommendation-list.js +72 -0
- package/lib/components/recommendation-list/recommendation-list.scss +61 -0
- package/lib/components/recommendation-list/recommendation-list.test.js +38 -0
- package/lib/components/remote-toggle/__snapshots__/remote-toggle.test.js.snap +3 -0
- package/lib/components/remote-toggle/index.js +13 -0
- package/lib/components/remote-toggle/remote-toggle.js +35 -0
- package/lib/components/remote-toggle/remote-toggle.scss +0 -0
- package/lib/components/remote-toggle/remote-toggle.test.js +10 -0
- package/lib/components/share/index.js +9 -0
- package/lib/components/share/share.js +109 -0
- package/lib/components/share/share.scss +66 -0
- package/lib/components/streaming-api-doc/index.js +9 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.js +76 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.scss +23 -0
- package/lib/components/streaming-api-doc/streaming-api-doc.test.js +24 -0
- package/lib/components/tooltip/index.js +9 -0
- package/lib/components/tooltip/tooltip.js +17 -0
- package/lib/components/tooltip/tooltip.scss +16 -0
- package/lib/components/tooltip/tooltip.test.js +19 -0
- package/lib/components/visualization-list-menu-item/index.js +9 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.js +53 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.scss +21 -0
- package/lib/components/visualization-list-menu-item/visualization-list-menu-item.test.js +42 -0
- package/lib/components/visualization-save-menu-item/index.js +9 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.js +101 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.scss +37 -0
- package/lib/components/visualization-save-menu-item/visualization-save-menu-item.test.js +185 -0
- package/lib/components/visualizations/geojson/connector.js +29 -0
- package/lib/components/visualizations/geojson/geojson-visualization.js +151 -0
- package/lib/components/visualizations/geojson/geojson-visualization.scss +24 -0
- package/lib/components/visualizations/geojson/geojson-visualization.test.js +238 -0
- package/lib/components/visualizations/geojson/index.js +9 -0
- package/lib/pages/apikey-view/apiKey-view.test.js +204 -0
- package/lib/pages/apikey-view/apikey-view.js +166 -0
- package/lib/pages/apikey-view/apikey-view.scss +340 -0
- package/lib/pages/apikey-view/connector.js +31 -0
- package/lib/pages/apikey-view/index.js +9 -0
- package/lib/pages/chart-view/chart-view.js +92 -0
- package/lib/pages/chart-view/chart-view.scss +35 -0
- package/lib/pages/chart-view/chart-view.test.js +206 -0
- package/lib/pages/chart-view/connector.js +30 -0
- package/lib/pages/chart-view/index.js +9 -0
- package/lib/pages/dataset-detail-view/connector.js +38 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view-connector.test.js +42 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.js +99 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.scss +190 -0
- package/lib/pages/dataset-detail-view/dataset-detail-view.test.js +305 -0
- package/lib/pages/dataset-detail-view/index.js +9 -0
- package/lib/pages/dataset-list-view/connector.js +30 -0
- package/lib/pages/dataset-list-view/dataset-list-view.js +132 -0
- package/lib/pages/dataset-list-view/dataset-list-view.scss +242 -0
- package/lib/pages/dataset-list-view/dataset-list-view.test.js +162 -0
- package/lib/pages/dataset-list-view/index.js +9 -0
- package/lib/pages/dataset-view/connector.js +55 -0
- package/lib/pages/dataset-view/dataset-view-connector.test.js +78 -0
- package/lib/pages/dataset-view/dataset-view.js +175 -0
- package/lib/pages/dataset-view/dataset-view.scss +95 -0
- package/lib/pages/dataset-view/dataset-view.test.js +157 -0
- package/lib/pages/dataset-view/index.js +9 -0
- package/lib/pages/login-view/connector.js +25 -0
- package/lib/pages/login-view/index.js +9 -0
- package/lib/pages/login-view/login-view.js +83 -0
- package/lib/pages/login-view/login-view.scss +62 -0
- package/lib/pages/login-view/login-view.test.js +23 -0
- package/lib/pages/oauth-error-view/index.js +9 -0
- package/lib/pages/oauth-error-view/oauth-error-view.js +25 -0
- package/lib/pages/oauth-error-view/oauth-error-view.scss +13 -0
- package/lib/pages/oauth-error-view/oauth-error-view.test.js +13 -0
- package/lib/pages/oauth-view/connector.js +22 -0
- package/lib/pages/oauth-view/index.js +9 -0
- package/lib/pages/oauth-view/oauth-view.js +124 -0
- package/lib/pages/oauth-view/oauth-view.scss +7 -0
- package/lib/pages/oauth-view/oauth-view.test.js +195 -0
- package/lib/pages/query-view/connector.js +40 -0
- package/lib/pages/query-view/index.js +9 -0
- package/lib/pages/query-view/query-view.js +80 -0
- package/lib/pages/query-view/query-view.scss +39 -0
- package/lib/pages/query-view/query-view.test.js +104 -0
- package/lib/pages/user-profile-view/connector.js +39 -0
- package/lib/pages/user-profile-view/index.js +9 -0
- package/lib/pages/user-profile-view/user-profile-view.js +154 -0
- package/lib/pages/user-profile-view/user-profile-view.scss +81 -0
- package/lib/pages/user-profile-view/user-profile-view.test.js +129 -0
- package/lib/pages/visualization-view/connector.js +52 -0
- package/lib/pages/visualization-view/index.js +9 -0
- package/lib/pages/visualization-view/visualization-view-connector.test.js +62 -0
- package/lib/pages/visualization-view/visualization-view.js +128 -0
- package/lib/pages/visualization-view/visualization-view.scss +115 -0
- package/lib/pages/visualization-view/visualization-view.test.js +188 -0
- package/lib/routes.js +18 -0
- package/lib/search-params/search-params-manager.js +171 -0
- package/lib/search-params/search-params-manager.test.js +490 -0
- package/lib/store/actions.js +428 -0
- package/lib/store/dataset-selectors.js +47 -0
- package/lib/store/dataset-selectors.test.js +154 -0
- package/lib/store/query-selectors.js +53 -0
- package/lib/store/query-selectors.test.js +153 -0
- package/lib/store/reducers/index.js +20 -0
- package/lib/store/reducers/query-reducer.js +52 -0
- package/lib/store/reducers/query-reducer.test.js +89 -0
- package/lib/store/reducers/reducers.js +196 -0
- package/lib/store/reducers/reducers.test.js +309 -0
- package/lib/store/reducers/visualization-reducer.js +167 -0
- package/lib/store/reducers/visualization-reducer.test.js +426 -0
- package/lib/store/sagas/api-invoker.js +79 -0
- package/lib/store/sagas/api-invoker.test.js +139 -0
- package/lib/store/sagas/apiKey-saga.js +81 -0
- package/lib/store/sagas/apiKey-saga.test.js +57 -0
- package/lib/store/sagas/dataset-download-saga.js +43 -0
- package/lib/store/sagas/dataset-list-saga.js +49 -0
- package/lib/store/sagas/dataset-list-saga.test.js +72 -0
- package/lib/store/sagas/dataset-preview-saga.js +44 -0
- package/lib/store/sagas/dataset-query-saga.js +43 -0
- package/lib/store/sagas/dataset-recommendation-saga.js +40 -0
- package/lib/store/sagas/dataset-saga.js +50 -0
- package/lib/store/sagas/freestyle-query-saga.js +127 -0
- package/lib/store/sagas/freestyle-query-saga.test.js +145 -0
- package/lib/store/sagas/index.js +44 -0
- package/lib/store/sagas/login-saga.js +85 -0
- package/lib/store/sagas/login-saga.test.js +84 -0
- package/lib/store/sagas/logout-saga.js +96 -0
- package/lib/store/sagas/oauth-saga.js +78 -0
- package/lib/store/sagas/oauth-saga.test.js +51 -0
- package/lib/store/sagas/process-login-saga.js +62 -0
- package/lib/store/sagas/process-login-saga.test.js +83 -0
- package/lib/store/sagas/visualization-saga.js +371 -0
- package/lib/store/sagas/visualization-saga.test.js +388 -0
- package/lib/store/selectors.js +83 -0
- package/lib/store/visualization-selectors.js +85 -0
- package/lib/store/visualization-selectors.test.js +195 -0
- package/lib/styles/mixins.scss +117 -0
- package/lib/styles/variables.scss +41 -0
- package/lib/utils/file-type-utils.js +18 -0
- package/lib/utils/file-type-utils.test.js +29 -0
- package/lib/utils/geojson-utils.js +70 -0
- package/lib/utils/geojson-utils.test.js +129 -0
- package/lib/utils/http-clients.js +218 -0
- package/lib/utils/http-clients.test.js +88 -0
- package/lib/utils/index.js +34 -0
- package/lib/utils/modified-date-string-builder.js +29 -0
- package/lib/utils/modified-date-string-builder.test.js +93 -0
- package/lib/utils/query-string-builder.js +38 -0
- package/lib/utils/query-string-builder.test.js +33 -0
- package/lib/utils/recommendation-utils.js +12 -0
- package/lib/utils/recommendation-utils.test.js +9 -0
- package/package.json +172 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = freestyleQuerySaga;
|
|
8
|
+
var _effects = require("redux-saga/effects");
|
|
9
|
+
var _actions = require("../actions");
|
|
10
|
+
var _selectors = require("../selectors");
|
|
11
|
+
var _httpClients = require("../../utils/http-clients");
|
|
12
|
+
var _querySelectors = require("../query-selectors");
|
|
13
|
+
var _marked = /*#__PURE__*/_regeneratorRuntime().mark(freestyleQuerySaga);
|
|
14
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { throw: 1, return: 2, break: 3, continue: 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, catch: function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
15
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
16
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
17
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
18
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
19
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
20
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
21
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
22
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
23
|
+
var cancelMessage = 'Query cancelled by user';
|
|
24
|
+
var failureMessage = 'There may be a syntax issue or a table name might be misspelled';
|
|
25
|
+
function executeQuery(_ref) {
|
|
26
|
+
var queryText = _ref.queryText;
|
|
27
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
28
|
+
var cancelToken, queryBody, response, catchMessage;
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
cancelToken = _httpClients.AuthenticatedHTTPClient.cancelTokenSource();
|
|
33
|
+
if (!queryText) {
|
|
34
|
+
_context.next = 5;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
queryBody = queryText;
|
|
38
|
+
_context.next = 8;
|
|
39
|
+
break;
|
|
40
|
+
case 5:
|
|
41
|
+
_context.next = 7;
|
|
42
|
+
return (0, _effects.select)(_querySelectors.getFreestyleQueryText);
|
|
43
|
+
case 7:
|
|
44
|
+
queryBody = _context.sent;
|
|
45
|
+
case 8:
|
|
46
|
+
_context.next = 10;
|
|
47
|
+
return (0, _effects.put)((0, _actions.setQueryInProgress)(cancelToken));
|
|
48
|
+
case 10:
|
|
49
|
+
_context.prev = 10;
|
|
50
|
+
_context.next = 13;
|
|
51
|
+
return (0, _effects.call)(_httpClients.AuthenticatedHTTPClient.post, '/api/v1/query', queryBody, {
|
|
52
|
+
cancelToken: cancelToken.token,
|
|
53
|
+
baseURL: window.DISC_API_URL,
|
|
54
|
+
withCredentials: true,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'text/plain'
|
|
57
|
+
},
|
|
58
|
+
validateStatus: false
|
|
59
|
+
});
|
|
60
|
+
case 13:
|
|
61
|
+
response = _context.sent;
|
|
62
|
+
if (!(response.status < 400)) {
|
|
63
|
+
_context.next = 19;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
_context.next = 17;
|
|
67
|
+
return (0, _effects.put)((0, _actions.setQuerySuccess)(response.data));
|
|
68
|
+
case 17:
|
|
69
|
+
_context.next = 21;
|
|
70
|
+
break;
|
|
71
|
+
case 19:
|
|
72
|
+
_context.next = 21;
|
|
73
|
+
return (0, _effects.put)((0, _actions.setQueryFailure)(error_message(response.data.message)));
|
|
74
|
+
case 21:
|
|
75
|
+
_context.next = 28;
|
|
76
|
+
break;
|
|
77
|
+
case 23:
|
|
78
|
+
_context.prev = 23;
|
|
79
|
+
_context.t0 = _context["catch"](10);
|
|
80
|
+
catchMessage = _context.t0.message === cancelMessage ? cancelMessage : failureMessage;
|
|
81
|
+
_context.next = 28;
|
|
82
|
+
return (0, _effects.put)((0, _actions.setQueryFailure)(catchMessage));
|
|
83
|
+
case 28:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
86
|
+
}
|
|
87
|
+
}, _callee, null, [[10, 23]]);
|
|
88
|
+
})();
|
|
89
|
+
}
|
|
90
|
+
var cancelQuery = /*#__PURE__*/_regeneratorRuntime().mark(function cancelQuery() {
|
|
91
|
+
var cancelToken;
|
|
92
|
+
return _regeneratorRuntime().wrap(function cancelQuery$(_context2) {
|
|
93
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
_context2.next = 2;
|
|
96
|
+
return (0, _effects.select)(_selectors.getDatasetQueryCancelToken);
|
|
97
|
+
case 2:
|
|
98
|
+
cancelToken = _context2.sent;
|
|
99
|
+
return _context2.abrupt("return", cancelToken.cancel(cancelMessage));
|
|
100
|
+
case 4:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context2.stop();
|
|
103
|
+
}
|
|
104
|
+
}, cancelQuery);
|
|
105
|
+
});
|
|
106
|
+
function error_message(message) {
|
|
107
|
+
if (message == 'Bad Request') {
|
|
108
|
+
return failureMessage;
|
|
109
|
+
} else {
|
|
110
|
+
return message;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function freestyleQuerySaga() {
|
|
114
|
+
return _regeneratorRuntime().wrap(function freestyleQuerySaga$(_context3) {
|
|
115
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
_context3.next = 2;
|
|
118
|
+
return (0, _effects.takeEvery)(_actions.EXECUTE_FREESTYLE_QUERY, executeQuery);
|
|
119
|
+
case 2:
|
|
120
|
+
_context3.next = 4;
|
|
121
|
+
return (0, _effects.takeEvery)(_actions.CANCEL_FREESTYLE_QUERY, cancelQuery);
|
|
122
|
+
case 4:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context3.stop();
|
|
125
|
+
}
|
|
126
|
+
}, _marked);
|
|
127
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeFreestyleQuery,
|
|
3
|
+
setQuerySuccess,
|
|
4
|
+
setQueryInProgress,
|
|
5
|
+
setQueryFailure,
|
|
6
|
+
cancelFreestyleQuery,
|
|
7
|
+
setQueryText
|
|
8
|
+
} from '../actions'
|
|
9
|
+
import freestyleQuerySaga from './freestyle-query-saga'
|
|
10
|
+
import { createStore, applyMiddleware } from 'redux'
|
|
11
|
+
import createSagaMiddleware from 'redux-saga'
|
|
12
|
+
import { AuthenticatedHTTPClient } from '../../utils/http-clients'
|
|
13
|
+
import oneTrueReducer from '../reducers'
|
|
14
|
+
|
|
15
|
+
const ERROR_MESSAGE_CONSTANT = 'There may be a syntax issue or a table name might be misspelled'
|
|
16
|
+
|
|
17
|
+
const setUpSagaMiddleware = reducer => {
|
|
18
|
+
const sagaMiddleware = createSagaMiddleware()
|
|
19
|
+
const store = createStore(reducer, applyMiddleware(sagaMiddleware))
|
|
20
|
+
sagaMiddleware.run(freestyleQuerySaga)
|
|
21
|
+
|
|
22
|
+
return store
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('freestyle-query-saga', () => {
|
|
26
|
+
let store
|
|
27
|
+
const actionTrackingReducer = (state = [], action) => {
|
|
28
|
+
return [...state, action]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const queryText = 'select * from lettuce'
|
|
32
|
+
const queryData = [{ hello: 'world' }, { hello: 'columbus' }]
|
|
33
|
+
const response = {
|
|
34
|
+
status: 200,
|
|
35
|
+
data: queryData
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
window.DISC_API_URL = 'http://example.com/'
|
|
40
|
+
AuthenticatedHTTPClient.post = jest.fn()
|
|
41
|
+
AuthenticatedHTTPClient.cancelTokenSource = jest.fn(() => ({ token: {} }))
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
jest.resetAllMocks()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('success', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
AuthenticatedHTTPClient.post.mockImplementationOnce(() => (response))
|
|
51
|
+
store = setUpSagaMiddleware(actionTrackingReducer)
|
|
52
|
+
store.dispatch(executeFreestyleQuery(queryText))
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('calls multiple query api with query', () => {
|
|
56
|
+
expect(AuthenticatedHTTPClient.post).toHaveBeenCalledWith('/api/v1/query', queryText, {
|
|
57
|
+
cancelToken: expect.any(Object),
|
|
58
|
+
baseURL: window.DISC_API_URL,
|
|
59
|
+
withCredentials: true,
|
|
60
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
61
|
+
validateStatus: false
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('dispatches a QUERY_DATASET_SUCCEEDED event', () => {
|
|
66
|
+
expect(store.getState()).toContainEqual(setQuerySuccess(queryData))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('dispatches a QUERY_DATASET_IN_PROGRESS event', () => {
|
|
70
|
+
expect(store.getState()).toContainEqual(setQueryInProgress({ token: {} }))
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('failure', () => {
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
store = setUpSagaMiddleware(actionTrackingReducer)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('dispatches a QUERY_DATASET_FAILED event based on 400 code', () => {
|
|
80
|
+
const mock_error_message = 'bad things happened'
|
|
81
|
+
const data = { message: mock_error_message }
|
|
82
|
+
const response = {
|
|
83
|
+
status: 400,
|
|
84
|
+
data
|
|
85
|
+
}
|
|
86
|
+
AuthenticatedHTTPClient.post.mockImplementationOnce(() => (response))
|
|
87
|
+
|
|
88
|
+
store.dispatch(executeFreestyleQuery(queryText))
|
|
89
|
+
|
|
90
|
+
expect(store.getState()).toContainEqual(setQueryFailure(mock_error_message))
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('dispatches a QUERY_DATASET_FAILED event on a catastrophic failure', () => {
|
|
94
|
+
const errorMsg = "It's all over"
|
|
95
|
+
|
|
96
|
+
AuthenticatedHTTPClient.post.mockImplementationOnce(() => { throw new Error(errorMsg) })
|
|
97
|
+
|
|
98
|
+
store.dispatch(executeFreestyleQuery(queryText))
|
|
99
|
+
|
|
100
|
+
expect(store.getState()).toContainEqual(setQueryFailure(ERROR_MESSAGE_CONSTANT))
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
describe('without provided query text', () => {
|
|
105
|
+
const queryTextInStore = 'select * from cabbage'
|
|
106
|
+
beforeEach(() => {
|
|
107
|
+
store = setUpSagaMiddleware(oneTrueReducer)
|
|
108
|
+
|
|
109
|
+
AuthenticatedHTTPClient.post.mockImplementationOnce(() => (response))
|
|
110
|
+
|
|
111
|
+
store.dispatch(setQueryText(queryTextInStore))
|
|
112
|
+
store.dispatch(executeFreestyleQuery())
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('calls multiple query api with the query from store', () => {
|
|
116
|
+
expect(AuthenticatedHTTPClient.post).toHaveBeenCalledWith('/api/v1/query', queryTextInStore, {
|
|
117
|
+
cancelToken: expect.any(Object),
|
|
118
|
+
baseURL: window.DISC_API_URL,
|
|
119
|
+
withCredentials: true,
|
|
120
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
121
|
+
validateStatus: false
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
describe('freestyle-query-saga QUERY_DATASET_CANCELLED event', () => {
|
|
128
|
+
let store
|
|
129
|
+
let cancelMock
|
|
130
|
+
|
|
131
|
+
beforeEach(() => {
|
|
132
|
+
store = setUpSagaMiddleware(oneTrueReducer)
|
|
133
|
+
AuthenticatedHTTPClient.cancelTokenSource = jest.fn(() => ({ token: {} }))
|
|
134
|
+
|
|
135
|
+
cancelMock = jest.fn()
|
|
136
|
+
const cancelToken = { token: {}, cancel: cancelMock }
|
|
137
|
+
|
|
138
|
+
store.dispatch(setQueryInProgress(cancelToken))
|
|
139
|
+
store.dispatch(cancelFreestyleQuery())
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('cancels the query', () => {
|
|
143
|
+
expect(cancelMock).toHaveBeenCalled()
|
|
144
|
+
})
|
|
145
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = allSagas;
|
|
8
|
+
var _effects = require("redux-saga/effects");
|
|
9
|
+
var _datasetListSaga = _interopRequireDefault(require("./dataset-list-saga"));
|
|
10
|
+
var _datasetSaga = _interopRequireDefault(require("./dataset-saga"));
|
|
11
|
+
var _datasetPreviewSaga = _interopRequireDefault(require("./dataset-preview-saga"));
|
|
12
|
+
var _loginSaga = _interopRequireDefault(require("./login-saga"));
|
|
13
|
+
var _processLoginSaga = _interopRequireDefault(require("./process-login-saga"));
|
|
14
|
+
var _logoutSaga = _interopRequireDefault(require("./logout-saga"));
|
|
15
|
+
var _datasetDownloadSaga = _interopRequireDefault(require("./dataset-download-saga"));
|
|
16
|
+
var _datasetQuerySaga = _interopRequireDefault(require("./dataset-query-saga"));
|
|
17
|
+
var _freestyleQuerySaga = _interopRequireDefault(require("./freestyle-query-saga"));
|
|
18
|
+
var _visualizationSaga = _interopRequireDefault(require("./visualization-saga"));
|
|
19
|
+
var _datasetRecommendationSaga = _interopRequireDefault(require("./dataset-recommendation-saga"));
|
|
20
|
+
var _oauthSaga = _interopRequireDefault(require("./oauth-saga"));
|
|
21
|
+
var _apiKeySaga = _interopRequireDefault(require("./apiKey-saga"));
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { throw: 1, return: 2, break: 3, continue: 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, catch: function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
24
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
25
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
26
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
27
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
28
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
29
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
30
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
31
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
32
|
+
var _marked = /*#__PURE__*/_regeneratorRuntime().mark(allSagas);
|
|
33
|
+
function allSagas() {
|
|
34
|
+
return _regeneratorRuntime().wrap(function allSagas$(_context) {
|
|
35
|
+
while (1) switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
_context.next = 2;
|
|
38
|
+
return (0, _effects.all)([(0, _effects.fork)(_datasetListSaga.default), (0, _effects.fork)(_datasetSaga.default), (0, _effects.fork)(_datasetPreviewSaga.default), (0, _effects.fork)(_loginSaga.default), (0, _effects.fork)(_processLoginSaga.default), (0, _effects.fork)(_logoutSaga.default), (0, _effects.fork)(_datasetDownloadSaga.default), (0, _effects.fork)(_datasetQuerySaga.default), (0, _effects.fork)(_freestyleQuerySaga.default), (0, _effects.fork)(_visualizationSaga.default), (0, _effects.fork)(_datasetRecommendationSaga.default), (0, _effects.fork)(_oauthSaga.default), (0, _effects.fork)(_apiKeySaga.default)]);
|
|
39
|
+
case 2:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}, _marked);
|
|
44
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = loginSaga;
|
|
8
|
+
var _effects = require("redux-saga/effects");
|
|
9
|
+
var _actions = require("../actions");
|
|
10
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
var _marked = /*#__PURE__*/_regeneratorRuntime().mark(loginSaga);
|
|
13
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { throw: 1, return: 2, break: 3, continue: 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, catch: function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
14
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
15
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
16
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
17
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
18
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
19
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
20
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
21
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
22
|
+
function login(_ref) {
|
|
23
|
+
var _ref$value = _ref.value,
|
|
24
|
+
username = _ref$value.username,
|
|
25
|
+
password = _ref$value.password,
|
|
26
|
+
history = _ref$value.history;
|
|
27
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
28
|
+
var response;
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
_context.prev = 0;
|
|
33
|
+
_context.next = 3;
|
|
34
|
+
return (0, _effects.call)(_axios.default.get, '/api/v1/login', {
|
|
35
|
+
baseURL: window.DISC_API_URL,
|
|
36
|
+
auth: {
|
|
37
|
+
username: username,
|
|
38
|
+
password: password
|
|
39
|
+
},
|
|
40
|
+
withCredentials: true
|
|
41
|
+
});
|
|
42
|
+
case 3:
|
|
43
|
+
response = _context.sent;
|
|
44
|
+
if (!(response.status === 200)) {
|
|
45
|
+
_context.next = 9;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
_context.next = 7;
|
|
49
|
+
return (0, _effects.put)((0, _actions.loginSuccess)({
|
|
50
|
+
token: response.headers.token,
|
|
51
|
+
history: history
|
|
52
|
+
}));
|
|
53
|
+
case 7:
|
|
54
|
+
_context.next = 11;
|
|
55
|
+
break;
|
|
56
|
+
case 9:
|
|
57
|
+
_context.next = 11;
|
|
58
|
+
return (0, _effects.put)((0, _actions.loginFailure)(response.data));
|
|
59
|
+
case 11:
|
|
60
|
+
_context.next = 17;
|
|
61
|
+
break;
|
|
62
|
+
case 13:
|
|
63
|
+
_context.prev = 13;
|
|
64
|
+
_context.t0 = _context["catch"](0);
|
|
65
|
+
_context.next = 17;
|
|
66
|
+
return (0, _effects.put)((0, _actions.loginFailure)(_context.t0.message));
|
|
67
|
+
case 17:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee, null, [[0, 13]]);
|
|
72
|
+
})();
|
|
73
|
+
}
|
|
74
|
+
function loginSaga() {
|
|
75
|
+
return _regeneratorRuntime().wrap(function loginSaga$(_context2) {
|
|
76
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
_context2.next = 2;
|
|
79
|
+
return (0, _effects.takeLatest)(_actions.LOGIN, login);
|
|
80
|
+
case 2:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context2.stop();
|
|
83
|
+
}
|
|
84
|
+
}, _marked);
|
|
85
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { login, loginSuccess, loginFailure } from '../actions'
|
|
2
|
+
import loginSaga from './login-saga'
|
|
3
|
+
import mockAxios from 'axios'
|
|
4
|
+
import { createStore, applyMiddleware } from 'redux'
|
|
5
|
+
import createSagaMiddleware from 'redux-saga'
|
|
6
|
+
|
|
7
|
+
describe('login-saga', () => {
|
|
8
|
+
let store
|
|
9
|
+
let sagaMiddleware
|
|
10
|
+
const reducer = (state = [], action) => {
|
|
11
|
+
return [...state, action]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const username = 'lettuce'
|
|
15
|
+
const password = 'tarpsoff99'
|
|
16
|
+
const token = 'sus'
|
|
17
|
+
const history = jest.fn()
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
window.DISC_API_URL = 'http://example.com/'
|
|
21
|
+
|
|
22
|
+
sagaMiddleware = createSagaMiddleware()
|
|
23
|
+
store = createStore(reducer, applyMiddleware(sagaMiddleware))
|
|
24
|
+
sagaMiddleware.run(loginSaga)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
jest.resetAllMocks()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('success', () => {
|
|
32
|
+
const data = 'lettuce logged in.'
|
|
33
|
+
const response = {
|
|
34
|
+
status: 200,
|
|
35
|
+
headers: {
|
|
36
|
+
token: token
|
|
37
|
+
},
|
|
38
|
+
data: data
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
mockAxios.get.mockImplementationOnce(() => (response))
|
|
43
|
+
|
|
44
|
+
store.dispatch(login({ username, password, history }))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('calls login api with the correct credentials', () => {
|
|
48
|
+
expect(mockAxios.get).toHaveBeenCalledWith('/api/v1/login', {
|
|
49
|
+
baseURL: window.DISC_API_URL,
|
|
50
|
+
auth: { username, password },
|
|
51
|
+
withCredentials: true
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('dispatches a LOGIN_SUCCESS event based on success', () => {
|
|
56
|
+
expect(store.getState()).toContainEqual(loginSuccess({ token, history }))
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('failure', () => {
|
|
61
|
+
const data = 'lettuce failed to log in.'
|
|
62
|
+
|
|
63
|
+
it('dispatches a LOGIN_FAILURE event based on 401 code', () => {
|
|
64
|
+
const response = {
|
|
65
|
+
status: 401,
|
|
66
|
+
data: data
|
|
67
|
+
}
|
|
68
|
+
mockAxios.get.mockImplementationOnce(() => (response))
|
|
69
|
+
|
|
70
|
+
store.dispatch(login({ username, password }))
|
|
71
|
+
|
|
72
|
+
expect(store.getState()).toContainEqual(loginFailure(data))
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('dispatches a LOGIN_FAILURE event on a catastrophic failure', () => {
|
|
76
|
+
const errorMsg = "It's all over"
|
|
77
|
+
mockAxios.get.mockImplementationOnce(() => { throw new Error(errorMsg) })
|
|
78
|
+
|
|
79
|
+
store.dispatch(login({ username, password }))
|
|
80
|
+
|
|
81
|
+
expect(store.getState()).toContainEqual(loginFailure(errorMsg))
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = logoutSaga;
|
|
8
|
+
var _effects = require("redux-saga/effects");
|
|
9
|
+
var _actions = require("../actions");
|
|
10
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
var _marked = /*#__PURE__*/_regeneratorRuntime().mark(logoutSaga);
|
|
13
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { throw: 1, return: 2, break: 3, continue: 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, catch: function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
14
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
15
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
16
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
17
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
18
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
19
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
20
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
21
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
22
|
+
function logout(_ref) {
|
|
23
|
+
var _ref$value = _ref.value,
|
|
24
|
+
username = _ref$value.username,
|
|
25
|
+
password = _ref$value.password,
|
|
26
|
+
history = _ref$value.history;
|
|
27
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
28
|
+
var token, location, response;
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
_context.prev = 0;
|
|
33
|
+
token = sessionStorage.getItem('api-token');
|
|
34
|
+
location = _.get(history, 'location.state.from', {
|
|
35
|
+
pathname: '/',
|
|
36
|
+
search: ''
|
|
37
|
+
});
|
|
38
|
+
_context.next = 5;
|
|
39
|
+
return (0, _effects.call)(_axios.default.get, '/api/v1/logout', {
|
|
40
|
+
baseURL: window.DISC_API_URL,
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: "Bearer ".concat(token)
|
|
43
|
+
},
|
|
44
|
+
withCredentials: true
|
|
45
|
+
});
|
|
46
|
+
case 5:
|
|
47
|
+
response = _context.sent;
|
|
48
|
+
if (!(response.status === 200)) {
|
|
49
|
+
_context.next = 14;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
_context.next = 9;
|
|
53
|
+
return (0, _effects.put)((0, _actions.logoutSuccess)({
|
|
54
|
+
token: response.headers.token,
|
|
55
|
+
history: history
|
|
56
|
+
}));
|
|
57
|
+
case 9:
|
|
58
|
+
sessionStorage.removeItem('api-token');
|
|
59
|
+
_context.next = 12;
|
|
60
|
+
return history.push({
|
|
61
|
+
pathname: location.pathname,
|
|
62
|
+
search: location.search
|
|
63
|
+
});
|
|
64
|
+
case 12:
|
|
65
|
+
_context.next = 16;
|
|
66
|
+
break;
|
|
67
|
+
case 14:
|
|
68
|
+
_context.next = 16;
|
|
69
|
+
return (0, _effects.put)((0, _actions.logoutFailure)(response.data));
|
|
70
|
+
case 16:
|
|
71
|
+
_context.next = 22;
|
|
72
|
+
break;
|
|
73
|
+
case 18:
|
|
74
|
+
_context.prev = 18;
|
|
75
|
+
_context.t0 = _context["catch"](0);
|
|
76
|
+
_context.next = 22;
|
|
77
|
+
return (0, _effects.put)((0, _actions.logoutFailure)(_context.t0.message));
|
|
78
|
+
case 22:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee, null, [[0, 18]]);
|
|
83
|
+
})();
|
|
84
|
+
}
|
|
85
|
+
function logoutSaga() {
|
|
86
|
+
return _regeneratorRuntime().wrap(function logoutSaga$(_context2) {
|
|
87
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
88
|
+
case 0:
|
|
89
|
+
_context2.next = 2;
|
|
90
|
+
return (0, _effects.takeLatest)(_actions.LOGOUT, logout);
|
|
91
|
+
case 2:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context2.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _marked);
|
|
96
|
+
}
|