@atlaskit/media-client 21.0.0 → 21.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 (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client/file-fetcher/error.js +4 -4
  3. package/dist/cjs/client/file-fetcher/index.js +283 -297
  4. package/dist/cjs/client/media-client.js +42 -48
  5. package/dist/cjs/client/media-store/index.js +389 -310
  6. package/dist/cjs/client/media-store/resolveAuth.js +33 -36
  7. package/dist/cjs/client/stargate-client.js +17 -20
  8. package/dist/cjs/index.js +6 -0
  9. package/dist/cjs/models/media.js +4 -4
  10. package/dist/cjs/uploader/error.js +4 -4
  11. package/dist/cjs/uploader/index.js +97 -108
  12. package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
  13. package/dist/cjs/utils/createFileDataLoader.js +68 -73
  14. package/dist/cjs/utils/getDimensionsFromBlob.js +26 -29
  15. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +27 -30
  16. package/dist/cjs/utils/hashing/hasherCreator.js +35 -37
  17. package/dist/cjs/utils/mobileUpload/error.js +4 -4
  18. package/dist/cjs/utils/mobileUpload/helpers.js +44 -47
  19. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +17 -20
  20. package/dist/cjs/utils/parseJwt.js +52 -0
  21. package/dist/cjs/utils/polling/index.js +43 -46
  22. package/dist/cjs/utils/request/errors.js +9 -9
  23. package/dist/cjs/utils/request/helpers.js +154 -167
  24. package/dist/cjs/utils/request/index.js +27 -30
  25. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +42 -45
  26. package/dist/cjs/version.json +1 -1
  27. package/dist/es2019/client/file-fetcher/index.js +1 -3
  28. package/dist/es2019/client/media-store/index.js +58 -6
  29. package/dist/es2019/index.js +1 -1
  30. package/dist/es2019/models/media.js +3 -3
  31. package/dist/es2019/utils/parseJwt.js +46 -0
  32. package/dist/es2019/version.json +1 -1
  33. package/dist/esm/client/file-fetcher/error.js +4 -4
  34. package/dist/esm/client/file-fetcher/index.js +282 -296
  35. package/dist/esm/client/media-client.js +40 -47
  36. package/dist/esm/client/media-store/index.js +389 -310
  37. package/dist/esm/client/media-store/resolveAuth.js +33 -36
  38. package/dist/esm/client/stargate-client.js +17 -20
  39. package/dist/esm/index.js +1 -1
  40. package/dist/esm/models/media.js +3 -3
  41. package/dist/esm/uploader/error.js +4 -4
  42. package/dist/esm/uploader/index.js +97 -108
  43. package/dist/esm/utils/convertBase64ToBlob.js +2 -2
  44. package/dist/esm/utils/createFileDataLoader.js +68 -73
  45. package/dist/esm/utils/getDimensionsFromBlob.js +26 -29
  46. package/dist/esm/utils/getVideoDimensionsFromBlob.js +27 -30
  47. package/dist/esm/utils/hashing/hasherCreator.js +31 -34
  48. package/dist/esm/utils/mobileUpload/error.js +4 -4
  49. package/dist/esm/utils/mobileUpload/helpers.js +44 -47
  50. package/dist/esm/utils/mobileUpload/stateMachine/index.js +17 -20
  51. package/dist/esm/utils/parseJwt.js +46 -0
  52. package/dist/esm/utils/polling/index.js +43 -46
  53. package/dist/esm/utils/request/errors.js +9 -9
  54. package/dist/esm/utils/request/helpers.js +154 -167
  55. package/dist/esm/utils/request/index.js +27 -30
  56. package/dist/esm/utils/shouldFetchRemoteFileStates.js +42 -45
  57. package/dist/esm/version.json +1 -1
  58. package/dist/types/client/media-store/index.d.ts +15 -0
  59. package/dist/types/index.d.ts +1 -1
  60. package/dist/types/utils/parseJwt.d.ts +1 -0
  61. package/package.json +2 -2
  62. package/report.api.md +31 -0
@@ -1,9 +1,12 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
4
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
5
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
6
  import _createClass from "@babel/runtime/helpers/createClass";
5
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
8
+ var _excluded = ["size"];
9
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
10
  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; }
8
11
  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) { _defineProperty(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; }
9
12
  import { getRandomHex } from '@atlaskit/media-common';
@@ -12,6 +15,7 @@ import { getArtifactUrl } from '../../models/artifacts';
12
15
  import { request as _request } from '../../utils/request';
13
16
  import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
14
17
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
18
+ import parseJwt from '../../utils/parseJwt';
15
19
  export { MediaStoreError, isMediaStoreError } from './error';
16
20
  var MEDIA_API_REGION = 'media-api-region';
17
21
  var MEDIA_API_ENVIRONMENT = 'media-api-environment';
@@ -47,43 +51,41 @@ export var MediaStore = /*#__PURE__*/function () {
47
51
  _createClass(MediaStore, [{
48
52
  key: "removeCollectionFile",
49
53
  value: function () {
50
- var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
54
+ var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
51
55
  var metadata, body, options;
52
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
- while (1) {
54
- switch (_context.prev = _context.next) {
55
- case 0:
56
- metadata = {
57
- method: 'PUT',
58
- endpoint: '/collection/{collectionName}'
59
- };
60
- body = {
61
- actions: [{
62
- action: 'remove',
63
- item: {
64
- type: 'file',
65
- id: id,
66
- occurrenceKey: occurrenceKey
67
- }
68
- }]
69
- };
70
- options = _objectSpread(_objectSpread({}, metadata), {}, {
71
- authContext: {
72
- collectionName: collectionName
73
- },
74
- headers: {
75
- Accept: 'application/json',
76
- 'Content-Type': 'application/json'
77
- },
78
- body: JSON.stringify(body),
79
- traceContext: traceContext
80
- });
81
- _context.next = 5;
82
- return this.request("/collection/".concat(collectionName), options);
83
- case 5:
84
- case "end":
85
- return _context.stop();
86
- }
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) switch (_context.prev = _context.next) {
58
+ case 0:
59
+ metadata = {
60
+ method: 'PUT',
61
+ endpoint: '/collection/{collectionName}'
62
+ };
63
+ body = {
64
+ actions: [{
65
+ action: 'remove',
66
+ item: {
67
+ type: 'file',
68
+ id: id,
69
+ occurrenceKey: occurrenceKey
70
+ }
71
+ }]
72
+ };
73
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
74
+ authContext: {
75
+ collectionName: collectionName
76
+ },
77
+ headers: {
78
+ Accept: 'application/json',
79
+ 'Content-Type': 'application/json'
80
+ },
81
+ body: JSON.stringify(body),
82
+ traceContext: traceContext
83
+ });
84
+ _context.next = 5;
85
+ return this.request("/collection/".concat(collectionName), options);
86
+ case 5:
87
+ case "end":
88
+ return _context.stop();
87
89
  }
88
90
  }, _callee, this);
89
91
  }));
@@ -119,33 +121,31 @@ export var MediaStore = /*#__PURE__*/function () {
119
121
  }, {
120
122
  key: "uploadChunk",
121
123
  value: function () {
122
- var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
124
+ var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
123
125
  var metadata, options;
124
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
125
- while (1) {
126
- switch (_context2.prev = _context2.next) {
127
- case 0:
128
- metadata = {
129
- method: 'PUT',
130
- endpoint: '/chunk/{etag}'
131
- };
132
- options = _objectSpread(_objectSpread({}, metadata), {}, {
133
- params: {
134
- uploadId: uploadId,
135
- partNumber: partNumber
136
- },
137
- authContext: {
138
- collectionName: collectionName
139
- },
140
- body: blob,
141
- traceContext: traceContext
142
- });
143
- _context2.next = 4;
144
- return this.request("/chunk/".concat(etag), options);
145
- case 4:
146
- case "end":
147
- return _context2.stop();
148
- }
126
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
127
+ while (1) switch (_context2.prev = _context2.next) {
128
+ case 0:
129
+ metadata = {
130
+ method: 'PUT',
131
+ endpoint: '/chunk/{etag}'
132
+ };
133
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
134
+ params: {
135
+ uploadId: uploadId,
136
+ partNumber: partNumber
137
+ },
138
+ authContext: {
139
+ collectionName: collectionName
140
+ },
141
+ body: blob,
142
+ traceContext: traceContext
143
+ });
144
+ _context2.next = 4;
145
+ return this.request("/chunk/".concat(etag), options);
146
+ case 4:
147
+ case "end":
148
+ return _context2.stop();
149
149
  }
150
150
  }, _callee2, this);
151
151
  }));
@@ -197,24 +197,108 @@ export var MediaStore = /*#__PURE__*/function () {
197
197
  return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
198
198
  }
199
199
  }, {
200
- key: "touchFiles",
201
- value: function touchFiles(body) {
202
- var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
203
- var traceContext = arguments.length > 2 ? arguments[2] : undefined;
204
- var metadata = {
205
- method: 'POST',
206
- endpoint: '/upload/createWithFiles'
200
+ key: "getRejectedResponseFromDescriptor",
201
+ value: function getRejectedResponseFromDescriptor(descriptor, limit) {
202
+ return {
203
+ fileId: descriptor.fileId,
204
+ error: {
205
+ code: 'ExceedMaxFileSizeLimit',
206
+ title: 'The expected file size exceeded the maximum size limit.',
207
+ href: 'https://dt-api-filestore--app.ap-southeast-2.dev.atl-paas.net/api.html#BadRequest',
208
+ limit: limit,
209
+ size: descriptor.size
210
+ }
207
211
  };
208
- var options = _objectSpread(_objectSpread({}, metadata), {}, {
209
- authContext: {
210
- collectionName: params.collection
211
- },
212
- headers: jsonHeaders,
213
- body: JSON.stringify(body),
214
- traceContext: traceContext
215
- });
216
- return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
217
212
  }
213
+ }, {
214
+ key: "touchFiles",
215
+ value: function () {
216
+ var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(body) {
217
+ var _this2 = this;
218
+ var params,
219
+ traceContext,
220
+ metadata,
221
+ auth,
222
+ maxFileSize,
223
+ decoded,
224
+ _body$descriptors$red,
225
+ _body$descriptors$red2,
226
+ filteredDescriptors,
227
+ rejectedResponse,
228
+ options,
229
+ _args3 = arguments;
230
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
231
+ while (1) switch (_context3.prev = _context3.next) {
232
+ case 0:
233
+ params = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
234
+ traceContext = _args3.length > 2 ? _args3[2] : undefined;
235
+ metadata = {
236
+ method: 'POST',
237
+ endpoint: '/upload/createWithFiles'
238
+ };
239
+ _context3.next = 5;
240
+ return this.resolveAuth({
241
+ collectionName: params.collection
242
+ });
243
+ case 5:
244
+ auth = _context3.sent;
245
+ try {
246
+ decoded = parseJwt(auth.token);
247
+ maxFileSize = decoded.fileSizeLimit;
248
+ } catch (error) {
249
+ // we're relying on the backend to throw an error when there's an invalid token
250
+ }
251
+
252
+ // TODO MEX-2318: backend eventually will allow `size` in the body of this request, then some of this logic will need to be altered
253
+ _body$descriptors$red = body.descriptors.reduce(function (_ref, curr) {
254
+ var _ref2 = _slicedToArray(_ref, 2),
255
+ filtered = _ref2[0],
256
+ rejected = _ref2[1];
257
+ var size = curr.size,
258
+ descriptor = _objectWithoutProperties(curr, _excluded);
259
+ if (maxFileSize && size && size > maxFileSize) {
260
+ return [filtered, [].concat(_toConsumableArray(rejected), [_this2.getRejectedResponseFromDescriptor(curr, maxFileSize)])];
261
+ }
262
+ return [[].concat(_toConsumableArray(filtered), [descriptor]), rejected];
263
+ }, [[], []]), _body$descriptors$red2 = _slicedToArray(_body$descriptors$red, 2), filteredDescriptors = _body$descriptors$red2[0], rejectedResponse = _body$descriptors$red2[1];
264
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
265
+ authContext: {
266
+ collectionName: params.collection
267
+ },
268
+ headers: jsonHeaders,
269
+ body: JSON.stringify(_objectSpread(_objectSpread({}, body), {}, {
270
+ descriptors: filteredDescriptors
271
+ })),
272
+ traceContext: traceContext,
273
+ resolvedAuth: auth
274
+ });
275
+ if (!(filteredDescriptors.length === 0)) {
276
+ _context3.next = 11;
277
+ break;
278
+ }
279
+ return _context3.abrupt("return", {
280
+ data: {
281
+ created: [],
282
+ rejected: rejectedResponse
283
+ }
284
+ });
285
+ case 11:
286
+ return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)).then(function (res) {
287
+ // TODO MEX-2318: backend eventually will include `rejected`, then this logic will need to be removed
288
+ res.data.rejected = rejectedResponse;
289
+ return res;
290
+ }));
291
+ case 12:
292
+ case "end":
293
+ return _context3.stop();
294
+ }
295
+ }, _callee3, this);
296
+ }));
297
+ function touchFiles(_x11) {
298
+ return _touchFiles.apply(this, arguments);
299
+ }
300
+ return touchFiles;
301
+ }()
218
302
  }, {
219
303
  key: "getFile",
220
304
  value: function getFile(fileId) {
@@ -236,28 +320,26 @@ export var MediaStore = /*#__PURE__*/function () {
236
320
  }, {
237
321
  key: "getFileImageURL",
238
322
  value: function () {
239
- var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id, params) {
240
- var _ref, collectionName, auth;
241
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
242
- while (1) {
243
- switch (_context3.prev = _context3.next) {
244
- case 0:
245
- _ref = params || {}, collectionName = _ref.collection;
246
- _context3.next = 3;
247
- return this.resolveAuth({
248
- collectionName: collectionName
249
- });
250
- case 3:
251
- auth = _context3.sent;
252
- return _context3.abrupt("return", this.createFileImageURL(id, auth, params));
253
- case 5:
254
- case "end":
255
- return _context3.stop();
256
- }
323
+ var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
324
+ var _ref3, collectionName, auth;
325
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
326
+ while (1) switch (_context4.prev = _context4.next) {
327
+ case 0:
328
+ _ref3 = params || {}, collectionName = _ref3.collection;
329
+ _context4.next = 3;
330
+ return this.resolveAuth({
331
+ collectionName: collectionName
332
+ });
333
+ case 3:
334
+ auth = _context4.sent;
335
+ return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
336
+ case 5:
337
+ case "end":
338
+ return _context4.stop();
257
339
  }
258
- }, _callee3, this);
340
+ }, _callee4, this);
259
341
  }));
260
- function getFileImageURL(_x11, _x12) {
342
+ function getFileImageURL(_x12, _x13) {
261
343
  return _getFileImageURL.apply(this, arguments);
262
344
  }
263
345
  return getFileImageURL;
@@ -280,35 +362,33 @@ export var MediaStore = /*#__PURE__*/function () {
280
362
  }, {
281
363
  key: "getFileBinaryURL",
282
364
  value: function () {
283
- var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id, collectionName) {
365
+ var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
284
366
  var auth, options;
285
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
286
- while (1) {
287
- switch (_context4.prev = _context4.next) {
288
- case 0:
289
- _context4.next = 2;
290
- return this.resolveAuth({
291
- collectionName: collectionName
292
- });
293
- case 2:
294
- auth = _context4.sent;
295
- options = {
296
- params: {
297
- dl: true,
298
- collection: collectionName,
299
- 'max-age': FILE_CACHE_MAX_AGE
300
- },
301
- auth: auth
302
- };
303
- return _context4.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
304
- case 5:
305
- case "end":
306
- return _context4.stop();
307
- }
367
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
368
+ while (1) switch (_context5.prev = _context5.next) {
369
+ case 0:
370
+ _context5.next = 2;
371
+ return this.resolveAuth({
372
+ collectionName: collectionName
373
+ });
374
+ case 2:
375
+ auth = _context5.sent;
376
+ options = {
377
+ params: {
378
+ dl: true,
379
+ collection: collectionName,
380
+ 'max-age': FILE_CACHE_MAX_AGE
381
+ },
382
+ auth: auth
383
+ };
384
+ return _context5.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
385
+ case 5:
386
+ case "end":
387
+ return _context5.stop();
308
388
  }
309
- }, _callee4, this);
389
+ }, _callee5, this);
310
390
  }));
311
- function getFileBinaryURL(_x13, _x14) {
391
+ function getFileBinaryURL(_x14, _x15) {
312
392
  return _getFileBinaryURL.apply(this, arguments);
313
393
  }
314
394
  return getFileBinaryURL;
@@ -316,41 +396,39 @@ export var MediaStore = /*#__PURE__*/function () {
316
396
  }, {
317
397
  key: "getArtifactURL",
318
398
  value: function () {
319
- var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(artifacts, artifactName, collectionName) {
399
+ var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(artifacts, artifactName, collectionName) {
320
400
  var artifactUrl, auth, options;
321
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
322
- while (1) {
323
- switch (_context5.prev = _context5.next) {
324
- case 0:
325
- artifactUrl = getArtifactUrl(artifacts, artifactName);
326
- if (artifactUrl) {
327
- _context5.next = 3;
328
- break;
329
- }
330
- throw new Error("artifact ".concat(artifactName, " not found"));
331
- case 3:
332
- _context5.next = 5;
333
- return this.resolveAuth({
334
- collectionName: collectionName
335
- });
336
- case 5:
337
- auth = _context5.sent;
338
- options = {
339
- params: {
340
- collection: collectionName,
341
- 'max-age': FILE_CACHE_MAX_AGE
342
- },
343
- auth: auth
344
- };
345
- return _context5.abrupt("return", createUrl("".concat(auth.baseUrl).concat(artifactUrl), options));
346
- case 8:
347
- case "end":
348
- return _context5.stop();
349
- }
401
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
402
+ while (1) switch (_context6.prev = _context6.next) {
403
+ case 0:
404
+ artifactUrl = getArtifactUrl(artifacts, artifactName);
405
+ if (artifactUrl) {
406
+ _context6.next = 3;
407
+ break;
408
+ }
409
+ throw new Error("artifact ".concat(artifactName, " not found"));
410
+ case 3:
411
+ _context6.next = 5;
412
+ return this.resolveAuth({
413
+ collectionName: collectionName
414
+ });
415
+ case 5:
416
+ auth = _context6.sent;
417
+ options = {
418
+ params: {
419
+ collection: collectionName,
420
+ 'max-age': FILE_CACHE_MAX_AGE
421
+ },
422
+ auth: auth
423
+ };
424
+ return _context6.abrupt("return", createUrl("".concat(auth.baseUrl).concat(artifactUrl), options));
425
+ case 8:
426
+ case "end":
427
+ return _context6.stop();
350
428
  }
351
- }, _callee5, this);
429
+ }, _callee6, this);
352
430
  }));
353
- function getArtifactURL(_x15, _x16, _x17) {
431
+ function getArtifactURL(_x16, _x17, _x18) {
354
432
  return _getArtifactURL.apply(this, arguments);
355
433
  }
356
434
  return getArtifactURL;
@@ -358,39 +436,37 @@ export var MediaStore = /*#__PURE__*/function () {
358
436
  }, {
359
437
  key: "getImage",
360
438
  value: function () {
361
- var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id, params, controller, fetchMaxRes, traceContext) {
439
+ var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
362
440
  var isWebpSupported, headers, metadata, options;
363
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
364
- while (1) {
365
- switch (_context6.prev = _context6.next) {
366
- case 0:
367
- // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
368
- isWebpSupported = false;
369
- headers = {};
370
- if (isWebpSupported) {
371
- headers.accept = 'image/webp,image/*,*/*;q=0.8';
372
- }
373
- metadata = {
374
- method: 'GET',
375
- endpoint: '/file/{fileId}/image'
376
- };
377
- options = _objectSpread(_objectSpread({}, metadata), {}, {
378
- authContext: {
379
- collectionName: params && params.collection
380
- },
381
- params: extendImageParams(params, fetchMaxRes),
382
- headers: headers,
383
- traceContext: traceContext
384
- });
385
- return _context6.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
386
- case 6:
387
- case "end":
388
- return _context6.stop();
389
- }
441
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
442
+ while (1) switch (_context7.prev = _context7.next) {
443
+ case 0:
444
+ // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
445
+ isWebpSupported = false;
446
+ headers = {};
447
+ if (isWebpSupported) {
448
+ headers.accept = 'image/webp,image/*,*/*;q=0.8';
449
+ }
450
+ metadata = {
451
+ method: 'GET',
452
+ endpoint: '/file/{fileId}/image'
453
+ };
454
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
455
+ authContext: {
456
+ collectionName: params && params.collection
457
+ },
458
+ params: extendImageParams(params, fetchMaxRes),
459
+ headers: headers,
460
+ traceContext: traceContext
461
+ });
462
+ return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
463
+ case 6:
464
+ case "end":
465
+ return _context7.stop();
390
466
  }
391
- }, _callee6, this);
467
+ }, _callee7, this);
392
468
  }));
393
- function getImage(_x18, _x19, _x20, _x21, _x22) {
469
+ function getImage(_x19, _x20, _x21, _x22, _x23) {
394
470
  return _getImage.apply(this, arguments);
395
471
  }
396
472
  return getImage;
@@ -398,42 +474,40 @@ export var MediaStore = /*#__PURE__*/function () {
398
474
  }, {
399
475
  key: "getItems",
400
476
  value: function () {
401
- var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ids, collectionName, traceContext) {
477
+ var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
402
478
  var descriptors, metadata, options;
403
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
404
- while (1) {
405
- switch (_context7.prev = _context7.next) {
406
- case 0:
407
- descriptors = ids.map(function (id) {
408
- return {
409
- type: 'file',
410
- id: id,
411
- collection: collectionName
412
- };
413
- });
414
- metadata = {
415
- method: 'POST',
416
- endpoint: '/items'
479
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
480
+ while (1) switch (_context8.prev = _context8.next) {
481
+ case 0:
482
+ descriptors = ids.map(function (id) {
483
+ return {
484
+ type: 'file',
485
+ id: id,
486
+ collection: collectionName
417
487
  };
418
- options = _objectSpread(_objectSpread({}, metadata), {}, {
419
- authContext: {
420
- collectionName: collectionName
421
- },
422
- headers: jsonHeaders,
423
- body: JSON.stringify({
424
- descriptors: descriptors
425
- }),
426
- traceContext: traceContext
427
- });
428
- return _context7.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
429
- case 4:
430
- case "end":
431
- return _context7.stop();
432
- }
488
+ });
489
+ metadata = {
490
+ method: 'POST',
491
+ endpoint: '/items'
492
+ };
493
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
494
+ authContext: {
495
+ collectionName: collectionName
496
+ },
497
+ headers: jsonHeaders,
498
+ body: JSON.stringify({
499
+ descriptors: descriptors
500
+ }),
501
+ traceContext: traceContext
502
+ });
503
+ return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
504
+ case 4:
505
+ case "end":
506
+ return _context8.stop();
433
507
  }
434
- }, _callee7, this);
508
+ }, _callee8, this);
435
509
  }));
436
- function getItems(_x23, _x24, _x25) {
510
+ function getItems(_x24, _x25, _x26) {
437
511
  return _getItems.apply(this, arguments);
438
512
  }
439
513
  return getItems;
@@ -441,32 +515,30 @@ export var MediaStore = /*#__PURE__*/function () {
441
515
  }, {
442
516
  key: "getImageMetadata",
443
517
  value: function () {
444
- var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id, params, traceContext) {
518
+ var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
445
519
  var metadata, options;
446
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
447
- while (1) {
448
- switch (_context8.prev = _context8.next) {
449
- case 0:
450
- metadata = {
451
- method: 'GET',
452
- endpoint: '/file/{fileId}/image/metadata'
453
- };
454
- options = _objectSpread(_objectSpread({}, metadata), {}, {
455
- authContext: {
456
- collectionName: params && params.collection
457
- },
458
- params: params,
459
- traceContext: traceContext
460
- });
461
- return _context8.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
462
- case 3:
463
- case "end":
464
- return _context8.stop();
465
- }
520
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
521
+ while (1) switch (_context9.prev = _context9.next) {
522
+ case 0:
523
+ metadata = {
524
+ method: 'GET',
525
+ endpoint: '/file/{fileId}/image/metadata'
526
+ };
527
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
528
+ authContext: {
529
+ collectionName: params && params.collection
530
+ },
531
+ params: params,
532
+ traceContext: traceContext
533
+ });
534
+ return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
535
+ case 3:
536
+ case "end":
537
+ return _context9.stop();
466
538
  }
467
- }, _callee8, this);
539
+ }, _callee9, this);
468
540
  }));
469
- function getImageMetadata(_x26, _x27, _x28) {
541
+ function getImageMetadata(_x27, _x28, _x29) {
470
542
  return _getImageMetadata.apply(this, arguments);
471
543
  }
472
544
  return getImageMetadata;
@@ -474,34 +546,32 @@ export var MediaStore = /*#__PURE__*/function () {
474
546
  }, {
475
547
  key: "appendChunksToUpload",
476
548
  value: function () {
477
- var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(uploadId, body, collectionName, traceContext) {
549
+ var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
478
550
  var metadata, options;
479
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
480
- while (1) {
481
- switch (_context9.prev = _context9.next) {
482
- case 0:
483
- metadata = {
484
- method: 'PUT',
485
- endpoint: '/upload/{uploadId}/chunks'
486
- };
487
- options = _objectSpread(_objectSpread({}, metadata), {}, {
488
- authContext: {
489
- collectionName: collectionName
490
- },
491
- headers: jsonHeaders,
492
- body: JSON.stringify(body),
493
- traceContext: traceContext
494
- });
495
- _context9.next = 4;
496
- return this.request("/upload/".concat(uploadId, "/chunks"), options);
497
- case 4:
498
- case "end":
499
- return _context9.stop();
500
- }
551
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
552
+ while (1) switch (_context10.prev = _context10.next) {
553
+ case 0:
554
+ metadata = {
555
+ method: 'PUT',
556
+ endpoint: '/upload/{uploadId}/chunks'
557
+ };
558
+ options = _objectSpread(_objectSpread({}, metadata), {}, {
559
+ authContext: {
560
+ collectionName: collectionName
561
+ },
562
+ headers: jsonHeaders,
563
+ body: JSON.stringify(body),
564
+ traceContext: traceContext
565
+ });
566
+ _context10.next = 4;
567
+ return this.request("/upload/".concat(uploadId, "/chunks"), options);
568
+ case 4:
569
+ case "end":
570
+ return _context10.stop();
501
571
  }
502
- }, _callee9, this);
572
+ }, _callee10, this);
503
573
  }));
504
- function appendChunksToUpload(_x29, _x30, _x31, _x32) {
574
+ function appendChunksToUpload(_x30, _x31, _x32, _x33) {
505
575
  return _appendChunksToUpload.apply(this, arguments);
506
576
  }
507
577
  return appendChunksToUpload;
@@ -530,7 +600,7 @@ export var MediaStore = /*#__PURE__*/function () {
530
600
  }, {
531
601
  key: "request",
532
602
  value: function () {
533
- var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(path) {
603
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(path) {
534
604
  var options,
535
605
  controller,
536
606
  method,
@@ -541,52 +611,61 @@ export var MediaStore = /*#__PURE__*/function () {
541
611
  body,
542
612
  clientOptions,
543
613
  traceContext,
614
+ resolvedAuth,
544
615
  auth,
545
616
  extendedTraceContext,
546
617
  response,
547
- _args10 = arguments;
548
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
549
- while (1) {
550
- switch (_context10.prev = _context10.next) {
551
- case 0:
552
- options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {
553
- method: 'GET',
554
- endpoint: undefined,
555
- authContext: {}
556
- };
557
- controller = _args10.length > 2 ? _args10[2] : undefined;
558
- method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
559
- _context10.next = 5;
560
- return this.resolveAuth(authContext);
561
- case 5:
562
- auth = _context10.sent;
563
- extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
564
- spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
565
- }) : undefined;
566
- _context10.next = 9;
567
- return _request("".concat(auth.baseUrl).concat(path), {
568
- method: method,
569
- endpoint: endpoint,
570
- auth: auth,
571
- params: params,
572
- headers: headers,
573
- body: body,
574
- clientOptions: clientOptions,
575
- traceContext: extendedTraceContext
576
- }, controller);
577
- case 9:
578
- response = _context10.sent;
579
- setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
580
- setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
581
- return _context10.abrupt("return", response);
582
- case 13:
583
- case "end":
584
- return _context10.stop();
585
- }
618
+ _args11 = arguments;
619
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
620
+ while (1) switch (_context11.prev = _context11.next) {
621
+ case 0:
622
+ options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {
623
+ method: 'GET',
624
+ endpoint: undefined,
625
+ authContext: {}
626
+ };
627
+ controller = _args11.length > 2 ? _args11[2] : undefined;
628
+ method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, resolvedAuth = options.resolvedAuth;
629
+ if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
630
+ _context11.next = 7;
631
+ break;
632
+ }
633
+ _context11.t0 = resolvedAuth;
634
+ _context11.next = 10;
635
+ break;
636
+ case 7:
637
+ _context11.next = 9;
638
+ return this.resolveAuth(authContext);
639
+ case 9:
640
+ _context11.t0 = _context11.sent;
641
+ case 10:
642
+ auth = _context11.t0;
643
+ extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
644
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
645
+ }) : undefined;
646
+ _context11.next = 14;
647
+ return _request("".concat(auth.baseUrl).concat(path), {
648
+ method: method,
649
+ endpoint: endpoint,
650
+ auth: auth,
651
+ params: params,
652
+ headers: headers,
653
+ body: body,
654
+ clientOptions: clientOptions,
655
+ traceContext: extendedTraceContext
656
+ }, controller);
657
+ case 14:
658
+ response = _context11.sent;
659
+ setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
660
+ setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
661
+ return _context11.abrupt("return", response);
662
+ case 18:
663
+ case "end":
664
+ return _context11.stop();
586
665
  }
587
- }, _callee10, this);
666
+ }, _callee11, this);
588
667
  }));
589
- function request(_x33) {
668
+ function request(_x34) {
590
669
  return _request2.apply(this, arguments);
591
670
  }
592
671
  return request;