@atlaskit/media-client 22.0.2 → 22.0.4
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 +15 -0
- package/dist/cjs/client/file-fetcher/index.js +3 -103
- package/dist/cjs/client/media-client.js +1 -1
- package/dist/cjs/client/media-store/index.js +13 -80
- package/dist/cjs/models/media.js +1 -8
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +0 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +3 -104
- package/dist/es2019/client/media-client.js +1 -1
- package/dist/es2019/client/media-store/index.js +5 -45
- package/dist/es2019/models/media.js +1 -9
- package/dist/es2019/utils/shouldFetchRemoteFileStates.js +0 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +4 -104
- package/dist/esm/client/media-client.js +1 -1
- package/dist/esm/client/media-store/index.js +13 -80
- package/dist/esm/models/media.js +1 -9
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +0 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/client/file-fetcher/error.d.ts +1 -1
- package/dist/types/client/file-fetcher/index.d.ts +4 -7
- package/dist/types/client/media-store/index.d.ts +1 -2
- package/dist/types/models/errors/types.d.ts +1 -1
- package/dist/types/models/media.d.ts +1 -1
- package/dist/types/utils/shouldFetchRemoteFileStates.d.ts +0 -2
- package/dist/types-ts4.5/client/file-fetcher/error.d.ts +1 -1
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -7
- package/dist/types-ts4.5/client/media-store/index.d.ts +1 -2
- package/dist/types-ts4.5/models/errors/types.d.ts +1 -1
- package/dist/types-ts4.5/models/media.d.ts +1 -1
- package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +0 -2
- package/package.json +4 -4
- package/report.api.md +5 -9
- package/dist/cjs/utils/parseJwt.js +0 -52
- package/dist/es2019/utils/parseJwt.js +0 -46
- package/dist/esm/utils/parseJwt.js +0 -46
- package/dist/types/utils/parseJwt.d.ts +0 -1
- package/dist/types-ts4.5/utils/parseJwt.d.ts +0 -1
|
@@ -6,9 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { Subscription } from 'rxjs/Subscription';
|
|
9
|
-
import { of } from 'rxjs/observable/of';
|
|
10
9
|
import { map } from 'rxjs/operators/map';
|
|
11
|
-
import { concatMap } from 'rxjs/operators/concatMap';
|
|
12
10
|
import uuid from 'uuid/v4';
|
|
13
11
|
// import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
14
12
|
// @see https://github.com/graphql/dataloader/issues/249
|
|
@@ -31,13 +29,12 @@ import { toPromise, fromObservable } from '../../utils/mediaSubscribable';
|
|
|
31
29
|
import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
32
30
|
import { createMediaSubject } from '../../utils/createMediaSubject';
|
|
33
31
|
import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
34
|
-
import { shouldFetchRemoteFileStates
|
|
32
|
+
import { shouldFetchRemoteFileStates } from '../../utils/shouldFetchRemoteFileStates';
|
|
35
33
|
import { PollingFunction } from '../../utils/polling';
|
|
36
34
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
37
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
38
35
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
39
36
|
export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
40
|
-
function FileFetcherImpl(mediaStore
|
|
37
|
+
function FileFetcherImpl(mediaStore) {
|
|
41
38
|
var _this = this;
|
|
42
39
|
_classCallCheck(this, FileFetcherImpl);
|
|
43
40
|
// TODO: ----- ADD TICKET TO PASS TRACE ID to this.dataloader.load
|
|
@@ -135,7 +132,6 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
135
132
|
};
|
|
136
133
|
});
|
|
137
134
|
this.mediaStore = mediaStore;
|
|
138
|
-
this.featureFlags = featureFlags;
|
|
139
135
|
this.dataloader = createFileDataloader(mediaStore);
|
|
140
136
|
}
|
|
141
137
|
_createClass(FileFetcherImpl, [{
|
|
@@ -327,10 +323,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
327
323
|
return uploadExternal;
|
|
328
324
|
}()
|
|
329
325
|
}, {
|
|
330
|
-
key: "
|
|
331
|
-
value:
|
|
332
|
-
// TODO: make this the public upload method when the FF is removed
|
|
333
|
-
function uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
326
|
+
key: "upload",
|
|
327
|
+
value: function upload(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
334
328
|
var _this4 = this;
|
|
335
329
|
var collection = file.collection;
|
|
336
330
|
var upfrontId = uploadableFileUpfrontIds || this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
@@ -372,100 +366,6 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
372
366
|
setTimeout(onProgress, 0, 0);
|
|
373
367
|
return fromObservable(subject);
|
|
374
368
|
}
|
|
375
|
-
}, {
|
|
376
|
-
key: "uploadConditionallyPullFileStates",
|
|
377
|
-
value: function uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext) {
|
|
378
|
-
var _this5 = this;
|
|
379
|
-
if (typeof file.content === 'string') {
|
|
380
|
-
file.content = convertBase64ToBlob(file.content);
|
|
381
|
-
}
|
|
382
|
-
var content = file.content,
|
|
383
|
-
_file$name2 = file.name,
|
|
384
|
-
name = _file$name2 === void 0 ? '' : _file$name2,
|
|
385
|
-
collection = file.collection;
|
|
386
|
-
if (!uploadableFileUpfrontIds) {
|
|
387
|
-
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
388
|
-
}
|
|
389
|
-
var id = uploadableFileUpfrontIds.id;
|
|
390
|
-
var occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
391
|
-
var mimeType = '';
|
|
392
|
-
var size = 0;
|
|
393
|
-
var preview;
|
|
394
|
-
// TODO [MSW-796]: get file size for base64
|
|
395
|
-
var mediaType = getMediaTypeFromUploadableFile(file);
|
|
396
|
-
var subject = createMediaSubject();
|
|
397
|
-
var processingSubscription = new Subscription();
|
|
398
|
-
if (content instanceof Blob) {
|
|
399
|
-
size = content.size;
|
|
400
|
-
mimeType = content.type;
|
|
401
|
-
if (isMimeTypeSupportedByBrowser(content.type)) {
|
|
402
|
-
preview = {
|
|
403
|
-
value: content,
|
|
404
|
-
origin: 'local'
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
var stateBase = {
|
|
409
|
-
id: id,
|
|
410
|
-
occurrenceKey: occurrenceKey,
|
|
411
|
-
name: name,
|
|
412
|
-
size: size,
|
|
413
|
-
mediaType: mediaType,
|
|
414
|
-
mimeType: mimeType,
|
|
415
|
-
preview: preview
|
|
416
|
-
};
|
|
417
|
-
var onProgress = function onProgress(progress) {
|
|
418
|
-
subject.next(_objectSpread(_objectSpread({
|
|
419
|
-
status: 'uploading'
|
|
420
|
-
}, stateBase), {}, {
|
|
421
|
-
progress: progress
|
|
422
|
-
}));
|
|
423
|
-
};
|
|
424
|
-
var onUploadFinish = function onUploadFinish(error) {
|
|
425
|
-
if (error) {
|
|
426
|
-
return subject.error(error);
|
|
427
|
-
}
|
|
428
|
-
processingSubscription.add(shouldFetchRemoteFileStatesObservable(mediaType, mimeType, preview).pipe(concatMap(function (shouldFetchRemoteFileStates) {
|
|
429
|
-
if (shouldFetchRemoteFileStates) {
|
|
430
|
-
return _this5.createDownloadFileStream(id, collection, occurrenceKey).pipe(map(function (remoteFileState) {
|
|
431
|
-
return _objectSpread(_objectSpread(_objectSpread({}, stateBase), remoteFileState), overrideMediaTypeIfUnknown(remoteFileState, mediaType));
|
|
432
|
-
}));
|
|
433
|
-
}
|
|
434
|
-
return of(_objectSpread({
|
|
435
|
-
status: 'processing',
|
|
436
|
-
representations: {}
|
|
437
|
-
}, stateBase));
|
|
438
|
-
})).subscribe(subject));
|
|
439
|
-
};
|
|
440
|
-
var _uploadFile2 = uploadFile(file, this.mediaStore, uploadableFileUpfrontIds, {
|
|
441
|
-
onUploadFinish: onUploadFinish,
|
|
442
|
-
onProgress: onProgress
|
|
443
|
-
}, traceContext),
|
|
444
|
-
cancel = _uploadFile2.cancel;
|
|
445
|
-
getFileStreamsCache().set(id, subject);
|
|
446
|
-
|
|
447
|
-
// We should report progress asynchronously, since this is what consumer expects
|
|
448
|
-
// (otherwise in newUploadService file-converting event will be emitted before files-added)
|
|
449
|
-
setTimeout(function () {
|
|
450
|
-
onProgress(0);
|
|
451
|
-
}, 0);
|
|
452
|
-
if (controller) {
|
|
453
|
-
controller.setAbort(function () {
|
|
454
|
-
cancel();
|
|
455
|
-
processingSubscription.unsubscribe();
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
return fromObservable(subject);
|
|
459
|
-
}
|
|
460
|
-
}, {
|
|
461
|
-
key: "upload",
|
|
462
|
-
value: function upload(file, controller, uploadableFileUpfrontIds, traceContext, featureFlags) {
|
|
463
|
-
var shouldAlwaysFetchFileState = getMediaFeatureFlag('fetchFileStateAfterUpload', featureFlags || this.featureFlags);
|
|
464
|
-
if (shouldAlwaysFetchFileState) {
|
|
465
|
-
return this.uploadAwlaysPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
466
|
-
}
|
|
467
|
-
return this.uploadConditionallyPullFileStates(file, controller, uploadableFileUpfrontIds, traceContext);
|
|
468
|
-
}
|
|
469
369
|
|
|
470
370
|
// TODO: ----- ADD TICKET
|
|
471
371
|
}, {
|
|
@@ -20,7 +20,7 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
20
20
|
initialAuth: mediaClientConfig.initialAuth
|
|
21
21
|
}, featureFlags);
|
|
22
22
|
this.config = mediaClientConfig;
|
|
23
|
-
this.file = new FileFetcherImpl(this.mediaStore
|
|
23
|
+
this.file = new FileFetcherImpl(this.mediaStore);
|
|
24
24
|
this.eventEmitter = new EventEmitter2();
|
|
25
25
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
26
26
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
7
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
var _excluded = ["size"];
|
|
9
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
6
|
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; }
|
|
11
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -15,7 +11,6 @@ import { getArtifactUrl } from '../../models/artifacts';
|
|
|
15
11
|
import { request as _request } from '../../utils/request';
|
|
16
12
|
import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
|
|
17
13
|
import { resolveAuth, resolveInitialAuth } from './resolveAuth';
|
|
18
|
-
import parseJwt from '../../utils/parseJwt';
|
|
19
14
|
export { MediaStoreError, isMediaStoreError } from './error';
|
|
20
15
|
var MEDIA_API_REGION = 'media-api-region';
|
|
21
16
|
var MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
@@ -214,17 +209,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
214
209
|
key: "touchFiles",
|
|
215
210
|
value: function () {
|
|
216
211
|
var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(body) {
|
|
217
|
-
var _this2 = this;
|
|
218
212
|
var params,
|
|
219
213
|
traceContext,
|
|
220
214
|
metadata,
|
|
221
|
-
auth,
|
|
222
|
-
maxFileSize,
|
|
223
|
-
decoded,
|
|
224
|
-
_body$descriptors$red,
|
|
225
|
-
_body$descriptors$red2,
|
|
226
|
-
filteredDescriptors,
|
|
227
|
-
rejectedResponse,
|
|
228
215
|
options,
|
|
229
216
|
_args3 = arguments;
|
|
230
217
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -236,59 +223,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
236
223
|
method: 'POST',
|
|
237
224
|
endpoint: '/upload/createWithFiles'
|
|
238
225
|
};
|
|
239
|
-
_context3.next = 5;
|
|
240
|
-
return this.resolveAuth({
|
|
241
|
-
collectionName: params.collection
|
|
242
|
-
});
|
|
243
|
-
case 5:
|
|
244
|
-
auth = _context3.sent;
|
|
245
|
-
try {
|
|
246
|
-
decoded = parseJwt(auth.token);
|
|
247
|
-
maxFileSize = decoded.fileSizeLimit;
|
|
248
|
-
} catch (error) {
|
|
249
|
-
// we're relying on the backend to throw an error when there's an invalid token
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// TODO MEX-2318: backend eventually will allow `size` in the body of this request, then some of this logic will need to be altered
|
|
253
|
-
_body$descriptors$red = body.descriptors.reduce(function (_ref, curr) {
|
|
254
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
255
|
-
filtered = _ref2[0],
|
|
256
|
-
rejected = _ref2[1];
|
|
257
|
-
var size = curr.size,
|
|
258
|
-
descriptor = _objectWithoutProperties(curr, _excluded);
|
|
259
|
-
if (maxFileSize && size && size > maxFileSize) {
|
|
260
|
-
return [filtered, [].concat(_toConsumableArray(rejected), [_this2.getRejectedResponseFromDescriptor(curr, maxFileSize)])];
|
|
261
|
-
}
|
|
262
|
-
return [[].concat(_toConsumableArray(filtered), [descriptor]), rejected];
|
|
263
|
-
}, [[], []]), _body$descriptors$red2 = _slicedToArray(_body$descriptors$red, 2), filteredDescriptors = _body$descriptors$red2[0], rejectedResponse = _body$descriptors$red2[1];
|
|
264
226
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
265
227
|
authContext: {
|
|
266
228
|
collectionName: params.collection
|
|
267
229
|
},
|
|
268
230
|
headers: jsonHeaders,
|
|
269
|
-
body: JSON.stringify(
|
|
270
|
-
|
|
271
|
-
})),
|
|
272
|
-
traceContext: traceContext,
|
|
273
|
-
resolvedAuth: auth
|
|
274
|
-
});
|
|
275
|
-
if (!(filteredDescriptors.length === 0)) {
|
|
276
|
-
_context3.next = 11;
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
return _context3.abrupt("return", {
|
|
280
|
-
data: {
|
|
281
|
-
created: [],
|
|
282
|
-
rejected: rejectedResponse
|
|
283
|
-
}
|
|
231
|
+
body: JSON.stringify(body),
|
|
232
|
+
traceContext: traceContext
|
|
284
233
|
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
// TODO MEX-2318: backend eventually will include `rejected`, then this logic will need to be removed
|
|
288
|
-
res.data.rejected = rejectedResponse;
|
|
289
|
-
return res;
|
|
290
|
-
}));
|
|
291
|
-
case 12:
|
|
234
|
+
return _context3.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)));
|
|
235
|
+
case 5:
|
|
292
236
|
case "end":
|
|
293
237
|
return _context3.stop();
|
|
294
238
|
}
|
|
@@ -321,11 +265,11 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
321
265
|
key: "getFileImageURL",
|
|
322
266
|
value: function () {
|
|
323
267
|
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, params) {
|
|
324
|
-
var
|
|
268
|
+
var _ref, collectionName, auth;
|
|
325
269
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
326
270
|
while (1) switch (_context4.prev = _context4.next) {
|
|
327
271
|
case 0:
|
|
328
|
-
|
|
272
|
+
_ref = params || {}, collectionName = _ref.collection;
|
|
329
273
|
_context4.next = 3;
|
|
330
274
|
return this.resolveAuth({
|
|
331
275
|
collectionName: collectionName
|
|
@@ -611,7 +555,6 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
611
555
|
body,
|
|
612
556
|
clientOptions,
|
|
613
557
|
traceContext,
|
|
614
|
-
resolvedAuth,
|
|
615
558
|
auth,
|
|
616
559
|
extendedTraceContext,
|
|
617
560
|
response,
|
|
@@ -625,25 +568,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
625
568
|
authContext: {}
|
|
626
569
|
};
|
|
627
570
|
controller = _args11.length > 2 ? _args11[2] : undefined;
|
|
628
|
-
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext
|
|
629
|
-
|
|
630
|
-
_context11.next = 7;
|
|
631
|
-
break;
|
|
632
|
-
}
|
|
633
|
-
_context11.t0 = resolvedAuth;
|
|
634
|
-
_context11.next = 10;
|
|
635
|
-
break;
|
|
636
|
-
case 7:
|
|
637
|
-
_context11.next = 9;
|
|
571
|
+
method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
|
|
572
|
+
_context11.next = 5;
|
|
638
573
|
return this.resolveAuth(authContext);
|
|
639
|
-
case
|
|
640
|
-
|
|
641
|
-
case 10:
|
|
642
|
-
auth = _context11.t0;
|
|
574
|
+
case 5:
|
|
575
|
+
auth = _context11.sent;
|
|
643
576
|
extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
|
|
644
577
|
spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
|
|
645
578
|
}) : undefined;
|
|
646
|
-
_context11.next =
|
|
579
|
+
_context11.next = 9;
|
|
647
580
|
return _request("".concat(auth.baseUrl).concat(path), {
|
|
648
581
|
method: method,
|
|
649
582
|
endpoint: endpoint,
|
|
@@ -654,12 +587,12 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
654
587
|
clientOptions: clientOptions,
|
|
655
588
|
traceContext: extendedTraceContext
|
|
656
589
|
}, controller);
|
|
657
|
-
case
|
|
590
|
+
case 9:
|
|
658
591
|
response = _context11.sent;
|
|
659
592
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
660
593
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
661
594
|
return _context11.abrupt("return", response);
|
|
662
|
-
case
|
|
595
|
+
case 13:
|
|
663
596
|
case "end":
|
|
664
597
|
return _context11.stop();
|
|
665
598
|
}
|
package/dist/esm/models/media.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
2
|
-
|
|
3
1
|
// Warning! You can't add new media file processing status!
|
|
4
2
|
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
5
3
|
export var isPreviewableType = function isPreviewableType(type, featureFlags) {
|
|
6
|
-
|
|
7
|
-
var defaultPreviewableTypes = ['audio', 'video', 'image'];
|
|
8
|
-
|
|
9
|
-
// in the new experience, docs are previewable too
|
|
10
|
-
if (getMediaFeatureFlag('newCardExperience', featureFlags)) {
|
|
11
|
-
return [].concat(defaultPreviewableTypes, ['doc']).indexOf(type) > -1;
|
|
12
|
-
}
|
|
4
|
+
var defaultPreviewableTypes = ['audio', 'video', 'image', 'doc'];
|
|
13
5
|
return defaultPreviewableTypes.indexOf(type) > -1;
|
|
14
6
|
};
|
|
15
7
|
export var DATA_UNIT = /*#__PURE__*/function (DATA_UNIT) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { from } from 'rxjs/observable/from';
|
|
4
3
|
import { isMimeTypeSupportedByBrowser, isMimeTypeSupportedByServer } from '@atlaskit/media-common/mediaTypeUtils';
|
|
5
4
|
import { getVideoDimensionsFromBlob } from './getVideoDimensionsFromBlob';
|
|
6
5
|
|
|
@@ -65,7 +64,4 @@ function _shouldFetchRemoteFileStates() {
|
|
|
65
64
|
}, _callee, null, [[8, 17]]);
|
|
66
65
|
}));
|
|
67
66
|
return _shouldFetchRemoteFileStates.apply(this, arguments);
|
|
68
|
-
}
|
|
69
|
-
export function shouldFetchRemoteFileStatesObservable(mediaType, mimeType, preview) {
|
|
70
|
-
return from(shouldFetchRemoteFileStates(mediaType, mimeType, preview));
|
|
71
67
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
-
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile';
|
|
2
|
+
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName';
|
|
3
3
|
export type FileFetcherErrorAttributes = {
|
|
4
4
|
readonly reason: FileFetcherErrorReason;
|
|
5
5
|
readonly id: string;
|
|
@@ -8,7 +8,7 @@ import { MediaFileArtifacts } from '../../models/artifacts';
|
|
|
8
8
|
import { UploadController } from '../../upload-controller';
|
|
9
9
|
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
10
|
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
-
import {
|
|
11
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
12
12
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
13
13
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
14
14
|
export interface CopySourceFile {
|
|
@@ -32,7 +32,7 @@ export interface FileFetcher {
|
|
|
32
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
|
|
35
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): 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>;
|
|
@@ -41,9 +41,8 @@ export interface FileFetcher {
|
|
|
41
41
|
}
|
|
42
42
|
export declare class FileFetcherImpl implements FileFetcher {
|
|
43
43
|
private readonly mediaStore;
|
|
44
|
-
private readonly featureFlags?;
|
|
45
44
|
private readonly dataloader;
|
|
46
|
-
constructor(mediaStore: MediaStore
|
|
45
|
+
constructor(mediaStore: MediaStore);
|
|
47
46
|
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
48
47
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
49
48
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
@@ -53,9 +52,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
53
52
|
private generateUploadableFileUpfrontIds;
|
|
54
53
|
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
55
54
|
private getUploadingFileStateBase;
|
|
56
|
-
|
|
57
|
-
private uploadConditionallyPullFileStates;
|
|
58
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
|
|
55
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
59
56
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
60
57
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
61
58
|
}
|
|
@@ -67,7 +67,6 @@ export type MediaStoreRequestOptions = RequestMetadata & {
|
|
|
67
67
|
readonly body?: any;
|
|
68
68
|
readonly clientOptions?: ClientOptions;
|
|
69
69
|
readonly traceContext?: MediaTraceContext;
|
|
70
|
-
readonly resolvedAuth?: Auth;
|
|
71
70
|
};
|
|
72
71
|
export type MediaStoreCreateFileFromUploadParams = {
|
|
73
72
|
readonly collection?: string;
|
|
@@ -162,7 +161,7 @@ export type RejectionError = {
|
|
|
162
161
|
};
|
|
163
162
|
export type TouchedFiles = {
|
|
164
163
|
created: CreatedTouchedFile[];
|
|
165
|
-
rejected
|
|
164
|
+
rejected?: RejectedTouchFile[];
|
|
166
165
|
};
|
|
167
166
|
export interface EmptyFile {
|
|
168
167
|
readonly id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
1
|
+
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
2
2
|
export interface MediaClientErrorAttributes {
|
|
3
3
|
reason: MediaClientErrorReason;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MediaTraceContext, MediaFeatureFlags, MediaType } from '@atlaskit/media-common';
|
|
2
2
|
import type { MediaFileArtifacts } from './artifacts';
|
|
3
3
|
export type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
|
|
4
4
|
export type { MediaType } from '@atlaskit/media-common';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Observable } from 'rxjs/Observable';
|
|
2
1
|
import { FilePreview } from '../models/file-state';
|
|
3
2
|
import { MediaType } from '../models/media';
|
|
4
3
|
/**
|
|
@@ -13,4 +12,3 @@ import { MediaType } from '../models/media';
|
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
14
|
export declare function shouldFetchRemoteFileStates(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Promise<boolean>;
|
|
16
|
-
export declare function shouldFetchRemoteFileStatesObservable(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Observable<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
-
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile';
|
|
2
|
+
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName';
|
|
3
3
|
export type FileFetcherErrorAttributes = {
|
|
4
4
|
readonly reason: FileFetcherErrorReason;
|
|
5
5
|
readonly id: string;
|
|
@@ -8,7 +8,7 @@ import { MediaFileArtifacts } from '../../models/artifacts';
|
|
|
8
8
|
import { UploadController } from '../../upload-controller';
|
|
9
9
|
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
10
|
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
-
import {
|
|
11
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
12
12
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
13
13
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
14
14
|
export interface CopySourceFile {
|
|
@@ -32,7 +32,7 @@ export interface FileFetcher {
|
|
|
32
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
|
|
35
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): 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>;
|
|
@@ -41,9 +41,8 @@ export interface FileFetcher {
|
|
|
41
41
|
}
|
|
42
42
|
export declare class FileFetcherImpl implements FileFetcher {
|
|
43
43
|
private readonly mediaStore;
|
|
44
|
-
private readonly featureFlags?;
|
|
45
44
|
private readonly dataloader;
|
|
46
|
-
constructor(mediaStore: MediaStore
|
|
45
|
+
constructor(mediaStore: MediaStore);
|
|
47
46
|
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
48
47
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
49
48
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
@@ -53,9 +52,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
53
52
|
private generateUploadableFileUpfrontIds;
|
|
54
53
|
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
55
54
|
private getUploadingFileStateBase;
|
|
56
|
-
|
|
57
|
-
private uploadConditionallyPullFileStates;
|
|
58
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
|
|
55
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
59
56
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
60
57
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
61
58
|
}
|
|
@@ -67,7 +67,6 @@ export type MediaStoreRequestOptions = RequestMetadata & {
|
|
|
67
67
|
readonly body?: any;
|
|
68
68
|
readonly clientOptions?: ClientOptions;
|
|
69
69
|
readonly traceContext?: MediaTraceContext;
|
|
70
|
-
readonly resolvedAuth?: Auth;
|
|
71
70
|
};
|
|
72
71
|
export type MediaStoreCreateFileFromUploadParams = {
|
|
73
72
|
readonly collection?: string;
|
|
@@ -162,7 +161,7 @@ export type RejectionError = {
|
|
|
162
161
|
};
|
|
163
162
|
export type TouchedFiles = {
|
|
164
163
|
created: CreatedTouchedFile[];
|
|
165
|
-
rejected
|
|
164
|
+
rejected?: RejectedTouchFile[];
|
|
166
165
|
};
|
|
167
166
|
export interface EmptyFile {
|
|
168
167
|
readonly id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
1
|
+
export type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit' | 'deprecatedEndpoint';
|
|
2
2
|
export interface MediaClientErrorAttributes {
|
|
3
3
|
reason: MediaClientErrorReason;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MediaTraceContext, MediaFeatureFlags, MediaType } from '@atlaskit/media-common';
|
|
2
2
|
import type { MediaFileArtifacts } from './artifacts';
|
|
3
3
|
export type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
|
|
4
4
|
export type { MediaType } from '@atlaskit/media-common';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Observable } from 'rxjs/Observable';
|
|
2
1
|
import { FilePreview } from '../models/file-state';
|
|
3
2
|
import { MediaType } from '../models/media';
|
|
4
3
|
/**
|
|
@@ -13,4 +12,3 @@ import { MediaType } from '../models/media';
|
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
14
|
export declare function shouldFetchRemoteFileStates(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Promise<boolean>;
|
|
16
|
-
export declare function shouldFetchRemoteFileStatesObservable(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Observable<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.4",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/chunkinator": "^4.2.0",
|
|
39
|
-
"@atlaskit/media-common": "^
|
|
39
|
+
"@atlaskit/media-common": "^5.0.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"dataloader": "^2.0.0",
|
|
42
42
|
"deep-equal": "^1.0.1",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@atlaskit/button": "^16.7.0",
|
|
59
59
|
"@atlaskit/docs": "*",
|
|
60
|
-
"@atlaskit/media-card": "^
|
|
60
|
+
"@atlaskit/media-card": "^76.0.0",
|
|
61
61
|
"@atlaskit/media-core": "^34.1.0",
|
|
62
62
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
63
63
|
"@atlaskit/ssr": "*",
|
|
64
|
-
"@atlaskit/tokens": "^1.
|
|
64
|
+
"@atlaskit/tokens": "^1.5.0",
|
|
65
65
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
66
66
|
"@emotion/react": "^11.7.1",
|
|
67
67
|
"@types/deep-equal": "^1.0.1",
|