@atlaskit/media-client 21.0.0 → 22.0.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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +283 -297
- package/dist/cjs/client/media-client.js +42 -48
- package/dist/cjs/client/media-store/index.js +389 -310
- package/dist/cjs/client/media-store/resolveAuth.js +33 -36
- package/dist/cjs/client/stargate-client.js +17 -20
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/models/media.js +4 -4
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +97 -108
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +68 -73
- package/dist/cjs/utils/getDimensionsFromBlob.js +26 -29
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +27 -30
- package/dist/cjs/utils/hashing/hasherCreator.js +35 -37
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +44 -47
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +17 -20
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +43 -46
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +154 -167
- package/dist/cjs/utils/request/index.js +27 -30
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +42 -45
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-store/index.js +58 -6
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/models/media.js +3 -3
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +282 -296
- package/dist/esm/client/media-client.js +40 -47
- package/dist/esm/client/media-store/index.js +389 -310
- package/dist/esm/client/media-store/resolveAuth.js +33 -36
- package/dist/esm/client/stargate-client.js +17 -20
- package/dist/esm/index.js +1 -1
- package/dist/esm/models/media.js +3 -3
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +97 -108
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +68 -73
- package/dist/esm/utils/getDimensionsFromBlob.js +26 -29
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +27 -30
- package/dist/esm/utils/hashing/hasherCreator.js +31 -34
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +44 -47
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +17 -20
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +43 -46
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +154 -167
- package/dist/esm/utils/request/index.js +27 -30
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +42 -45
- package/dist/esm/version.json +1 -1
- package/dist/types/client/media-store/index.d.ts +15 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +9 -9
- package/report.api.md +31 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -19,6 +18,10 @@ Object.defineProperty(exports, "isMediaStoreError", {
|
|
|
19
18
|
return _error.isMediaStoreError;
|
|
20
19
|
}
|
|
21
20
|
});
|
|
21
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
22
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
23
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
24
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
22
25
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
23
26
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
24
27
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -29,8 +32,9 @@ var _artifacts = require("../../models/artifacts");
|
|
|
29
32
|
var _request3 = require("../../utils/request");
|
|
30
33
|
var _helpers = require("../../utils/request/helpers");
|
|
31
34
|
var _resolveAuth = require("./resolveAuth");
|
|
35
|
+
var _parseJwt = _interopRequireDefault(require("../../utils/parseJwt"));
|
|
32
36
|
var _error = require("./error");
|
|
33
|
-
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; }
|
|
37
|
+
var _excluded = ["size"];
|
|
34
38
|
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; }
|
|
35
39
|
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; }
|
|
36
40
|
var MEDIA_API_REGION = 'media-api-region';
|
|
@@ -67,43 +71,41 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
67
71
|
(0, _createClass2.default)(MediaStore, [{
|
|
68
72
|
key: "removeCollectionFile",
|
|
69
73
|
value: function () {
|
|
70
|
-
var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
74
|
+
var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
|
|
71
75
|
var metadata, body, options;
|
|
72
|
-
return
|
|
73
|
-
while (1) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return _context.stop();
|
|
106
|
-
}
|
|
76
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
metadata = {
|
|
80
|
+
method: 'PUT',
|
|
81
|
+
endpoint: '/collection/{collectionName}'
|
|
82
|
+
};
|
|
83
|
+
body = {
|
|
84
|
+
actions: [{
|
|
85
|
+
action: 'remove',
|
|
86
|
+
item: {
|
|
87
|
+
type: 'file',
|
|
88
|
+
id: id,
|
|
89
|
+
occurrenceKey: occurrenceKey
|
|
90
|
+
}
|
|
91
|
+
}]
|
|
92
|
+
};
|
|
93
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
94
|
+
authContext: {
|
|
95
|
+
collectionName: collectionName
|
|
96
|
+
},
|
|
97
|
+
headers: {
|
|
98
|
+
Accept: 'application/json',
|
|
99
|
+
'Content-Type': 'application/json'
|
|
100
|
+
},
|
|
101
|
+
body: JSON.stringify(body),
|
|
102
|
+
traceContext: traceContext
|
|
103
|
+
});
|
|
104
|
+
_context.next = 5;
|
|
105
|
+
return this.request("/collection/".concat(collectionName), options);
|
|
106
|
+
case 5:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context.stop();
|
|
107
109
|
}
|
|
108
110
|
}, _callee, this);
|
|
109
111
|
}));
|
|
@@ -139,33 +141,31 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
139
141
|
}, {
|
|
140
142
|
key: "uploadChunk",
|
|
141
143
|
value: function () {
|
|
142
|
-
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
144
|
+
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
143
145
|
var metadata, options;
|
|
144
|
-
return
|
|
145
|
-
while (1) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return _context2.stop();
|
|
168
|
-
}
|
|
146
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
metadata = {
|
|
150
|
+
method: 'PUT',
|
|
151
|
+
endpoint: '/chunk/{etag}'
|
|
152
|
+
};
|
|
153
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
154
|
+
params: {
|
|
155
|
+
uploadId: uploadId,
|
|
156
|
+
partNumber: partNumber
|
|
157
|
+
},
|
|
158
|
+
authContext: {
|
|
159
|
+
collectionName: collectionName
|
|
160
|
+
},
|
|
161
|
+
body: blob,
|
|
162
|
+
traceContext: traceContext
|
|
163
|
+
});
|
|
164
|
+
_context2.next = 4;
|
|
165
|
+
return this.request("/chunk/".concat(etag), options);
|
|
166
|
+
case 4:
|
|
167
|
+
case "end":
|
|
168
|
+
return _context2.stop();
|
|
169
169
|
}
|
|
170
170
|
}, _callee2, this);
|
|
171
171
|
}));
|
|
@@ -217,24 +217,108 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
217
217
|
return this.request('/file/upload', options).then((0, _helpers.createMapResponseToJson)(metadata));
|
|
218
218
|
}
|
|
219
219
|
}, {
|
|
220
|
-
key: "
|
|
221
|
-
value: function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
key: "getRejectedResponseFromDescriptor",
|
|
221
|
+
value: function getRejectedResponseFromDescriptor(descriptor, limit) {
|
|
222
|
+
return {
|
|
223
|
+
fileId: descriptor.fileId,
|
|
224
|
+
error: {
|
|
225
|
+
code: 'ExceedMaxFileSizeLimit',
|
|
226
|
+
title: 'The expected file size exceeded the maximum size limit.',
|
|
227
|
+
href: 'https://dt-api-filestore--app.ap-southeast-2.dev.atl-paas.net/api.html#BadRequest',
|
|
228
|
+
limit: limit,
|
|
229
|
+
size: descriptor.size
|
|
230
|
+
}
|
|
227
231
|
};
|
|
228
|
-
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
229
|
-
authContext: {
|
|
230
|
-
collectionName: params.collection
|
|
231
|
-
},
|
|
232
|
-
headers: jsonHeaders,
|
|
233
|
-
body: JSON.stringify(body),
|
|
234
|
-
traceContext: traceContext
|
|
235
|
-
});
|
|
236
|
-
return this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata));
|
|
237
232
|
}
|
|
233
|
+
}, {
|
|
234
|
+
key: "touchFiles",
|
|
235
|
+
value: function () {
|
|
236
|
+
var _touchFiles = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(body) {
|
|
237
|
+
var _this2 = this;
|
|
238
|
+
var params,
|
|
239
|
+
traceContext,
|
|
240
|
+
metadata,
|
|
241
|
+
auth,
|
|
242
|
+
maxFileSize,
|
|
243
|
+
decoded,
|
|
244
|
+
_body$descriptors$red,
|
|
245
|
+
_body$descriptors$red2,
|
|
246
|
+
filteredDescriptors,
|
|
247
|
+
rejectedResponse,
|
|
248
|
+
options,
|
|
249
|
+
_args3 = arguments;
|
|
250
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
251
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
252
|
+
case 0:
|
|
253
|
+
params = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
254
|
+
traceContext = _args3.length > 2 ? _args3[2] : undefined;
|
|
255
|
+
metadata = {
|
|
256
|
+
method: 'POST',
|
|
257
|
+
endpoint: '/upload/createWithFiles'
|
|
258
|
+
};
|
|
259
|
+
_context3.next = 5;
|
|
260
|
+
return this.resolveAuth({
|
|
261
|
+
collectionName: params.collection
|
|
262
|
+
});
|
|
263
|
+
case 5:
|
|
264
|
+
auth = _context3.sent;
|
|
265
|
+
try {
|
|
266
|
+
decoded = (0, _parseJwt.default)(auth.token);
|
|
267
|
+
maxFileSize = decoded.fileSizeLimit;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
// we're relying on the backend to throw an error when there's an invalid token
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// TODO MEX-2318: backend eventually will allow `size` in the body of this request, then some of this logic will need to be altered
|
|
273
|
+
_body$descriptors$red = body.descriptors.reduce(function (_ref, curr) {
|
|
274
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
275
|
+
filtered = _ref2[0],
|
|
276
|
+
rejected = _ref2[1];
|
|
277
|
+
var size = curr.size,
|
|
278
|
+
descriptor = (0, _objectWithoutProperties2.default)(curr, _excluded);
|
|
279
|
+
if (maxFileSize && size && size > maxFileSize) {
|
|
280
|
+
return [filtered, [].concat((0, _toConsumableArray2.default)(rejected), [_this2.getRejectedResponseFromDescriptor(curr, maxFileSize)])];
|
|
281
|
+
}
|
|
282
|
+
return [[].concat((0, _toConsumableArray2.default)(filtered), [descriptor]), rejected];
|
|
283
|
+
}, [[], []]), _body$descriptors$red2 = (0, _slicedToArray2.default)(_body$descriptors$red, 2), filteredDescriptors = _body$descriptors$red2[0], rejectedResponse = _body$descriptors$red2[1];
|
|
284
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
285
|
+
authContext: {
|
|
286
|
+
collectionName: params.collection
|
|
287
|
+
},
|
|
288
|
+
headers: jsonHeaders,
|
|
289
|
+
body: JSON.stringify(_objectSpread(_objectSpread({}, body), {}, {
|
|
290
|
+
descriptors: filteredDescriptors
|
|
291
|
+
})),
|
|
292
|
+
traceContext: traceContext,
|
|
293
|
+
resolvedAuth: auth
|
|
294
|
+
});
|
|
295
|
+
if (!(filteredDescriptors.length === 0)) {
|
|
296
|
+
_context3.next = 11;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
return _context3.abrupt("return", {
|
|
300
|
+
data: {
|
|
301
|
+
created: [],
|
|
302
|
+
rejected: rejectedResponse
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
case 11:
|
|
306
|
+
return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata)).then(function (res) {
|
|
307
|
+
// TODO MEX-2318: backend eventually will include `rejected`, then this logic will need to be removed
|
|
308
|
+
res.data.rejected = rejectedResponse;
|
|
309
|
+
return res;
|
|
310
|
+
}));
|
|
311
|
+
case 12:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context3.stop();
|
|
314
|
+
}
|
|
315
|
+
}, _callee3, this);
|
|
316
|
+
}));
|
|
317
|
+
function touchFiles(_x11) {
|
|
318
|
+
return _touchFiles.apply(this, arguments);
|
|
319
|
+
}
|
|
320
|
+
return touchFiles;
|
|
321
|
+
}()
|
|
238
322
|
}, {
|
|
239
323
|
key: "getFile",
|
|
240
324
|
value: function getFile(fileId) {
|
|
@@ -256,28 +340,26 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
256
340
|
}, {
|
|
257
341
|
key: "getFileImageURL",
|
|
258
342
|
value: function () {
|
|
259
|
-
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
260
|
-
var
|
|
261
|
-
return
|
|
262
|
-
while (1) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return _context3.stop();
|
|
276
|
-
}
|
|
343
|
+
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, params) {
|
|
344
|
+
var _ref3, collectionName, auth;
|
|
345
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
346
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
347
|
+
case 0:
|
|
348
|
+
_ref3 = params || {}, collectionName = _ref3.collection;
|
|
349
|
+
_context4.next = 3;
|
|
350
|
+
return this.resolveAuth({
|
|
351
|
+
collectionName: collectionName
|
|
352
|
+
});
|
|
353
|
+
case 3:
|
|
354
|
+
auth = _context4.sent;
|
|
355
|
+
return _context4.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
356
|
+
case 5:
|
|
357
|
+
case "end":
|
|
358
|
+
return _context4.stop();
|
|
277
359
|
}
|
|
278
|
-
},
|
|
360
|
+
}, _callee4, this);
|
|
279
361
|
}));
|
|
280
|
-
function getFileImageURL(
|
|
362
|
+
function getFileImageURL(_x12, _x13) {
|
|
281
363
|
return _getFileImageURL.apply(this, arguments);
|
|
282
364
|
}
|
|
283
365
|
return getFileImageURL;
|
|
@@ -300,35 +382,33 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
300
382
|
}, {
|
|
301
383
|
key: "getFileBinaryURL",
|
|
302
384
|
value: function () {
|
|
303
|
-
var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
385
|
+
var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName) {
|
|
304
386
|
var auth, options;
|
|
305
|
-
return
|
|
306
|
-
while (1) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return _context4.stop();
|
|
327
|
-
}
|
|
387
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
388
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
389
|
+
case 0:
|
|
390
|
+
_context5.next = 2;
|
|
391
|
+
return this.resolveAuth({
|
|
392
|
+
collectionName: collectionName
|
|
393
|
+
});
|
|
394
|
+
case 2:
|
|
395
|
+
auth = _context5.sent;
|
|
396
|
+
options = {
|
|
397
|
+
params: {
|
|
398
|
+
dl: true,
|
|
399
|
+
collection: collectionName,
|
|
400
|
+
'max-age': _constants.FILE_CACHE_MAX_AGE
|
|
401
|
+
},
|
|
402
|
+
auth: auth
|
|
403
|
+
};
|
|
404
|
+
return _context5.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/binary"), options));
|
|
405
|
+
case 5:
|
|
406
|
+
case "end":
|
|
407
|
+
return _context5.stop();
|
|
328
408
|
}
|
|
329
|
-
},
|
|
409
|
+
}, _callee5, this);
|
|
330
410
|
}));
|
|
331
|
-
function getFileBinaryURL(
|
|
411
|
+
function getFileBinaryURL(_x14, _x15) {
|
|
332
412
|
return _getFileBinaryURL.apply(this, arguments);
|
|
333
413
|
}
|
|
334
414
|
return getFileBinaryURL;
|
|
@@ -336,41 +416,39 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
336
416
|
}, {
|
|
337
417
|
key: "getArtifactURL",
|
|
338
418
|
value: function () {
|
|
339
|
-
var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
419
|
+
var _getArtifactURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(artifacts, artifactName, collectionName) {
|
|
340
420
|
var artifactUrl, auth, options;
|
|
341
|
-
return
|
|
342
|
-
while (1) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return _context5.stop();
|
|
369
|
-
}
|
|
421
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
422
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
423
|
+
case 0:
|
|
424
|
+
artifactUrl = (0, _artifacts.getArtifactUrl)(artifacts, artifactName);
|
|
425
|
+
if (artifactUrl) {
|
|
426
|
+
_context6.next = 3;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
430
|
+
case 3:
|
|
431
|
+
_context6.next = 5;
|
|
432
|
+
return this.resolveAuth({
|
|
433
|
+
collectionName: collectionName
|
|
434
|
+
});
|
|
435
|
+
case 5:
|
|
436
|
+
auth = _context6.sent;
|
|
437
|
+
options = {
|
|
438
|
+
params: {
|
|
439
|
+
collection: collectionName,
|
|
440
|
+
'max-age': _constants.FILE_CACHE_MAX_AGE
|
|
441
|
+
},
|
|
442
|
+
auth: auth
|
|
443
|
+
};
|
|
444
|
+
return _context6.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl).concat(artifactUrl), options));
|
|
445
|
+
case 8:
|
|
446
|
+
case "end":
|
|
447
|
+
return _context6.stop();
|
|
370
448
|
}
|
|
371
|
-
},
|
|
449
|
+
}, _callee6, this);
|
|
372
450
|
}));
|
|
373
|
-
function getArtifactURL(
|
|
451
|
+
function getArtifactURL(_x16, _x17, _x18) {
|
|
374
452
|
return _getArtifactURL.apply(this, arguments);
|
|
375
453
|
}
|
|
376
454
|
return getArtifactURL;
|
|
@@ -378,39 +456,37 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
378
456
|
}, {
|
|
379
457
|
key: "getImage",
|
|
380
458
|
value: function () {
|
|
381
|
-
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
459
|
+
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
|
|
382
460
|
var isWebpSupported, headers, metadata, options;
|
|
383
|
-
return
|
|
384
|
-
while (1) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return _context6.stop();
|
|
409
|
-
}
|
|
461
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
462
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
463
|
+
case 0:
|
|
464
|
+
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
465
|
+
isWebpSupported = false;
|
|
466
|
+
headers = {};
|
|
467
|
+
if (isWebpSupported) {
|
|
468
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
469
|
+
}
|
|
470
|
+
metadata = {
|
|
471
|
+
method: 'GET',
|
|
472
|
+
endpoint: '/file/{fileId}/image'
|
|
473
|
+
};
|
|
474
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
475
|
+
authContext: {
|
|
476
|
+
collectionName: params && params.collection
|
|
477
|
+
},
|
|
478
|
+
params: extendImageParams(params, fetchMaxRes),
|
|
479
|
+
headers: headers,
|
|
480
|
+
traceContext: traceContext
|
|
481
|
+
});
|
|
482
|
+
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
483
|
+
case 6:
|
|
484
|
+
case "end":
|
|
485
|
+
return _context7.stop();
|
|
410
486
|
}
|
|
411
|
-
},
|
|
487
|
+
}, _callee7, this);
|
|
412
488
|
}));
|
|
413
|
-
function getImage(
|
|
489
|
+
function getImage(_x19, _x20, _x21, _x22, _x23) {
|
|
414
490
|
return _getImage.apply(this, arguments);
|
|
415
491
|
}
|
|
416
492
|
return getImage;
|
|
@@ -418,42 +494,40 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
418
494
|
}, {
|
|
419
495
|
key: "getItems",
|
|
420
496
|
value: function () {
|
|
421
|
-
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
497
|
+
var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(ids, collectionName, traceContext) {
|
|
422
498
|
var descriptors, metadata, options;
|
|
423
|
-
return
|
|
424
|
-
while (1) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
collection: collectionName
|
|
432
|
-
};
|
|
433
|
-
});
|
|
434
|
-
metadata = {
|
|
435
|
-
method: 'POST',
|
|
436
|
-
endpoint: '/items'
|
|
499
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
500
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
501
|
+
case 0:
|
|
502
|
+
descriptors = ids.map(function (id) {
|
|
503
|
+
return {
|
|
504
|
+
type: 'file',
|
|
505
|
+
id: id,
|
|
506
|
+
collection: collectionName
|
|
437
507
|
};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
508
|
+
});
|
|
509
|
+
metadata = {
|
|
510
|
+
method: 'POST',
|
|
511
|
+
endpoint: '/items'
|
|
512
|
+
};
|
|
513
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
514
|
+
authContext: {
|
|
515
|
+
collectionName: collectionName
|
|
516
|
+
},
|
|
517
|
+
headers: jsonHeaders,
|
|
518
|
+
body: JSON.stringify({
|
|
519
|
+
descriptors: descriptors
|
|
520
|
+
}),
|
|
521
|
+
traceContext: traceContext
|
|
522
|
+
});
|
|
523
|
+
return _context8.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
524
|
+
case 4:
|
|
525
|
+
case "end":
|
|
526
|
+
return _context8.stop();
|
|
453
527
|
}
|
|
454
|
-
},
|
|
528
|
+
}, _callee8, this);
|
|
455
529
|
}));
|
|
456
|
-
function getItems(
|
|
530
|
+
function getItems(_x24, _x25, _x26) {
|
|
457
531
|
return _getItems.apply(this, arguments);
|
|
458
532
|
}
|
|
459
533
|
return getItems;
|
|
@@ -461,32 +535,30 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
461
535
|
}, {
|
|
462
536
|
key: "getImageMetadata",
|
|
463
537
|
value: function () {
|
|
464
|
-
var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
538
|
+
var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(id, params, traceContext) {
|
|
465
539
|
var metadata, options;
|
|
466
|
-
return
|
|
467
|
-
while (1) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
return _context8.stop();
|
|
485
|
-
}
|
|
540
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
541
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
542
|
+
case 0:
|
|
543
|
+
metadata = {
|
|
544
|
+
method: 'GET',
|
|
545
|
+
endpoint: '/file/{fileId}/image/metadata'
|
|
546
|
+
};
|
|
547
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
548
|
+
authContext: {
|
|
549
|
+
collectionName: params && params.collection
|
|
550
|
+
},
|
|
551
|
+
params: params,
|
|
552
|
+
traceContext: traceContext
|
|
553
|
+
});
|
|
554
|
+
return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
|
|
555
|
+
case 3:
|
|
556
|
+
case "end":
|
|
557
|
+
return _context9.stop();
|
|
486
558
|
}
|
|
487
|
-
},
|
|
559
|
+
}, _callee9, this);
|
|
488
560
|
}));
|
|
489
|
-
function getImageMetadata(
|
|
561
|
+
function getImageMetadata(_x27, _x28, _x29) {
|
|
490
562
|
return _getImageMetadata.apply(this, arguments);
|
|
491
563
|
}
|
|
492
564
|
return getImageMetadata;
|
|
@@ -494,34 +566,32 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
494
566
|
}, {
|
|
495
567
|
key: "appendChunksToUpload",
|
|
496
568
|
value: function () {
|
|
497
|
-
var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
569
|
+
var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(uploadId, body, collectionName, traceContext) {
|
|
498
570
|
var metadata, options;
|
|
499
|
-
return
|
|
500
|
-
while (1) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return _context9.stop();
|
|
520
|
-
}
|
|
571
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
572
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
573
|
+
case 0:
|
|
574
|
+
metadata = {
|
|
575
|
+
method: 'PUT',
|
|
576
|
+
endpoint: '/upload/{uploadId}/chunks'
|
|
577
|
+
};
|
|
578
|
+
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
579
|
+
authContext: {
|
|
580
|
+
collectionName: collectionName
|
|
581
|
+
},
|
|
582
|
+
headers: jsonHeaders,
|
|
583
|
+
body: JSON.stringify(body),
|
|
584
|
+
traceContext: traceContext
|
|
585
|
+
});
|
|
586
|
+
_context10.next = 4;
|
|
587
|
+
return this.request("/upload/".concat(uploadId, "/chunks"), options);
|
|
588
|
+
case 4:
|
|
589
|
+
case "end":
|
|
590
|
+
return _context10.stop();
|
|
521
591
|
}
|
|
522
|
-
},
|
|
592
|
+
}, _callee10, this);
|
|
523
593
|
}));
|
|
524
|
-
function appendChunksToUpload(
|
|
594
|
+
function appendChunksToUpload(_x30, _x31, _x32, _x33) {
|
|
525
595
|
return _appendChunksToUpload.apply(this, arguments);
|
|
526
596
|
}
|
|
527
597
|
return appendChunksToUpload;
|
|
@@ -550,7 +620,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
550
620
|
}, {
|
|
551
621
|
key: "request",
|
|
552
622
|
value: function () {
|
|
553
|
-
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
623
|
+
var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(path) {
|
|
554
624
|
var options,
|
|
555
625
|
controller,
|
|
556
626
|
method,
|
|
@@ -561,52 +631,61 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
561
631
|
body,
|
|
562
632
|
clientOptions,
|
|
563
633
|
traceContext,
|
|
634
|
+
resolvedAuth,
|
|
564
635
|
auth,
|
|
565
636
|
extendedTraceContext,
|
|
566
637
|
response,
|
|
567
|
-
|
|
568
|
-
return
|
|
569
|
-
while (1) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
638
|
+
_args11 = arguments;
|
|
639
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
640
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
641
|
+
case 0:
|
|
642
|
+
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {
|
|
643
|
+
method: 'GET',
|
|
644
|
+
endpoint: undefined,
|
|
645
|
+
authContext: {}
|
|
646
|
+
};
|
|
647
|
+
controller = _args11.length > 2 ? _args11[2] : undefined;
|
|
648
|
+
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;
|
|
649
|
+
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
650
|
+
_context11.next = 7;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
_context11.t0 = resolvedAuth;
|
|
654
|
+
_context11.next = 10;
|
|
655
|
+
break;
|
|
656
|
+
case 7:
|
|
657
|
+
_context11.next = 9;
|
|
658
|
+
return this.resolveAuth(authContext);
|
|
659
|
+
case 9:
|
|
660
|
+
_context11.t0 = _context11.sent;
|
|
661
|
+
case 10:
|
|
662
|
+
auth = _context11.t0;
|
|
663
|
+
extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
664
|
+
spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || (0, _mediaCommon.getRandomHex)(8)
|
|
665
|
+
}) : undefined;
|
|
666
|
+
_context11.next = 14;
|
|
667
|
+
return (0, _request3.request)("".concat(auth.baseUrl).concat(path), {
|
|
668
|
+
method: method,
|
|
669
|
+
endpoint: endpoint,
|
|
670
|
+
auth: auth,
|
|
671
|
+
params: params,
|
|
672
|
+
headers: headers,
|
|
673
|
+
body: body,
|
|
674
|
+
clientOptions: clientOptions,
|
|
675
|
+
traceContext: extendedTraceContext
|
|
676
|
+
}, controller);
|
|
677
|
+
case 14:
|
|
678
|
+
response = _context11.sent;
|
|
679
|
+
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
680
|
+
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
681
|
+
return _context11.abrupt("return", response);
|
|
682
|
+
case 18:
|
|
683
|
+
case "end":
|
|
684
|
+
return _context11.stop();
|
|
606
685
|
}
|
|
607
|
-
},
|
|
686
|
+
}, _callee11, this);
|
|
608
687
|
}));
|
|
609
|
-
function request(
|
|
688
|
+
function request(_x34) {
|
|
610
689
|
return _request2.apply(this, arguments);
|
|
611
690
|
}
|
|
612
691
|
return request;
|