@jetbrains/ring-ui 5.0.155 → 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.
Files changed (299) hide show
  1. package/components/checkbox/checkbox.css +1 -1
  2. package/components/global/variables_dark.css +2 -2
  3. package/components/radio/radio.css +1 -1
  4. package/dist/_helpers/_rollupPluginBabelHelpers.js +642 -1
  5. package/dist/_helpers/anchor.js +6 -7
  6. package/dist/_helpers/button__classes.js +16 -28
  7. package/dist/_helpers/card.js +107 -95
  8. package/dist/_helpers/dialog__body-scroll-preventer.js +20 -11
  9. package/dist/_helpers/footer.js +29 -34
  10. package/dist/_helpers/query-assist__suggestions.js +91 -74
  11. package/dist/_helpers/select__filter.js +71 -48
  12. package/dist/_helpers/services-link.js +41 -29
  13. package/dist/_helpers/sidebar.js +103 -99
  14. package/dist/_helpers/theme.js +42 -35
  15. package/dist/_helpers/title.js +71 -57
  16. package/dist/alert/alert.js +199 -158
  17. package/dist/alert/container.js +43 -32
  18. package/dist/alert-service/alert-service.js +172 -104
  19. package/dist/analytics/analytics.js +92 -68
  20. package/dist/analytics/analytics__custom-plugin.js +84 -60
  21. package/dist/analytics/analytics__fus-plugin.js +28 -15
  22. package/dist/analytics/analytics__ga-plugin.js +60 -43
  23. package/dist/analytics/analytics__plugin-utils.js +28 -22
  24. package/dist/auth/auth.js +36 -4
  25. package/dist/auth/auth__core.js +1458 -732
  26. package/dist/auth/background-flow.js +129 -87
  27. package/dist/auth/down-notification.js +75 -30
  28. package/dist/auth/iframe-flow.js +136 -75
  29. package/dist/auth/landing.js +90 -30
  30. package/dist/auth/request-builder.js +82 -46
  31. package/dist/auth/response-parser.js +119 -86
  32. package/dist/auth/storage.js +333 -171
  33. package/dist/auth/token-validator.js +244 -137
  34. package/dist/auth/window-flow.js +136 -92
  35. package/dist/auth-dialog/auth-dialog.js +176 -114
  36. package/dist/auth-dialog-service/auth-dialog-service.js +32 -7
  37. package/dist/auth-ng/auth-ng.js +70 -34
  38. package/dist/auth-ng/auth-ng.mock.js +6 -6
  39. package/dist/autofocus-ng/autofocus-ng.js +23 -8
  40. package/dist/avatar/avatar-example-datauri.js +1 -23
  41. package/dist/avatar/avatar.js +155 -119
  42. package/dist/avatar/fallback-avatar.js +41 -22
  43. package/dist/avatar-editor-ng/avatar-editor-ng.js +56 -23
  44. package/dist/avatar-editor-ng/avatar-editor-ng__template.js +1 -28
  45. package/dist/avatar-ng/avatar-ng.js +23 -1
  46. package/dist/badge/badge.js +43 -35
  47. package/dist/badge-ng/badge-ng.js +13 -1
  48. package/dist/breadcrumb-ng/breadcrumb-ng.js +15 -29
  49. package/dist/button/button.js +111 -87
  50. package/dist/button/button__classes.js +1 -0
  51. package/dist/button-group/button-group.js +35 -19
  52. package/dist/button-group/caption.js +22 -14
  53. package/dist/button-group-ng/button-group-ng.js +13 -7
  54. package/dist/button-ng/button-ng.js +154 -133
  55. package/dist/button-set/button-set.js +34 -20
  56. package/dist/button-set-ng/button-set-ng.js +2 -2
  57. package/dist/button-toolbar/button-toolbar.js +33 -19
  58. package/dist/button-toolbar-ng/button-toolbar-ng.js +5 -3
  59. package/dist/caret/caret.js +225 -188
  60. package/dist/checkbox/checkbox.js +104 -76
  61. package/dist/checkbox-ng/checkbox-ng.js +18 -27
  62. package/dist/clipboard/clipboard-fallback.js +10 -10
  63. package/dist/clipboard/clipboard.js +131 -34
  64. package/dist/code/code.js +168 -92
  65. package/dist/compiler-ng/compiler-ng.js +18 -15
  66. package/dist/confirm/confirm.js +108 -66
  67. package/dist/confirm-ng/confirm-ng.js +33 -4
  68. package/dist/confirm-service/confirm-service.js +66 -42
  69. package/dist/content-layout/content-layout.js +64 -43
  70. package/dist/content-layout/sidebar.js +1 -0
  71. package/dist/contenteditable/contenteditable.js +61 -50
  72. package/dist/control-label/control-label.js +11 -15
  73. package/dist/data-list/data-list.js +184 -128
  74. package/dist/data-list/data-list.mock.js +11 -2
  75. package/dist/data-list/item.js +174 -143
  76. package/dist/data-list/selection.js +139 -76
  77. package/dist/data-list/title.js +13 -1
  78. package/dist/data-list-ng/data-list-ng.js +31 -1
  79. package/dist/date-picker/consts.js +18 -15
  80. package/dist/date-picker/date-input.js +147 -115
  81. package/dist/date-picker/date-picker.js +285 -228
  82. package/dist/date-picker/date-popup.js +397 -356
  83. package/dist/date-picker/day.js +98 -84
  84. package/dist/date-picker/month-names.js +64 -43
  85. package/dist/date-picker/month-slider.js +74 -51
  86. package/dist/date-picker/month.js +21 -15
  87. package/dist/date-picker/months.js +48 -43
  88. package/dist/date-picker/weekdays.js +18 -12
  89. package/dist/date-picker/years.js +109 -84
  90. package/dist/dialog/dialog.js +189 -141
  91. package/dist/dialog/dialog__body-scroll-preventer.js +5 -0
  92. package/dist/dialog-ng/dialog-ng.js +401 -287
  93. package/dist/dialog-ng/dialog-ng__template.js +1 -70
  94. package/dist/docked-panel-ng/docked-panel-ng.js +33 -18
  95. package/dist/dropdown/anchor.js +10 -0
  96. package/dist/dropdown/dropdown.js +214 -182
  97. package/dist/dropdown-menu/dropdown-menu.js +102 -72
  98. package/dist/editable-heading/editable-heading.js +100 -58
  99. package/dist/error-bubble/error-bubble.js +64 -31
  100. package/dist/error-message/error-message.js +61 -38
  101. package/dist/error-message-ng/error-message-ng.js +11 -22
  102. package/dist/footer/footer.js +11 -1
  103. package/dist/footer-ng/footer-ng.js +64 -36
  104. package/dist/form-ng/form-ng.js +66 -56
  105. package/dist/global/angular-component-factory.js +76 -53
  106. package/dist/global/compose.js +10 -1
  107. package/dist/global/composeRefs.js +12 -7
  108. package/dist/global/controls-height.js +2 -2
  109. package/dist/global/create-stateful-context.js +19 -19
  110. package/dist/global/data-tests.js +15 -7
  111. package/dist/global/dom.js +95 -53
  112. package/dist/global/focus-sensor-hoc.js +134 -122
  113. package/dist/global/fuzzy-highlight.js +41 -27
  114. package/dist/global/get-event-key.js +8 -8
  115. package/dist/global/get-uid.js +8 -4
  116. package/dist/global/inject-styles.js +15 -10
  117. package/dist/global/linear-function.js +2 -2
  118. package/dist/global/listeners.js +53 -27
  119. package/dist/global/memoize.js +13 -6
  120. package/dist/global/normalize-indent.js +51 -19
  121. package/dist/global/promise-with-timeout.js +8 -6
  122. package/dist/global/prop-types.js +5 -3
  123. package/dist/global/react-dom-renderer.js +47 -28
  124. package/dist/global/react-render-adapter.js +19 -13
  125. package/dist/global/rerender-hoc.js +41 -16
  126. package/dist/global/ring-angular-component.js +20 -10
  127. package/dist/global/schedule-raf.js +6 -5
  128. package/dist/global/sniffer.js +1 -1
  129. package/dist/global/theme.js +24 -0
  130. package/dist/global/trivial-template-tag.js +10 -3
  131. package/dist/global/typescript-utils.js +6 -2
  132. package/dist/global/url.js +27 -21
  133. package/dist/global/use-event-callback.js +4 -6
  134. package/dist/grid/col.js +55 -35
  135. package/dist/grid/grid.js +36 -17
  136. package/dist/grid/row.js +48 -35
  137. package/dist/group/group.js +27 -17
  138. package/dist/group-ng/group-ng.js +2 -2
  139. package/dist/header/header.js +80 -33
  140. package/dist/header/logo.js +39 -20
  141. package/dist/header/profile.js +188 -150
  142. package/dist/header/services-link.js +9 -0
  143. package/dist/header/services.js +118 -73
  144. package/dist/header/smart-profile.js +207 -111
  145. package/dist/header/smart-services.js +115 -62
  146. package/dist/header/tray-icon.js +38 -21
  147. package/dist/header/tray.js +34 -21
  148. package/dist/heading/heading.js +25 -26
  149. package/dist/heading-ng/heading-ng.js +11 -1
  150. package/dist/http/http.js +368 -215
  151. package/dist/http/http.mock.js +104 -49
  152. package/dist/hub-source/hub-source.js +191 -83
  153. package/dist/hub-source/hub-source__user.js +45 -11
  154. package/dist/hub-source/hub-source__users-groups.js +67 -37
  155. package/dist/i18n/i18n-context.js +14 -10
  156. package/dist/i18n/i18n.js +11 -7
  157. package/dist/icon/icon.js +94 -76
  158. package/dist/icon/icon__svg.js +31 -24
  159. package/dist/icon/index.js +9 -0
  160. package/dist/icon-ng/icon-ng.js +27 -15
  161. package/dist/input/input.js +184 -145
  162. package/dist/input-ng/input-ng.js +96 -118
  163. package/dist/island/adaptive-island-hoc.js +45 -30
  164. package/dist/island/content.js +130 -115
  165. package/dist/island/header.js +69 -56
  166. package/dist/island/island.js +40 -28
  167. package/dist/island-legacy/content-legacy.js +27 -17
  168. package/dist/island-legacy/header-legacy.js +29 -19
  169. package/dist/island-legacy/island-legacy.js +27 -17
  170. package/dist/island-ng/island-content-ng.js +17 -26
  171. package/dist/island-ng/island-header-ng.js +9 -12
  172. package/dist/island-ng/island-ng-class-fixer.js +3 -0
  173. package/dist/island-ng/island-ng.js +6 -10
  174. package/dist/link/clickableLink.js +61 -44
  175. package/dist/link/link.js +85 -74
  176. package/dist/link-ng/link-ng.js +3 -5
  177. package/dist/list/consts.js +1 -1
  178. package/dist/list/list.js +696 -602
  179. package/dist/list/list__custom.js +61 -44
  180. package/dist/list/list__hint.js +21 -10
  181. package/dist/list/list__item.js +167 -129
  182. package/dist/list/list__link.js +54 -37
  183. package/dist/list/list__separator.js +24 -14
  184. package/dist/list/list__title.js +32 -22
  185. package/dist/list/list__users-groups-source.js +131 -54
  186. package/dist/loader/loader.js +78 -43
  187. package/dist/loader/loader__core.js +257 -189
  188. package/dist/loader-inline/loader-inline.js +37 -23
  189. package/dist/loader-inline-ng/loader-inline-ng.js +2 -2
  190. package/dist/loader-ng/loader-ng.js +46 -19
  191. package/dist/loader-screen/loader-screen.js +48 -25
  192. package/dist/loader-screen-ng/loader-screen-ng.js +46 -30
  193. package/dist/login-dialog/login-dialog.js +162 -111
  194. package/dist/login-dialog/service.js +35 -7
  195. package/dist/markdown/code.js +31 -9
  196. package/dist/markdown/heading.js +3 -5
  197. package/dist/markdown/link.js +13 -6
  198. package/dist/markdown/markdown.js +66 -33
  199. package/dist/message/message.js +157 -125
  200. package/dist/message-bundle-ng/message-bundle-ng.js +128 -44
  201. package/dist/old-browsers-message/old-browsers-message.js +19 -11
  202. package/dist/old-browsers-message/old-browsers-message__stop.js +8 -0
  203. package/dist/old-browsers-message/white-list.js +16 -9
  204. package/dist/pager/pager.js +275 -210
  205. package/dist/pager-ng/pager-ng.js +36 -1
  206. package/dist/panel/panel.js +27 -17
  207. package/dist/panel-ng/panel-ng.js +14 -1
  208. package/dist/permissions/permissions.js +173 -127
  209. package/dist/permissions/permissions__cache.js +225 -194
  210. package/dist/permissions-ng/permissions-ng.js +86 -35
  211. package/dist/place-under-ng/place-under-ng.js +68 -45
  212. package/dist/popup/popup.consts.js +1 -1
  213. package/dist/popup/popup.js +342 -280
  214. package/dist/popup/popup.target.js +8 -9
  215. package/dist/popup/position.js +153 -153
  216. package/dist/popup-menu/popup-menu.js +86 -44
  217. package/dist/progress-bar/progress-bar.js +97 -80
  218. package/dist/progress-bar-ng/progress-bar-ng.js +11 -1
  219. package/dist/promised-click-ng/promised-click-ng.js +92 -58
  220. package/dist/proxy-attrs/proxy-attrs.js +18 -9
  221. package/dist/query-assist/query-assist.js +903 -832
  222. package/dist/query-assist/query-assist__suggestions.js +33 -1
  223. package/dist/query-assist-ng/query-assist-ng.js +38 -1
  224. package/dist/radio/radio.js +36 -19
  225. package/dist/radio/radio__item.js +71 -52
  226. package/dist/radio-ng/radio-ng.js +14 -25
  227. package/dist/save-field-ng/save-field-ng.js +86 -52
  228. package/dist/save-field-ng/save-field-ng__template.js +1 -32
  229. package/dist/select/select.js +937 -835
  230. package/dist/select/select__filter.js +33 -0
  231. package/dist/select/select__popup.js +472 -359
  232. package/dist/select-ng/select-ng.js +125 -74
  233. package/dist/select-ng/select-ng__lazy.js +101 -50
  234. package/dist/select-ng/select-ng__options.js +107 -81
  235. package/dist/shortcuts/core.js +218 -166
  236. package/dist/shortcuts/shortcut-title.js +11 -6
  237. package/dist/shortcuts/shortcuts-hoc.js +47 -19
  238. package/dist/shortcuts/shortcuts.js +77 -50
  239. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +104 -53
  240. package/dist/shortcuts-hint-ng/shortcuts-hint-ng__template.js +1 -48
  241. package/dist/shortcuts-ng/shortcuts-ng.js +86 -51
  242. package/dist/sidebar-ng/sidebar-ng.js +53 -22
  243. package/dist/sidebar-ng/sidebar-ng__button-template.js +1 -18
  244. package/dist/sidebar-ng/sidebar-ng__template.js +1 -10
  245. package/dist/storage/storage.js +35 -4
  246. package/dist/storage/storage__fallback.js +224 -149
  247. package/dist/storage/storage__local.js +156 -90
  248. package/dist/style.css +1 -1
  249. package/dist/tab-trap/tab-trap.js +157 -122
  250. package/dist/table/cell.js +28 -14
  251. package/dist/table/disable-hover-hoc.js +53 -33
  252. package/dist/table/header-cell.js +87 -64
  253. package/dist/table/header.js +126 -98
  254. package/dist/table/multitable.js +127 -107
  255. package/dist/table/row-with-focus-sensor.js +73 -25
  256. package/dist/table/row.js +208 -170
  257. package/dist/table/selection-adapter.js +3 -1
  258. package/dist/table/selection-shortcuts-hoc.js +184 -181
  259. package/dist/table/selection.js +228 -156
  260. package/dist/table/smart-table.js +93 -51
  261. package/dist/table/table.js +348 -281
  262. package/dist/table-legacy-ng/table-legacy-ng.js +117 -102
  263. package/dist/table-legacy-ng/table-legacy-ng__pager.js +42 -10
  264. package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +92 -69
  265. package/dist/table-legacy-ng/table-legacy-ng__selection.js +169 -119
  266. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +36 -21
  267. package/dist/table-ng/smart-table-ng.js +31 -1
  268. package/dist/table-ng/table-ng.js +31 -1
  269. package/dist/tabs/collapsible-more.js +87 -50
  270. package/dist/tabs/collapsible-tab.js +45 -38
  271. package/dist/tabs/collapsible-tabs.js +161 -94
  272. package/dist/tabs/custom-item.js +2 -4
  273. package/dist/tabs/dumb-tabs.js +122 -75
  274. package/dist/tabs/smart-tabs.js +75 -29
  275. package/dist/tabs/tab-link.js +29 -19
  276. package/dist/tabs/tab.js +33 -19
  277. package/dist/tabs/tabs.js +35 -0
  278. package/dist/tabs-ng/tabs-ng.js +38 -24
  279. package/dist/tabs-ng/tabs-ng__template.js +1 -38
  280. package/dist/tag/tag.js +170 -133
  281. package/dist/tags-input/tags-input.js +428 -327
  282. package/dist/tags-input-ng/tags-input-ng.js +37 -1
  283. package/dist/tags-list/tags-list.js +80 -56
  284. package/dist/template-ng/template-ng.js +50 -39
  285. package/dist/text/text.js +38 -28
  286. package/dist/title-ng/title-ng.js +28 -23
  287. package/dist/toggle/toggle.js +72 -56
  288. package/dist/toggle-ng/toggle-ng.js +14 -1
  289. package/dist/tooltip/tooltip.js +192 -146
  290. package/dist/tooltip-ng/tooltip-ng.js +51 -25
  291. package/dist/user-agreement/service.js +374 -227
  292. package/dist/user-agreement/toolbox.eula.js +1 -160
  293. package/dist/user-agreement/user-agreement.js +128 -86
  294. package/dist/user-card/card.js +32 -0
  295. package/dist/user-card/smart-user-card-tooltip.js +116 -51
  296. package/dist/user-card/tooltip.js +90 -48
  297. package/dist/user-card/user-card.js +32 -0
  298. package/dist/user-card-ng/user-card-ng.js +34 -2
  299. package/package.json +13 -13
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
- const TOKEN_TYPE = 'Bearer';
8
- const STATUS_OK_IF_MORE_THAN = 200;
9
- const STATUS_BAD_IF_MORE_THAN = 300;
10
- const defaultFetchConfig = {
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
- class HTTPError extends ExtendableError {
18
- data;
19
- status;
20
- constructor(response) {
21
- let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22
- super(`${response.status} ${response.statusText || ''}`);
23
- this.data = data;
24
- this.status = response.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
- const CODE = {
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
- class HTTP {
34
- baseUrl = null;
35
- _requestsMeta = new WeakMap();
36
- fetchConfig;
37
- requestToken;
38
- shouldRefreshToken;
39
- forceTokenUpdate;
40
- constructor(auth, baseUrl) {
41
- let fetchConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
42
- if (auth) {
43
- this.setAuth(auth);
44
- }
45
- this.setBaseUrl(baseUrl);
46
- const {
47
- headers,
48
- ...defaultConfig
49
- } = defaultFetchConfig;
50
- this.fetchConfig = {
51
- ...defaultConfig,
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
- let bodyToSend;
97
- if (isRawBody(params)) {
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
- _storeRequestMeta(parsedResponse, rawResponse) {
110
- const {
111
- headers,
112
- ok,
113
- redirected,
114
- status,
115
- statusText,
116
- type,
117
- url
118
- } = rawResponse;
119
- this._requestsMeta.set(parsedResponse, {
120
- headers,
121
- ok,
122
- redirected,
123
- status,
124
- statusText,
125
- type,
126
- url
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
- async _processResponse(response) {
130
- const contentType = response.headers?.get('content-type');
131
- const isJson = contentType && contentType.indexOf('application/json') !== -1;
132
- if (response.status != null && HTTP._isErrorStatus(response.status)) {
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
- try {
142
- const parsedResponse = await (isJson ? response.json?.() : {
143
- data: await response.text?.()
144
- });
145
- this._storeRequestMeta(parsedResponse, response);
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
- static _isErrorStatus(status) {
152
- return status < STATUS_OK_IF_MORE_THAN || status >= STATUS_BAD_IF_MORE_THAN;
153
- }
154
- // TODO: Replace any to never/unknown in next release and remove eslint-disable
155
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
- fetch = (() => {
157
- var _this = this;
158
- return async function (url) {
159
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
160
- const {
161
- body,
162
- query = {},
163
- ...fetchConfig
164
- } = params;
165
- const response = await _this._fetch(_this._makeRequestUrl(url, query), {
166
- ...fetchConfig,
167
- headers: fetchConfig.headers,
168
- body: body !== null && body !== undefined && body !== '' ? JSON.stringify(body) : body
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
- return _this._processResponse(response);
171
- };
172
- })();
173
- async authorizedFetch() {
174
- const response = await this._performRequest(...arguments);
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
- throw error;
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
- getMetaForResponse = response => this._requestsMeta.get(response);
199
- // TODO: Replace any to never/unknown in next release and remove eslint-disable
200
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
- get = (url, params) => this.request(url, {
202
- ...params,
203
- method: 'GET'
204
- });
205
- // TODO: Replace any to never/unknown in next release and remove eslint-disable
206
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
207
- post = (url, params) => this.request(url, {
208
- ...params,
209
- method: 'POST'
210
- });
211
- // TODO: Replace any to never/unknown in next release and remove eslint-disable
212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
- delete = (url, params) => this.request(url, {
214
- ...params,
215
- method: 'DELETE'
216
- });
217
- // TODO: Replace any to never/unknown in next release and remove eslint-disable
218
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
219
- put = (url, params) => this.request(url, {
220
- ...params,
221
- method: 'PUT'
222
- });
223
- /**
224
- * Usage: const {promise, abort} = http.abortify(http.get<{id: string}>)('http://test.com');
225
- * @param method
226
- */
227
- abortify = method => {
228
- var _this2 = this;
229
- return function () {
230
- for (var _len = arguments.length, _ref2 = new Array(_len), _key = 0; _key < _len; _key++) {
231
- _ref2[_key] = arguments[_key];
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
- let [url, params] = _ref2;
234
- const ctrl = new AbortController();
235
- if (params && !('signal' in params)) {
236
- params.signal = ctrl.signal;
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
- promise: method.call(_this2, url, params),
240
- abort: () => ctrl.abort()
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 };