@jetbrains/ring-ui-built 7.0.0-beta.1 → 7.0.0-beta.11
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/components/_helpers/_rollupPluginBabelHelpers.js +1 -504
- package/components/_helpers/anchor.js +7 -10
- package/components/_helpers/button__classes.js +23 -20
- package/components/_helpers/caption.js +11 -21
- package/components/_helpers/card.js +91 -123
- package/components/_helpers/dialog__body-scroll-preventer.js +10 -17
- package/components/_helpers/header.js +1 -1
- package/components/_helpers/icon__svg.js +27 -29
- package/components/_helpers/input.js +151 -193
- package/components/_helpers/query-assist__suggestions.js +79 -94
- package/components/_helpers/select__filter.js +56 -75
- package/components/_helpers/services-link.js +23 -39
- package/components/_helpers/sidebar.js +91 -102
- package/components/_helpers/tab-link.js +8 -12
- package/components/_helpers/theme.js +61 -51
- package/components/_helpers/title.js +59 -84
- package/components/alert/alert.d.ts +7 -24
- package/components/alert/alert.js +111 -179
- package/components/alert/container.d.ts +0 -5
- package/components/alert/container.js +32 -44
- package/components/alert-service/alert-service.js +104 -162
- package/components/analytics/analytics.js +12 -20
- package/components/analytics/analytics__custom-plugin.js +52 -68
- package/components/auth/auth.js +2 -31
- package/components/auth/auth__core.d.ts +4 -4
- package/components/auth/auth__core.js +755 -1433
- package/components/auth/background-flow.js +84 -121
- package/components/auth/down-notification.js +32 -79
- package/components/auth/iframe-flow.js +71 -125
- package/components/auth/request-builder.js +46 -77
- package/components/auth/response-parser.js +84 -112
- package/components/auth/storage.js +162 -324
- package/components/auth/token-validator.js +132 -227
- package/components/auth/window-flow.js +84 -121
- package/components/auth-dialog/auth-dialog.d.ts +0 -18
- package/components/auth-dialog/auth-dialog.js +107 -176
- package/components/auth-dialog-service/auth-dialog-service.js +12 -33
- package/components/avatar/avatar-example-datauri.js +1 -1
- package/components/avatar/avatar.d.ts +0 -13
- package/components/avatar/avatar.js +94 -136
- package/components/avatar/fallback-avatar.d.ts +1 -10
- package/components/avatar/fallback-avatar.js +20 -40
- package/components/badge/badge.d.ts +0 -10
- package/components/badge/badge.js +32 -48
- package/components/breadcrumbs/breadcrumbs.js +13 -17
- package/components/button/button.d.ts +0 -21
- package/components/button/button.js +68 -104
- package/components/button/button__classes.d.ts +1 -1
- package/components/button-group/button-group.d.ts +0 -5
- package/components/button-group/button-group.js +27 -41
- package/components/button-group/caption.d.ts +0 -4
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.d.ts +0 -6
- package/components/button-set/button-set.js +19 -33
- package/components/button-toolbar/button-toolbar.d.ts +0 -6
- package/components/button-toolbar/button-toolbar.js +17 -31
- package/components/caret/caret.js +184 -211
- package/components/checkbox/checkbox.d.ts +0 -19
- package/components/checkbox/checkbox.js +69 -104
- package/components/clipboard/clipboard-fallback.js +7 -7
- package/components/clipboard/clipboard.js +36 -129
- package/components/code/code.d.ts +0 -12
- package/components/code/code.js +83 -163
- package/components/collapse/collapse-content.js +42 -60
- package/components/collapse/collapse-context.js +2 -2
- package/components/collapse/collapse-control.js +12 -12
- package/components/collapse/collapse.js +12 -17
- package/components/collapse/consts.js +4 -4
- package/components/collapse/utils.js +1 -3
- package/components/confirm/confirm.d.ts +0 -14
- package/components/confirm/confirm.js +68 -112
- package/components/confirm-service/confirm-service.js +25 -47
- package/components/content-layout/content-layout.d.ts +0 -7
- package/components/content-layout/content-layout.js +41 -63
- package/components/content-layout/sidebar.d.ts +0 -9
- package/components/content-layout/sidebar.js +1 -2
- package/components/contenteditable/contenteditable.d.ts +1 -22
- package/components/contenteditable/contenteditable.js +37 -60
- package/components/control-help/control-help.js +5 -3
- package/components/control-label/control-label.js +9 -14
- package/components/data-list/data-list.d.ts +0 -2
- package/components/data-list/data-list.js +115 -179
- package/components/data-list/data-list.mock.js +3 -6
- package/components/data-list/item.js +119 -165
- package/components/data-list/selection.js +77 -135
- package/components/data-list/title.d.ts +2 -2
- package/components/data-list/title.js +2 -12
- package/components/date-picker/consts.d.ts +0 -2
- package/components/date-picker/consts.js +16 -24
- package/components/date-picker/date-input.d.ts +0 -20
- package/components/date-picker/date-input.js +100 -148
- package/components/date-picker/date-picker.d.ts +0 -29
- package/components/date-picker/date-picker.js +143 -224
- package/components/date-picker/date-popup.d.ts +0 -22
- package/components/date-picker/date-popup.js +282 -352
- package/components/date-picker/day.d.ts +0 -14
- package/components/date-picker/day.js +72 -109
- package/components/date-picker/month-names.d.ts +1 -11
- package/components/date-picker/month-names.js +42 -72
- package/components/date-picker/month-slider.d.ts +0 -9
- package/components/date-picker/month-slider.js +43 -71
- package/components/date-picker/month.d.ts +1 -9
- package/components/date-picker/month.js +18 -30
- package/components/date-picker/months.d.ts +1 -9
- package/components/date-picker/months.js +45 -55
- package/components/date-picker/weekdays.d.ts +2 -8
- package/components/date-picker/weekdays.js +12 -25
- package/components/date-picker/years.d.ts +0 -6
- package/components/date-picker/years.js +77 -104
- package/components/dialog/dialog.d.ts +0 -20
- package/components/dialog/dialog.js +153 -211
- package/components/dialog/dialog__body-scroll-preventer.js +0 -3
- package/components/dropdown/anchor.d.ts +1 -8
- package/components/dropdown/anchor.js +0 -7
- package/components/dropdown/dropdown.d.ts +4 -22
- package/components/dropdown/dropdown.js +134 -176
- package/components/dropdown-menu/dropdown-menu.js +51 -103
- package/components/editable-heading/editable-heading.js +69 -118
- package/components/error-bubble/error-bubble.d.ts +0 -6
- package/components/error-bubble/error-bubble.js +30 -60
- package/components/error-message/error-message.d.ts +0 -10
- package/components/error-message/error-message.js +34 -59
- package/components/footer/footer.js +28 -44
- package/components/form/form.js +1 -1
- package/components/global/compose.js +1 -8
- package/components/global/composeRefs.d.ts +0 -3
- package/components/global/composeRefs.js +8 -15
- package/components/global/controls-height.js +2 -2
- package/components/global/create-stateful-context.d.ts +0 -4
- package/components/global/create-stateful-context.js +14 -17
- package/components/global/data-tests.js +7 -12
- package/components/global/dom.js +49 -82
- package/components/global/focus-sensor-hoc.js +95 -122
- package/components/global/fuzzy-highlight.js +23 -34
- package/components/global/get-event-key.js +8 -8
- package/components/global/get-uid.js +3 -7
- package/components/global/inject-styles.js +7 -14
- package/components/global/listeners.js +28 -47
- package/components/global/memoize.js +6 -10
- package/components/global/normalize-indent.js +19 -46
- package/components/global/promise-with-timeout.js +6 -8
- package/components/global/react-dom-renderer.d.ts +0 -5
- package/components/global/react-dom-renderer.js +29 -45
- package/components/global/rerender-hoc.d.ts +2 -2
- package/components/global/rerender-hoc.js +16 -32
- package/components/global/schedule-raf.js +4 -4
- package/components/global/sniffer.js +1 -1
- package/components/global/theme.d.ts +8 -2
- package/components/global/theme.js +2 -20
- package/components/global/trivial-template-tag.js +4 -9
- package/components/global/typescript-utils.js +2 -6
- package/components/global/url.js +20 -23
- package/components/global/use-event-callback.js +7 -4
- package/components/grid/col.d.ts +0 -14
- package/components/grid/col.js +27 -53
- package/components/grid/grid.d.ts +0 -5
- package/components/grid/grid.js +20 -32
- package/components/grid/row.d.ts +0 -18
- package/components/grid/row.js +23 -47
- package/components/group/group.d.ts +0 -5
- package/components/group/group.js +18 -27
- package/components/header/header-icon.d.ts +0 -22
- package/components/header/header-icon.js +20 -37
- package/components/header/header.d.ts +0 -7
- package/components/header/header.js +30 -74
- package/components/header/links.d.ts +2 -0
- package/components/header/links.js +20 -0
- package/components/header/logo.d.ts +0 -4
- package/components/header/logo.js +15 -30
- package/components/header/profile.d.ts +1 -39
- package/components/header/profile.js +126 -191
- package/components/header/services-link.d.ts +0 -10
- package/components/header/services-link.js +1 -4
- package/components/header/services.d.ts +0 -14
- package/components/header/services.js +65 -110
- package/components/header/smart-profile.d.ts +0 -9
- package/components/header/smart-profile.js +116 -205
- package/components/header/smart-services.d.ts +0 -4
- package/components/header/smart-services.js +72 -141
- package/components/header/tray.d.ts +0 -5
- package/components/header/tray.js +21 -35
- package/components/heading/heading.js +21 -26
- package/components/http/http.js +162 -319
- package/components/http/http.mock.js +50 -98
- package/components/hub-source/hub-source.js +77 -182
- package/components/hub-source/hub-source__user.js +9 -37
- package/components/hub-source/hub-source__users-groups.js +34 -60
- package/components/i18n/i18n-context.js +7 -8
- package/components/i18n/i18n.js +3 -6
- package/components/icon/icon.d.ts +0 -11
- package/components/icon/icon.js +60 -85
- package/components/icon/icon__svg.d.ts +0 -8
- package/components/icon/icon__svg.js +0 -6
- package/components/icon/index.js +0 -6
- package/components/input/input-legacy.js +1 -1
- package/components/input/input.js +2 -14
- package/components/input-size/input-size.js +1 -1
- package/components/island/adaptive-island-hoc.d.ts +0 -1
- package/components/island/adaptive-island-hoc.js +30 -39
- package/components/island/content.d.ts +0 -10
- package/components/island/content.js +99 -119
- package/components/island/header.js +55 -73
- package/components/island/island.d.ts +0 -9
- package/components/island/island.js +25 -41
- package/components/island-legacy/content-legacy.d.ts +0 -5
- package/components/island-legacy/content-legacy.js +16 -27
- package/components/island-legacy/header-legacy.d.ts +0 -5
- package/components/island-legacy/header-legacy.js +19 -30
- package/components/island-legacy/island-legacy.d.ts +0 -5
- package/components/island-legacy/island-legacy.js +16 -27
- package/components/link/clickableLink.d.ts +0 -9
- package/components/link/clickableLink.js +33 -51
- package/components/link/link.d.ts +0 -25
- package/components/link/link.js +47 -68
- package/components/list/consts.js +2 -2
- package/components/list/list.d.ts +0 -32
- package/components/list/list.js +399 -516
- package/components/list/list__custom.js +51 -78
- package/components/list/list__hint.d.ts +0 -4
- package/components/list/list__hint.js +8 -21
- package/components/list/list__item.js +147 -211
- package/components/list/list__link.js +39 -59
- package/components/list/list__separator.js +15 -30
- package/components/list/list__title.js +25 -41
- package/components/list/list__users-groups-source.js +55 -123
- package/components/loader/loader.d.ts +0 -10
- package/components/loader/loader.js +38 -70
- package/components/loader/loader__core.js +123 -184
- package/components/loader-inline/loader-inline.d.ts +0 -6
- package/components/loader-inline/loader-inline.js +24 -38
- package/components/loader-screen/loader-screen.d.ts +0 -6
- package/components/loader-screen/loader-screen.js +24 -46
- package/components/login-dialog/login-dialog.d.ts +0 -11
- package/components/login-dialog/login-dialog.js +94 -145
- package/components/login-dialog/service.js +11 -33
- package/components/markdown/markdown.js +16 -29
- package/components/message/message.js +171 -218
- package/components/old-browsers-message/old-browsers-message.js +11 -14
- package/components/old-browsers-message/old-browsers-message__stop.js +1 -4
- package/components/old-browsers-message/white-list.js +8 -13
- package/components/pager/pager.js +211 -275
- package/components/panel/panel.d.ts +0 -5
- package/components/panel/panel.js +16 -27
- package/components/permissions/permissions.js +118 -161
- package/components/permissions/permissions__cache.js +191 -218
- package/components/popup/popup.consts.js +1 -1
- package/components/popup/popup.js +237 -329
- package/components/popup/popup.target.js +9 -12
- package/components/popup/position.js +94 -101
- package/components/popup-menu/popup-menu.js +31 -76
- package/components/progress-bar/progress-bar.d.ts +19 -33
- package/components/progress-bar/progress-bar.js +55 -99
- package/components/query-assist/query-assist.d.ts +63 -93
- package/components/query-assist/query-assist.js +585 -748
- package/components/query-assist/query-assist__suggestions.js +2 -28
- package/components/radio/radio.d.ts +0 -8
- package/components/radio/radio.js +15 -35
- package/components/radio/radio__item.d.ts +0 -9
- package/components/radio/radio__item.js +52 -72
- package/components/scrollable-section/scrollable-section.js +53 -0
- package/components/select/select.d.ts +3 -0
- package/components/select/select.js +714 -863
- package/components/select/select__filter.js +2 -29
- package/components/select/select__popup.js +317 -465
- package/components/shortcuts/core.js +147 -195
- package/components/shortcuts/shortcut-title.js +6 -10
- package/components/shortcuts/shortcuts-hoc.d.ts +0 -5
- package/components/shortcuts/shortcuts-hoc.js +23 -46
- package/components/shortcuts/shortcuts.d.ts +0 -8
- package/components/shortcuts/shortcuts.js +41 -72
- package/components/slider/slider.js +93 -113
- package/components/slider/slider.utils.js +16 -23
- package/components/storage/storage.d.ts +2 -3
- package/components/storage/storage.js +2 -46
- package/components/storage/storage__local.js +89 -148
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +35 -61
- package/components/table/cell.d.ts +0 -6
- package/components/table/cell.js +11 -27
- package/components/table/disable-hover-hoc.d.ts +0 -1
- package/components/table/disable-hover-hoc.js +27 -42
- package/components/table/header-cell.d.ts +0 -10
- package/components/table/header-cell.js +59 -85
- package/components/table/header.d.ts +1 -23
- package/components/table/header.js +89 -126
- package/components/table/multitable.d.ts +0 -4
- package/components/table/multitable.js +83 -93
- package/components/table/row-with-focus-sensor.d.ts +2 -2
- package/components/table/row-with-focus-sensor.js +26 -60
- package/components/table/row.js +170 -235
- package/components/table/selection-adapter.js +2 -2
- package/components/table/selection-shortcuts-hoc.js +102 -126
- package/components/table/selection.js +150 -217
- package/components/table/simple-table.d.ts +0 -44
- package/components/table/simple-table.js +18 -59
- package/components/table/smart-table.d.ts +0 -48
- package/components/table/smart-table.js +41 -83
- package/components/table/table.d.ts +0 -2
- package/components/table/table.js +269 -377
- package/components/tabs/collapsible-more.d.ts +1 -9
- package/components/tabs/collapsible-more.js +47 -97
- package/components/tabs/collapsible-tab.js +32 -44
- package/components/tabs/collapsible-tabs.d.ts +2 -29
- package/components/tabs/collapsible-tabs.js +89 -161
- package/components/tabs/custom-item.d.ts +1 -7
- package/components/tabs/custom-item.js +4 -7
- package/components/tabs/dumb-tabs.d.ts +0 -11
- package/components/tabs/dumb-tabs.js +60 -104
- package/components/tabs/smart-tabs.d.ts +0 -6
- package/components/tabs/smart-tabs.js +29 -68
- package/components/tabs/tab-link.d.ts +0 -8
- package/components/tabs/tab-link.js +1 -4
- package/components/tabs/tab.d.ts +0 -8
- package/components/tabs/tab.js +14 -32
- package/components/tabs/tabs.js +1 -28
- package/components/tag/tag.d.ts +0 -19
- package/components/tag/tag.js +120 -179
- package/components/tags-input/tags-input.d.ts +7 -33
- package/components/tags-input/tags-input.js +224 -339
- package/components/tags-list/tags-list.d.ts +0 -13
- package/components/tags-list/tags-list.js +45 -74
- package/components/text/text.d.ts +0 -7
- package/components/text/text.js +27 -43
- package/components/toggle/toggle.d.ts +0 -15
- package/components/toggle/toggle.js +52 -77
- package/components/tooltip/tooltip.d.ts +4 -10
- package/components/tooltip/tooltip.js +105 -137
- package/components/user-agreement/service.d.ts +2 -1
- package/components/user-agreement/service.js +260 -405
- package/components/user-agreement/user-agreement.d.ts +0 -18
- package/components/user-agreement/user-agreement.js +92 -138
- package/components/user-card/card.d.ts +0 -35
- package/components/user-card/card.js +2 -27
- package/components/user-card/smart-user-card-tooltip.d.ts +0 -5
- package/components/user-card/smart-user-card-tooltip.js +52 -108
- package/components/user-card/tooltip.d.ts +0 -9
- package/components/user-card/tooltip.js +35 -74
- package/components/user-card/user-card.js +1 -26
- package/package.json +4 -6
- package/components/global/prop-types.d.ts +0 -4
- package/components/global/prop-types.js +0 -9
- package/components/global/react-render-adapter.d.ts +0 -1
- package/components/global/react-render-adapter.js +0 -6
- package/components/header/scrollable-section.js +0 -47
- package/components/header/tray-icon.d.ts +0 -1
- package/components/header/tray-icon.js +0 -26
- package/components/storage/storage__fallback.d.ts +0 -79
- package/components/storage/storage__fallback.js +0 -253
- /package/components/{header → scrollable-section}/scrollable-section.d.ts +0 -0
package/components/http/http.js
CHANGED
@@ -1,376 +1,219 @@
|
|
1
|
-
import {
|
2
|
-
import 'core-js/modules/es.array.concat.js';
|
3
|
-
import 'core-js/modules/es.array.index-of.js';
|
4
|
-
import 'core-js/modules/es.array.iterator.js';
|
5
|
-
import 'core-js/modules/es.object.entries.js';
|
6
|
-
import 'core-js/modules/es.object.to-string.js';
|
7
|
-
import 'core-js/modules/es.promise.js';
|
8
|
-
import 'core-js/modules/es.reflect.delete-property.js';
|
9
|
-
import 'core-js/modules/es.weak-map.js';
|
10
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
1
|
+
import { _ as _defineProperty, a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
11
2
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
12
3
|
import ExtendableError from 'es6-error';
|
13
4
|
import { encodeURL, joinBaseURLAndPath } from '../global/url.js';
|
14
5
|
import 'core-js/modules/es.regexp.exec.js';
|
15
|
-
import 'core-js/modules/es.string.match.js';
|
16
6
|
import 'core-js/modules/es.string.replace.js';
|
17
7
|
|
18
|
-
|
8
|
+
const _excluded = ["body", "query"],
|
19
9
|
_excluded2 = ["headers"],
|
20
10
|
_excluded3 = ["headers", "body", "query", "sendRawBody"];
|
21
11
|
/**
|
22
12
|
* @name HTTP
|
23
13
|
*/
|
24
|
-
|
25
|
-
|
14
|
+
const TOKEN_TYPE = 'Bearer';
|
15
|
+
const defaultFetchConfig = {
|
26
16
|
headers: {
|
27
17
|
'Content-Type': 'application/json',
|
28
18
|
Accept: 'application/json'
|
29
19
|
},
|
30
20
|
credentials: 'same-origin'
|
31
21
|
};
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
_this.data = data;
|
41
|
-
_this.status = response.status;
|
42
|
-
return _this;
|
22
|
+
class HTTPError extends ExtendableError {
|
23
|
+
constructor(response) {
|
24
|
+
let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
25
|
+
super("".concat(response.status, " ").concat(response.statusText || ''));
|
26
|
+
_defineProperty(this, "data", void 0);
|
27
|
+
_defineProperty(this, "status", void 0);
|
28
|
+
this.data = data;
|
29
|
+
this.status = response.status;
|
43
30
|
}
|
44
|
-
|
45
|
-
|
46
|
-
}(ExtendableError);
|
47
|
-
var CODE = {
|
31
|
+
}
|
32
|
+
const CODE = {
|
48
33
|
UNAUTHORIZED: 401
|
49
34
|
};
|
50
35
|
function isRawBody(params) {
|
51
36
|
return params.sendRawBody === true;
|
52
37
|
}
|
53
|
-
|
54
|
-
|
55
|
-
var
|
56
|
-
|
57
|
-
_classCallCheck(this, HTTP);
|
38
|
+
class HTTP {
|
39
|
+
constructor(_auth, _baseUrl) {
|
40
|
+
var _this = this;
|
41
|
+
let _fetchConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
58
42
|
_defineProperty(this, "baseUrl", null);
|
59
43
|
_defineProperty(this, "_requestsMeta", new WeakMap());
|
60
44
|
_defineProperty(this, "fetchConfig", void 0);
|
61
45
|
_defineProperty(this, "requestToken", void 0);
|
62
46
|
_defineProperty(this, "shouldRefreshToken", void 0);
|
63
47
|
_defineProperty(this, "forceTokenUpdate", void 0);
|
64
|
-
_defineProperty(this, "setAuth",
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
_this2.shouldRefreshToken = auth.constructor.shouldRefreshToken;
|
69
|
-
_this2.forceTokenUpdate = function () {
|
70
|
-
return auth.forceTokenUpdate();
|
71
|
-
};
|
48
|
+
_defineProperty(this, "setAuth", auth => {
|
49
|
+
this.requestToken = () => auth.requestToken();
|
50
|
+
this.shouldRefreshToken = auth.constructor.shouldRefreshToken;
|
51
|
+
this.forceTokenUpdate = () => auth.forceTokenUpdate();
|
72
52
|
});
|
73
|
-
_defineProperty(this, "setBaseUrl",
|
74
|
-
|
53
|
+
_defineProperty(this, "setBaseUrl", baseUrl => {
|
54
|
+
this.baseUrl = baseUrl;
|
75
55
|
});
|
76
|
-
_defineProperty(this, "fetch",
|
77
|
-
|
78
|
-
|
56
|
+
_defineProperty(this, "fetch", async function (url) {
|
57
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
58
|
+
const {
|
79
59
|
body,
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
while (1) switch (_context.prev = _context.next) {
|
87
|
-
case 0:
|
88
|
-
params = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
89
|
-
body = params.body, _params$query = params.query, query = _params$query === void 0 ? {} : _params$query, fetchConfig = _objectWithoutProperties(params, _excluded);
|
90
|
-
_context.next = 4;
|
91
|
-
return _this2._fetch(_this2._makeRequestUrl(url, query), _objectSpread2(_objectSpread2({}, fetchConfig), {}, {
|
92
|
-
headers: fetchConfig.headers,
|
93
|
-
body: body !== null && body !== undefined && body !== '' ? JSON.stringify(body) : body
|
94
|
-
}));
|
95
|
-
case 4:
|
96
|
-
response = _context.sent;
|
97
|
-
return _context.abrupt("return", _this2._processResponse(response));
|
98
|
-
case 6:
|
99
|
-
case "end":
|
100
|
-
return _context.stop();
|
101
|
-
}
|
102
|
-
}, _callee);
|
103
|
-
}));
|
104
|
-
return function (_x) {
|
105
|
-
return _ref.apply(this, arguments);
|
106
|
-
};
|
107
|
-
}());
|
108
|
-
_defineProperty(this, "request", /*#__PURE__*/function () {
|
109
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url, params) {
|
110
|
-
var _this2$requestToken;
|
111
|
-
var token, response, _this2$shouldRefreshT, shouldRefreshToken, _this2$forceTokenUpda;
|
112
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
113
|
-
while (1) switch (_context2.prev = _context2.next) {
|
114
|
-
case 0:
|
115
|
-
_context2.next = 2;
|
116
|
-
return (_this2$requestToken = _this2.requestToken) === null || _this2$requestToken === void 0 ? void 0 : _this2$requestToken.call(_this2);
|
117
|
-
case 2:
|
118
|
-
token = _context2.sent;
|
119
|
-
_context2.next = 5;
|
120
|
-
return _this2._performRequest(url, token, params);
|
121
|
-
case 5:
|
122
|
-
response = _context2.sent;
|
123
|
-
_context2.prev = 6;
|
124
|
-
_context2.next = 9;
|
125
|
-
return _this2._processResponse(response);
|
126
|
-
case 9:
|
127
|
-
return _context2.abrupt("return", _context2.sent);
|
128
|
-
case 12:
|
129
|
-
_context2.prev = 12;
|
130
|
-
_context2.t0 = _context2["catch"](6);
|
131
|
-
if (_context2.t0 instanceof HTTPError) {
|
132
|
-
_context2.next = 16;
|
133
|
-
break;
|
134
|
-
}
|
135
|
-
throw _context2.t0;
|
136
|
-
case 16:
|
137
|
-
shouldRefreshToken = typeof _context2.t0.data.error === 'string' ? (_this2$shouldRefreshT = _this2.shouldRefreshToken) === null || _this2$shouldRefreshT === void 0 ? void 0 : _this2$shouldRefreshT.call(_this2, _context2.t0.data.error) : false;
|
138
|
-
if (!shouldRefreshToken) {
|
139
|
-
_context2.next = 25;
|
140
|
-
break;
|
141
|
-
}
|
142
|
-
_context2.next = 20;
|
143
|
-
return (_this2$forceTokenUpda = _this2.forceTokenUpdate) === null || _this2$forceTokenUpda === void 0 ? void 0 : _this2$forceTokenUpda.call(_this2);
|
144
|
-
case 20:
|
145
|
-
token = _context2.sent;
|
146
|
-
_context2.next = 23;
|
147
|
-
return _this2._performRequest(url, token, params);
|
148
|
-
case 23:
|
149
|
-
response = _context2.sent;
|
150
|
-
return _context2.abrupt("return", _this2._processResponse(response));
|
151
|
-
case 25:
|
152
|
-
throw _context2.t0;
|
153
|
-
case 26:
|
154
|
-
case "end":
|
155
|
-
return _context2.stop();
|
156
|
-
}
|
157
|
-
}, _callee2, null, [[6, 12]]);
|
158
|
-
}));
|
159
|
-
return function (_x2, _x3) {
|
160
|
-
return _ref2.apply(this, arguments);
|
161
|
-
};
|
162
|
-
}());
|
163
|
-
_defineProperty(this, "getMetaForResponse", function (response) {
|
164
|
-
return _this2._requestsMeta.get(response);
|
165
|
-
});
|
166
|
-
_defineProperty(this, "get", function (url, params) {
|
167
|
-
return _this2.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
168
|
-
method: 'GET'
|
169
|
-
}));
|
170
|
-
});
|
171
|
-
_defineProperty(this, "post", function (url, params) {
|
172
|
-
return _this2.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
173
|
-
method: 'POST'
|
60
|
+
query = {}
|
61
|
+
} = params,
|
62
|
+
fetchConfig = _objectWithoutProperties(params, _excluded);
|
63
|
+
const response = await _this._fetch(_this._makeRequestUrl(url, query), _objectSpread2(_objectSpread2({}, fetchConfig), {}, {
|
64
|
+
headers: fetchConfig.headers,
|
65
|
+
body: body !== null && body !== undefined && body !== '' ? JSON.stringify(body) : body
|
174
66
|
}));
|
67
|
+
return _this._processResponse(response);
|
175
68
|
});
|
176
|
-
_defineProperty(this, "
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
69
|
+
_defineProperty(this, "request", async (url, params) => {
|
70
|
+
var _this$requestToken;
|
71
|
+
let token = await ((_this$requestToken = this.requestToken) === null || _this$requestToken === void 0 ? void 0 : _this$requestToken.call(this));
|
72
|
+
let response = await this._performRequest(url, token, params);
|
73
|
+
try {
|
74
|
+
// Wait for result to catch an HTTP error
|
75
|
+
return await this._processResponse(response);
|
76
|
+
} catch (error) {
|
77
|
+
var _this$shouldRefreshTo;
|
78
|
+
if (!(error instanceof HTTPError)) {
|
79
|
+
throw error;
|
80
|
+
}
|
81
|
+
const shouldRefreshToken = typeof error.data.error === 'string' ? (_this$shouldRefreshTo = this.shouldRefreshToken) === null || _this$shouldRefreshTo === void 0 ? void 0 : _this$shouldRefreshTo.call(this, error.data.error) : false;
|
82
|
+
if (shouldRefreshToken) {
|
83
|
+
var _this$forceTokenUpdat;
|
84
|
+
token = await ((_this$forceTokenUpdat = this.forceTokenUpdate) === null || _this$forceTokenUpdat === void 0 ? void 0 : _this$forceTokenUpdat.call(this));
|
85
|
+
response = await this._performRequest(url, token, params);
|
86
|
+
return this._processResponse(response);
|
87
|
+
}
|
88
|
+
throw error;
|
89
|
+
}
|
185
90
|
});
|
91
|
+
_defineProperty(this, "getMetaForResponse", response => this._requestsMeta.get(response));
|
92
|
+
_defineProperty(this, "get", (url, params) => this.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
93
|
+
method: 'GET'
|
94
|
+
})));
|
95
|
+
_defineProperty(this, "post", (url, params) => this.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
96
|
+
method: 'POST'
|
97
|
+
})));
|
98
|
+
_defineProperty(this, "delete", (url, params) => this.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
99
|
+
method: 'DELETE'
|
100
|
+
})));
|
101
|
+
_defineProperty(this, "put", (url, params) => this.request(url, _objectSpread2(_objectSpread2({}, params), {}, {
|
102
|
+
method: 'PUT'
|
103
|
+
})));
|
186
104
|
/**
|
187
105
|
* Usage: const {promise, abort} = http.abortify(http.get<{id: string}>)('http://test.com');
|
188
106
|
* @param method
|
189
107
|
*/
|
190
|
-
_defineProperty(this, "abortify", function (
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
promise: method.call(_this2, url, params),
|
203
|
-
abort: function abort() {
|
204
|
-
return ctrl.abort();
|
205
|
-
}
|
206
|
-
};
|
108
|
+
_defineProperty(this, "abortify", method => function () {
|
109
|
+
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
110
|
+
_ref[_key] = arguments[_key];
|
111
|
+
}
|
112
|
+
let [url, params] = _ref;
|
113
|
+
const ctrl = new AbortController();
|
114
|
+
if (params && !('signal' in params)) {
|
115
|
+
params.signal = ctrl.signal;
|
116
|
+
}
|
117
|
+
return {
|
118
|
+
promise: method.call(_this, url, params),
|
119
|
+
abort: () => ctrl.abort()
|
207
120
|
};
|
208
121
|
});
|
209
122
|
if (_auth) {
|
210
123
|
this.setAuth(_auth);
|
211
124
|
}
|
212
125
|
this.setBaseUrl(_baseUrl);
|
213
|
-
|
126
|
+
const {
|
127
|
+
headers
|
128
|
+
} = defaultFetchConfig,
|
214
129
|
defaultConfig = _objectWithoutProperties(defaultFetchConfig, _excluded2);
|
215
130
|
this.fetchConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, defaultConfig), _fetchConfig), {}, {
|
216
131
|
headers: _objectSpread2(_objectSpread2({}, headers), _fetchConfig.headers)
|
217
132
|
});
|
218
133
|
}
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
134
|
+
_fetch() {
|
135
|
+
return fetch(...arguments);
|
136
|
+
}
|
137
|
+
_makeRequestUrl(url, queryObject) {
|
138
|
+
const urlWithQuery = encodeURL(url, queryObject);
|
139
|
+
return joinBaseURLAndPath(this.baseUrl, urlWithQuery);
|
140
|
+
}
|
141
|
+
_performRequest(url, token) {
|
142
|
+
let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
143
|
+
const {
|
144
|
+
headers,
|
145
|
+
body,
|
146
|
+
query = {},
|
147
|
+
sendRawBody
|
148
|
+
} = params,
|
149
|
+
fetchConfig = _objectWithoutProperties(params, _excluded3);
|
150
|
+
const combinedHeaders = _objectSpread2(_objectSpread2(_objectSpread2({}, this.fetchConfig.headers), token ? {
|
151
|
+
Authorization: "".concat(TOKEN_TYPE, " ").concat(token)
|
152
|
+
} : {}), headers);
|
153
|
+
Object.entries(combinedHeaders).forEach(_ref2 => {
|
154
|
+
let [key, header] = _ref2;
|
155
|
+
if (header === null || header === undefined) {
|
156
|
+
Reflect.deleteProperty(combinedHeaders, key);
|
157
|
+
}
|
158
|
+
});
|
159
|
+
let bodyToSend;
|
160
|
+
if (isRawBody(params)) {
|
161
|
+
bodyToSend = params.body;
|
162
|
+
} else {
|
163
|
+
bodyToSend = params.body === null || params.body === undefined || params.body === '' ? params.body : JSON.stringify(body);
|
229
164
|
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
165
|
+
return this._fetch(this._makeRequestUrl(url, query), _objectSpread2(_objectSpread2(_objectSpread2({}, this.fetchConfig), {}, {
|
166
|
+
headers: combinedHeaders
|
167
|
+
}, fetchConfig), {}, {
|
168
|
+
body: bodyToSend
|
169
|
+
}));
|
170
|
+
}
|
171
|
+
_storeRequestMeta(parsedResponse, rawResponse) {
|
172
|
+
const {
|
173
|
+
headers,
|
174
|
+
ok,
|
175
|
+
redirected,
|
176
|
+
status,
|
177
|
+
statusText,
|
178
|
+
type,
|
179
|
+
url
|
180
|
+
} = rawResponse;
|
181
|
+
this._requestsMeta.set(parsedResponse, {
|
182
|
+
headers,
|
183
|
+
ok,
|
184
|
+
redirected,
|
185
|
+
status,
|
186
|
+
statusText,
|
187
|
+
type,
|
188
|
+
url
|
189
|
+
});
|
190
|
+
}
|
191
|
+
async _processResponse(response) {
|
192
|
+
const contentType = response.headers.get('content-type');
|
193
|
+
const isJson = contentType && contentType.indexOf('application/json') !== -1;
|
194
|
+
if (!response.ok) {
|
195
|
+
let resJson;
|
196
|
+
try {
|
197
|
+
resJson = await (isJson ? response.json() : response.text());
|
198
|
+
} catch (err) {
|
199
|
+
// noop
|
256
200
|
}
|
257
|
-
|
258
|
-
headers: combinedHeaders
|
259
|
-
}, fetchConfig), {}, {
|
260
|
-
body: bodyToSend
|
261
|
-
}));
|
201
|
+
throw new HTTPError(response, resJson);
|
262
202
|
}
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
var headers = rawResponse.headers,
|
267
|
-
ok = rawResponse.ok,
|
268
|
-
redirected = rawResponse.redirected,
|
269
|
-
status = rawResponse.status,
|
270
|
-
statusText = rawResponse.statusText,
|
271
|
-
type = rawResponse.type,
|
272
|
-
url = rawResponse.url;
|
273
|
-
this._requestsMeta.set(parsedResponse, {
|
274
|
-
headers,
|
275
|
-
ok,
|
276
|
-
redirected,
|
277
|
-
status,
|
278
|
-
statusText,
|
279
|
-
type,
|
280
|
-
url
|
203
|
+
try {
|
204
|
+
const parsedResponse = await (isJson ? response.json() : {
|
205
|
+
data: await response.text()
|
281
206
|
});
|
207
|
+
this._storeRequestMeta(parsedResponse, response);
|
208
|
+
return parsedResponse;
|
209
|
+
} catch (err) {
|
210
|
+
return response;
|
282
211
|
}
|
283
|
-
}
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
while (1) switch (_context3.prev = _context3.next) {
|
290
|
-
case 0:
|
291
|
-
contentType = response.headers.get('content-type');
|
292
|
-
isJson = contentType && contentType.indexOf('application/json') !== -1;
|
293
|
-
if (response.ok) {
|
294
|
-
_context3.next = 12;
|
295
|
-
break;
|
296
|
-
}
|
297
|
-
_context3.prev = 3;
|
298
|
-
_context3.next = 6;
|
299
|
-
return isJson ? response.json() : response.text();
|
300
|
-
case 6:
|
301
|
-
resJson = _context3.sent;
|
302
|
-
_context3.next = 11;
|
303
|
-
break;
|
304
|
-
case 9:
|
305
|
-
_context3.prev = 9;
|
306
|
-
_context3.t0 = _context3["catch"](3);
|
307
|
-
case 11:
|
308
|
-
throw new HTTPError(response, resJson);
|
309
|
-
case 12:
|
310
|
-
_context3.prev = 12;
|
311
|
-
if (!isJson) {
|
312
|
-
_context3.next = 17;
|
313
|
-
break;
|
314
|
-
}
|
315
|
-
_context3.t1 = response.json();
|
316
|
-
_context3.next = 21;
|
317
|
-
break;
|
318
|
-
case 17:
|
319
|
-
_context3.next = 19;
|
320
|
-
return response.text();
|
321
|
-
case 19:
|
322
|
-
_context3.t2 = _context3.sent;
|
323
|
-
_context3.t1 = {
|
324
|
-
data: _context3.t2
|
325
|
-
};
|
326
|
-
case 21:
|
327
|
-
_context3.next = 23;
|
328
|
-
return _context3.t1;
|
329
|
-
case 23:
|
330
|
-
parsedResponse = _context3.sent;
|
331
|
-
this._storeRequestMeta(parsedResponse, response);
|
332
|
-
return _context3.abrupt("return", parsedResponse);
|
333
|
-
case 28:
|
334
|
-
_context3.prev = 28;
|
335
|
-
_context3.t3 = _context3["catch"](12);
|
336
|
-
return _context3.abrupt("return", response);
|
337
|
-
case 31:
|
338
|
-
case "end":
|
339
|
-
return _context3.stop();
|
340
|
-
}
|
341
|
-
}, _callee3, this, [[3, 9], [12, 28]]);
|
342
|
-
}));
|
343
|
-
function _processResponse(_x4) {
|
344
|
-
return _processResponse2.apply(this, arguments);
|
345
|
-
}
|
346
|
-
return _processResponse;
|
347
|
-
}()
|
348
|
-
}, {
|
349
|
-
key: "authorizedFetch",
|
350
|
-
value: function () {
|
351
|
-
var _authorizedFetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
352
|
-
var response,
|
353
|
-
_args4 = arguments;
|
354
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
355
|
-
while (1) switch (_context4.prev = _context4.next) {
|
356
|
-
case 0:
|
357
|
-
_context4.next = 2;
|
358
|
-
return this._performRequest.apply(this, _args4);
|
359
|
-
case 2:
|
360
|
-
response = _context4.sent;
|
361
|
-
return _context4.abrupt("return", this._processResponse(response));
|
362
|
-
case 4:
|
363
|
-
case "end":
|
364
|
-
return _context4.stop();
|
365
|
-
}
|
366
|
-
}, _callee4, this);
|
367
|
-
}));
|
368
|
-
function authorizedFetch() {
|
369
|
-
return _authorizedFetch.apply(this, arguments);
|
370
|
-
}
|
371
|
-
return authorizedFetch;
|
372
|
-
}()
|
373
|
-
}]);
|
374
|
-
}();
|
212
|
+
}
|
213
|
+
async authorizedFetch() {
|
214
|
+
const response = await this._performRequest(...arguments);
|
215
|
+
return this._processResponse(response);
|
216
|
+
}
|
217
|
+
}
|
375
218
|
|
376
219
|
export { CODE, HTTPError, HTTP as default, defaultFetchConfig };
|