@atlaskit/media-client 32.0.2 → 33.1.0

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 (30) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/client/file-fetcher/index.js +143 -114
  3. package/dist/cjs/client/media-client.js +1 -1
  4. package/dist/cjs/client/media-store/MediaStore.js +227 -138
  5. package/dist/cjs/utils/hashing/hasherCreator.js +20 -32
  6. package/dist/cjs/utils/request/helpers.js +1 -1
  7. package/dist/es2019/client/file-fetcher/index.js +15 -0
  8. package/dist/es2019/client/media-client.js +1 -1
  9. package/dist/es2019/client/media-store/MediaStore.js +63 -7
  10. package/dist/es2019/utils/hashing/hasherCreator.js +19 -23
  11. package/dist/es2019/utils/request/helpers.js +1 -1
  12. package/dist/esm/client/file-fetcher/index.js +143 -114
  13. package/dist/esm/client/media-client.js +1 -1
  14. package/dist/esm/client/media-store/MediaStore.js +227 -138
  15. package/dist/esm/utils/hashing/hasherCreator.js +19 -29
  16. package/dist/esm/utils/request/helpers.js +1 -1
  17. package/dist/types/client/file-fetcher/index.d.ts +4 -1
  18. package/dist/types/client/media-store/MediaStore.d.ts +3 -1
  19. package/dist/types/client/media-store/types.d.ts +13 -0
  20. package/dist/types/utils/hashing/hasherCreator.d.ts +1 -1
  21. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -1
  22. package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +3 -1
  23. package/dist/types-ts4.5/client/media-store/types.d.ts +13 -0
  24. package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +1 -1
  25. package/package.json +5 -5
  26. package/dist/cjs/utils/hashing/workerHasher.js +0 -113
  27. package/dist/es2019/utils/hashing/workerHasher.js +0 -89
  28. package/dist/esm/utils/hashing/workerHasher.js +0 -106
  29. package/dist/types/utils/hashing/workerHasher.d.ts +0 -16
  30. package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +0 -16
@@ -41,10 +41,8 @@ var jsonHeaders = {
41
41
  };
42
42
  var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
43
43
  var result = endpoint;
44
- if ((0, _platformFeatureFlags.fg)('platform_media_cdn_delivery')) {
45
- if ((0, _isCommercial.isCommercial)()) {
46
- result += '/cdn';
47
- }
44
+ if ((0, _isCommercial.isCommercial)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery')) {
45
+ result += '/cdn';
48
46
  }
49
47
  return result;
50
48
  };
@@ -52,6 +50,79 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
52
50
  function MediaStore(config) {
53
51
  var _this = this;
54
52
  (0, _classCallCheck2.default)(this, MediaStore);
53
+ (0, _defineProperty2.default)(this, "getArtifactBinary", /*#__PURE__*/function () {
54
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(artifacts, artifactName, _ref) {
55
+ var collectionName, abortController, _ref$maxAge, maxAge, traceContext, metadata, extendedTraceContext, options, artifactUrl;
56
+ return _regenerator.default.wrap(function _callee$(_context) {
57
+ while (1) switch (_context.prev = _context.next) {
58
+ case 0:
59
+ collectionName = _ref.collectionName, abortController = _ref.abortController, _ref$maxAge = _ref.maxAge, maxAge = _ref$maxAge === void 0 ? _constants.FILE_CACHE_MAX_AGE : _ref$maxAge, traceContext = _ref.traceContext;
60
+ metadata = {
61
+ method: 'GET',
62
+ endpoint: "artifact-cdn-url"
63
+ };
64
+ extendedTraceContext = (0, _helpers.extendTraceContext)(traceContext);
65
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
66
+ traceContext: extendedTraceContext
67
+ });
68
+ _context.next = 6;
69
+ return _this.getArtifactURL(artifacts, artifactName, collectionName, maxAge);
70
+ case 6:
71
+ artifactUrl = _context.sent;
72
+ return _context.abrupt("return", (0, _request3.request)(artifactUrl, options, abortController).then((0, _helpers.createMapResponseToBlob)(metadata)));
73
+ case 8:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }, _callee);
78
+ }));
79
+ return function (_x, _x2, _x3) {
80
+ return _ref2.apply(this, arguments);
81
+ };
82
+ }());
83
+ (0, _defineProperty2.default)(this, "uploadArtifact", /*#__PURE__*/function () {
84
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, file, params, collectionName, traceContext) {
85
+ var metadata, headers, extendedParams, authContext, options;
86
+ return _regenerator.default.wrap(function _callee2$(_context2) {
87
+ while (1) switch (_context2.prev = _context2.next) {
88
+ case 0:
89
+ metadata = {
90
+ method: 'POST',
91
+ endpoint: '/file/{fileId}/artifact/binary'
92
+ };
93
+ headers = {
94
+ Accept: 'application/json',
95
+ 'Content-Type': file.type
96
+ };
97
+ extendedParams = _objectSpread(_objectSpread({}, params), {}, {
98
+ name: file.name
99
+ });
100
+ authContext = {
101
+ collectionName: collectionName,
102
+ access: [{
103
+ type: 'file',
104
+ id: id,
105
+ actions: ['update']
106
+ }]
107
+ };
108
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
109
+ authContext: authContext,
110
+ headers: headers,
111
+ params: extendedParams,
112
+ body: file,
113
+ traceContext: traceContext
114
+ });
115
+ return _context2.abrupt("return", _this.request("/file/".concat(id, "/artifact/binary"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
116
+ case 6:
117
+ case "end":
118
+ return _context2.stop();
119
+ }
120
+ }, _callee2);
121
+ }));
122
+ return function (_x4, _x5, _x6, _x7, _x8) {
123
+ return _ref3.apply(this, arguments);
124
+ };
125
+ }());
55
126
  (0, _defineProperty2.default)(this, "resolveAuth", function (authContext) {
56
127
  return (0, _resolveAuth.resolveAuth)(_this.config.authProvider, authContext, _this.config.authProviderTimeout);
57
128
  });
@@ -59,15 +130,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
59
130
  return (0, _resolveAuth.resolveInitialAuth)(_this.config.initialAuth);
60
131
  });
61
132
  this.config = config;
62
- this._chunkHashAlgorithm = config.chunkHashAlgorithm || _mediaCore.ChunkHashAlgorithm.Sha1;
133
+ this._chunkHashAlgorithm = config.chunkHashAlgorithm || _mediaCore.ChunkHashAlgorithm.Sha256;
63
134
  }
64
135
  return (0, _createClass2.default)(MediaStore, [{
65
136
  key: "removeCollectionFile",
66
137
  value: function () {
67
- var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
138
+ var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, collectionName, occurrenceKey, traceContext) {
68
139
  var metadata, body, options;
69
- return _regenerator.default.wrap(function _callee$(_context) {
70
- while (1) switch (_context.prev = _context.next) {
140
+ return _regenerator.default.wrap(function _callee3$(_context3) {
141
+ while (1) switch (_context3.prev = _context3.next) {
71
142
  case 0:
72
143
  metadata = {
73
144
  method: 'PUT',
@@ -94,15 +165,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
94
165
  body: JSON.stringify(body),
95
166
  traceContext: traceContext
96
167
  });
97
- _context.next = 5;
168
+ _context3.next = 5;
98
169
  return this.request("/collection/".concat(collectionName), options);
99
170
  case 5:
100
171
  case "end":
101
- return _context.stop();
172
+ return _context3.stop();
102
173
  }
103
- }, _callee, this);
174
+ }, _callee3, this);
104
175
  }));
105
- function removeCollectionFile(_x, _x2, _x3, _x4) {
176
+ function removeCollectionFile(_x9, _x10, _x11, _x12) {
106
177
  return _removeCollectionFile.apply(this, arguments);
107
178
  }
108
179
  return removeCollectionFile;
@@ -135,10 +206,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
135
206
  }, {
136
207
  key: "uploadChunk",
137
208
  value: function () {
138
- var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
209
+ var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(etag, blob, uploadId, partNumber, collectionName, traceContext) {
139
210
  var metadata, options;
140
- return _regenerator.default.wrap(function _callee2$(_context2) {
141
- while (1) switch (_context2.prev = _context2.next) {
211
+ return _regenerator.default.wrap(function _callee4$(_context4) {
212
+ while (1) switch (_context4.prev = _context4.next) {
142
213
  case 0:
143
214
  metadata = {
144
215
  method: 'PUT',
@@ -155,15 +226,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
155
226
  body: blob,
156
227
  traceContext: traceContext
157
228
  });
158
- _context2.next = 4;
229
+ _context4.next = 4;
159
230
  return this.request("/chunk/".concat(etag), options);
160
231
  case 4:
161
232
  case "end":
162
- return _context2.stop();
233
+ return _context4.stop();
163
234
  }
164
- }, _callee2, this);
235
+ }, _callee4, this);
165
236
  }));
166
- function uploadChunk(_x5, _x6, _x7, _x8, _x9, _x10) {
237
+ function uploadChunk(_x13, _x14, _x15, _x16, _x17, _x18) {
167
238
  return _uploadChunk.apply(this, arguments);
168
239
  }
169
240
  return uploadChunk;
@@ -205,17 +276,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
205
276
  }, {
206
277
  key: "touchFiles",
207
278
  value: function () {
208
- var _touchFiles = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(body) {
279
+ var _touchFiles = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(body) {
209
280
  var params,
210
281
  traceContext,
211
282
  metadata,
212
283
  options,
213
- _args3 = arguments;
214
- return _regenerator.default.wrap(function _callee3$(_context3) {
215
- while (1) switch (_context3.prev = _context3.next) {
284
+ _args5 = arguments;
285
+ return _regenerator.default.wrap(function _callee5$(_context5) {
286
+ while (1) switch (_context5.prev = _context5.next) {
216
287
  case 0:
217
- params = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
218
- traceContext = _args3.length > 2 ? _args3[2] : undefined;
288
+ params = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
289
+ traceContext = _args5.length > 2 ? _args5[2] : undefined;
219
290
  metadata = {
220
291
  method: 'POST',
221
292
  endpoint: '/upload/createWithFiles'
@@ -231,14 +302,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
231
302
  hashAlgorithm: this._chunkHashAlgorithm
232
303
  }
233
304
  });
234
- return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata)));
305
+ return _context5.abrupt("return", this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata)));
235
306
  case 5:
236
307
  case "end":
237
- return _context3.stop();
308
+ return _context5.stop();
238
309
  }
239
- }, _callee3, this);
310
+ }, _callee5, this);
240
311
  }));
241
- function touchFiles(_x11) {
312
+ function touchFiles(_x19) {
242
313
  return _touchFiles.apply(this, arguments);
243
314
  }
244
315
  return touchFiles;
@@ -264,26 +335,26 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
264
335
  }, {
265
336
  key: "getFileImageURL",
266
337
  value: function () {
267
- var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, params) {
268
- var _ref, collectionName, auth;
269
- return _regenerator.default.wrap(function _callee4$(_context4) {
270
- while (1) switch (_context4.prev = _context4.next) {
338
+ var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(id, params) {
339
+ var _ref4, collectionName, auth;
340
+ return _regenerator.default.wrap(function _callee6$(_context6) {
341
+ while (1) switch (_context6.prev = _context6.next) {
271
342
  case 0:
272
- _ref = params || {}, collectionName = _ref.collection;
273
- _context4.next = 3;
343
+ _ref4 = params || {}, collectionName = _ref4.collection;
344
+ _context6.next = 3;
274
345
  return this.resolveAuth({
275
346
  collectionName: collectionName
276
347
  });
277
348
  case 3:
278
- auth = _context4.sent;
279
- return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
349
+ auth = _context6.sent;
350
+ return _context6.abrupt("return", this.createFileImageURL(id, auth, params));
280
351
  case 5:
281
352
  case "end":
282
- return _context4.stop();
353
+ return _context6.stop();
283
354
  }
284
- }, _callee4, this);
355
+ }, _callee6, this);
285
356
  }));
286
- function getFileImageURL(_x12, _x13) {
357
+ function getFileImageURL(_x20, _x21) {
287
358
  return _getFileImageURL.apply(this, arguments);
288
359
  }
289
360
  return getFileImageURL;
@@ -307,17 +378,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
307
378
  }, {
308
379
  key: "getFileBinary",
309
380
  value: function () {
310
- var _getFileBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName, abortController) {
381
+ var _getFileBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, collectionName, abortController) {
311
382
  var maxAge,
312
383
  headers,
313
384
  binaryEndpoint,
314
385
  metadata,
315
386
  options,
316
- _args5 = arguments;
317
- return _regenerator.default.wrap(function _callee5$(_context5) {
318
- while (1) switch (_context5.prev = _context5.next) {
387
+ _args7 = arguments;
388
+ return _regenerator.default.wrap(function _callee7$(_context7) {
389
+ while (1) switch (_context7.prev = _context7.next) {
319
390
  case 0:
320
- maxAge = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : _constants.FILE_CACHE_MAX_AGE;
391
+ maxAge = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : _constants.FILE_CACHE_MAX_AGE;
321
392
  headers = {};
322
393
  binaryEndpoint = cdnFeatureFlag('binary');
323
394
  metadata = {
@@ -334,14 +405,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
334
405
  'max-age': "".concat(maxAge)
335
406
  }
336
407
  });
337
- return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
408
+ return _context7.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
338
409
  case 6:
339
410
  case "end":
340
- return _context5.stop();
411
+ return _context7.stop();
341
412
  }
342
- }, _callee5, this);
413
+ }, _callee7, this);
343
414
  }));
344
- function getFileBinary(_x14, _x15, _x16) {
415
+ function getFileBinary(_x22, _x23, _x24) {
345
416
  return _getFileBinary.apply(this, arguments);
346
417
  }
347
418
  return getFileBinary;
@@ -349,22 +420,22 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
349
420
  }, {
350
421
  key: "getFileBinaryURL",
351
422
  value: function () {
352
- var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(id, collectionName) {
423
+ var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(id, collectionName) {
353
424
  var maxAge,
354
425
  auth,
355
426
  options,
356
427
  binaryEndpoint,
357
- _args6 = arguments;
358
- return _regenerator.default.wrap(function _callee6$(_context6) {
359
- while (1) switch (_context6.prev = _context6.next) {
428
+ _args8 = arguments;
429
+ return _regenerator.default.wrap(function _callee8$(_context8) {
430
+ while (1) switch (_context8.prev = _context8.next) {
360
431
  case 0:
361
- maxAge = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : _constants.FILE_CACHE_MAX_AGE;
362
- _context6.next = 3;
432
+ maxAge = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : _constants.FILE_CACHE_MAX_AGE;
433
+ _context8.next = 3;
363
434
  return this.resolveAuth({
364
435
  collectionName: collectionName
365
436
  });
366
437
  case 3:
367
- auth = _context6.sent;
438
+ auth = _context8.sent;
368
439
  options = {
369
440
  params: {
370
441
  dl: true,
@@ -374,14 +445,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
374
445
  auth: auth
375
446
  };
376
447
  binaryEndpoint = cdnFeatureFlag('binary');
377
- return _context6.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
448
+ return _context8.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
378
449
  case 7:
379
450
  case "end":
380
- return _context6.stop();
451
+ return _context8.stop();
381
452
  }
382
- }, _callee6, this);
453
+ }, _callee8, this);
383
454
  }));
384
- function getFileBinaryURL(_x17, _x18) {
455
+ function getFileBinaryURL(_x25, _x26) {
385
456
  return _getFileBinaryURL.apply(this, arguments);
386
457
  }
387
458
  return getFileBinaryURL;
@@ -389,39 +460,57 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
389
460
  }, {
390
461
  key: "getArtifactURL",
391
462
  value: function () {
392
- var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(artifacts, artifactName, collectionName) {
393
- var artifactUrl, auth, options;
394
- return _regenerator.default.wrap(function _callee7$(_context7) {
395
- while (1) switch (_context7.prev = _context7.next) {
463
+ var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(artifacts, artifactName, collectionName) {
464
+ var maxAge,
465
+ _artifacts$artifactNa,
466
+ cdnUrl,
467
+ artifactUrl,
468
+ auth,
469
+ options,
470
+ _args9 = arguments;
471
+ return _regenerator.default.wrap(function _callee9$(_context9) {
472
+ while (1) switch (_context9.prev = _context9.next) {
396
473
  case 0:
474
+ maxAge = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : _constants.FILE_CACHE_MAX_AGE;
475
+ if (!((0, _isCommercial.isCommercial)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery'))) {
476
+ _context9.next = 5;
477
+ break;
478
+ }
479
+ cdnUrl = (_artifacts$artifactNa = artifacts[artifactName]) === null || _artifacts$artifactNa === void 0 ? void 0 : _artifacts$artifactNa.cdnUrl;
480
+ if (!cdnUrl) {
481
+ _context9.next = 5;
482
+ break;
483
+ }
484
+ return _context9.abrupt("return", cdnUrl);
485
+ case 5:
397
486
  artifactUrl = (0, _artifacts.getArtifactUrl)(artifacts, artifactName);
398
487
  if (artifactUrl) {
399
- _context7.next = 3;
488
+ _context9.next = 8;
400
489
  break;
401
490
  }
402
491
  throw new Error("artifact ".concat(artifactName, " not found"));
403
- case 3:
404
- _context7.next = 5;
492
+ case 8:
493
+ _context9.next = 10;
405
494
  return this.resolveAuth({
406
495
  collectionName: collectionName
407
496
  });
408
- case 5:
409
- auth = _context7.sent;
497
+ case 10:
498
+ auth = _context9.sent;
410
499
  options = {
411
500
  params: {
412
501
  collection: collectionName,
413
- 'max-age': _constants.FILE_CACHE_MAX_AGE
502
+ 'max-age': maxAge
414
503
  },
415
504
  auth: auth
416
505
  };
417
- return _context7.abrupt("return", (0, _helpers.createUrl)((0, _mediaCdn.mapToMediaCdnUrl)(artifactUrl, auth.token), options));
418
- case 8:
506
+ return _context9.abrupt("return", (0, _helpers.createUrl)((0, _mediaCdn.mapToMediaCdnUrl)(artifactUrl, auth.token), options));
507
+ case 13:
419
508
  case "end":
420
- return _context7.stop();
509
+ return _context9.stop();
421
510
  }
422
- }, _callee7, this);
511
+ }, _callee9, this);
423
512
  }));
424
- function getArtifactURL(_x19, _x20, _x21) {
513
+ function getArtifactURL(_x27, _x28, _x29) {
425
514
  return _getArtifactURL.apply(this, arguments);
426
515
  }
427
516
  return getArtifactURL;
@@ -429,10 +518,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
429
518
  }, {
430
519
  key: "getImage",
431
520
  value: function () {
432
- var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(id, params, controller, fetchMaxRes, traceContext) {
521
+ var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, params, controller, fetchMaxRes, traceContext) {
433
522
  var isWebpSupported, headers, imageEndpoint, metadata, options;
434
- return _regenerator.default.wrap(function _callee8$(_context8) {
435
- while (1) switch (_context8.prev = _context8.next) {
523
+ return _regenerator.default.wrap(function _callee10$(_context10) {
524
+ while (1) switch (_context10.prev = _context10.next) {
436
525
  case 0:
437
526
  // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
438
527
  isWebpSupported = false;
@@ -454,14 +543,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
454
543
  traceContext: traceContext,
455
544
  addMediaClientParam: true
456
545
  });
457
- return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
546
+ return _context10.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
458
547
  case 7:
459
548
  case "end":
460
- return _context8.stop();
549
+ return _context10.stop();
461
550
  }
462
- }, _callee8, this);
551
+ }, _callee10, this);
463
552
  }));
464
- function getImage(_x22, _x23, _x24, _x25, _x26) {
553
+ function getImage(_x30, _x31, _x32, _x33, _x34) {
465
554
  return _getImage.apply(this, arguments);
466
555
  }
467
556
  return getImage;
@@ -469,10 +558,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
469
558
  }, {
470
559
  key: "getItems",
471
560
  value: function () {
472
- var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
561
+ var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
473
562
  var descriptors, metadata, options;
474
- return _regenerator.default.wrap(function _callee9$(_context9) {
475
- while (1) switch (_context9.prev = _context9.next) {
563
+ return _regenerator.default.wrap(function _callee11$(_context11) {
564
+ while (1) switch (_context11.prev = _context11.next) {
476
565
  case 0:
477
566
  descriptors = ids.map(function (id) {
478
567
  return {
@@ -496,14 +585,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
496
585
  }),
497
586
  traceContext: traceContext
498
587
  });
499
- return _context9.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
588
+ return _context11.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
500
589
  case 4:
501
590
  case "end":
502
- return _context9.stop();
591
+ return _context11.stop();
503
592
  }
504
- }, _callee9, this);
593
+ }, _callee11, this);
505
594
  }));
506
- function getItems(_x27, _x28, _x29, _x30) {
595
+ function getItems(_x35, _x36, _x37, _x38) {
507
596
  return _getItems.apply(this, arguments);
508
597
  }
509
598
  return getItems;
@@ -511,10 +600,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
511
600
  }, {
512
601
  key: "getImageMetadata",
513
602
  value: function () {
514
- var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, params, traceContext) {
603
+ var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(id, params, traceContext) {
515
604
  var metadata, options;
516
- return _regenerator.default.wrap(function _callee10$(_context10) {
517
- while (1) switch (_context10.prev = _context10.next) {
605
+ return _regenerator.default.wrap(function _callee12$(_context12) {
606
+ while (1) switch (_context12.prev = _context12.next) {
518
607
  case 0:
519
608
  metadata = {
520
609
  method: 'GET',
@@ -527,14 +616,14 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
527
616
  params: params,
528
617
  traceContext: traceContext
529
618
  });
530
- return _context10.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
619
+ return _context12.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
531
620
  case 3:
532
621
  case "end":
533
- return _context10.stop();
622
+ return _context12.stop();
534
623
  }
535
- }, _callee10, this);
624
+ }, _callee12, this);
536
625
  }));
537
- function getImageMetadata(_x31, _x32, _x33) {
626
+ function getImageMetadata(_x39, _x40, _x41) {
538
627
  return _getImageMetadata.apply(this, arguments);
539
628
  }
540
629
  return getImageMetadata;
@@ -542,10 +631,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
542
631
  }, {
543
632
  key: "appendChunksToUpload",
544
633
  value: function () {
545
- var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(uploadId, body, collectionName, traceContext) {
634
+ var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(uploadId, body, collectionName, traceContext) {
546
635
  var metadata, options;
547
- return _regenerator.default.wrap(function _callee11$(_context11) {
548
- while (1) switch (_context11.prev = _context11.next) {
636
+ return _regenerator.default.wrap(function _callee13$(_context13) {
637
+ while (1) switch (_context13.prev = _context13.next) {
549
638
  case 0:
550
639
  metadata = {
551
640
  method: 'PUT',
@@ -559,15 +648,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
559
648
  body: JSON.stringify(body),
560
649
  traceContext: traceContext
561
650
  });
562
- _context11.next = 4;
651
+ _context13.next = 4;
563
652
  return this.request("/upload/".concat(uploadId, "/chunks"), options);
564
653
  case 4:
565
654
  case "end":
566
- return _context11.stop();
655
+ return _context13.stop();
567
656
  }
568
- }, _callee11, this);
657
+ }, _callee13, this);
569
658
  }));
570
- function appendChunksToUpload(_x34, _x35, _x36, _x37) {
659
+ function appendChunksToUpload(_x42, _x43, _x44, _x45) {
571
660
  return _appendChunksToUpload.apply(this, arguments);
572
661
  }
573
662
  return appendChunksToUpload;
@@ -624,10 +713,10 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
624
713
  }, {
625
714
  key: "registerCopyIntents",
626
715
  value: function () {
627
- var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(files, traceContext, resolvedAuth) {
716
+ var _registerCopyIntents = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(files, traceContext, resolvedAuth) {
628
717
  var metadata, options;
629
- return _regenerator.default.wrap(function _callee12$(_context12) {
630
- while (1) switch (_context12.prev = _context12.next) {
718
+ return _regenerator.default.wrap(function _callee14$(_context14) {
719
+ while (1) switch (_context14.prev = _context14.next) {
631
720
  case 0:
632
721
  metadata = {
633
722
  method: 'POST',
@@ -641,15 +730,15 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
641
730
  traceContext: traceContext,
642
731
  resolvedAuth: resolvedAuth
643
732
  });
644
- _context12.next = 4;
733
+ _context14.next = 4;
645
734
  return this.request('/file/copy/intents', options);
646
735
  case 4:
647
736
  case "end":
648
- return _context12.stop();
737
+ return _context14.stop();
649
738
  }
650
- }, _callee12, this);
739
+ }, _callee14, this);
651
740
  }));
652
- function registerCopyIntents(_x38, _x39, _x40) {
741
+ function registerCopyIntents(_x46, _x47, _x48) {
653
742
  return _registerCopyIntents.apply(this, arguments);
654
743
  }
655
744
  return registerCopyIntents;
@@ -657,7 +746,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
657
746
  }, {
658
747
  key: "request",
659
748
  value: function () {
660
- var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(path) {
749
+ var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(path) {
661
750
  var options,
662
751
  controller,
663
752
  useMediaCdn,
@@ -677,32 +766,32 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
677
766
  extendedParams,
678
767
  url,
679
768
  response,
680
- _args13 = arguments;
681
- return _regenerator.default.wrap(function _callee13$(_context13) {
682
- while (1) switch (_context13.prev = _context13.next) {
769
+ _args15 = arguments;
770
+ return _regenerator.default.wrap(function _callee15$(_context15) {
771
+ while (1) switch (_context15.prev = _context15.next) {
683
772
  case 0:
684
- options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {
773
+ options = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {
685
774
  method: 'GET',
686
775
  endpoint: undefined,
687
776
  authContext: {}
688
777
  };
689
- controller = _args13.length > 2 ? _args13[2] : undefined;
690
- useMediaCdn = _args13.length > 3 ? _args13[3] : undefined;
778
+ controller = _args15.length > 2 ? _args15[2] : undefined;
779
+ useMediaCdn = _args15.length > 3 ? _args15[3] : undefined;
691
780
  method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, addMediaClientParam = options.addMediaClientParam, resolvedAuth = options.resolvedAuth;
692
781
  if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
693
- _context13.next = 8;
782
+ _context15.next = 8;
694
783
  break;
695
784
  }
696
- _context13.t0 = resolvedAuth;
697
- _context13.next = 11;
785
+ _context15.t0 = resolvedAuth;
786
+ _context15.next = 11;
698
787
  break;
699
788
  case 8:
700
- _context13.next = 10;
789
+ _context15.next = 10;
701
790
  return this.resolveAuth(authContext);
702
791
  case 10:
703
- _context13.t0 = _context13.sent;
792
+ _context15.t0 = _context15.sent;
704
793
  case 11:
705
- auth = _context13.t0;
794
+ auth = _context15.t0;
706
795
  clientId = (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined;
707
796
  extendedTraceContext = (0, _helpers.extendTraceContext)(traceContext);
708
797
  extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
@@ -712,7 +801,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
712
801
  if (useMediaCdn) {
713
802
  url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
714
803
  }
715
- _context13.next = 19;
804
+ _context15.next = 19;
716
805
  return (0, _request3.request)(url, {
717
806
  method: method,
718
807
  endpoint: endpoint,
@@ -724,17 +813,17 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
724
813
  traceContext: extendedTraceContext
725
814
  }, controller);
726
815
  case 19:
727
- response = _context13.sent;
816
+ response = _context15.sent;
728
817
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
729
818
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
730
- return _context13.abrupt("return", response);
819
+ return _context15.abrupt("return", response);
731
820
  case 23:
732
821
  case "end":
733
- return _context13.stop();
822
+ return _context15.stop();
734
823
  }
735
- }, _callee13, this);
824
+ }, _callee15, this);
736
825
  }));
737
- function request(_x41) {
826
+ function request(_x49) {
738
827
  return _request2.apply(this, arguments);
739
828
  }
740
829
  return request;
@@ -742,16 +831,16 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
742
831
  }, {
743
832
  key: "testUrl",
744
833
  value: function () {
745
- var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(url) {
834
+ var _testUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(url) {
746
835
  var options,
747
836
  traceContext,
748
- _args14 = arguments;
749
- return _regenerator.default.wrap(function _callee14$(_context14) {
750
- while (1) switch (_context14.prev = _context14.next) {
837
+ _args16 = arguments;
838
+ return _regenerator.default.wrap(function _callee16$(_context16) {
839
+ while (1) switch (_context16.prev = _context16.next) {
751
840
  case 0:
752
- options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
841
+ options = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
753
842
  traceContext = options.traceContext;
754
- _context14.next = 4;
843
+ _context16.next = 4;
755
844
  return (0, _request3.request)(url, {
756
845
  method: 'HEAD',
757
846
  traceContext: (0, _helpers.extendTraceContext)(traceContext),
@@ -763,11 +852,11 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
763
852
  });
764
853
  case 4:
765
854
  case "end":
766
- return _context14.stop();
855
+ return _context16.stop();
767
856
  }
768
- }, _callee14);
857
+ }, _callee16);
769
858
  }));
770
- function testUrl(_x42) {
859
+ function testUrl(_x50) {
771
860
  return _testUrl.apply(this, arguments);
772
861
  }
773
862
  return testUrl;