@atlaskit/media-client 29.1.0 → 30.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 +23 -0
- package/dist/cjs/client/file-fetcher/error.js +12 -10
- package/dist/cjs/client/file-fetcher/index.js +28 -46
- package/dist/cjs/client/media-store/error.js +4 -5
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/models/errors/index.js +68 -5
- package/dist/cjs/models/errors/types.js +5 -1
- package/dist/cjs/uploader/error.js +11 -9
- package/dist/cjs/uploader/index.js +2 -1
- package/dist/cjs/utils/mobileUpload/error.js +12 -10
- package/dist/cjs/utils/mobileUpload/helpers.js +4 -2
- package/dist/cjs/utils/polling/errors.js +6 -7
- package/dist/cjs/utils/polling/index.js +6 -2
- package/dist/cjs/utils/request/errors.js +4 -6
- package/dist/cjs/utils/request/helpers.js +8 -3
- package/dist/es2019/client/file-fetcher/error.js +10 -7
- package/dist/es2019/client/file-fetcher/index.js +22 -45
- package/dist/es2019/client/media-store/error.js +4 -3
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/models/errors/index.js +62 -5
- package/dist/es2019/models/errors/types.js +1 -0
- package/dist/es2019/uploader/error.js +10 -7
- package/dist/es2019/uploader/index.js +2 -1
- package/dist/es2019/utils/mobileUpload/error.js +10 -7
- package/dist/es2019/utils/mobileUpload/helpers.js +4 -2
- package/dist/es2019/utils/polling/errors.js +8 -5
- package/dist/es2019/utils/polling/index.js +6 -2
- package/dist/es2019/utils/request/errors.js +4 -4
- package/dist/es2019/utils/request/helpers.js +8 -3
- package/dist/esm/client/file-fetcher/error.js +12 -10
- package/dist/esm/client/file-fetcher/index.js +29 -47
- package/dist/esm/client/media-store/error.js +4 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/models/errors/index.js +67 -4
- package/dist/esm/models/errors/types.js +1 -0
- package/dist/esm/uploader/error.js +11 -9
- package/dist/esm/uploader/index.js +2 -1
- package/dist/esm/utils/mobileUpload/error.js +12 -10
- package/dist/esm/utils/mobileUpload/helpers.js +4 -2
- package/dist/esm/utils/polling/errors.js +6 -7
- package/dist/esm/utils/polling/index.js +6 -2
- package/dist/esm/utils/request/errors.js +4 -6
- package/dist/esm/utils/request/helpers.js +8 -3
- package/dist/types/client/file-fetcher/error.d.ts +9 -12
- package/dist/types/client/media-store/error.d.ts +3 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/models/errors/index.d.ts +17 -4
- package/dist/types/models/errors/types.d.ts +7 -0
- package/dist/types/uploader/error.d.ts +8 -10
- package/dist/types/utils/mobileUpload/error.d.ts +9 -12
- package/dist/types/utils/polling/errors.d.ts +4 -5
- package/dist/types/utils/polling/types.d.ts +3 -0
- package/dist/types/utils/request/errors.d.ts +3 -5
- package/dist/types-ts4.5/client/file-fetcher/error.d.ts +9 -12
- package/dist/types-ts4.5/client/media-store/error.d.ts +3 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/models/errors/index.d.ts +17 -4
- package/dist/types-ts4.5/models/errors/types.d.ts +7 -0
- package/dist/types-ts4.5/uploader/error.d.ts +8 -10
- package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +9 -12
- package/dist/types-ts4.5/utils/polling/errors.d.ts +4 -5
- package/dist/types-ts4.5/utils/polling/types.d.ts +3 -0
- package/dist/types-ts4.5/utils/request/errors.d.ts +3 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 30.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#102527](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102527)
|
|
8
|
+
[`a90d34cd14faf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a90d34cd14faf) -
|
|
9
|
+
Updated the constructor of the following classes. Consult the type definitions for details.
|
|
10
|
+
|
|
11
|
+
- `RequestError`
|
|
12
|
+
|
|
13
|
+
- `PollingError`
|
|
14
|
+
|
|
15
|
+
- `FileFetcherError`
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#102527](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102527)
|
|
20
|
+
[`a90d34cd14faf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a90d34cd14faf) - -
|
|
21
|
+
New error verification helper `isCommonMediaClientError`
|
|
22
|
+
|
|
23
|
+
- `ErrorFileState` is now deserializable into a `CommonMediaClientError` using new export
|
|
24
|
+
`toCommonMediaClientError`
|
|
25
|
+
|
|
3
26
|
## 29.1.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -18,26 +18,28 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
18
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
20
|
var FileFetcherError = exports.FileFetcherError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
21
|
-
|
|
21
|
+
// Legacy Attribute. Should be removed
|
|
22
|
+
|
|
23
|
+
function FileFetcherError(reason, metadata) {
|
|
22
24
|
var _this;
|
|
23
25
|
(0, _classCallCheck2.default)(this, FileFetcherError);
|
|
24
|
-
_this = _callSuper(this, FileFetcherError, [reason]);
|
|
25
|
-
_this.
|
|
26
|
-
_this.id = id;
|
|
27
|
-
_this.metadata = metadata;
|
|
26
|
+
_this = _callSuper(this, FileFetcherError, [reason, metadata, undefined]);
|
|
27
|
+
_this.id = metadata.id;
|
|
28
28
|
return _this;
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
32
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
30
33
|
(0, _inherits2.default)(FileFetcherError, _BaseMediaClientError);
|
|
31
34
|
return (0, _createClass2.default)(FileFetcherError, [{
|
|
32
35
|
key: "attributes",
|
|
33
36
|
get: function get() {
|
|
34
37
|
var reason = this.reason,
|
|
35
|
-
id = this.id,
|
|
36
38
|
_this$metadata = this.metadata,
|
|
37
|
-
|
|
38
|
-
collectionName = _this$
|
|
39
|
-
occurrenceKey = _this$
|
|
40
|
-
traceContext = _this$
|
|
39
|
+
id = _this$metadata.id,
|
|
40
|
+
collectionName = _this$metadata.collectionName,
|
|
41
|
+
occurrenceKey = _this$metadata.occurrenceKey,
|
|
42
|
+
traceContext = _this$metadata.traceContext;
|
|
41
43
|
return _objectSpread({
|
|
42
44
|
reason: reason,
|
|
43
45
|
id: id,
|
|
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "isFileFetcherError", {
|
|
|
19
19
|
});
|
|
20
20
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
21
21
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
22
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
23
22
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
24
23
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
25
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -51,8 +50,7 @@ var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
|
51
50
|
var _mediaState = require("@atlaskit/media-state");
|
|
52
51
|
var _createCopyIntentRegisterationBatcher = require("../../utils/createCopyIntentRegisterationBatcher");
|
|
53
52
|
var _helpers = require("../../utils/request/helpers");
|
|
54
|
-
var
|
|
55
|
-
_excluded2 = ["metadata"];
|
|
53
|
+
var _errors = require("../../models/errors");
|
|
56
54
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
57
55
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
58
56
|
var isCopySourceFileWithToken = function isCopySourceFileWithToken(token) {
|
|
@@ -67,26 +65,20 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
67
65
|
var store = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _mediaState.mediaStore;
|
|
68
66
|
(0, _classCallCheck2.default)(this, FileFetcherImpl);
|
|
69
67
|
(0, _defineProperty2.default)(this, "getErrorFileState", function (error, id, occurrenceKey) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
details: _objectSpread(_objectSpread({}, attributes), (metadata === null || metadata === void 0 ? void 0 : metadata.traceContext) && {
|
|
85
|
-
metadata: metadata
|
|
86
|
-
}),
|
|
87
|
-
occurrenceKey: occurrenceKey,
|
|
88
|
-
message: error === null || error === void 0 ? void 0 : error.message
|
|
89
|
-
};
|
|
68
|
+
if ((0, _errors.isCommonMediaClientError)(error)) {
|
|
69
|
+
return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, error);
|
|
70
|
+
}
|
|
71
|
+
// ________________________________________________
|
|
72
|
+
// Legacy serializers
|
|
73
|
+
// We need to revisit all the incoming error types and ensure all the "reason" values are known
|
|
74
|
+
// We need to change the input error: any for a known type.
|
|
75
|
+
if (typeof error === 'string') {
|
|
76
|
+
var err = new _errors.CommonMediaClientError(error);
|
|
77
|
+
return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, err);
|
|
78
|
+
} else {
|
|
79
|
+
var _err = new _errors.CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
|
|
80
|
+
return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, _err);
|
|
81
|
+
}
|
|
90
82
|
});
|
|
91
83
|
(0, _defineProperty2.default)(this, "setFileState", function (id, fileState) {
|
|
92
84
|
_this.store.setState(function (state) {
|
|
@@ -119,7 +111,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
119
111
|
_context.next = 5;
|
|
120
112
|
break;
|
|
121
113
|
}
|
|
122
|
-
throw new _error.FileFetcherError('emptyItems',
|
|
114
|
+
throw new _error.FileFetcherError('emptyItems', {
|
|
115
|
+
id: id,
|
|
123
116
|
collectionName: collectionName,
|
|
124
117
|
occurrenceKey: occurrenceKey,
|
|
125
118
|
traceContext: response.metadataTraceContext
|
|
@@ -129,7 +122,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
129
122
|
_context.next = 7;
|
|
130
123
|
break;
|
|
131
124
|
}
|
|
132
|
-
throw new _error.FileFetcherError('zeroVersionFile',
|
|
125
|
+
throw new _error.FileFetcherError('zeroVersionFile', {
|
|
126
|
+
id: id,
|
|
133
127
|
collectionName: collectionName,
|
|
134
128
|
occurrenceKey: occurrenceKey,
|
|
135
129
|
traceContext: response.metadataTraceContext
|
|
@@ -202,25 +196,13 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
202
196
|
occurrenceKey = options.occurrenceKey,
|
|
203
197
|
includeHashForDuplicateFiles = options.includeHashForDuplicateFiles;
|
|
204
198
|
if (!(0, _uuidValidate.default)(id)) {
|
|
205
|
-
var _err$attributes;
|
|
206
199
|
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
207
|
-
var err = new _error.FileFetcherError('invalidFileId',
|
|
200
|
+
var err = new _error.FileFetcherError('invalidFileId', {
|
|
201
|
+
id: id,
|
|
208
202
|
collectionName: collectionName,
|
|
209
203
|
occurrenceKey: occurrenceKey
|
|
210
204
|
});
|
|
211
|
-
var
|
|
212
|
-
metadata = _ref3.metadata,
|
|
213
|
-
attributes = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
|
|
214
|
-
var errorFileState = {
|
|
215
|
-
status: 'error',
|
|
216
|
-
id: id,
|
|
217
|
-
reason: err === null || err === void 0 ? void 0 : err.reason,
|
|
218
|
-
message: err === null || err === void 0 ? void 0 : err.message,
|
|
219
|
-
occurrenceKey: occurrenceKey,
|
|
220
|
-
details: _objectSpread(_objectSpread({}, attributes), (metadata === null || metadata === void 0 ? void 0 : metadata.traceContext) && {
|
|
221
|
-
metadata: metadata
|
|
222
|
-
})
|
|
223
|
-
};
|
|
205
|
+
var errorFileState = this.getErrorFileState(err, id, occurrenceKey);
|
|
224
206
|
subject.error(err);
|
|
225
207
|
this.setFileState(id, errorFileState);
|
|
226
208
|
return (0, _mediaSubscribable.fromObservable)(subject);
|
|
@@ -261,8 +243,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
261
243
|
descriptors: descriptors
|
|
262
244
|
}, {
|
|
263
245
|
collection: collection
|
|
264
|
-
}, traceContext).then(function (
|
|
265
|
-
var data =
|
|
246
|
+
}, traceContext).then(function (_ref2) {
|
|
247
|
+
var data = _ref2.data;
|
|
266
248
|
return data;
|
|
267
249
|
});
|
|
268
250
|
}
|
|
@@ -303,7 +285,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
303
285
|
return undefined;
|
|
304
286
|
});
|
|
305
287
|
preview = new Promise( /*#__PURE__*/function () {
|
|
306
|
-
var
|
|
288
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resolve, reject) {
|
|
307
289
|
var blob;
|
|
308
290
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
309
291
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -326,7 +308,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
326
308
|
}, _callee2);
|
|
327
309
|
}));
|
|
328
310
|
return function (_x4, _x5) {
|
|
329
|
-
return
|
|
311
|
+
return _ref3.apply(this, arguments);
|
|
330
312
|
};
|
|
331
313
|
}());
|
|
332
314
|
name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
|
|
@@ -345,7 +327,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
345
327
|
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
|
|
346
328
|
this.setFileState(id, fileState);
|
|
347
329
|
return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
348
|
-
var
|
|
330
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) {
|
|
349
331
|
var blob, type, size, file, mediaType, dimensions;
|
|
350
332
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
351
333
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -406,7 +388,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
406
388
|
}, _callee3, null, [[10, 16]]);
|
|
407
389
|
}));
|
|
408
390
|
return function (_x6, _x7) {
|
|
409
|
-
return
|
|
391
|
+
return _ref4.apply(this, arguments);
|
|
410
392
|
};
|
|
411
393
|
}()));
|
|
412
394
|
case 11:
|
|
@@ -16,13 +16,12 @@ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0,
|
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var MediaStoreError = exports.MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
18
|
function MediaStoreError(reason, innerError) {
|
|
19
|
-
var _this;
|
|
20
19
|
(0, _classCallCheck2.default)(this, MediaStoreError);
|
|
21
|
-
|
|
22
|
-
_this.reason = reason;
|
|
23
|
-
_this.innerError = innerError;
|
|
24
|
-
return _this;
|
|
20
|
+
return _callSuper(this, MediaStoreError, [reason, undefined, innerError]);
|
|
25
21
|
}
|
|
22
|
+
|
|
23
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
24
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
26
25
|
(0, _inherits2.default)(MediaStoreError, _BaseMediaClientError);
|
|
27
26
|
return (0, _createClass2.default)(MediaStoreError, [{
|
|
28
27
|
key: "attributes",
|
package/dist/cjs/index.js
CHANGED
|
@@ -183,6 +183,12 @@ Object.defineProperty(exports, "isAbortedRequestError", {
|
|
|
183
183
|
return _helpers.isAbortedRequestError;
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
|
+
Object.defineProperty(exports, "isCommonMediaClientError", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function get() {
|
|
189
|
+
return _errors.isCommonMediaClientError;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
186
192
|
Object.defineProperty(exports, "isDifferentIdentifier", {
|
|
187
193
|
enumerable: true,
|
|
188
194
|
get: function get() {
|
|
@@ -315,6 +321,12 @@ Object.defineProperty(exports, "request", {
|
|
|
315
321
|
return _request.request;
|
|
316
322
|
}
|
|
317
323
|
});
|
|
324
|
+
Object.defineProperty(exports, "toCommonMediaClientError", {
|
|
325
|
+
enumerable: true,
|
|
326
|
+
get: function get() {
|
|
327
|
+
return _errors.toCommonMediaClientError;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
318
330
|
Object.defineProperty(exports, "uploadFile", {
|
|
319
331
|
enumerable: true,
|
|
320
332
|
get: function get() {
|
|
@@ -4,19 +4,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.BaseMediaClientError = void 0;
|
|
7
|
+
exports.fromCommonMediaClientError = exports.CommonMediaClientError = exports.BaseMediaClientError = void 0;
|
|
8
8
|
Object.defineProperty(exports, "getMediaClientErrorReason", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
11
|
return _helpers.getMediaClientErrorReason;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
+
exports.isCommonMediaClientError = isCommonMediaClientError;
|
|
14
15
|
Object.defineProperty(exports, "isMediaClientError", {
|
|
15
16
|
enumerable: true,
|
|
16
17
|
get: function get() {
|
|
17
18
|
return _helpers.isMediaClientError;
|
|
18
19
|
}
|
|
19
20
|
});
|
|
21
|
+
exports.toCommonMediaClientError = void 0;
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
23
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
24
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
22
25
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -24,19 +27,23 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
24
27
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
28
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
26
29
|
var _helpers = require("./helpers");
|
|
30
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
32
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
28
33
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
29
34
|
/**
|
|
30
35
|
* Base class for media errors
|
|
31
36
|
*/
|
|
32
37
|
var BaseMediaClientError = exports.BaseMediaClientError = /*#__PURE__*/function (_Error) {
|
|
33
|
-
function BaseMediaClientError(
|
|
38
|
+
function BaseMediaClientError(reason, metadata, innerError) {
|
|
34
39
|
var _this;
|
|
35
40
|
(0, _classCallCheck2.default)(this, BaseMediaClientError);
|
|
36
|
-
_this = _callSuper(this, BaseMediaClientError, [
|
|
41
|
+
_this = _callSuper(this, BaseMediaClientError, [reason]);
|
|
37
42
|
|
|
38
43
|
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
|
|
39
|
-
_this.
|
|
44
|
+
_this.reason = reason;
|
|
45
|
+
_this.metadata = metadata;
|
|
46
|
+
_this.innerError = innerError;
|
|
40
47
|
Object.setPrototypeOf(_this, (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
|
|
41
48
|
|
|
42
49
|
// https://v8.dev/docs/stack-trace-api
|
|
@@ -45,6 +52,62 @@ var BaseMediaClientError = exports.BaseMediaClientError = /*#__PURE__*/function
|
|
|
45
52
|
}
|
|
46
53
|
return _this;
|
|
47
54
|
}
|
|
55
|
+
|
|
56
|
+
// TODO: Deprecate attributes getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
48
57
|
(0, _inherits2.default)(BaseMediaClientError, _Error);
|
|
49
58
|
return (0, _createClass2.default)(BaseMediaClientError);
|
|
50
|
-
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error
|
|
59
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error
|
|
60
|
+
// TODO: Deprecate attributes getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
61
|
+
)); // The only reason why this class exists is because BaseMediaClientError is abstract class, so it can't be used to deserialize ErrorFileState. We can refactor and simplify this later.
|
|
62
|
+
/** Generic Media Client Erorr. All errors extending BaseMediaClientError match CommonMediaClientError attributes. Used to deserialize ErrorFileState */
|
|
63
|
+
var CommonMediaClientError = exports.CommonMediaClientError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
64
|
+
function CommonMediaClientError(reason, metadata, innerError) {
|
|
65
|
+
(0, _classCallCheck2.default)(this, CommonMediaClientError);
|
|
66
|
+
return _callSuper(this, CommonMediaClientError, [reason, metadata, innerError]);
|
|
67
|
+
}
|
|
68
|
+
(0, _inherits2.default)(CommonMediaClientError, _BaseMediaClientError);
|
|
69
|
+
return (0, _createClass2.default)(CommonMediaClientError, [{
|
|
70
|
+
key: "attributes",
|
|
71
|
+
get: function get() {
|
|
72
|
+
return {
|
|
73
|
+
reason: this.reason
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}]);
|
|
77
|
+
}(BaseMediaClientError);
|
|
78
|
+
function isCommonMediaClientError(error) {
|
|
79
|
+
if (!error) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// Check if the error is an instance of Error
|
|
83
|
+
if (error instanceof CommonMediaClientError) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return typeof error.reason === 'string' && ('metadata' in error || error.metadata === undefined) && ('innerError' in error || error.innerError === undefined);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Deserializer ErrorFileState -> CommonMediaClientError */
|
|
90
|
+
var toCommonMediaClientError = exports.toCommonMediaClientError = function toCommonMediaClientError(errorFileState) {
|
|
91
|
+
var _errorFileState$detai;
|
|
92
|
+
var error = (_errorFileState$detai = errorFileState.details) === null || _errorFileState$detai === void 0 ? void 0 : _errorFileState$detai.error;
|
|
93
|
+
return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error.metadata, error.innerError);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** Serializer CommonMediaClientError -> ErrorFileState */
|
|
97
|
+
var fromCommonMediaClientError = exports.fromCommonMediaClientError = function fromCommonMediaClientError(id, occurrenceKey, error) {
|
|
98
|
+
return {
|
|
99
|
+
status: 'error',
|
|
100
|
+
id: id,
|
|
101
|
+
occurrenceKey: occurrenceKey,
|
|
102
|
+
reason: error.reason,
|
|
103
|
+
details: _objectSpread({
|
|
104
|
+
/** Use this attr to translate back into CommonMediaClientError (toCommonMediaClientError) */
|
|
105
|
+
error: {
|
|
106
|
+
reason: error === null || error === void 0 ? void 0 : error.reason,
|
|
107
|
+
metadata: error === null || error === void 0 ? void 0 : error.metadata,
|
|
108
|
+
innerError: error === null || error === void 0 ? void 0 : error.innerError
|
|
109
|
+
}
|
|
110
|
+
}, error === null || error === void 0 ? void 0 : error.attributes),
|
|
111
|
+
message: error === null || error === void 0 ? void 0 : error.message
|
|
112
|
+
};
|
|
113
|
+
};
|
|
@@ -15,25 +15,27 @@ var _errors = require("../models/errors");
|
|
|
15
15
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var UploaderError = exports.UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
|
-
|
|
18
|
+
// Legacy Attribute. Should be removed
|
|
19
|
+
|
|
20
|
+
function UploaderError(reason, metadata) {
|
|
19
21
|
var _this;
|
|
20
22
|
(0, _classCallCheck2.default)(this, UploaderError);
|
|
21
|
-
_this = _callSuper(this, UploaderError, [reason]);
|
|
22
|
-
_this.
|
|
23
|
-
_this.id = id;
|
|
24
|
-
_this.metadata = metadata;
|
|
23
|
+
_this = _callSuper(this, UploaderError, [reason, metadata, undefined]);
|
|
24
|
+
_this.id = metadata.id;
|
|
25
25
|
return _this;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
29
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
27
30
|
(0, _inherits2.default)(UploaderError, _BaseMediaClientError);
|
|
28
31
|
return (0, _createClass2.default)(UploaderError, [{
|
|
29
32
|
key: "attributes",
|
|
30
33
|
get: function get() {
|
|
31
34
|
var reason = this.reason,
|
|
32
|
-
id = this.id,
|
|
33
35
|
_this$metadata = this.metadata,
|
|
34
|
-
|
|
35
|
-
collectionName = _this$
|
|
36
|
-
occurrenceKey = _this$
|
|
36
|
+
id = _this$metadata.id,
|
|
37
|
+
collectionName = _this$metadata.collectionName,
|
|
38
|
+
occurrenceKey = _this$metadata.occurrenceKey;
|
|
37
39
|
return {
|
|
38
40
|
reason: reason,
|
|
39
41
|
id: id,
|
|
@@ -149,7 +149,8 @@ var uploadFile = exports.uploadFile = function uploadFile(file, store, uploadabl
|
|
|
149
149
|
}
|
|
150
150
|
} catch (err) {
|
|
151
151
|
if (err instanceof Error && err.message === _calculateChunkSize.fileSizeError) {
|
|
152
|
-
callbacks === null || callbacks === void 0 || callbacks.onUploadFinish(new _error.UploaderError(err.message,
|
|
152
|
+
callbacks === null || callbacks === void 0 || callbacks.onUploadFinish(new _error.UploaderError(err.message, {
|
|
153
|
+
id: id,
|
|
153
154
|
collectionName: collection,
|
|
154
155
|
occurrenceKey: occurrenceKey
|
|
155
156
|
}));
|
|
@@ -15,26 +15,28 @@ var _errors = require("../../models/errors");
|
|
|
15
15
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var MobileUploadError = exports.MobileUploadError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
|
-
|
|
18
|
+
// Legacy Attribute. Should be removed
|
|
19
|
+
|
|
20
|
+
function MobileUploadError(reason, metadata) {
|
|
19
21
|
var _this;
|
|
20
22
|
(0, _classCallCheck2.default)(this, MobileUploadError);
|
|
21
|
-
_this = _callSuper(this, MobileUploadError, [reason]);
|
|
22
|
-
_this.
|
|
23
|
-
_this.id = id;
|
|
24
|
-
_this.metadata = metadata;
|
|
23
|
+
_this = _callSuper(this, MobileUploadError, [reason, metadata, undefined]);
|
|
24
|
+
_this.id = metadata.id;
|
|
25
25
|
return _this;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
29
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
27
30
|
(0, _inherits2.default)(MobileUploadError, _BaseMediaClientError);
|
|
28
31
|
return (0, _createClass2.default)(MobileUploadError, [{
|
|
29
32
|
key: "attributes",
|
|
30
33
|
get: function get() {
|
|
31
34
|
var reason = this.reason,
|
|
32
|
-
id = this.id,
|
|
33
35
|
_this$metadata = this.metadata,
|
|
34
|
-
|
|
35
|
-
collectionName = _this$
|
|
36
|
-
occurrenceKey = _this$
|
|
37
|
-
traceContext = _this$
|
|
36
|
+
id = _this$metadata.id,
|
|
37
|
+
collectionName = _this$metadata.collectionName,
|
|
38
|
+
occurrenceKey = _this$metadata.occurrenceKey,
|
|
39
|
+
traceContext = _this$metadata.traceContext;
|
|
38
40
|
return {
|
|
39
41
|
reason: reason,
|
|
40
42
|
id: id,
|
|
@@ -47,7 +47,8 @@ var createMobileDownloadFileStream = exports.createMobileDownloadFileStream = fu
|
|
|
47
47
|
_context.next = 5;
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
|
-
throw new _error.MobileUploadError('emptyItems',
|
|
50
|
+
throw new _error.MobileUploadError('emptyItems', {
|
|
51
|
+
id: id,
|
|
51
52
|
collectionName: collectionName,
|
|
52
53
|
occurrenceKey: occurrenceKey,
|
|
53
54
|
traceContext: response.metadataTraceContext
|
|
@@ -57,7 +58,8 @@ var createMobileDownloadFileStream = exports.createMobileDownloadFileStream = fu
|
|
|
57
58
|
_context.next = 7;
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
|
-
throw new _error.MobileUploadError('zeroVersionFile',
|
|
61
|
+
throw new _error.MobileUploadError('zeroVersionFile', {
|
|
62
|
+
id: id,
|
|
61
63
|
collectionName: collectionName,
|
|
62
64
|
occurrenceKey: occurrenceKey,
|
|
63
65
|
traceContext: response.metadataTraceContext
|
|
@@ -15,20 +15,19 @@ var _errors = require("../../models/errors");
|
|
|
15
15
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var PollingError = exports.PollingError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
|
-
function PollingError(reason,
|
|
19
|
-
var _this;
|
|
18
|
+
function PollingError(reason, metadata) {
|
|
20
19
|
(0, _classCallCheck2.default)(this, PollingError);
|
|
21
|
-
|
|
22
|
-
_this.reason = reason;
|
|
23
|
-
_this.attempts = attempts;
|
|
24
|
-
return _this;
|
|
20
|
+
return _callSuper(this, PollingError, [reason, metadata, undefined]);
|
|
25
21
|
}
|
|
22
|
+
|
|
23
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
24
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
26
25
|
(0, _inherits2.default)(PollingError, _BaseMediaClientError);
|
|
27
26
|
return (0, _createClass2.default)(PollingError, [{
|
|
28
27
|
key: "attributes",
|
|
29
28
|
get: function get() {
|
|
30
29
|
var reason = this.reason,
|
|
31
|
-
attempts = this.attempts;
|
|
30
|
+
attempts = this.metadata.attempts;
|
|
32
31
|
return {
|
|
33
32
|
reason: reason,
|
|
34
33
|
attempts: attempts
|
|
@@ -68,7 +68,9 @@ var PollingFunction = exports.PollingFunction = /*#__PURE__*/function () {
|
|
|
68
68
|
_context.next = 3;
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
|
-
return _context.abrupt("return", this.fail(new _errors.PollingError('pollingMaxAttemptsExceeded',
|
|
71
|
+
return _context.abrupt("return", this.fail(new _errors.PollingError('pollingMaxAttemptsExceeded', {
|
|
72
|
+
attempts: this.attempt
|
|
73
|
+
})));
|
|
72
74
|
case 3:
|
|
73
75
|
_context.prev = 3;
|
|
74
76
|
// executor must explicitly call this.next() for triggering next iteration (pull)
|
|
@@ -86,7 +88,9 @@ var PollingFunction = exports.PollingFunction = /*#__PURE__*/function () {
|
|
|
86
88
|
_context.next = 11;
|
|
87
89
|
break;
|
|
88
90
|
}
|
|
89
|
-
return _context.abrupt("return", this.fail(new _errors.PollingError('pollingMaxAttemptsExceeded',
|
|
91
|
+
return _context.abrupt("return", this.fail(new _errors.PollingError('pollingMaxAttemptsExceeded', {
|
|
92
|
+
attempts: this.attempt
|
|
93
|
+
})));
|
|
90
94
|
case 11:
|
|
91
95
|
this.poll_intervalMs = this.getIntervalMsForIteration(this.attempt);
|
|
92
96
|
this.attempt++;
|
|
@@ -16,14 +16,12 @@ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0,
|
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
17
|
var RequestError = exports.RequestError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
18
18
|
function RequestError(reason, metadata, innerError) {
|
|
19
|
-
var _this;
|
|
20
19
|
(0, _classCallCheck2.default)(this, RequestError);
|
|
21
|
-
|
|
22
|
-
_this.reason = reason;
|
|
23
|
-
_this.metadata = metadata;
|
|
24
|
-
_this.innerError = innerError;
|
|
25
|
-
return _this;
|
|
20
|
+
return _callSuper(this, RequestError, [reason, metadata, innerError]);
|
|
26
21
|
}
|
|
22
|
+
|
|
23
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
24
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
27
25
|
(0, _inherits2.default)(RequestError, _BaseMediaClientError);
|
|
28
26
|
return (0, _createClass2.default)(RequestError, [{
|
|
29
27
|
key: "attributes",
|
|
@@ -33,6 +33,10 @@ var _authQueryParameters = require("../../models/auth-query-parameters");
|
|
|
33
33
|
var _errors = require("./errors");
|
|
34
34
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
35
35
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
36
|
+
var getStatusCode = function getStatusCode(error) {
|
|
37
|
+
var _error$metadata;
|
|
38
|
+
return (0, _errors.isRequestError)(error) && ((_error$metadata = error.metadata) === null || _error$metadata === void 0 ? void 0 : _error$metadata.statusCode) && error.metadata.statusCode;
|
|
39
|
+
};
|
|
36
40
|
function waitPromise(timeout) {
|
|
37
41
|
return new Promise(function (resolve) {
|
|
38
42
|
return setTimeout(resolve, timeout);
|
|
@@ -47,7 +51,8 @@ function isFetchNetworkError(err) {
|
|
|
47
51
|
return err instanceof TypeError;
|
|
48
52
|
}
|
|
49
53
|
function isRateLimitedError(error) {
|
|
50
|
-
|
|
54
|
+
var statusCode = error && getStatusCode(error);
|
|
55
|
+
return statusCode === 429 || !!error && !!error.message && error.message.includes('429');
|
|
51
56
|
}
|
|
52
57
|
var extendTraceContext = exports.extendTraceContext = function extendTraceContext(traceContext) {
|
|
53
58
|
return traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
@@ -160,8 +165,8 @@ function createMapResponseToBlob(metadata) {
|
|
|
160
165
|
}();
|
|
161
166
|
}
|
|
162
167
|
var defaultShouldRetryError = exports.defaultShouldRetryError = function defaultShouldRetryError(err) {
|
|
163
|
-
var
|
|
164
|
-
return isFetchNetworkError(err) || (
|
|
168
|
+
var statusCode = getStatusCode(err);
|
|
169
|
+
return isFetchNetworkError(err) || (statusCode ? statusCode >= 500 : false);
|
|
165
170
|
};
|
|
166
171
|
var DEFAULT_RETRY_OPTIONS = exports.DEFAULT_RETRY_OPTIONS = {
|
|
167
172
|
startTimeoutInMs: 1000,
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { BaseMediaClientError } from '../../models/errors';
|
|
2
2
|
export class FileFetcherError extends BaseMediaClientError {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
3
|
+
// Legacy Attribute. Should be removed
|
|
4
|
+
|
|
5
|
+
constructor(reason, metadata) {
|
|
6
|
+
super(reason, metadata, undefined);
|
|
7
|
+
this.id = metadata.id;
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
// TODO: Deprecate this getter https://product-fabric.atlassian.net/browse/CXP-4665
|
|
11
|
+
/** Will be deprecated. Use the properties `reason` and `metadata` instead */
|
|
9
12
|
get attributes() {
|
|
10
13
|
const {
|
|
11
14
|
reason,
|
|
12
|
-
id,
|
|
13
15
|
metadata: {
|
|
16
|
+
id,
|
|
14
17
|
collectionName,
|
|
15
18
|
occurrenceKey,
|
|
16
19
|
traceContext
|
|
17
|
-
}
|
|
20
|
+
}
|
|
18
21
|
} = this;
|
|
19
22
|
return {
|
|
20
23
|
reason,
|