@atlaskit/media-client 20.0.1 → 20.0.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.
Files changed (161) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client/collection-fetcher.js +4 -44
  3. package/dist/cjs/client/file-fetcher/error.js +3 -19
  4. package/dist/cjs/client/file-fetcher/index.js +72 -191
  5. package/dist/cjs/client/media-client.js +2 -26
  6. package/dist/cjs/client/media-store/error.js +1 -17
  7. package/dist/cjs/client/media-store/index.js +13 -103
  8. package/dist/cjs/client/media-store/resolveAuth.js +2 -23
  9. package/dist/cjs/client/mobile-upload.js +9 -22
  10. package/dist/cjs/client/stargate-client.js +0 -12
  11. package/dist/cjs/constants.js +0 -3
  12. package/dist/cjs/file-streams-cache.js +0 -11
  13. package/dist/cjs/globalMediaEventEmitter.js +0 -3
  14. package/dist/cjs/identifier.js +0 -8
  15. package/dist/cjs/index.js +0 -38
  16. package/dist/cjs/models/artifacts.js +0 -4
  17. package/dist/cjs/models/auth-headers.js +0 -2
  18. package/dist/cjs/models/auth-query-parameters.js +0 -2
  19. package/dist/cjs/models/errors/helpers.js +0 -2
  20. package/dist/cjs/models/errors/index.js +4 -20
  21. package/dist/cjs/models/file-state.js +10 -36
  22. package/dist/cjs/models/media.js +2 -8
  23. package/dist/cjs/upload-controller.js +0 -6
  24. package/dist/cjs/uploader/calculateChunkSize.js +1 -10
  25. package/dist/cjs/uploader/error.js +3 -19
  26. package/dist/cjs/uploader/index.js +3 -43
  27. package/dist/cjs/utils/checkWebpSupport.js +3 -7
  28. package/dist/cjs/utils/convertBase64ToBlob.js +0 -5
  29. package/dist/cjs/utils/createFileDataLoader.js +4 -28
  30. package/dist/cjs/utils/createMediaSubject.js +0 -4
  31. package/dist/cjs/utils/detectEmptyFile.js +8 -15
  32. package/dist/cjs/utils/getDimensionsFromBlob.js +0 -14
  33. package/dist/cjs/utils/getImageDimensionsFromBlob.js +0 -4
  34. package/dist/cjs/utils/getMediaTypeFromUploadableFile.js +0 -3
  35. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +2 -8
  36. package/dist/cjs/utils/hashing/hasherCreator.js +0 -20
  37. package/dist/cjs/utils/hashing/simpleHasher.js +0 -12
  38. package/dist/cjs/utils/hashing/workerHasher.js +3 -24
  39. package/dist/cjs/utils/imageResizeModeToFileImageMode.js +0 -2
  40. package/dist/cjs/utils/isImageRemote.js +0 -5
  41. package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -4
  42. package/dist/cjs/utils/mediaSubscribable/index.js +0 -2
  43. package/dist/cjs/utils/mediaSubscribable/toPromise.js +1 -3
  44. package/dist/cjs/utils/mobileUpload/error.js +3 -19
  45. package/dist/cjs/utils/mobileUpload/helpers.js +2 -26
  46. package/dist/cjs/utils/mobileUpload/index.js +0 -4
  47. package/dist/cjs/utils/mobileUpload/servicesCache.js +0 -2
  48. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +0 -22
  49. package/dist/cjs/utils/mobileUpload/stateMachine/states/processing.js +0 -2
  50. package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +0 -7
  51. package/dist/cjs/utils/overrideMediaTypeIfUnknown.js +0 -4
  52. package/dist/cjs/utils/polling/errors.js +1 -17
  53. package/dist/cjs/utils/polling/index.js +1 -30
  54. package/dist/cjs/utils/request/errors.js +8 -24
  55. package/dist/cjs/utils/request/helpers.js +19 -103
  56. package/dist/cjs/utils/request/index.js +15 -26
  57. package/dist/cjs/utils/safeUnsubscribe.js +0 -2
  58. package/dist/cjs/utils/setTimeoutPromise.js +0 -4
  59. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +0 -21
  60. package/dist/cjs/utils/url.js +4 -27
  61. package/dist/cjs/utils/with-media-client-hoc.js +12 -28
  62. package/dist/cjs/version.json +1 -1
  63. package/dist/es2019/client/collection-fetcher.js +6 -18
  64. package/dist/es2019/client/file-fetcher/error.js +0 -2
  65. package/dist/es2019/client/file-fetcher/index.js +49 -91
  66. package/dist/es2019/client/media-client.js +3 -13
  67. package/dist/es2019/client/media-store/error.js +0 -2
  68. package/dist/es2019/client/media-store/index.js +37 -52
  69. package/dist/es2019/client/media-store/resolveAuth.js +1 -5
  70. package/dist/es2019/client/mobile-upload.js +0 -8
  71. package/dist/es2019/client/stargate-client.js +0 -3
  72. package/dist/es2019/constants.js +0 -1
  73. package/dist/es2019/file-streams-cache.js +0 -11
  74. package/dist/es2019/globalMediaEventEmitter.js +0 -4
  75. package/dist/es2019/index.js +4 -11
  76. package/dist/es2019/models/artifacts.js +0 -2
  77. package/dist/es2019/models/errors/index.js +5 -4
  78. package/dist/es2019/models/file-state.js +6 -7
  79. package/dist/es2019/models/media.js +2 -3
  80. package/dist/es2019/upload-controller.js +0 -3
  81. package/dist/es2019/uploader/calculateChunkSize.js +1 -4
  82. package/dist/es2019/uploader/error.js +0 -2
  83. package/dist/es2019/uploader/index.js +0 -13
  84. package/dist/es2019/utils/checkWebpSupport.js +3 -4
  85. package/dist/es2019/utils/convertBase64ToBlob.js +0 -2
  86. package/dist/es2019/utils/createFileDataLoader.js +6 -9
  87. package/dist/es2019/utils/createMediaSubject.js +0 -2
  88. package/dist/es2019/utils/detectEmptyFile.js +1 -5
  89. package/dist/es2019/utils/getDimensionsFromBlob.js +0 -3
  90. package/dist/es2019/utils/getImageDimensionsFromBlob.js +0 -2
  91. package/dist/es2019/utils/getVideoDimensionsFromBlob.js +2 -1
  92. package/dist/es2019/utils/hashing/hasherCreator.js +0 -2
  93. package/dist/es2019/utils/hashing/simpleHasher.js +0 -3
  94. package/dist/es2019/utils/hashing/workerHasher.js +1 -16
  95. package/dist/es2019/utils/isImageRemote.js +0 -2
  96. package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -1
  97. package/dist/es2019/utils/mediaSubscribable/toPromise.js +1 -1
  98. package/dist/es2019/utils/mobileUpload/error.js +0 -2
  99. package/dist/es2019/utils/mobileUpload/helpers.js +2 -7
  100. package/dist/es2019/utils/mobileUpload/stateMachine/index.js +0 -2
  101. package/dist/es2019/utils/mobileUpload/stateMachine/states/uploading.js +2 -1
  102. package/dist/es2019/utils/overrideMediaTypeIfUnknown.js +0 -1
  103. package/dist/es2019/utils/polling/errors.js +0 -2
  104. package/dist/es2019/utils/polling/index.js +3 -20
  105. package/dist/es2019/utils/request/errors.js +0 -2
  106. package/dist/es2019/utils/request/helpers.js +24 -35
  107. package/dist/es2019/utils/request/index.js +2 -2
  108. package/dist/es2019/utils/shouldFetchRemoteFileStates.js +1 -5
  109. package/dist/es2019/utils/url.js +6 -14
  110. package/dist/es2019/utils/with-media-client-hoc.js +10 -7
  111. package/dist/es2019/version.json +1 -1
  112. package/dist/esm/client/collection-fetcher.js +4 -34
  113. package/dist/esm/client/file-fetcher/error.js +3 -12
  114. package/dist/esm/client/file-fetcher/index.js +74 -161
  115. package/dist/esm/client/media-client.js +3 -16
  116. package/dist/esm/client/media-store/error.js +1 -10
  117. package/dist/esm/client/media-store/index.js +13 -89
  118. package/dist/esm/client/media-store/resolveAuth.js +2 -13
  119. package/dist/esm/client/mobile-upload.js +9 -15
  120. package/dist/esm/client/stargate-client.js +0 -7
  121. package/dist/esm/constants.js +0 -1
  122. package/dist/esm/file-streams-cache.js +0 -6
  123. package/dist/esm/globalMediaEventEmitter.js +0 -1
  124. package/dist/esm/index.js +4 -11
  125. package/dist/esm/models/artifacts.js +0 -2
  126. package/dist/esm/models/errors/index.js +5 -12
  127. package/dist/esm/models/file-state.js +10 -17
  128. package/dist/esm/models/media.js +2 -3
  129. package/dist/esm/upload-controller.js +0 -2
  130. package/dist/esm/uploader/calculateChunkSize.js +1 -4
  131. package/dist/esm/uploader/error.js +3 -12
  132. package/dist/esm/uploader/index.js +3 -32
  133. package/dist/esm/utils/checkWebpSupport.js +3 -4
  134. package/dist/esm/utils/convertBase64ToBlob.js +0 -3
  135. package/dist/esm/utils/createFileDataLoader.js +4 -18
  136. package/dist/esm/utils/createMediaSubject.js +0 -2
  137. package/dist/esm/utils/detectEmptyFile.js +8 -12
  138. package/dist/esm/utils/getDimensionsFromBlob.js +0 -7
  139. package/dist/esm/utils/getImageDimensionsFromBlob.js +0 -2
  140. package/dist/esm/utils/getVideoDimensionsFromBlob.js +2 -3
  141. package/dist/esm/utils/hashing/hasherCreator.js +0 -9
  142. package/dist/esm/utils/hashing/simpleHasher.js +0 -4
  143. package/dist/esm/utils/hashing/workerHasher.js +3 -18
  144. package/dist/esm/utils/isImageRemote.js +0 -3
  145. package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -1
  146. package/dist/esm/utils/mediaSubscribable/toPromise.js +1 -1
  147. package/dist/esm/utils/mobileUpload/error.js +3 -12
  148. package/dist/esm/utils/mobileUpload/helpers.js +2 -11
  149. package/dist/esm/utils/mobileUpload/stateMachine/index.js +0 -6
  150. package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +0 -3
  151. package/dist/esm/utils/overrideMediaTypeIfUnknown.js +0 -1
  152. package/dist/esm/utils/polling/errors.js +1 -10
  153. package/dist/esm/utils/polling/index.js +1 -27
  154. package/dist/esm/utils/request/errors.js +8 -17
  155. package/dist/esm/utils/request/helpers.js +22 -76
  156. package/dist/esm/utils/request/index.js +15 -20
  157. package/dist/esm/utils/shouldFetchRemoteFileStates.js +1 -15
  158. package/dist/esm/utils/url.js +4 -18
  159. package/dist/esm/utils/with-media-client-hoc.js +12 -17
  160. package/dist/esm/version.json +1 -1
  161. package/package.json +7 -5
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -19,35 +18,20 @@ Object.defineProperty(exports, "isMediaStoreError", {
19
18
  return _error.isMediaStoreError;
20
19
  }
21
20
  });
22
-
23
21
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
24
-
25
22
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
26
-
27
23
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
28
-
29
24
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
30
-
31
25
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
32
-
33
26
  var _mediaCommon = require("@atlaskit/media-common");
34
-
35
27
  var _constants = require("../../constants");
36
-
37
28
  var _artifacts = require("../../models/artifacts");
38
-
39
29
  var _request3 = require("../../utils/request");
40
-
41
30
  var _helpers = require("../../utils/request/helpers");
42
-
43
31
  var _resolveAuth = require("./resolveAuth");
44
-
45
32
  var _error = require("./error");
46
-
47
33
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
48
-
49
34
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
50
-
51
35
  var MEDIA_API_REGION = 'media-api-region';
52
36
  var MEDIA_API_ENVIRONMENT = 'media-api-environment';
53
37
  var defaultImageOptions = {
@@ -59,7 +43,6 @@ var defaultGetCollectionItems = {
59
43
  limit: 30,
60
44
  sortDirection: 'desc'
61
45
  };
62
-
63
46
  var extendImageParams = function extendImageParams(params) {
64
47
  var fetchMaxRes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
65
48
  return _objectSpread(_objectSpread(_objectSpread({}, defaultImageOptions), params), fetchMaxRes ? {
@@ -67,16 +50,13 @@ var extendImageParams = function extendImageParams(params) {
67
50
  height: _constants.MAX_RESOLUTION
68
51
  } : {});
69
52
  };
70
-
71
53
  var jsonHeaders = {
72
54
  Accept: 'application/json',
73
55
  'Content-Type': 'application/json'
74
56
  };
75
-
76
57
  var MediaStore = /*#__PURE__*/function () {
77
58
  function MediaStore(config, featureFlags) {
78
59
  var _this = this;
79
-
80
60
  (0, _classCallCheck2.default)(this, MediaStore);
81
61
  (0, _defineProperty2.default)(this, "resolveAuth", function (authContext) {
82
62
  return (0, _resolveAuth.resolveAuth)(_this.config.authProvider, authContext);
@@ -87,13 +67,11 @@ var MediaStore = /*#__PURE__*/function () {
87
67
  this.config = config;
88
68
  this.featureFlags = featureFlags;
89
69
  }
90
-
91
70
  (0, _createClass2.default)(MediaStore, [{
92
71
  key: "getCollectionItems",
93
72
  value: function () {
94
73
  var _getCollectionItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionName, params, traceContext) {
95
74
  var metadata, options, response, _yield$createMapRespo, _yield$createMapRespo2, contents, nextInclusiveStartKey, contentsWithoutEmptyFiles;
96
-
97
75
  return _regenerator.default.wrap(function _callee$(_context) {
98
76
  while (1) {
99
77
  switch (_context.prev = _context.next) {
@@ -114,12 +92,10 @@ var MediaStore = /*#__PURE__*/function () {
114
92
  });
115
93
  _context.next = 4;
116
94
  return this.request("/collection/".concat(collectionName, "/items"), options);
117
-
118
95
  case 4:
119
96
  response = _context.sent;
120
97
  _context.next = 7;
121
98
  return (0, _helpers.createMapResponseToJson)(metadata)(response);
122
-
123
99
  case 7:
124
100
  _yield$createMapRespo = _context.sent;
125
101
  _yield$createMapRespo2 = _yield$createMapRespo.data;
@@ -136,7 +112,6 @@ var MediaStore = /*#__PURE__*/function () {
136
112
  nextInclusiveStartKey: nextInclusiveStartKey
137
113
  }
138
114
  });
139
-
140
115
  case 13:
141
116
  case "end":
142
117
  return _context.stop();
@@ -144,11 +119,9 @@ var MediaStore = /*#__PURE__*/function () {
144
119
  }
145
120
  }, _callee, this);
146
121
  }));
147
-
148
122
  function getCollectionItems(_x, _x2, _x3) {
149
123
  return _getCollectionItems.apply(this, arguments);
150
124
  }
151
-
152
125
  return getCollectionItems;
153
126
  }()
154
127
  }, {
@@ -187,7 +160,6 @@ var MediaStore = /*#__PURE__*/function () {
187
160
  });
188
161
  _context2.next = 5;
189
162
  return this.request("/collection/".concat(collectionName), options);
190
-
191
163
  case 5:
192
164
  case "end":
193
165
  return _context2.stop();
@@ -195,11 +167,9 @@ var MediaStore = /*#__PURE__*/function () {
195
167
  }
196
168
  }, _callee2, this);
197
169
  }));
198
-
199
170
  function removeCollectionFile(_x4, _x5, _x6, _x7) {
200
171
  return _removeCollectionFile.apply(this, arguments);
201
172
  }
202
-
203
173
  return removeCollectionFile;
204
174
  }()
205
175
  }, {
@@ -212,7 +182,6 @@ var MediaStore = /*#__PURE__*/function () {
212
182
  method: 'POST',
213
183
  endpoint: '/upload'
214
184
  };
215
-
216
185
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
217
186
  authContext: {
218
187
  collectionName: collectionName
@@ -225,7 +194,6 @@ var MediaStore = /*#__PURE__*/function () {
225
194
  },
226
195
  traceContext: traceContext
227
196
  });
228
-
229
197
  return this.request("/upload", options).then((0, _helpers.createMapResponseToJson)(metadata));
230
198
  }
231
199
  }, {
@@ -254,7 +222,6 @@ var MediaStore = /*#__PURE__*/function () {
254
222
  });
255
223
  _context3.next = 4;
256
224
  return this.request("/chunk/".concat(etag), options);
257
-
258
225
  case 4:
259
226
  case "end":
260
227
  return _context3.stop();
@@ -262,11 +229,9 @@ var MediaStore = /*#__PURE__*/function () {
262
229
  }
263
230
  }, _callee3, this);
264
231
  }));
265
-
266
232
  function uploadChunk(_x8, _x9, _x10, _x11, _x12, _x13) {
267
233
  return _uploadChunk.apply(this, arguments);
268
234
  }
269
-
270
235
  return uploadChunk;
271
236
  }()
272
237
  }, {
@@ -276,7 +241,6 @@ var MediaStore = /*#__PURE__*/function () {
276
241
  method: 'POST',
277
242
  endpoint: '/chunk/probe'
278
243
  };
279
-
280
244
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
281
245
  params: {
282
246
  uploadId: uploadId
@@ -290,7 +254,6 @@ var MediaStore = /*#__PURE__*/function () {
290
254
  }),
291
255
  traceContext: traceContext
292
256
  });
293
-
294
257
  return this.request("/chunk/probe", options).then((0, _helpers.createMapResponseToJson)(metadata));
295
258
  }
296
259
  }, {
@@ -302,7 +265,6 @@ var MediaStore = /*#__PURE__*/function () {
302
265
  method: 'POST',
303
266
  endpoint: '/file/upload'
304
267
  };
305
-
306
268
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
307
269
  authContext: {
308
270
  collectionName: params.collection
@@ -312,7 +274,6 @@ var MediaStore = /*#__PURE__*/function () {
312
274
  body: JSON.stringify(body),
313
275
  traceContext: traceContext
314
276
  });
315
-
316
277
  return this.request('/file/upload', options).then((0, _helpers.createMapResponseToJson)(metadata));
317
278
  }
318
279
  }, {
@@ -324,7 +285,6 @@ var MediaStore = /*#__PURE__*/function () {
324
285
  method: 'POST',
325
286
  endpoint: '/upload/createWithFiles'
326
287
  };
327
-
328
288
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
329
289
  authContext: {
330
290
  collectionName: params.collection
@@ -333,7 +293,6 @@ var MediaStore = /*#__PURE__*/function () {
333
293
  body: JSON.stringify(body),
334
294
  traceContext: traceContext
335
295
  });
336
-
337
296
  return this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata));
338
297
  }
339
298
  }, {
@@ -345,7 +304,6 @@ var MediaStore = /*#__PURE__*/function () {
345
304
  method: 'GET',
346
305
  endpoint: '/file/{fileId}'
347
306
  };
348
-
349
307
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
350
308
  authContext: {
351
309
  collectionName: params.collection
@@ -353,7 +311,6 @@ var MediaStore = /*#__PURE__*/function () {
353
311
  params: params,
354
312
  traceContext: traceContext
355
313
  });
356
-
357
314
  return this.request("/file/".concat(fileId), options).then((0, _helpers.createMapResponseToJson)(metadata));
358
315
  }
359
316
  }, {
@@ -361,7 +318,6 @@ var MediaStore = /*#__PURE__*/function () {
361
318
  value: function () {
362
319
  var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, params) {
363
320
  var _ref, collectionName, auth;
364
-
365
321
  return _regenerator.default.wrap(function _callee4$(_context4) {
366
322
  while (1) {
367
323
  switch (_context4.prev = _context4.next) {
@@ -371,11 +327,9 @@ var MediaStore = /*#__PURE__*/function () {
371
327
  return this.resolveAuth({
372
328
  collectionName: collectionName
373
329
  });
374
-
375
330
  case 3:
376
331
  auth = _context4.sent;
377
332
  return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
378
-
379
333
  case 5:
380
334
  case "end":
381
335
  return _context4.stop();
@@ -383,14 +337,11 @@ var MediaStore = /*#__PURE__*/function () {
383
337
  }
384
338
  }, _callee4, this);
385
339
  }));
386
-
387
340
  function getFileImageURL(_x14, _x15) {
388
341
  return _getFileImageURL.apply(this, arguments);
389
342
  }
390
-
391
343
  return getFileImageURL;
392
344
  }() // TODO Create ticket in case Trace Id can be supported through query params
393
-
394
345
  }, {
395
346
  key: "getFileImageURLSync",
396
347
  value: function getFileImageURLSync(id, params) {
@@ -419,7 +370,6 @@ var MediaStore = /*#__PURE__*/function () {
419
370
  return this.resolveAuth({
420
371
  collectionName: collectionName
421
372
  });
422
-
423
373
  case 2:
424
374
  auth = _context5.sent;
425
375
  options = {
@@ -431,7 +381,6 @@ var MediaStore = /*#__PURE__*/function () {
431
381
  auth: auth
432
382
  };
433
383
  return _context5.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
434
-
435
384
  case 5:
436
385
  case "end":
437
386
  return _context5.stop();
@@ -439,11 +388,9 @@ var MediaStore = /*#__PURE__*/function () {
439
388
  }
440
389
  }, _callee5, this);
441
390
  }));
442
-
443
391
  function getFileBinaryURL(_x16, _x17) {
444
392
  return _getFileBinaryURL.apply(this, arguments);
445
393
  }
446
-
447
394
  return getFileBinaryURL;
448
395
  }()
449
396
  }, {
@@ -456,20 +403,16 @@ var MediaStore = /*#__PURE__*/function () {
456
403
  switch (_context6.prev = _context6.next) {
457
404
  case 0:
458
405
  artifactUrl = (0, _artifacts.getArtifactUrl)(artifacts, artifactName);
459
-
460
406
  if (artifactUrl) {
461
407
  _context6.next = 3;
462
408
  break;
463
409
  }
464
-
465
410
  throw new Error("artifact ".concat(artifactName, " not found"));
466
-
467
411
  case 3:
468
412
  _context6.next = 5;
469
413
  return this.resolveAuth({
470
414
  collectionName: collectionName
471
415
  });
472
-
473
416
  case 5:
474
417
  auth = _context6.sent;
475
418
  options = {
@@ -480,7 +423,6 @@ var MediaStore = /*#__PURE__*/function () {
480
423
  auth: auth
481
424
  };
482
425
  return _context6.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl).concat(artifactUrl), options));
483
-
484
426
  case 8:
485
427
  case "end":
486
428
  return _context6.stop();
@@ -488,11 +430,9 @@ var MediaStore = /*#__PURE__*/function () {
488
430
  }
489
431
  }, _callee6, this);
490
432
  }));
491
-
492
433
  function getArtifactURL(_x18, _x19, _x20) {
493
434
  return _getArtifactURL.apply(this, arguments);
494
435
  }
495
-
496
436
  return getArtifactURL;
497
437
  }()
498
438
  }, {
@@ -507,11 +447,9 @@ var MediaStore = /*#__PURE__*/function () {
507
447
  // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
508
448
  isWebpSupported = false;
509
449
  headers = {};
510
-
511
450
  if (isWebpSupported) {
512
451
  headers.accept = 'image/webp,image/*,*/*;q=0.8';
513
452
  }
514
-
515
453
  metadata = {
516
454
  method: 'GET',
517
455
  endpoint: '/file/{fileId}/image'
@@ -525,7 +463,6 @@ var MediaStore = /*#__PURE__*/function () {
525
463
  traceContext: traceContext
526
464
  });
527
465
  return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
528
-
529
466
  case 6:
530
467
  case "end":
531
468
  return _context7.stop();
@@ -533,11 +470,9 @@ var MediaStore = /*#__PURE__*/function () {
533
470
  }
534
471
  }, _callee7, this);
535
472
  }));
536
-
537
473
  function getImage(_x21, _x22, _x23, _x24, _x25) {
538
474
  return _getImage.apply(this, arguments);
539
475
  }
540
-
541
476
  return getImage;
542
477
  }()
543
478
  }, {
@@ -571,7 +506,6 @@ var MediaStore = /*#__PURE__*/function () {
571
506
  traceContext: traceContext
572
507
  });
573
508
  return _context8.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
574
-
575
509
  case 4:
576
510
  case "end":
577
511
  return _context8.stop();
@@ -579,11 +513,9 @@ var MediaStore = /*#__PURE__*/function () {
579
513
  }
580
514
  }, _callee8, this);
581
515
  }));
582
-
583
516
  function getItems(_x26, _x27, _x28) {
584
517
  return _getItems.apply(this, arguments);
585
518
  }
586
-
587
519
  return getItems;
588
520
  }()
589
521
  }, {
@@ -607,7 +539,6 @@ var MediaStore = /*#__PURE__*/function () {
607
539
  traceContext: traceContext
608
540
  });
609
541
  return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
610
-
611
542
  case 3:
612
543
  case "end":
613
544
  return _context9.stop();
@@ -615,11 +546,9 @@ var MediaStore = /*#__PURE__*/function () {
615
546
  }
616
547
  }, _callee9, this);
617
548
  }));
618
-
619
549
  function getImageMetadata(_x29, _x30, _x31) {
620
550
  return _getImageMetadata.apply(this, arguments);
621
551
  }
622
-
623
552
  return getImageMetadata;
624
553
  }()
625
554
  }, {
@@ -645,7 +574,6 @@ var MediaStore = /*#__PURE__*/function () {
645
574
  });
646
575
  _context10.next = 4;
647
576
  return this.request("/upload/".concat(uploadId, "/chunks"), options);
648
-
649
577
  case 4:
650
578
  case "end":
651
579
  return _context10.stop();
@@ -653,11 +581,9 @@ var MediaStore = /*#__PURE__*/function () {
653
581
  }
654
582
  }, _callee10, this);
655
583
  }));
656
-
657
584
  function appendChunksToUpload(_x32, _x33, _x34, _x35) {
658
585
  return _appendChunksToUpload.apply(this, arguments);
659
586
  }
660
-
661
587
  return appendChunksToUpload;
662
588
  }()
663
589
  }, {
@@ -667,7 +593,6 @@ var MediaStore = /*#__PURE__*/function () {
667
593
  method: 'POST',
668
594
  endpoint: '/file/copy/withToken'
669
595
  };
670
-
671
596
  var options = _objectSpread(_objectSpread({}, metadata), {}, {
672
597
  authContext: {
673
598
  collectionName: params.collection
@@ -680,7 +605,6 @@ var MediaStore = /*#__PURE__*/function () {
680
605
  // Contains collection name to read from
681
606
  traceContext: traceContext
682
607
  });
683
-
684
608
  return this.request('/file/copy/withToken', options).then((0, _helpers.createMapResponseToJson)(metadata));
685
609
  }
686
610
  }, {
@@ -688,19 +612,19 @@ var MediaStore = /*#__PURE__*/function () {
688
612
  value: function () {
689
613
  var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(path) {
690
614
  var options,
691
- controller,
692
- method,
693
- endpoint,
694
- authContext,
695
- params,
696
- headers,
697
- body,
698
- clientOptions,
699
- traceContext,
700
- auth,
701
- extendedTraceContext,
702
- response,
703
- _args11 = arguments;
615
+ controller,
616
+ method,
617
+ endpoint,
618
+ authContext,
619
+ params,
620
+ headers,
621
+ body,
622
+ clientOptions,
623
+ traceContext,
624
+ auth,
625
+ extendedTraceContext,
626
+ response,
627
+ _args11 = arguments;
704
628
  return _regenerator.default.wrap(function _callee11$(_context11) {
705
629
  while (1) {
706
630
  switch (_context11.prev = _context11.next) {
@@ -714,7 +638,6 @@ var MediaStore = /*#__PURE__*/function () {
714
638
  method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
715
639
  _context11.next = 5;
716
640
  return this.resolveAuth(authContext);
717
-
718
641
  case 5:
719
642
  auth = _context11.sent;
720
643
  extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
@@ -731,13 +654,11 @@ var MediaStore = /*#__PURE__*/function () {
731
654
  clientOptions: clientOptions,
732
655
  traceContext: extendedTraceContext
733
656
  }, controller);
734
-
735
657
  case 9:
736
658
  response = _context11.sent;
737
659
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
738
660
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
739
661
  return _context11.abrupt("return", response);
740
-
741
662
  case 13:
742
663
  case "end":
743
664
  return _context11.stop();
@@ -745,43 +666,32 @@ var MediaStore = /*#__PURE__*/function () {
745
666
  }
746
667
  }, _callee11, this);
747
668
  }));
748
-
749
669
  function request(_x36) {
750
670
  return _request2.apply(this, arguments);
751
671
  }
752
-
753
672
  return request;
754
673
  }()
755
674
  }]);
756
675
  return MediaStore;
757
676
  }();
758
-
759
677
  exports.MediaStore = MediaStore;
760
-
761
678
  var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
762
679
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
763
680
  };
764
-
765
681
  var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
766
682
  if (!value || !(window && window.sessionStorage)) {
767
683
  return;
768
684
  }
769
-
770
685
  var currentValue = window.sessionStorage.getItem(key);
771
-
772
686
  if (currentValue !== value) {
773
687
  window.sessionStorage.setItem(key, value);
774
688
  }
775
689
  };
776
-
777
690
  var getMediaEnvironment = function getMediaEnvironment() {
778
691
  return getValueFromSessionStorage(MEDIA_API_ENVIRONMENT);
779
692
  };
780
-
781
693
  exports.getMediaEnvironment = getMediaEnvironment;
782
-
783
694
  var getMediaRegion = function getMediaRegion() {
784
695
  return getValueFromSessionStorage(MEDIA_API_REGION);
785
696
  };
786
-
787
697
  exports.getMediaRegion = getMediaRegion;
@@ -1,28 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.resolveInitialAuth = exports.resolveAuth = exports.DEFAULT_AUTH_PROVIDER_TIMEOUT = void 0;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _error = require("./error");
15
-
16
11
  var _setTimeoutPromise = require("../../utils/setTimeoutPromise");
17
-
18
12
  var DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
19
13
  exports.DEFAULT_AUTH_PROVIDER_TIMEOUT = DEFAULT_AUTH_PROVIDER_TIMEOUT;
20
-
21
14
  var resolveAuth = /*#__PURE__*/function () {
22
15
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(authProvider, authContext) {
23
16
  var authProviderTimeout,
24
- auth,
25
- _args = arguments;
17
+ auth,
18
+ _args = arguments;
26
19
  return _regenerator.default.wrap(function _callee$(_context) {
27
20
  while (1) {
28
21
  switch (_context.prev = _context.next) {
@@ -31,37 +24,28 @@ var resolveAuth = /*#__PURE__*/function () {
31
24
  _context.prev = 1;
32
25
  _context.next = 4;
33
26
  return Promise.race([authProvider(authContext), (0, _setTimeoutPromise.rejectTimeout)(authProviderTimeout, new _error.MediaStoreError('authProviderTimedOut'))]);
34
-
35
27
  case 4:
36
28
  auth = _context.sent;
37
29
  _context.next = 12;
38
30
  break;
39
-
40
31
  case 7:
41
32
  _context.prev = 7;
42
33
  _context.t0 = _context["catch"](1);
43
-
44
34
  if (!(_context.t0 instanceof _error.MediaStoreError)) {
45
35
  _context.next = 11;
46
36
  break;
47
37
  }
48
-
49
38
  throw _context.t0;
50
-
51
39
  case 11:
52
40
  throw new _error.MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
53
-
54
41
  case 12:
55
42
  if (auth) {
56
43
  _context.next = 14;
57
44
  break;
58
45
  }
59
-
60
46
  throw new _error.MediaStoreError('emptyAuth');
61
-
62
47
  case 14:
63
48
  return _context.abrupt("return", auth);
64
-
65
49
  case 15:
66
50
  case "end":
67
51
  return _context.stop();
@@ -69,20 +53,15 @@ var resolveAuth = /*#__PURE__*/function () {
69
53
  }
70
54
  }, _callee, null, [[1, 7]]);
71
55
  }));
72
-
73
56
  return function resolveAuth(_x, _x2) {
74
57
  return _ref.apply(this, arguments);
75
58
  };
76
59
  }();
77
-
78
60
  exports.resolveAuth = resolveAuth;
79
-
80
61
  var resolveInitialAuth = function resolveInitialAuth(auth) {
81
62
  if (!auth) {
82
63
  throw new _error.MediaStoreError('missingInitialAuth');
83
64
  }
84
-
85
65
  return auth;
86
66
  };
87
-
88
67
  exports.resolveInitialAuth = resolveInitialAuth;