@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.
- package/CHANGELOG.md +6 -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 +2 -2
- package/report.api.md +31 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
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
|
|
54
|
+
var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
|
|
51
55
|
var metadata, body, options;
|
|
52
|
-
return _regeneratorRuntime
|
|
53
|
-
while (1) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
|
124
|
+
var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(etag, blob, uploadId, partNumber, collectionName, traceContext) {
|
|
123
125
|
var metadata, options;
|
|
124
|
-
return _regeneratorRuntime
|
|
125
|
-
while (1) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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: "
|
|
201
|
-
value: function
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
240
|
-
var
|
|
241
|
-
return _regeneratorRuntime
|
|
242
|
-
while (1) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
},
|
|
340
|
+
}, _callee4, this);
|
|
259
341
|
}));
|
|
260
|
-
function getFileImageURL(
|
|
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
|
|
365
|
+
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
|
|
284
366
|
var auth, options;
|
|
285
|
-
return _regeneratorRuntime
|
|
286
|
-
while (1) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
},
|
|
389
|
+
}, _callee5, this);
|
|
310
390
|
}));
|
|
311
|
-
function getFileBinaryURL(
|
|
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
|
|
399
|
+
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(artifacts, artifactName, collectionName) {
|
|
320
400
|
var artifactUrl, auth, options;
|
|
321
|
-
return _regeneratorRuntime
|
|
322
|
-
while (1) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
},
|
|
429
|
+
}, _callee6, this);
|
|
352
430
|
}));
|
|
353
|
-
function getArtifactURL(
|
|
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
|
|
439
|
+
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
|
|
362
440
|
var isWebpSupported, headers, metadata, options;
|
|
363
|
-
return _regeneratorRuntime
|
|
364
|
-
while (1) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
},
|
|
467
|
+
}, _callee7, this);
|
|
392
468
|
}));
|
|
393
|
-
function getImage(
|
|
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
|
|
477
|
+
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
|
|
402
478
|
var descriptors, metadata, options;
|
|
403
|
-
return _regeneratorRuntime
|
|
404
|
-
while (1) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
},
|
|
508
|
+
}, _callee8, this);
|
|
435
509
|
}));
|
|
436
|
-
function getItems(
|
|
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
|
|
518
|
+
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
|
|
445
519
|
var metadata, options;
|
|
446
|
-
return _regeneratorRuntime
|
|
447
|
-
while (1) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
-
},
|
|
539
|
+
}, _callee9, this);
|
|
468
540
|
}));
|
|
469
|
-
function getImageMetadata(
|
|
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
|
|
549
|
+
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
|
|
478
550
|
var metadata, options;
|
|
479
|
-
return _regeneratorRuntime
|
|
480
|
-
while (1) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
-
},
|
|
572
|
+
}, _callee10, this);
|
|
503
573
|
}));
|
|
504
|
-
function appendChunksToUpload(
|
|
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
|
|
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
|
-
|
|
548
|
-
return _regeneratorRuntime
|
|
549
|
-
while (1) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
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
|
-
},
|
|
666
|
+
}, _callee11, this);
|
|
588
667
|
}));
|
|
589
|
-
function request(
|
|
668
|
+
function request(_x34) {
|
|
590
669
|
return _request2.apply(this, arguments);
|
|
591
670
|
}
|
|
592
671
|
return request;
|