@atlaskit/media-client 35.3.1 → 35.3.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 35.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b87ad4064e4f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b87ad4064e4f8) -
8
+ Added path based routing support to media client behind a feature flag and added retry logic for
9
+ serverUnexpectedError for Edge due to hot
10
+
3
11
  ## 35.3.1
4
12
 
5
13
  ### Patch Changes
@@ -17,6 +17,8 @@ var _request3 = require("../../utils/request");
17
17
  var _helpers = require("../../utils/request/helpers");
18
18
  var _mediaCdn = require("../../utils/mediaCdn");
19
19
  var _resolveAuth = require("./resolveAuth");
20
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
+ var _pathBasedUrl = require("../../utils/pathBasedUrl");
20
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
24
  var MEDIA_API_REGION = 'media-api-region';
@@ -926,7 +928,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
926
928
  if (useMediaCdn) {
927
929
  url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
928
930
  }
929
- _context16.next = 19;
931
+ if ((0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
932
+ url = (0, _pathBasedUrl.mapToPathBasedUrl)(url);
933
+ }
934
+ _context16.next = 20;
930
935
  return (0, _request3.request)(url, {
931
936
  method: method,
932
937
  endpoint: endpoint,
@@ -937,12 +942,12 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
937
942
  clientOptions: clientOptions,
938
943
  traceContext: extendedTraceContext
939
944
  }, controller);
940
- case 19:
945
+ case 20:
941
946
  response = _context16.sent;
942
947
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
943
948
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
944
949
  return _context16.abrupt("return", response);
945
- case 23:
950
+ case 24:
946
951
  case "end":
947
952
  return _context16.stop();
948
953
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = function _default() {
8
+ if (typeof window === 'undefined') {
9
+ return;
10
+ }
11
+ if (typeof window.document === 'undefined') {
12
+ return;
13
+ }
14
+ return window.document;
15
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = function _default() {
8
+ if (typeof window === 'undefined') {
9
+ return;
10
+ }
11
+ if (typeof window.navigator === 'undefined') {
12
+ return;
13
+ }
14
+ return window.navigator;
15
+ };
@@ -20,7 +20,7 @@ var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
20
20
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
21
21
  function isCDNEnabled() {
22
22
  var isIsolatedCloudWithDisabledCDN = (0, _platformFeatureFlags.fg)('platform_disable_isolated_cloud_media_cdn_delivery') && (0, _atlassianContext.isIsolatedCloud)();
23
- return (0, _isCommercial.isCommercial)() && !isIsolatedCloudWithDisabledCDN && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery');
23
+ return (0, _isCommercial.isCommercial)() && !isIsolatedCloudWithDisabledCDN && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery') && !(0, _platformFeatureFlags.fg)('platform_media_path_based_route');
24
24
  }
25
25
  function mapToMediaCdnUrl(url, token) {
26
26
  var _token$length;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.mapRetryUrlToPathBasedUrl = mapRetryUrlToPathBasedUrl;
8
+ exports.mapToPathBasedUrl = mapToPathBasedUrl;
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _getDocument3 = _interopRequireDefault(require("./getDocument"));
11
+ function mapToPathBasedUrl(url) {
12
+ if ((0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
13
+ var _getDocument$location, _getDocument;
14
+ var parsedUrl = new URL(url);
15
+ parsedUrl.host = (_getDocument$location = (_getDocument = (0, _getDocument3.default)()) === null || _getDocument === void 0 ? void 0 : _getDocument.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : parsedUrl.host;
16
+ parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
17
+ return parsedUrl.toString();
18
+ }
19
+ return url;
20
+ }
21
+ function mapRetryUrlToPathBasedUrl(url) {
22
+ var _getDocument$location2, _getDocument2;
23
+ var parsedUrl = new URL(url);
24
+ parsedUrl.host = (_getDocument$location2 = (_getDocument2 = (0, _getDocument3.default)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location2 !== void 0 ? _getDocument$location2 : parsedUrl.host;
25
+
26
+ // remove CDN from the URL for retry if it exists
27
+ var pathname = parsedUrl.pathname;
28
+ if (pathname.endsWith('/cdn')) {
29
+ parsedUrl.pathname = pathname.replace('/cdn', '');
30
+ }
31
+ parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
32
+ return parsedUrl;
33
+ }
@@ -30,9 +30,15 @@ Object.defineProperty(exports, "isRequestError", {
30
30
  });
31
31
  exports.request = request;
32
32
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
33
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
33
34
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
34
35
  var _errors = require("./errors");
35
36
  var _helpers = require("./helpers");
37
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
38
+ var _pathBasedUrl = require("../pathBasedUrl");
39
+ var _getNavigator3 = _interopRequireDefault(require("../getNavigator"));
40
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
41
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
36
42
  function request(_x) {
37
43
  return _request.apply(this, arguments);
38
44
  }
@@ -53,6 +59,9 @@ function _request() {
53
59
  retryOptions,
54
60
  metadata,
55
61
  doFetch,
62
+ shouldRetryError,
63
+ _getNavigator2,
64
+ doFetchWithPathBasedUrl,
56
65
  _args = arguments;
57
66
  return _regenerator.default.wrap(function _callee$(_context) {
58
67
  while (1) switch (_context.prev = _context.next) {
@@ -76,12 +85,51 @@ function _request() {
76
85
  signal: controller && controller.signal
77
86
  }).then((0, _helpers.createProcessFetchResponse)(metadata));
78
87
  };
88
+ if (!(0, _platformFeatureFlags.fg)('platform_media_retry_edge_error')) {
89
+ _context.next = 20;
90
+ break;
91
+ }
92
+ shouldRetryError = function shouldRetryError(err) {
93
+ var _getNavigator;
94
+ if ((0, _helpers.isFetchNetworkError)(err) && (_getNavigator = (0, _getNavigator3.default)()) !== null && _getNavigator !== void 0 && _getNavigator.userAgent.includes('Edg/')) {
95
+ return false;
96
+ }
97
+ return (0, _helpers.defaultShouldRetryError)(err);
98
+ };
99
+ _context.prev = 8;
100
+ _context.next = 11;
101
+ return (0, _helpers.fetchRetry)(doFetch, metadata, _objectSpread(_objectSpread({}, retryOptions), {}, {
102
+ shouldRetryError: shouldRetryError
103
+ }));
104
+ case 11:
105
+ return _context.abrupt("return", _context.sent);
106
+ case 14:
107
+ _context.prev = 14;
108
+ _context.t0 = _context["catch"](8);
109
+ if (!((0, _helpers.isFetchNetworkError)(_context.t0) && (_getNavigator2 = (0, _getNavigator3.default)()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/'))) {
110
+ _context.next = 19;
111
+ break;
112
+ }
113
+ doFetchWithPathBasedUrl = function doFetchWithPathBasedUrl() {
114
+ return fetch((0, _helpers.createUrl)((0, _pathBasedUrl.mapRetryUrlToPathBasedUrl)(url).toString(), {
115
+ params: params
116
+ }), {
117
+ method: method,
118
+ body: body,
119
+ headers: (0, _helpers.extendHeaders)(headers, auth, traceContext),
120
+ signal: controller && controller.signal
121
+ }).then((0, _helpers.createProcessFetchResponse)(metadata));
122
+ };
123
+ return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetchWithPathBasedUrl, metadata, retryOptions));
124
+ case 19:
125
+ throw _context.t0;
126
+ case 20:
79
127
  return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetch, metadata, retryOptions));
80
- case 7:
128
+ case 21:
81
129
  case "end":
82
130
  return _context.stop();
83
131
  }
84
- }, _callee);
132
+ }, _callee, null, [[8, 14]]);
85
133
  }));
86
134
  return _request.apply(this, arguments);
87
135
  }
@@ -7,6 +7,8 @@ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultSho
7
7
  import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
8
8
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
9
9
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { mapToPathBasedUrl } from '../../utils/pathBasedUrl';
10
12
  const MEDIA_API_REGION = 'media-api-region';
11
13
  const MEDIA_API_ENVIRONMENT = 'media-api-environment';
12
14
  const extendImageParams = (params, fetchMaxRes = false) => {
@@ -561,6 +563,9 @@ export class MediaStore {
561
563
  if (useMediaCdn) {
562
564
  url = mapToMediaCdnUrl(url, auth.token);
563
565
  }
566
+ if (fg('platform_media_path_based_route')) {
567
+ url = mapToPathBasedUrl(url);
568
+ }
564
569
  const response = await request(url, {
565
570
  method,
566
571
  endpoint,
@@ -0,0 +1,9 @@
1
+ export default (() => {
2
+ if (typeof window === 'undefined') {
3
+ return;
4
+ }
5
+ if (typeof window.document === 'undefined') {
6
+ return;
7
+ }
8
+ return window.document;
9
+ });
@@ -0,0 +1,9 @@
1
+ export default (() => {
2
+ if (typeof window === 'undefined') {
3
+ return;
4
+ }
5
+ if (typeof window.navigator === 'undefined') {
6
+ return;
7
+ }
8
+ return window.navigator;
9
+ });
@@ -12,7 +12,7 @@ export const MEDIA_CDN_MAP = {
12
12
  const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
13
  export function isCDNEnabled() {
14
14
  const isIsolatedCloudWithDisabledCDN = fg('platform_disable_isolated_cloud_media_cdn_delivery') && isIsolatedCloud();
15
- return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery');
15
+ return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery') && !fg('platform_media_path_based_route');
16
16
  }
17
17
  export function mapToMediaCdnUrl(url, token) {
18
18
  var _token$length;
@@ -0,0 +1,25 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import getDocument from './getDocument';
3
+ export function mapToPathBasedUrl(url) {
4
+ if (fg('platform_media_path_based_route')) {
5
+ var _getDocument$location, _getDocument;
6
+ const parsedUrl = new URL(url);
7
+ parsedUrl.host = (_getDocument$location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : parsedUrl.host;
8
+ parsedUrl.pathname = `/media-api${parsedUrl.pathname}`;
9
+ return parsedUrl.toString();
10
+ }
11
+ return url;
12
+ }
13
+ export function mapRetryUrlToPathBasedUrl(url) {
14
+ var _getDocument$location2, _getDocument2;
15
+ const parsedUrl = new URL(url);
16
+ parsedUrl.host = (_getDocument$location2 = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location2 !== void 0 ? _getDocument$location2 : parsedUrl.host;
17
+
18
+ // remove CDN from the URL for retry if it exists
19
+ const pathname = parsedUrl.pathname;
20
+ if (pathname.endsWith('/cdn')) {
21
+ parsedUrl.pathname = pathname.replace('/cdn', '');
22
+ }
23
+ parsedUrl.pathname = `/media-api${parsedUrl.pathname}`;
24
+ return parsedUrl;
25
+ }
@@ -1,6 +1,9 @@
1
1
  export { RequestError, isRequestError } from './errors';
2
2
  export { isRateLimitedError, createRequestErrorReason } from './helpers';
3
- import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders } from './helpers';
3
+ import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders, isFetchNetworkError, defaultShouldRetryError } from './helpers';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { mapRetryUrlToPathBasedUrl } from '../pathBasedUrl';
6
+ import getNavigator from '../getNavigator';
4
7
  export async function request(url, options = {}, controller) {
5
8
  const {
6
9
  method = 'GET',
@@ -30,5 +33,34 @@ export async function request(url, options = {}, controller) {
30
33
  headers: extendHeaders(headers, auth, traceContext),
31
34
  signal: controller && controller.signal
32
35
  }).then(createProcessFetchResponse(metadata));
36
+ if (fg('platform_media_retry_edge_error')) {
37
+ const shouldRetryError = err => {
38
+ var _getNavigator;
39
+ if (isFetchNetworkError(err) && (_getNavigator = getNavigator()) !== null && _getNavigator !== void 0 && _getNavigator.userAgent.includes('Edg/')) {
40
+ return false;
41
+ }
42
+ return defaultShouldRetryError(err);
43
+ };
44
+ try {
45
+ return await fetchRetry(doFetch, metadata, {
46
+ ...retryOptions,
47
+ shouldRetryError
48
+ });
49
+ } catch (error) {
50
+ var _getNavigator2;
51
+ if (isFetchNetworkError(error) && (_getNavigator2 = getNavigator()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/')) {
52
+ const doFetchWithPathBasedUrl = () => fetch(createUrl(mapRetryUrlToPathBasedUrl(url).toString(), {
53
+ params
54
+ }), {
55
+ method,
56
+ body,
57
+ headers: extendHeaders(headers, auth, traceContext),
58
+ signal: controller && controller.signal
59
+ }).then(createProcessFetchResponse(metadata));
60
+ return fetchRetry(doFetchWithPathBasedUrl, metadata, retryOptions);
61
+ }
62
+ throw error;
63
+ }
64
+ }
33
65
  return fetchRetry(doFetch, metadata, retryOptions);
34
66
  }
@@ -13,6 +13,8 @@ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultSho
13
13
  import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
14
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
15
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { mapToPathBasedUrl } from '../../utils/pathBasedUrl';
16
18
  var MEDIA_API_REGION = 'media-api-region';
17
19
  var MEDIA_API_ENVIRONMENT = 'media-api-environment';
18
20
  var extendImageParams = function extendImageParams(params) {
@@ -920,7 +922,10 @@ export var MediaStore = /*#__PURE__*/function () {
920
922
  if (useMediaCdn) {
921
923
  url = mapToMediaCdnUrl(url, auth.token);
922
924
  }
923
- _context16.next = 19;
925
+ if (fg('platform_media_path_based_route')) {
926
+ url = mapToPathBasedUrl(url);
927
+ }
928
+ _context16.next = 20;
924
929
  return _request(url, {
925
930
  method: method,
926
931
  endpoint: endpoint,
@@ -931,12 +936,12 @@ export var MediaStore = /*#__PURE__*/function () {
931
936
  clientOptions: clientOptions,
932
937
  traceContext: extendedTraceContext
933
938
  }, controller);
934
- case 19:
939
+ case 20:
935
940
  response = _context16.sent;
936
941
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
937
942
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
938
943
  return _context16.abrupt("return", response);
939
- case 23:
944
+ case 24:
940
945
  case "end":
941
946
  return _context16.stop();
942
947
  }
@@ -0,0 +1,9 @@
1
+ export default (function () {
2
+ if (typeof window === 'undefined') {
3
+ return;
4
+ }
5
+ if (typeof window.document === 'undefined') {
6
+ return;
7
+ }
8
+ return window.document;
9
+ });
@@ -0,0 +1,9 @@
1
+ export default (function () {
2
+ if (typeof window === 'undefined') {
3
+ return;
4
+ }
5
+ if (typeof window.navigator === 'undefined') {
6
+ return;
7
+ }
8
+ return window.navigator;
9
+ });
@@ -12,7 +12,7 @@ export var MEDIA_CDN_MAP = {
12
12
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
13
  export function isCDNEnabled() {
14
14
  var isIsolatedCloudWithDisabledCDN = fg('platform_disable_isolated_cloud_media_cdn_delivery') && isIsolatedCloud();
15
- return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery');
15
+ return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery') && !fg('platform_media_path_based_route');
16
16
  }
17
17
  export function mapToMediaCdnUrl(url, token) {
18
18
  var _token$length;
@@ -0,0 +1,25 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import getDocument from './getDocument';
3
+ export function mapToPathBasedUrl(url) {
4
+ if (fg('platform_media_path_based_route')) {
5
+ var _getDocument$location, _getDocument;
6
+ var parsedUrl = new URL(url);
7
+ parsedUrl.host = (_getDocument$location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : parsedUrl.host;
8
+ parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
9
+ return parsedUrl.toString();
10
+ }
11
+ return url;
12
+ }
13
+ export function mapRetryUrlToPathBasedUrl(url) {
14
+ var _getDocument$location2, _getDocument2;
15
+ var parsedUrl = new URL(url);
16
+ parsedUrl.host = (_getDocument$location2 = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location2 !== void 0 ? _getDocument$location2 : parsedUrl.host;
17
+
18
+ // remove CDN from the URL for retry if it exists
19
+ var pathname = parsedUrl.pathname;
20
+ if (pathname.endsWith('/cdn')) {
21
+ parsedUrl.pathname = pathname.replace('/cdn', '');
22
+ }
23
+ parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
24
+ return parsedUrl;
25
+ }
@@ -1,8 +1,14 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
6
  export { RequestError, isRequestError } from './errors';
4
7
  export { isRateLimitedError, createRequestErrorReason } from './helpers';
5
- import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders } from './helpers';
8
+ import { createUrl, fetchRetry, createProcessFetchResponse, extendHeaders, isFetchNetworkError, defaultShouldRetryError } from './helpers';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { mapRetryUrlToPathBasedUrl } from '../pathBasedUrl';
11
+ import getNavigator from '../getNavigator';
6
12
  export function request(_x) {
7
13
  return _request.apply(this, arguments);
8
14
  }
@@ -23,6 +29,9 @@ function _request() {
23
29
  retryOptions,
24
30
  metadata,
25
31
  doFetch,
32
+ shouldRetryError,
33
+ _getNavigator2,
34
+ doFetchWithPathBasedUrl,
26
35
  _args = arguments;
27
36
  return _regeneratorRuntime.wrap(function _callee$(_context) {
28
37
  while (1) switch (_context.prev = _context.next) {
@@ -46,12 +55,51 @@ function _request() {
46
55
  signal: controller && controller.signal
47
56
  }).then(createProcessFetchResponse(metadata));
48
57
  };
58
+ if (!fg('platform_media_retry_edge_error')) {
59
+ _context.next = 20;
60
+ break;
61
+ }
62
+ shouldRetryError = function shouldRetryError(err) {
63
+ var _getNavigator;
64
+ if (isFetchNetworkError(err) && (_getNavigator = getNavigator()) !== null && _getNavigator !== void 0 && _getNavigator.userAgent.includes('Edg/')) {
65
+ return false;
66
+ }
67
+ return defaultShouldRetryError(err);
68
+ };
69
+ _context.prev = 8;
70
+ _context.next = 11;
71
+ return fetchRetry(doFetch, metadata, _objectSpread(_objectSpread({}, retryOptions), {}, {
72
+ shouldRetryError: shouldRetryError
73
+ }));
74
+ case 11:
75
+ return _context.abrupt("return", _context.sent);
76
+ case 14:
77
+ _context.prev = 14;
78
+ _context.t0 = _context["catch"](8);
79
+ if (!(isFetchNetworkError(_context.t0) && (_getNavigator2 = getNavigator()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/'))) {
80
+ _context.next = 19;
81
+ break;
82
+ }
83
+ doFetchWithPathBasedUrl = function doFetchWithPathBasedUrl() {
84
+ return fetch(createUrl(mapRetryUrlToPathBasedUrl(url).toString(), {
85
+ params: params
86
+ }), {
87
+ method: method,
88
+ body: body,
89
+ headers: extendHeaders(headers, auth, traceContext),
90
+ signal: controller && controller.signal
91
+ }).then(createProcessFetchResponse(metadata));
92
+ };
93
+ return _context.abrupt("return", fetchRetry(doFetchWithPathBasedUrl, metadata, retryOptions));
94
+ case 19:
95
+ throw _context.t0;
96
+ case 20:
49
97
  return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
50
- case 7:
98
+ case 21:
51
99
  case "end":
52
100
  return _context.stop();
53
101
  }
54
- }, _callee);
102
+ }, _callee, null, [[8, 14]]);
55
103
  }));
56
104
  return _request.apply(this, arguments);
57
105
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Document | undefined;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Navigator | undefined;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export declare function mapToPathBasedUrl(url: string): string;
2
+ export declare function mapRetryUrlToPathBasedUrl(url: string): URL;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Document | undefined;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Navigator | undefined;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export declare function mapToPathBasedUrl(url: string): string;
2
+ export declare function mapRetryUrlToPathBasedUrl(url: string): URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "35.3.1",
3
+ "version": "35.3.2",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -22,11 +22,6 @@
22
22
  },
23
23
  "sideEffects": false,
24
24
  "atlaskit:src": "src/index.ts",
25
- "af:exports": {
26
- "./constants": "./src/constants.ts",
27
- "./test-helpers": "./src/test-helpers/index.ts",
28
- ".": "./src/index.ts"
29
- },
30
25
  "atlassian": {
31
26
  "team": "Media Exif",
32
27
  "website": {
@@ -58,7 +53,7 @@
58
53
  "@atlaskit/media-core": "^37.0.0",
59
54
  "@atlaskit/media-state": "^1.8.0",
60
55
  "@atlaskit/ssr": "workspace:^",
61
- "@atlaskit/tokens": "^6.0.0",
56
+ "@atlaskit/tokens": "^6.3.0",
62
57
  "@atlassian/feature-flags-test-utils": "^0.3.0",
63
58
  "@emotion/react": "^11.7.1",
64
59
  "@types/deep-equal": "^1.0.1",
@@ -87,6 +82,12 @@
87
82
  "platform_media_cdn_delivery": {
88
83
  "type": "boolean"
89
84
  },
85
+ "platform_media_path_based_route": {
86
+ "type": "boolean"
87
+ },
88
+ "platform_media_retry_edge_error": {
89
+ "type": "boolean"
90
+ },
90
91
  "platform_disable_isolated_cloud_media_cdn_delivery": {
91
92
  "type": "boolean"
92
93
  }