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