@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
|
});
|
|
@@ -25,6 +24,7 @@ exports.mapResponseToBlob = mapResponseToBlob;
|
|
|
25
24
|
exports.mapResponseToJson = mapResponseToJson;
|
|
26
25
|
exports.mapResponseToVoid = mapResponseToVoid;
|
|
27
26
|
exports.waitPromise = waitPromise;
|
|
27
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
28
28
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
29
29
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
30
30
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -32,7 +32,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
32
32
|
var _mediaCore = require("@atlaskit/media-core");
|
|
33
33
|
var _authQueryParameters = require("../../models/auth-query-parameters");
|
|
34
34
|
var _errors = require("./errors");
|
|
35
|
-
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; }
|
|
36
35
|
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; }
|
|
37
36
|
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; }
|
|
38
37
|
function clientTimeoutPromise(timeout) {
|
|
@@ -120,28 +119,26 @@ function mapResponseToJson(_x) {
|
|
|
120
119
|
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
121
120
|
*/
|
|
122
121
|
function _mapResponseToJson() {
|
|
123
|
-
_mapResponseToJson = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
124
|
-
return
|
|
125
|
-
while (1) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return _context3.stop();
|
|
144
|
-
}
|
|
122
|
+
_mapResponseToJson = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(response) {
|
|
123
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
124
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
console.warn('Helper is deprecated and will be remove in the next major version');
|
|
128
|
+
_context3.prev = 1;
|
|
129
|
+
_context3.next = 4;
|
|
130
|
+
return response.json();
|
|
131
|
+
case 4:
|
|
132
|
+
return _context3.abrupt("return", _context3.sent);
|
|
133
|
+
case 7:
|
|
134
|
+
_context3.prev = 7;
|
|
135
|
+
_context3.t0 = _context3["catch"](1);
|
|
136
|
+
throw new _errors.RequestError('serverInvalidBody', {
|
|
137
|
+
statusCode: response.status
|
|
138
|
+
}, _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
139
|
+
case 10:
|
|
140
|
+
case "end":
|
|
141
|
+
return _context3.stop();
|
|
145
142
|
}
|
|
146
143
|
}, _callee3, null, [[1, 7]]);
|
|
147
144
|
}));
|
|
@@ -155,28 +152,26 @@ function mapResponseToBlob(_x2) {
|
|
|
155
152
|
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
156
153
|
*/
|
|
157
154
|
function _mapResponseToBlob() {
|
|
158
|
-
_mapResponseToBlob = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
159
|
-
return
|
|
160
|
-
while (1) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return _context4.stop();
|
|
179
|
-
}
|
|
155
|
+
_mapResponseToBlob = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(response) {
|
|
156
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
157
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
// eslint-disable-next-line no-console
|
|
160
|
+
console.warn('Helper is deprecated and will be remove in the next major version');
|
|
161
|
+
_context4.prev = 1;
|
|
162
|
+
_context4.next = 4;
|
|
163
|
+
return response.blob();
|
|
164
|
+
case 4:
|
|
165
|
+
return _context4.abrupt("return", _context4.sent);
|
|
166
|
+
case 7:
|
|
167
|
+
_context4.prev = 7;
|
|
168
|
+
_context4.t0 = _context4["catch"](1);
|
|
169
|
+
throw new _errors.RequestError('serverInvalidBody', {
|
|
170
|
+
statusCode: response.status
|
|
171
|
+
}, _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
172
|
+
case 10:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context4.stop();
|
|
180
175
|
}
|
|
181
176
|
}, _callee4, null, [[1, 7]]);
|
|
182
177
|
}));
|
|
@@ -189,26 +184,24 @@ function mapResponseToVoid() {
|
|
|
189
184
|
}
|
|
190
185
|
function createMapResponseToJson(metadata) {
|
|
191
186
|
return /*#__PURE__*/function () {
|
|
192
|
-
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
193
|
-
return
|
|
194
|
-
while (1) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return _context.stop();
|
|
211
|
-
}
|
|
187
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(response) {
|
|
188
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
189
|
+
while (1) switch (_context.prev = _context.next) {
|
|
190
|
+
case 0:
|
|
191
|
+
_context.prev = 0;
|
|
192
|
+
_context.next = 3;
|
|
193
|
+
return response.json();
|
|
194
|
+
case 3:
|
|
195
|
+
return _context.abrupt("return", _context.sent);
|
|
196
|
+
case 6:
|
|
197
|
+
_context.prev = 6;
|
|
198
|
+
_context.t0 = _context["catch"](0);
|
|
199
|
+
throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
200
|
+
statusCode: response.status
|
|
201
|
+
}), _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
202
|
+
case 9:
|
|
203
|
+
case "end":
|
|
204
|
+
return _context.stop();
|
|
212
205
|
}
|
|
213
206
|
}, _callee, null, [[0, 6]]);
|
|
214
207
|
}));
|
|
@@ -219,26 +212,24 @@ function createMapResponseToJson(metadata) {
|
|
|
219
212
|
}
|
|
220
213
|
function createMapResponseToBlob(metadata) {
|
|
221
214
|
return /*#__PURE__*/function () {
|
|
222
|
-
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
223
|
-
return
|
|
224
|
-
while (1) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return _context2.stop();
|
|
241
|
-
}
|
|
215
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(response) {
|
|
216
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
217
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
218
|
+
case 0:
|
|
219
|
+
_context2.prev = 0;
|
|
220
|
+
_context2.next = 3;
|
|
221
|
+
return response.blob();
|
|
222
|
+
case 3:
|
|
223
|
+
return _context2.abrupt("return", _context2.sent);
|
|
224
|
+
case 6:
|
|
225
|
+
_context2.prev = 6;
|
|
226
|
+
_context2.t0 = _context2["catch"](0);
|
|
227
|
+
throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
228
|
+
statusCode: response.status
|
|
229
|
+
}), _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
230
|
+
case 9:
|
|
231
|
+
case "end":
|
|
232
|
+
return _context2.stop();
|
|
242
233
|
}
|
|
243
234
|
}, _callee2, null, [[0, 6]]);
|
|
244
235
|
}));
|
|
@@ -265,7 +256,7 @@ function fetchRetry(_x5, _x6) {
|
|
|
265
256
|
return _fetchRetry.apply(this, arguments);
|
|
266
257
|
}
|
|
267
258
|
function _fetchRetry() {
|
|
268
|
-
_fetchRetry = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
259
|
+
_fetchRetry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(functionToRetry, metadata) {
|
|
269
260
|
var overwriteOptions,
|
|
270
261
|
options,
|
|
271
262
|
startTimeoutInMs,
|
|
@@ -276,88 +267,84 @@ function _fetchRetry() {
|
|
|
276
267
|
lastError,
|
|
277
268
|
waitAndBumpTimeout,
|
|
278
269
|
_args6 = arguments;
|
|
279
|
-
return
|
|
280
|
-
while (1) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
_context6.prev = 13;
|
|
322
|
-
_context6.t0 = _context6["catch"](7);
|
|
323
|
-
lastError = _context6.t0;
|
|
270
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
271
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
272
|
+
case 0:
|
|
273
|
+
overwriteOptions = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
|
|
274
|
+
options = _objectSpread(_objectSpread({}, DEFAULT_RETRY_OPTIONS), overwriteOptions);
|
|
275
|
+
startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor;
|
|
276
|
+
attempts = 0;
|
|
277
|
+
timeoutInMs = startTimeoutInMs;
|
|
278
|
+
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
279
|
+
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
280
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
281
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
_context5.next = 2;
|
|
284
|
+
return waitPromise(timeoutInMs);
|
|
285
|
+
case 2:
|
|
286
|
+
timeoutInMs *= factor;
|
|
287
|
+
attempts += 1;
|
|
288
|
+
case 4:
|
|
289
|
+
case "end":
|
|
290
|
+
return _context5.stop();
|
|
291
|
+
}
|
|
292
|
+
}, _callee5);
|
|
293
|
+
}));
|
|
294
|
+
return function waitAndBumpTimeout() {
|
|
295
|
+
return _ref7.apply(this, arguments);
|
|
296
|
+
};
|
|
297
|
+
}();
|
|
298
|
+
case 6:
|
|
299
|
+
if (!(attempts < maxAttempts)) {
|
|
300
|
+
_context6.next = 24;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
_context6.prev = 7;
|
|
304
|
+
_context6.next = 10;
|
|
305
|
+
return functionToRetry();
|
|
306
|
+
case 10:
|
|
307
|
+
return _context6.abrupt("return", _context6.sent);
|
|
308
|
+
case 13:
|
|
309
|
+
_context6.prev = 13;
|
|
310
|
+
_context6.t0 = _context6["catch"](7);
|
|
311
|
+
lastError = _context6.t0;
|
|
324
312
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
throw new _errors.RequestError('clientAbortedRequest', metadata, _context6.t0);
|
|
331
|
-
case 18:
|
|
332
|
-
if (!(!isFetchNetworkError(_context6.t0) && !(0, _errors.isRequestError)(_context6.t0) || (0, _errors.isRequestError)(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
|
|
333
|
-
_context6.next = 20;
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
throw _context6.t0;
|
|
337
|
-
case 20:
|
|
338
|
-
_context6.next = 22;
|
|
339
|
-
return waitAndBumpTimeout();
|
|
340
|
-
case 22:
|
|
341
|
-
_context6.next = 6;
|
|
313
|
+
// don't retry if request was aborted by user
|
|
314
|
+
if (!isAbortedRequestError(_context6.t0)) {
|
|
315
|
+
_context6.next = 18;
|
|
342
316
|
break;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
317
|
+
}
|
|
318
|
+
throw new _errors.RequestError('clientAbortedRequest', metadata, _context6.t0);
|
|
319
|
+
case 18:
|
|
320
|
+
if (!(!isFetchNetworkError(_context6.t0) && !(0, _errors.isRequestError)(_context6.t0) || (0, _errors.isRequestError)(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
|
|
321
|
+
_context6.next = 20;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
throw _context6.t0;
|
|
325
|
+
case 20:
|
|
326
|
+
_context6.next = 22;
|
|
327
|
+
return waitAndBumpTimeout();
|
|
328
|
+
case 22:
|
|
329
|
+
_context6.next = 6;
|
|
330
|
+
break;
|
|
331
|
+
case 24:
|
|
332
|
+
if (!(0, _errors.isRequestError)(lastError)) {
|
|
333
|
+
_context6.next = 26;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
throw cloneRequestError(lastError, {
|
|
337
|
+
attempts: attempts,
|
|
338
|
+
clientExhaustedRetries: true
|
|
339
|
+
});
|
|
340
|
+
case 26:
|
|
341
|
+
throw new _errors.RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
|
|
342
|
+
attempts: attempts,
|
|
343
|
+
clientExhaustedRetries: true
|
|
344
|
+
}), lastError);
|
|
345
|
+
case 27:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context6.stop();
|
|
361
348
|
}
|
|
362
349
|
}, _callee6, null, [[7, 13]]);
|
|
363
350
|
}));
|
|
@@ -23,16 +23,15 @@ Object.defineProperty(exports, "isRequestError", {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
exports.request = request;
|
|
26
|
-
var
|
|
26
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
27
27
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
28
28
|
var _errors = require("./errors");
|
|
29
29
|
var _helpers = require("./helpers");
|
|
30
|
-
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" == (0, _typeof2.default)(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; }
|
|
31
30
|
function request(_x) {
|
|
32
31
|
return _request.apply(this, arguments);
|
|
33
32
|
}
|
|
34
33
|
function _request() {
|
|
35
|
-
_request = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
34
|
+
_request = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
|
|
36
35
|
var options,
|
|
37
36
|
controller,
|
|
38
37
|
_options$method,
|
|
@@ -49,34 +48,32 @@ function _request() {
|
|
|
49
48
|
metadata,
|
|
50
49
|
doFetch,
|
|
51
50
|
_args = arguments;
|
|
52
|
-
return
|
|
53
|
-
while (1) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
52
|
+
while (1) switch (_context.prev = _context.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
55
|
+
controller = _args.length > 2 ? _args[2] : undefined;
|
|
56
|
+
_options$method = options.method, method = _options$method === void 0 ? 'GET' : _options$method, endpoint = options.endpoint, auth = options.auth, params = options.params, headers = options.headers, body = options.body, _options$clientOption = options.clientOptions, clientOptions = _options$clientOption === void 0 ? {} : _options$clientOption, traceContext = options.traceContext;
|
|
57
|
+
retryOptions = clientOptions.retryOptions;
|
|
58
|
+
metadata = {
|
|
59
|
+
method: method,
|
|
60
|
+
endpoint: endpoint,
|
|
61
|
+
traceContext: traceContext
|
|
62
|
+
}; // TODO BMPT-918: add client timeout feature behing a FF (using clientOptions.clientTimeout + Promise.race)
|
|
63
|
+
doFetch = function doFetch() {
|
|
64
|
+
return fetch((0, _helpers.createUrl)(url, {
|
|
65
|
+
params: params
|
|
66
|
+
}), {
|
|
61
67
|
method: method,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
headers: (0, _helpers.extendHeaders)(headers, auth, traceContext),
|
|
72
|
-
signal: controller && controller.signal
|
|
73
|
-
}).then((0, _helpers.createProcessFetchResponse)(metadata));
|
|
74
|
-
};
|
|
75
|
-
return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetch, metadata, retryOptions));
|
|
76
|
-
case 7:
|
|
77
|
-
case "end":
|
|
78
|
-
return _context.stop();
|
|
79
|
-
}
|
|
68
|
+
body: body,
|
|
69
|
+
headers: (0, _helpers.extendHeaders)(headers, auth, traceContext),
|
|
70
|
+
signal: controller && controller.signal
|
|
71
|
+
}).then((0, _helpers.createProcessFetchResponse)(metadata));
|
|
72
|
+
};
|
|
73
|
+
return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetch, metadata, retryOptions));
|
|
74
|
+
case 7:
|
|
75
|
+
case "end":
|
|
76
|
+
return _context.stop();
|
|
80
77
|
}
|
|
81
78
|
}, _callee);
|
|
82
79
|
}));
|