@atlaskit/media-client 20.2.1 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cjs/client/file-fetcher/error.js +4 -4
  3. package/dist/cjs/client/file-fetcher/index.js +275 -287
  4. package/dist/cjs/client/media-client.js +48 -34
  5. package/dist/cjs/client/media-store/index.js +367 -314
  6. package/dist/cjs/client/media-store/resolveAuth.js +30 -32
  7. package/dist/cjs/client/stargate-client.js +14 -16
  8. package/dist/cjs/index.js +6 -13
  9. package/dist/cjs/models/media.js +8 -9
  10. package/dist/cjs/uploader/error.js +4 -4
  11. package/dist/cjs/uploader/index.js +88 -96
  12. package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
  13. package/dist/cjs/utils/createFileDataLoader.js +67 -70
  14. package/dist/cjs/utils/getDimensionsFromBlob.js +23 -25
  15. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +24 -26
  16. package/dist/cjs/utils/hashing/hasherCreator.js +32 -34
  17. package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
  18. package/dist/cjs/utils/mobileUpload/error.js +4 -4
  19. package/dist/cjs/utils/mobileUpload/helpers.js +41 -43
  20. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +14 -16
  21. package/dist/cjs/utils/parseJwt.js +52 -0
  22. package/dist/cjs/utils/polling/index.js +40 -42
  23. package/dist/cjs/utils/request/errors.js +9 -9
  24. package/dist/cjs/utils/request/helpers.js +143 -155
  25. package/dist/cjs/utils/request/index.js +24 -26
  26. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +39 -41
  27. package/dist/cjs/version.json +1 -1
  28. package/dist/es2019/client/file-fetcher/index.js +1 -3
  29. package/dist/es2019/client/media-client.js +3 -2
  30. package/dist/es2019/client/media-store/index.js +58 -15
  31. package/dist/es2019/index.js +2 -3
  32. package/dist/es2019/models/media.js +6 -4
  33. package/dist/es2019/uploader/index.js +3 -0
  34. package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
  35. package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
  36. package/dist/es2019/utils/parseJwt.js +46 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/client/file-fetcher/error.js +4 -4
  39. package/dist/esm/client/file-fetcher/index.js +273 -286
  40. package/dist/esm/client/media-client.js +46 -32
  41. package/dist/esm/client/media-store/index.js +367 -314
  42. package/dist/esm/client/media-store/resolveAuth.js +30 -32
  43. package/dist/esm/client/stargate-client.js +14 -16
  44. package/dist/esm/index.js +2 -3
  45. package/dist/esm/models/media.js +6 -6
  46. package/dist/esm/uploader/error.js +4 -4
  47. package/dist/esm/uploader/index.js +89 -96
  48. package/dist/esm/utils/convertBase64ToBlob.js +2 -2
  49. package/dist/esm/utils/createFileDataLoader.js +65 -69
  50. package/dist/esm/utils/getDimensionsFromBlob.js +23 -25
  51. package/dist/esm/utils/getVideoDimensionsFromBlob.js +24 -26
  52. package/dist/esm/utils/hashing/hasherCreator.js +28 -30
  53. package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
  54. package/dist/esm/utils/mobileUpload/error.js +4 -4
  55. package/dist/esm/utils/mobileUpload/helpers.js +41 -43
  56. package/dist/esm/utils/mobileUpload/stateMachine/index.js +14 -16
  57. package/dist/esm/utils/parseJwt.js +46 -0
  58. package/dist/esm/utils/polling/index.js +40 -42
  59. package/dist/esm/utils/request/errors.js +9 -9
  60. package/dist/esm/utils/request/helpers.js +143 -155
  61. package/dist/esm/utils/request/index.js +24 -26
  62. package/dist/esm/utils/shouldFetchRemoteFileStates.js +39 -41
  63. package/dist/esm/version.json +1 -1
  64. package/dist/types/client/__mocks__/media-client.d.ts +0 -2
  65. package/dist/types/client/file-fetcher/index.d.ts +4 -4
  66. package/dist/types/client/media-client.d.ts +1 -2
  67. package/dist/types/client/media-store/index.d.ts +17 -13
  68. package/dist/types/index.d.ts +4 -6
  69. package/dist/types/models/file-state.d.ts +2 -2
  70. package/dist/types/models/media.d.ts +1 -21
  71. package/dist/types/utils/createFileDataLoader.d.ts +2 -2
  72. package/dist/types/utils/createMediaSubject.d.ts +2 -2
  73. package/dist/types/utils/detectEmptyFile.d.ts +2 -2
  74. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
  75. package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
  76. package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
  77. package/dist/types/utils/parseJwt.d.ts +1 -0
  78. package/package.json +2 -2
  79. package/report.api.md +77 -126
  80. package/dist/cjs/client/collection-fetcher.js +0 -98
  81. package/dist/cjs/models/media-subscribable.js +0 -5
  82. package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
  83. package/dist/es2019/client/collection-fetcher.js +0 -38
  84. package/dist/es2019/models/media-subscribable.js +0 -1
  85. package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
  86. package/dist/esm/client/collection-fetcher.js +0 -89
  87. package/dist/esm/models/media-subscribable.js +0 -1
  88. package/dist/esm/utils/deprecatedEndpointError.js +0 -34
  89. package/dist/types/client/collection-fetcher.d.ts +0 -42
  90. package/dist/types/models/media-subscribable.d.ts +0 -3
  91. package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
@@ -95,26 +95,24 @@ export function mapResponseToJson(_x) {
95
95
  function _mapResponseToJson() {
96
96
  _mapResponseToJson = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(response) {
97
97
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
98
- while (1) {
99
- switch (_context3.prev = _context3.next) {
100
- case 0:
101
- // eslint-disable-next-line no-console
102
- console.warn('Helper is deprecated and will be remove in the next major version');
103
- _context3.prev = 1;
104
- _context3.next = 4;
105
- return response.json();
106
- case 4:
107
- return _context3.abrupt("return", _context3.sent);
108
- case 7:
109
- _context3.prev = 7;
110
- _context3.t0 = _context3["catch"](1);
111
- throw new RequestError('serverInvalidBody', {
112
- statusCode: response.status
113
- }, _context3.t0 instanceof Error ? _context3.t0 : undefined);
114
- case 10:
115
- case "end":
116
- return _context3.stop();
117
- }
98
+ while (1) switch (_context3.prev = _context3.next) {
99
+ case 0:
100
+ // eslint-disable-next-line no-console
101
+ console.warn('Helper is deprecated and will be remove in the next major version');
102
+ _context3.prev = 1;
103
+ _context3.next = 4;
104
+ return response.json();
105
+ case 4:
106
+ return _context3.abrupt("return", _context3.sent);
107
+ case 7:
108
+ _context3.prev = 7;
109
+ _context3.t0 = _context3["catch"](1);
110
+ throw new RequestError('serverInvalidBody', {
111
+ statusCode: response.status
112
+ }, _context3.t0 instanceof Error ? _context3.t0 : undefined);
113
+ case 10:
114
+ case "end":
115
+ return _context3.stop();
118
116
  }
119
117
  }, _callee3, null, [[1, 7]]);
120
118
  }));
@@ -131,26 +129,24 @@ export function mapResponseToBlob(_x2) {
131
129
  function _mapResponseToBlob() {
132
130
  _mapResponseToBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(response) {
133
131
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
134
- while (1) {
135
- switch (_context4.prev = _context4.next) {
136
- case 0:
137
- // eslint-disable-next-line no-console
138
- console.warn('Helper is deprecated and will be remove in the next major version');
139
- _context4.prev = 1;
140
- _context4.next = 4;
141
- return response.blob();
142
- case 4:
143
- return _context4.abrupt("return", _context4.sent);
144
- case 7:
145
- _context4.prev = 7;
146
- _context4.t0 = _context4["catch"](1);
147
- throw new RequestError('serverInvalidBody', {
148
- statusCode: response.status
149
- }, _context4.t0 instanceof Error ? _context4.t0 : undefined);
150
- case 10:
151
- case "end":
152
- return _context4.stop();
153
- }
132
+ while (1) switch (_context4.prev = _context4.next) {
133
+ case 0:
134
+ // eslint-disable-next-line no-console
135
+ console.warn('Helper is deprecated and will be remove in the next major version');
136
+ _context4.prev = 1;
137
+ _context4.next = 4;
138
+ return response.blob();
139
+ case 4:
140
+ return _context4.abrupt("return", _context4.sent);
141
+ case 7:
142
+ _context4.prev = 7;
143
+ _context4.t0 = _context4["catch"](1);
144
+ throw new RequestError('serverInvalidBody', {
145
+ statusCode: response.status
146
+ }, _context4.t0 instanceof Error ? _context4.t0 : undefined);
147
+ case 10:
148
+ case "end":
149
+ return _context4.stop();
154
150
  }
155
151
  }, _callee4, null, [[1, 7]]);
156
152
  }));
@@ -165,24 +161,22 @@ export function createMapResponseToJson(metadata) {
165
161
  return /*#__PURE__*/function () {
166
162
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
167
163
  return _regeneratorRuntime.wrap(function _callee$(_context) {
168
- while (1) {
169
- switch (_context.prev = _context.next) {
170
- case 0:
171
- _context.prev = 0;
172
- _context.next = 3;
173
- return response.json();
174
- case 3:
175
- return _context.abrupt("return", _context.sent);
176
- case 6:
177
- _context.prev = 6;
178
- _context.t0 = _context["catch"](0);
179
- throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
180
- statusCode: response.status
181
- }), _context.t0 instanceof Error ? _context.t0 : undefined);
182
- case 9:
183
- case "end":
184
- return _context.stop();
185
- }
164
+ while (1) switch (_context.prev = _context.next) {
165
+ case 0:
166
+ _context.prev = 0;
167
+ _context.next = 3;
168
+ return response.json();
169
+ case 3:
170
+ return _context.abrupt("return", _context.sent);
171
+ case 6:
172
+ _context.prev = 6;
173
+ _context.t0 = _context["catch"](0);
174
+ throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
175
+ statusCode: response.status
176
+ }), _context.t0 instanceof Error ? _context.t0 : undefined);
177
+ case 9:
178
+ case "end":
179
+ return _context.stop();
186
180
  }
187
181
  }, _callee, null, [[0, 6]]);
188
182
  }));
@@ -195,24 +189,22 @@ export function createMapResponseToBlob(metadata) {
195
189
  return /*#__PURE__*/function () {
196
190
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(response) {
197
191
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
198
- while (1) {
199
- switch (_context2.prev = _context2.next) {
200
- case 0:
201
- _context2.prev = 0;
202
- _context2.next = 3;
203
- return response.blob();
204
- case 3:
205
- return _context2.abrupt("return", _context2.sent);
206
- case 6:
207
- _context2.prev = 6;
208
- _context2.t0 = _context2["catch"](0);
209
- throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
210
- statusCode: response.status
211
- }), _context2.t0 instanceof Error ? _context2.t0 : undefined);
212
- case 9:
213
- case "end":
214
- return _context2.stop();
215
- }
192
+ while (1) switch (_context2.prev = _context2.next) {
193
+ case 0:
194
+ _context2.prev = 0;
195
+ _context2.next = 3;
196
+ return response.blob();
197
+ case 3:
198
+ return _context2.abrupt("return", _context2.sent);
199
+ case 6:
200
+ _context2.prev = 6;
201
+ _context2.t0 = _context2["catch"](0);
202
+ throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
203
+ statusCode: response.status
204
+ }), _context2.t0 instanceof Error ? _context2.t0 : undefined);
205
+ case 9:
206
+ case "end":
207
+ return _context2.stop();
216
208
  }
217
209
  }, _callee2, null, [[0, 6]]);
218
210
  }));
@@ -251,87 +243,83 @@ function _fetchRetry() {
251
243
  waitAndBumpTimeout,
252
244
  _args6 = arguments;
253
245
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
254
- while (1) {
255
- switch (_context6.prev = _context6.next) {
256
- case 0:
257
- overwriteOptions = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
258
- options = _objectSpread(_objectSpread({}, DEFAULT_RETRY_OPTIONS), overwriteOptions);
259
- startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor;
260
- attempts = 0;
261
- timeoutInMs = startTimeoutInMs;
262
- waitAndBumpTimeout = /*#__PURE__*/function () {
263
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
264
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
265
- while (1) {
266
- switch (_context5.prev = _context5.next) {
267
- case 0:
268
- _context5.next = 2;
269
- return waitPromise(timeoutInMs);
270
- case 2:
271
- timeoutInMs *= factor;
272
- attempts += 1;
273
- case 4:
274
- case "end":
275
- return _context5.stop();
276
- }
277
- }
278
- }, _callee5);
279
- }));
280
- return function waitAndBumpTimeout() {
281
- return _ref7.apply(this, arguments);
282
- };
283
- }();
284
- case 6:
285
- if (!(attempts < maxAttempts)) {
286
- _context6.next = 24;
287
- break;
288
- }
289
- _context6.prev = 7;
290
- _context6.next = 10;
291
- return functionToRetry();
292
- case 10:
293
- return _context6.abrupt("return", _context6.sent);
294
- case 13:
295
- _context6.prev = 13;
296
- _context6.t0 = _context6["catch"](7);
297
- lastError = _context6.t0;
246
+ while (1) switch (_context6.prev = _context6.next) {
247
+ case 0:
248
+ overwriteOptions = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
249
+ options = _objectSpread(_objectSpread({}, DEFAULT_RETRY_OPTIONS), overwriteOptions);
250
+ startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor;
251
+ attempts = 0;
252
+ timeoutInMs = startTimeoutInMs;
253
+ waitAndBumpTimeout = /*#__PURE__*/function () {
254
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
255
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
256
+ while (1) switch (_context5.prev = _context5.next) {
257
+ case 0:
258
+ _context5.next = 2;
259
+ return waitPromise(timeoutInMs);
260
+ case 2:
261
+ timeoutInMs *= factor;
262
+ attempts += 1;
263
+ case 4:
264
+ case "end":
265
+ return _context5.stop();
266
+ }
267
+ }, _callee5);
268
+ }));
269
+ return function waitAndBumpTimeout() {
270
+ return _ref7.apply(this, arguments);
271
+ };
272
+ }();
273
+ case 6:
274
+ if (!(attempts < maxAttempts)) {
275
+ _context6.next = 24;
276
+ break;
277
+ }
278
+ _context6.prev = 7;
279
+ _context6.next = 10;
280
+ return functionToRetry();
281
+ case 10:
282
+ return _context6.abrupt("return", _context6.sent);
283
+ case 13:
284
+ _context6.prev = 13;
285
+ _context6.t0 = _context6["catch"](7);
286
+ lastError = _context6.t0;
298
287
 
299
- // don't retry if request was aborted by user
300
- if (!isAbortedRequestError(_context6.t0)) {
301
- _context6.next = 18;
302
- break;
303
- }
304
- throw new RequestError('clientAbortedRequest', metadata, _context6.t0);
305
- case 18:
306
- if (!(!isFetchNetworkError(_context6.t0) && !isRequestError(_context6.t0) || isRequestError(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
307
- _context6.next = 20;
308
- break;
309
- }
310
- throw _context6.t0;
311
- case 20:
312
- _context6.next = 22;
313
- return waitAndBumpTimeout();
314
- case 22:
315
- _context6.next = 6;
288
+ // don't retry if request was aborted by user
289
+ if (!isAbortedRequestError(_context6.t0)) {
290
+ _context6.next = 18;
316
291
  break;
317
- case 24:
318
- if (!isRequestError(lastError)) {
319
- _context6.next = 26;
320
- break;
321
- }
322
- throw cloneRequestError(lastError, {
323
- attempts: attempts,
324
- clientExhaustedRetries: true
325
- });
326
- case 26:
327
- throw new RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
328
- attempts: attempts,
329
- clientExhaustedRetries: true
330
- }), lastError);
331
- case 27:
332
- case "end":
333
- return _context6.stop();
334
- }
292
+ }
293
+ throw new RequestError('clientAbortedRequest', metadata, _context6.t0);
294
+ case 18:
295
+ if (!(!isFetchNetworkError(_context6.t0) && !isRequestError(_context6.t0) || isRequestError(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
296
+ _context6.next = 20;
297
+ break;
298
+ }
299
+ throw _context6.t0;
300
+ case 20:
301
+ _context6.next = 22;
302
+ return waitAndBumpTimeout();
303
+ case 22:
304
+ _context6.next = 6;
305
+ break;
306
+ case 24:
307
+ if (!isRequestError(lastError)) {
308
+ _context6.next = 26;
309
+ break;
310
+ }
311
+ throw cloneRequestError(lastError, {
312
+ attempts: attempts,
313
+ clientExhaustedRetries: true
314
+ });
315
+ case 26:
316
+ throw new RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
317
+ attempts: attempts,
318
+ clientExhaustedRetries: true
319
+ }), lastError);
320
+ case 27:
321
+ case "end":
322
+ return _context6.stop();
335
323
  }
336
324
  }, _callee6, null, [[7, 13]]);
337
325
  }));
@@ -25,33 +25,31 @@ function _request() {
25
25
  doFetch,
26
26
  _args = arguments;
27
27
  return _regeneratorRuntime.wrap(function _callee$(_context) {
28
- while (1) {
29
- switch (_context.prev = _context.next) {
30
- case 0:
31
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
32
- controller = _args.length > 2 ? _args[2] : undefined;
33
- _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;
34
- retryOptions = clientOptions.retryOptions;
35
- metadata = {
28
+ while (1) switch (_context.prev = _context.next) {
29
+ case 0:
30
+ options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
31
+ controller = _args.length > 2 ? _args[2] : undefined;
32
+ _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;
33
+ retryOptions = clientOptions.retryOptions;
34
+ metadata = {
35
+ method: method,
36
+ endpoint: endpoint,
37
+ traceContext: traceContext
38
+ }; // TODO BMPT-918: add client timeout feature behing a FF (using clientOptions.clientTimeout + Promise.race)
39
+ doFetch = function doFetch() {
40
+ return fetch(createUrl(url, {
41
+ params: params
42
+ }), {
36
43
  method: method,
37
- endpoint: endpoint,
38
- traceContext: traceContext
39
- }; // TODO BMPT-918: add client timeout feature behing a FF (using clientOptions.clientTimeout + Promise.race)
40
- doFetch = function doFetch() {
41
- return fetch(createUrl(url, {
42
- params: params
43
- }), {
44
- method: method,
45
- body: body,
46
- headers: extendHeaders(headers, auth, traceContext),
47
- signal: controller && controller.signal
48
- }).then(createProcessFetchResponse(metadata));
49
- };
50
- return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
51
- case 7:
52
- case "end":
53
- return _context.stop();
54
- }
44
+ body: body,
45
+ headers: extendHeaders(headers, auth, traceContext),
46
+ signal: controller && controller.signal
47
+ }).then(createProcessFetchResponse(metadata));
48
+ };
49
+ return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
50
+ case 7:
51
+ case "end":
52
+ return _context.stop();
55
53
  }
56
54
  }, _callee);
57
55
  }));
@@ -22,47 +22,45 @@ function _shouldFetchRemoteFileStates() {
22
22
  _shouldFetchRemoteFileStates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaType, mimeType, preview) {
23
23
  var content, _yield$getVideoDimens, width, height;
24
24
  return _regeneratorRuntime.wrap(function _callee$(_context) {
25
- while (1) {
26
- switch (_context.prev = _context.next) {
27
- case 0:
28
- if (!((mediaType === 'doc' || !isMimeTypeSupportedByBrowser(mimeType) || !preview) && isMimeTypeSupportedByServer(mimeType))) {
29
- _context.next = 2;
30
- break;
31
- }
32
- return _context.abrupt("return", true);
33
- case 2:
34
- if (!(mediaType === 'video' && !!preview)) {
35
- _context.next = 20;
36
- break;
37
- }
38
- _context.next = 5;
39
- return preview;
40
- case 5:
41
- content = _context.sent.value;
42
- if (content instanceof Blob) {
43
- _context.next = 8;
44
- break;
45
- }
46
- return _context.abrupt("return", false);
47
- case 8:
48
- _context.prev = 8;
49
- _context.next = 11;
50
- return getVideoDimensionsFromBlob(content);
51
- case 11:
52
- _yield$getVideoDimens = _context.sent;
53
- width = _yield$getVideoDimens.width;
54
- height = _yield$getVideoDimens.height;
55
- return _context.abrupt("return", !width && !height);
56
- case 17:
57
- _context.prev = 17;
58
- _context.t0 = _context["catch"](8);
59
- return _context.abrupt("return", true);
60
- case 20:
61
- return _context.abrupt("return", false);
62
- case 21:
63
- case "end":
64
- return _context.stop();
65
- }
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ if (!((mediaType === 'doc' || !isMimeTypeSupportedByBrowser(mimeType) || !preview) && isMimeTypeSupportedByServer(mimeType))) {
28
+ _context.next = 2;
29
+ break;
30
+ }
31
+ return _context.abrupt("return", true);
32
+ case 2:
33
+ if (!(mediaType === 'video' && !!preview)) {
34
+ _context.next = 20;
35
+ break;
36
+ }
37
+ _context.next = 5;
38
+ return preview;
39
+ case 5:
40
+ content = _context.sent.value;
41
+ if (content instanceof Blob) {
42
+ _context.next = 8;
43
+ break;
44
+ }
45
+ return _context.abrupt("return", false);
46
+ case 8:
47
+ _context.prev = 8;
48
+ _context.next = 11;
49
+ return getVideoDimensionsFromBlob(content);
50
+ case 11:
51
+ _yield$getVideoDimens = _context.sent;
52
+ width = _yield$getVideoDimens.width;
53
+ height = _yield$getVideoDimens.height;
54
+ return _context.abrupt("return", !width && !height);
55
+ case 17:
56
+ _context.prev = 17;
57
+ _context.t0 = _context["catch"](8);
58
+ return _context.abrupt("return", true);
59
+ case 20:
60
+ return _context.abrupt("return", false);
61
+ case 21:
62
+ case "end":
63
+ return _context.stop();
66
64
  }
67
65
  }, _callee, null, [[8, 17]]);
68
66
  }));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "20.2.1",
3
+ "version": "21.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,8 @@
1
1
  /// <reference types="jest" />
2
2
  import { MediaClientConfig } from '@atlaskit/media-core';
3
- import { CollectionFetcher } from '../collection-fetcher';
4
3
  import { FileFetcher } from '../file-fetcher';
5
4
  export declare class MediaClient {
6
5
  readonly config: MediaClientConfig;
7
- readonly collection: CollectionFetcher;
8
6
  readonly file: FileFetcher;
9
7
  constructor(config: MediaClientConfig);
10
8
  getImage: jest.Mock<any, any>;
@@ -29,10 +29,10 @@ export declare type ExternalUploadPayload = {
29
29
  dimensions: Dimensions;
30
30
  };
31
31
  export interface FileFetcher {
32
- getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
32
+ getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
33
33
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
34
34
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
35
- upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable<FileState>;
35
+ upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
36
36
  uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
37
37
  downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
38
38
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
@@ -44,7 +44,7 @@ export declare class FileFetcherImpl implements FileFetcher {
44
44
  private readonly featureFlags?;
45
45
  private readonly dataloader;
46
46
  constructor(mediaStore: MediaStore, featureFlags?: MediaFeatureFlags | undefined);
47
- getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
47
+ getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
48
48
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
49
49
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
50
50
  getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
@@ -55,7 +55,7 @@ export declare class FileFetcherImpl implements FileFetcher {
55
55
  private getUploadingFileStateBase;
56
56
  private uploadAwlaysPullFileStates;
57
57
  private uploadConditionallyPullFileStates;
58
- upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable<FileState>;
58
+ upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
59
59
  downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
60
60
  copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
61
61
  }
@@ -1,7 +1,6 @@
1
1
  import { MediaClientConfig } from '@atlaskit/media-core';
2
2
  import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
3
3
  import { MediaStore, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
4
- import { CollectionFetcher } from './collection-fetcher';
5
4
  import { FileFetcher } from './file-fetcher';
6
5
  import { UploadEventPayloadMap, EventPayloadListener } from './events';
7
6
  import { StargateClient } from './stargate-client';
@@ -10,7 +9,6 @@ export declare class MediaClient {
10
9
  readonly mediaClientConfig: MediaClientConfig;
11
10
  readonly featureFlags?: MediaFeatureFlags | undefined;
12
11
  readonly mediaStore: MediaStore;
13
- readonly collection: CollectionFetcher;
14
12
  readonly file: FileFetcher;
15
13
  readonly stargate: StargateClient;
16
14
  private readonly eventEmitter;
@@ -22,6 +20,7 @@ export declare class MediaClient {
22
20
  getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
23
21
  getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
24
22
  mobileUploadPromise(): Promise<MobileUpload>;
23
+ removeFileFromCollection(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
25
24
  on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
26
25
  off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
27
26
  emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;