@atlaskit/media-client 22.0.1 → 22.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/client/file-fetcher/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/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/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/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/utils/shouldFetchRemoteFileStates.d.ts +0 -2
- package/dist/types-ts4.5/client/__mocks__/collection-fetcher.d.ts +8 -0
- package/dist/types-ts4.5/client/__mocks__/file-fetcher.d.ts +10 -0
- package/dist/types-ts4.5/client/__mocks__/media-client.d.ts +11 -0
- package/dist/types-ts4.5/client/events.d.ts +14 -0
- package/dist/types-ts4.5/client/file-fetcher/error.d.ts +29 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +58 -0
- package/dist/types-ts4.5/client/media-client.d.ts +27 -0
- package/dist/types-ts4.5/client/media-store/error.d.ts +16 -0
- package/dist/types-ts4.5/client/media-store/index.d.ts +169 -0
- package/dist/types-ts4.5/client/media-store/resolveAuth.d.ts +4 -0
- package/dist/types-ts4.5/client/mobile-upload.d.ts +11 -0
- package/dist/types-ts4.5/client/stargate-client.d.ts +15 -0
- package/dist/types-ts4.5/constants.d.ts +6 -0
- package/dist/types-ts4.5/file-streams-cache.d.ts +15 -0
- package/dist/types-ts4.5/globalMediaEventEmitter.d.ts +6 -0
- package/dist/types-ts4.5/identifier.d.ts +15 -0
- package/dist/types-ts4.5/index.d.ts +87 -0
- package/dist/types-ts4.5/models/artifacts.d.ts +12 -0
- package/dist/types-ts4.5/models/auth-headers.d.ts +11 -0
- package/dist/types-ts4.5/models/auth-query-parameters.d.ts +11 -0
- package/dist/types-ts4.5/models/errors/helpers.d.ts +6 -0
- package/dist/types-ts4.5/models/errors/index.d.ts +11 -0
- package/dist/types-ts4.5/models/errors/types.d.ts +15 -0
- package/dist/types-ts4.5/models/file-state.d.ts +94 -0
- package/dist/types-ts4.5/models/item.d.ts +25 -0
- package/dist/types-ts4.5/models/media.d.ts +48 -0
- package/dist/types-ts4.5/models/mobile-upload.d.ts +28 -0
- package/dist/types-ts4.5/upload-controller.d.ts +7 -0
- package/dist/types-ts4.5/uploader/calculateChunkSize.d.ts +11 -0
- package/dist/types-ts4.5/uploader/error.d.ts +29 -0
- package/dist/types-ts4.5/uploader/index.d.ts +22 -0
- package/dist/types-ts4.5/utils/checkWebpSupport.d.ts +1 -0
- package/dist/types-ts4.5/utils/convertBase64ToBlob.d.ts +1 -0
- package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +30 -0
- package/dist/types-ts4.5/utils/createMediaSubject.d.ts +3 -0
- package/dist/types-ts4.5/utils/detectEmptyFile.d.ts +16 -0
- package/dist/types-ts4.5/utils/getDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.5/utils/getImageDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.5/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
- package/dist/types-ts4.5/utils/getVideoDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.5/utils/hashing/hasher.d.ts +3 -0
- package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +3 -0
- package/dist/types-ts4.5/utils/hashing/simpleHasher.d.ts +4 -0
- package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +16 -0
- package/dist/types-ts4.5/utils/imageResizeModeToFileImageMode.d.ts +3 -0
- package/dist/types-ts4.5/utils/isImageRemote.d.ts +1 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +5 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/index.d.ts +3 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +10 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +17 -0
- package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +29 -0
- package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +8 -0
- package/dist/types-ts4.5/utils/mobileUpload/index.d.ts +5 -0
- package/dist/types-ts4.5/utils/mobileUpload/servicesCache.d.ts +4 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +7 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +69 -0
- package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
- package/dist/types-ts4.5/utils/polling/errors.d.ts +12 -0
- package/dist/types-ts4.5/utils/polling/index.d.ts +33 -0
- package/dist/types-ts4.5/utils/polling/types.d.ts +7 -0
- package/dist/types-ts4.5/utils/request/errors.d.ts +20 -0
- package/dist/types-ts4.5/utils/request/helpers.d.ts +46 -0
- package/dist/types-ts4.5/utils/request/index.d.ts +5 -0
- package/dist/types-ts4.5/utils/request/types.d.ts +46 -0
- package/dist/types-ts4.5/utils/safeUnsubscribe.d.ts +2 -0
- package/dist/types-ts4.5/utils/setTimeoutPromise.d.ts +2 -0
- package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +14 -0
- package/dist/types-ts4.5/utils/url.d.ts +17 -0
- package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +16 -0
- package/package.json +4 -4
- package/report.api.md +11 -15
- 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
|
@@ -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
|
}
|
|
@@ -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,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>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare class FileFetcher {
|
|
3
|
+
constructor();
|
|
4
|
+
getFileState: jest.Mock<any, any>;
|
|
5
|
+
getCurrentState: jest.Mock<any, any>;
|
|
6
|
+
getArtifactURL: jest.Mock<any, any>;
|
|
7
|
+
touchFiles: jest.Mock<any, any>;
|
|
8
|
+
upload: jest.Mock<any, any>;
|
|
9
|
+
downloadBinary: jest.Mock<any, any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
+
import { FileFetcher } from '../file-fetcher';
|
|
4
|
+
export declare class MediaClient {
|
|
5
|
+
readonly config: MediaClientConfig;
|
|
6
|
+
readonly file: FileFetcher;
|
|
7
|
+
constructor(config: MediaClientConfig);
|
|
8
|
+
getImage: jest.Mock<any, any>;
|
|
9
|
+
getImageUrl: jest.Mock<any, any>;
|
|
10
|
+
getImageMetadata: jest.Mock<any, any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FileState } from '../models/file-state';
|
|
2
|
+
export type EventPayloadMap<P> = {
|
|
3
|
+
readonly [event: string]: P;
|
|
4
|
+
};
|
|
5
|
+
export type EventPayloadListener<M extends EventPayloadMap<P>, E extends keyof M, P = any> = (payload: M[E]) => void;
|
|
6
|
+
export interface MediaViewedEventPayload {
|
|
7
|
+
fileId: string;
|
|
8
|
+
viewingLevel: 'minimal' | 'full' | 'download';
|
|
9
|
+
isUserCollection?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type UploadEventPayloadMap = {
|
|
12
|
+
'file-added': FileState;
|
|
13
|
+
'media-viewed': MediaViewedEventPayload;
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName';
|
|
3
|
+
export type FileFetcherErrorAttributes = {
|
|
4
|
+
readonly reason: FileFetcherErrorReason;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly metadata?: {
|
|
7
|
+
readonly collectionName?: string;
|
|
8
|
+
readonly occurrenceKey?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare class FileFetcherError extends BaseMediaClientError<FileFetcherErrorAttributes> {
|
|
12
|
+
readonly reason: FileFetcherErrorReason;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly metadata?: {
|
|
15
|
+
readonly collectionName?: string | undefined;
|
|
16
|
+
readonly occurrenceKey?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
constructor(reason: FileFetcherErrorReason, id: string, metadata?: {
|
|
19
|
+
readonly collectionName?: string | undefined;
|
|
20
|
+
readonly occurrenceKey?: string | undefined;
|
|
21
|
+
} | undefined);
|
|
22
|
+
get attributes(): {
|
|
23
|
+
reason: FileFetcherErrorReason;
|
|
24
|
+
id: string;
|
|
25
|
+
collectionName: string | undefined;
|
|
26
|
+
occurrenceKey: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function isFileFetcherError(err: Error): err is FileFetcherError;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import 'setimmediate';
|
|
2
|
+
import { AuthProvider } from '@atlaskit/media-core';
|
|
3
|
+
import { MediaStore, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
|
|
4
|
+
import { FilePreview, FileState, GetFileOptions } from '../../models/file-state';
|
|
5
|
+
import { MediaFile } from '../../models/media';
|
|
6
|
+
import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
|
|
7
|
+
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
8
|
+
import { UploadController } from '../../upload-controller';
|
|
9
|
+
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
|
+
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
12
|
+
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
13
|
+
export { isFileFetcherError, FileFetcherError } from './error';
|
|
14
|
+
export interface CopySourceFile {
|
|
15
|
+
id: string;
|
|
16
|
+
collection?: string;
|
|
17
|
+
authProvider: AuthProvider;
|
|
18
|
+
}
|
|
19
|
+
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
20
|
+
authProvider: AuthProvider;
|
|
21
|
+
mediaStore?: MediaStore;
|
|
22
|
+
}
|
|
23
|
+
export interface CopyFileOptions {
|
|
24
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
25
|
+
mimeType?: string;
|
|
26
|
+
}
|
|
27
|
+
export type ExternalUploadPayload = {
|
|
28
|
+
uploadableFileUpfrontIds: UploadableFileUpfrontIds;
|
|
29
|
+
dimensions: Dimensions;
|
|
30
|
+
};
|
|
31
|
+
export interface FileFetcher {
|
|
32
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
33
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
34
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
35
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
36
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
37
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
38
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
39
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
40
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
41
|
+
}
|
|
42
|
+
export declare class FileFetcherImpl implements FileFetcher {
|
|
43
|
+
private readonly mediaStore;
|
|
44
|
+
private readonly dataloader;
|
|
45
|
+
constructor(mediaStore: MediaStore);
|
|
46
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
47
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
48
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
49
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
50
|
+
private createDownloadFileStream;
|
|
51
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
52
|
+
private generateUploadableFileUpfrontIds;
|
|
53
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
54
|
+
private getUploadingFileStateBase;
|
|
55
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
56
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
57
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
2
|
+
import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
+
import { MediaStore, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
|
|
4
|
+
import { FileFetcher } from './file-fetcher';
|
|
5
|
+
import { UploadEventPayloadMap, EventPayloadListener } from './events';
|
|
6
|
+
import { StargateClient } from './stargate-client';
|
|
7
|
+
import { MobileUpload } from '../models/mobile-upload';
|
|
8
|
+
export declare class MediaClient {
|
|
9
|
+
readonly mediaClientConfig: MediaClientConfig;
|
|
10
|
+
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
11
|
+
readonly mediaStore: MediaStore;
|
|
12
|
+
readonly file: FileFetcher;
|
|
13
|
+
readonly stargate: StargateClient;
|
|
14
|
+
private readonly eventEmitter;
|
|
15
|
+
private mobileUpload?;
|
|
16
|
+
readonly config: MediaClientConfig;
|
|
17
|
+
constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
18
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
19
|
+
getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
20
|
+
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
21
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|
|
22
|
+
mobileUploadPromise(): Promise<MobileUpload>;
|
|
23
|
+
removeFileFromCollection(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
24
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
25
|
+
off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
26
|
+
emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export type MediaStoreErrorReason = 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut';
|
|
3
|
+
export type MediaStoreErrorAttributes = {
|
|
4
|
+
readonly reason: MediaStoreErrorReason;
|
|
5
|
+
readonly innerError?: Error;
|
|
6
|
+
};
|
|
7
|
+
export declare class MediaStoreError extends BaseMediaClientError<MediaStoreErrorAttributes> {
|
|
8
|
+
readonly reason: MediaStoreErrorReason;
|
|
9
|
+
readonly innerError?: Error | undefined;
|
|
10
|
+
constructor(reason: MediaStoreErrorReason, innerError?: Error | undefined);
|
|
11
|
+
get attributes(): {
|
|
12
|
+
reason: MediaStoreErrorReason;
|
|
13
|
+
innerError: Error | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function isMediaStoreError(err: Error): err is MediaStoreError;
|