@atlaskit/media-client 17.1.1 → 17.1.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 +13 -0
- package/constants/package.json +8 -1
- package/dist/cjs/client/media-store/resolveAuth.js +1 -1
- package/dist/cjs/utils/request/helpers.js +4 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/media-store/resolveAuth.js +1 -1
- package/dist/es2019/utils/request/helpers.js +4 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/media-store/resolveAuth.js +1 -1
- package/dist/esm/utils/request/helpers.js +4 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +8 -0
- package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +10 -0
- package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +13 -0
- package/dist/types-ts4.0/client/collection-fetcher.d.ts +35 -0
- package/dist/types-ts4.0/client/events.d.ts +14 -0
- package/dist/types-ts4.0/client/file-fetcher/error.d.ts +29 -0
- package/dist/types-ts4.0/client/file-fetcher/index.d.ts +56 -0
- package/dist/types-ts4.0/client/media-client.d.ts +28 -0
- package/dist/types-ts4.0/client/media-store/error.d.ts +16 -0
- package/dist/types-ts4.0/client/media-store/index.d.ts +167 -0
- package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +4 -0
- package/dist/types-ts4.0/client/mobile-upload.d.ts +11 -0
- package/dist/types-ts4.0/client/stargate-client.d.ts +15 -0
- package/dist/types-ts4.0/constants.d.ts +6 -0
- package/dist/types-ts4.0/file-streams-cache.d.ts +15 -0
- package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +6 -0
- package/dist/types-ts4.0/identifier.d.ts +15 -0
- package/dist/types-ts4.0/index.d.ts +90 -0
- package/dist/types-ts4.0/models/artifacts.d.ts +12 -0
- package/dist/types-ts4.0/models/auth-headers.d.ts +11 -0
- package/dist/types-ts4.0/models/auth-query-parameters.d.ts +11 -0
- package/dist/types-ts4.0/models/errors/helpers.d.ts +6 -0
- package/dist/types-ts4.0/models/errors/index.d.ts +11 -0
- package/dist/types-ts4.0/models/errors/types.d.ts +15 -0
- package/dist/types-ts4.0/models/file-state.d.ts +91 -0
- package/dist/types-ts4.0/models/item.d.ts +25 -0
- package/dist/types-ts4.0/models/media-subscribable.d.ts +3 -0
- package/dist/types-ts4.0/models/media.d.ts +66 -0
- package/dist/types-ts4.0/models/mobile-upload.d.ts +28 -0
- package/dist/types-ts4.0/upload-controller.d.ts +7 -0
- package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +11 -0
- package/dist/types-ts4.0/uploader/error.d.ts +29 -0
- package/dist/types-ts4.0/uploader/index.d.ts +21 -0
- package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +1 -0
- package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +1 -0
- package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +30 -0
- package/dist/types-ts4.0/utils/createMediaSubject.d.ts +3 -0
- package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +16 -0
- package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
- package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.0/utils/hashing/hasher.d.ts +3 -0
- package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +3 -0
- package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +4 -0
- package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +16 -0
- package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +3 -0
- package/dist/types-ts4.0/utils/isImageRemote.d.ts +1 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +5 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +3 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +10 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +16 -0
- package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +29 -0
- package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +8 -0
- package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +5 -0
- package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +4 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +7 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +69 -0
- package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
- package/dist/types-ts4.0/utils/polling/errors.d.ts +12 -0
- package/dist/types-ts4.0/utils/polling/index.d.ts +33 -0
- package/dist/types-ts4.0/utils/polling/types.d.ts +7 -0
- package/dist/types-ts4.0/utils/request/errors.d.ts +20 -0
- package/dist/types-ts4.0/utils/request/helpers.d.ts +38 -0
- package/dist/types-ts4.0/utils/request/index.d.ts +5 -0
- package/dist/types-ts4.0/utils/request/types.d.ts +43 -0
- package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +2 -0
- package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +2 -0
- package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +16 -0
- package/dist/types-ts4.0/utils/url.d.ts +17 -0
- package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +16 -0
- package/package.json +10 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UploadEventPayloadMap, EventPayloadListener } from './client/events';
|
|
2
|
+
export declare const globalMediaEventEmitter: {
|
|
3
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E, any>): void;
|
|
4
|
+
off<E_1 extends keyof UploadEventPayloadMap>(event: E_1, listener: EventPayloadListener<UploadEventPayloadMap, E_1, any>): void;
|
|
5
|
+
emit<E_2 extends keyof UploadEventPayloadMap>(event: E_2, payload: UploadEventPayloadMap[E_2]): boolean | undefined;
|
|
6
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type Identifier = FileIdentifier | ExternalImageIdentifier;
|
|
2
|
+
export interface FileIdentifier {
|
|
3
|
+
readonly mediaItemType: 'file';
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly occurrenceKey?: string;
|
|
6
|
+
readonly collectionName?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ExternalImageIdentifier {
|
|
9
|
+
readonly mediaItemType: 'external-image';
|
|
10
|
+
readonly dataURI: string;
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const isFileIdentifier: (identifier: Identifier) => identifier is FileIdentifier;
|
|
14
|
+
export declare const isExternalImageIdentifier: (identifier: Identifier) => identifier is ExternalImageIdentifier;
|
|
15
|
+
export declare const isDifferentIdentifier: (a: Identifier, b: Identifier) => boolean;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export { MediaStore, MediaStoreError, isMediaStoreError, getMediaEnvironment, getMediaRegion, } from './client/media-store';
|
|
2
|
+
export type { ResponseFileItem, ItemsPayload, ImageMetadataArtifact, ImageMetadata, MediaStoreResponse, MediaStoreRequestOptions, MediaStoreCreateFileFromUploadParams, MediaStoreCreateFileParams, MediaStoreTouchFileParams, TouchFileDescriptor, MediaStoreTouchFileBody, MediaStoreCreateFileFromBinaryParams, MediaStoreCreateFileFromUploadConditions, MediaStoreCreateFileFromUploadBody, MediaStoreGetFileParams, MediaStoreGetFileImageParams, MediaStoreGetCollectionItemsParams, SourceFile, MediaStoreCopyFileWithTokenBody, MediaStoreCopyFileWithTokenParams, AppendChunksToUploadRequestBody, CreatedTouchedFile, TouchedFiles, EmptyFile, MediaStoreErrorReason, MediaStoreErrorAttributes, } from './client/media-store';
|
|
3
|
+
export { UploadController } from './upload-controller';
|
|
4
|
+
export type { AbortFunction } from './upload-controller';
|
|
5
|
+
export type { MediaItemType, FileItem, FileProcessingStatus, MediaArtifact, Artifacts, FileDetails, } from './models/item';
|
|
6
|
+
export { isPreviewableType, isMediaCollectionItemFullDetails, } from './models/media';
|
|
7
|
+
export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaCollection, MediaCollectionItems, MediaCollectionItem, MediaCollectionItemMinimalDetails, MediaCollectionItemFullDetails, MediaRepresentations, MediaCollectionItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
|
|
8
|
+
export type { MediaSubscribableItem } from './models/media-subscribable';
|
|
9
|
+
export { getArtifactUrl } from './models/artifacts';
|
|
10
|
+
export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
|
|
11
|
+
export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
12
|
+
export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
|
|
13
|
+
export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
|
|
14
|
+
export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
|
|
15
|
+
export type { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
|
|
16
|
+
export { StreamsCache } from './file-streams-cache';
|
|
17
|
+
export { uploadFile } from './uploader';
|
|
18
|
+
export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
|
|
19
|
+
export { request, RequestError, isRequestError, isRateLimitedError, } from './utils/request';
|
|
20
|
+
export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './utils/request';
|
|
21
|
+
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, } from './utils/request/helpers';
|
|
22
|
+
export { PollingFunction } from './utils/polling';
|
|
23
|
+
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
24
|
+
export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
|
|
25
|
+
export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
|
|
26
|
+
export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
|
|
27
|
+
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
28
|
+
export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
|
|
29
|
+
export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
|
|
30
|
+
export { CollectionFetcher } from './client/collection-fetcher';
|
|
31
|
+
export { MediaClient } from './client/media-client';
|
|
32
|
+
export { StargateClient } from './client/stargate-client';
|
|
33
|
+
export type { EdgeData } from './client/stargate-client';
|
|
34
|
+
export { isImageRemote } from './utils/isImageRemote';
|
|
35
|
+
export { checkWebpSupport } from './utils/checkWebpSupport';
|
|
36
|
+
export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
|
|
37
|
+
export type { Dimensions } from './utils/getDimensionsFromBlob';
|
|
38
|
+
export { createMediaSubject } from './utils/createMediaSubject';
|
|
39
|
+
export { safeUnsubscribe } from './utils/safeUnsubscribe';
|
|
40
|
+
export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } from './identifier';
|
|
41
|
+
export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
|
|
42
|
+
export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
|
|
43
|
+
export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
|
|
44
|
+
export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
|
|
45
|
+
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
46
|
+
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
|
|
47
|
+
export type { MediaBlobUrlAttrs } from './utils/url';
|
|
48
|
+
export { createMediaSubscribable } from './utils/mediaSubscribable';
|
|
49
|
+
export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
|
|
50
|
+
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
53
|
+
*/
|
|
54
|
+
export declare const getMediaTypeFromMimeType: (mimeType: string) => import("@atlaskit/media-common").MediaType;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
57
|
+
*/
|
|
58
|
+
export declare const isImageMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
61
|
+
*/
|
|
62
|
+
export declare const isDocumentMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
65
|
+
*/
|
|
66
|
+
export declare const isMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
69
|
+
*/
|
|
70
|
+
export declare const isImageMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
73
|
+
*/
|
|
74
|
+
export declare const isDocumentMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
77
|
+
*/
|
|
78
|
+
export declare const isAudioMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
81
|
+
*/
|
|
82
|
+
export declare const isVideoMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
85
|
+
*/
|
|
86
|
+
export declare const isUnknownMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
89
|
+
*/
|
|
90
|
+
export declare const isMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MediaFileProcessingStatus } from './media';
|
|
2
|
+
export declare type MediaFileArtifact = {
|
|
3
|
+
readonly url: string;
|
|
4
|
+
readonly processingStatus: MediaFileProcessingStatus;
|
|
5
|
+
};
|
|
6
|
+
export interface MediaFileArtifacts {
|
|
7
|
+
'video_1280.mp4'?: MediaFileArtifact;
|
|
8
|
+
'video_640.mp4'?: MediaFileArtifact;
|
|
9
|
+
'document.pdf'?: MediaFileArtifact;
|
|
10
|
+
'audio.mp3'?: MediaFileArtifact;
|
|
11
|
+
}
|
|
12
|
+
export declare const getArtifactUrl: (artifacts: MediaFileArtifacts, prop: keyof MediaFileArtifacts) => string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Auth } from '@atlaskit/media-core';
|
|
2
|
+
export interface ClientBasedAuthHeaders {
|
|
3
|
+
readonly 'X-Client-Id': string;
|
|
4
|
+
readonly Authorization: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AsapBasedAuthHeaders {
|
|
7
|
+
readonly 'X-Issuer': string;
|
|
8
|
+
readonly Authorization: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type AuthHeaders = ClientBasedAuthHeaders | AsapBasedAuthHeaders;
|
|
11
|
+
export declare function mapAuthToAuthHeaders(auth: Auth): AuthHeaders;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Auth } from '@atlaskit/media-core';
|
|
2
|
+
export interface ClientBasedQueryParameters {
|
|
3
|
+
readonly client: string;
|
|
4
|
+
readonly token: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AsapBasedQueryParameters {
|
|
7
|
+
readonly issuer: string;
|
|
8
|
+
readonly token: string;
|
|
9
|
+
}
|
|
10
|
+
export declare type AuthQueryParameters = ClientBasedQueryParameters | AsapBasedQueryParameters;
|
|
11
|
+
export declare function mapAuthToQueryParameters(auth: Auth): AuthQueryParameters;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { MediaClientError, MediaClientErrorReason } from './types';
|
|
2
|
+
import { MediaClientError, MediaClientErrorReason } from './types';
|
|
3
|
+
export declare function isMediaClientError(error: any): error is MediaClientError<{
|
|
4
|
+
reason: MediaClientErrorReason;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function getMediaClientErrorReason(err: Error): MediaClientErrorReason | 'unknown';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MediaClientError, MediaClientErrorAttributes } from './types';
|
|
2
|
+
export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './types';
|
|
3
|
+
export { isMediaClientError, getMediaClientErrorReason } from './helpers';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for media errors
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseMediaClientError<Attributes extends MediaClientErrorAttributes> extends Error implements MediaClientError<Attributes> {
|
|
8
|
+
readonly message: string;
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
abstract get attributes(): Attributes;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type MediaClientErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError' | 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut' | 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'pollingMaxAttemptsExceeded' | 'fileSizeExceedsLimit';
|
|
2
|
+
export interface MediaClientErrorAttributes {
|
|
3
|
+
reason: MediaClientErrorReason;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* MediaClientError is the main interface which all the errors
|
|
7
|
+
* in Media Client must implement.
|
|
8
|
+
* MediaClientErrorReason is a dictionary that restricts all the possible
|
|
9
|
+
* reasons that the erros can define. Its values are private to this file.
|
|
10
|
+
* Any new error has to define its own Error Reasons locally, and also declare them
|
|
11
|
+
* here to comply with the interface restrictions
|
|
12
|
+
*/
|
|
13
|
+
export interface MediaClientError<Attributes extends MediaClientErrorAttributes> extends Error {
|
|
14
|
+
readonly attributes: Attributes;
|
|
15
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { FileStatus as CommonFileStatus } from '@atlaskit/media-common';
|
|
2
|
+
import { MediaStoreResponse } from '../client/media-store';
|
|
3
|
+
import { MediaFileArtifacts } from './artifacts';
|
|
4
|
+
import { MediaCollectionItemFullDetails, MediaFile, MediaRepresentations, MediaType } from './media';
|
|
5
|
+
export declare type FileStatus = CommonFileStatus;
|
|
6
|
+
export interface FilePreview {
|
|
7
|
+
value: Blob | string;
|
|
8
|
+
origin?: 'local' | 'remote';
|
|
9
|
+
originalDimensions?: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface PreviewOptions {
|
|
15
|
+
}
|
|
16
|
+
export interface GetFileOptions {
|
|
17
|
+
preview?: PreviewOptions;
|
|
18
|
+
collectionName?: string;
|
|
19
|
+
occurrenceKey?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UploadingFileState {
|
|
22
|
+
status: 'uploading';
|
|
23
|
+
id: string;
|
|
24
|
+
occurrenceKey?: string;
|
|
25
|
+
name: string;
|
|
26
|
+
size: number;
|
|
27
|
+
progress: number;
|
|
28
|
+
mediaType: MediaType;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
31
|
+
createdAt?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface PreviewableFileState {
|
|
34
|
+
preview: FilePreview | Promise<FilePreview>;
|
|
35
|
+
}
|
|
36
|
+
export interface ProcessingFileState {
|
|
37
|
+
status: 'processing';
|
|
38
|
+
id: string;
|
|
39
|
+
occurrenceKey?: string;
|
|
40
|
+
name: string;
|
|
41
|
+
size: number;
|
|
42
|
+
artifacts?: MediaFileArtifacts;
|
|
43
|
+
mediaType: MediaType;
|
|
44
|
+
mimeType: string;
|
|
45
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
46
|
+
representations?: MediaRepresentations;
|
|
47
|
+
createdAt?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ProcessedFileState {
|
|
50
|
+
status: 'processed';
|
|
51
|
+
id: string;
|
|
52
|
+
occurrenceKey?: string;
|
|
53
|
+
name: string;
|
|
54
|
+
size: number;
|
|
55
|
+
artifacts: MediaFileArtifacts;
|
|
56
|
+
mediaType: MediaType;
|
|
57
|
+
mimeType: string;
|
|
58
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
59
|
+
representations?: MediaRepresentations;
|
|
60
|
+
createdAt?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ProcessingFailedState {
|
|
63
|
+
status: 'failed-processing';
|
|
64
|
+
id: string;
|
|
65
|
+
occurrenceKey?: string;
|
|
66
|
+
name: string;
|
|
67
|
+
size: number;
|
|
68
|
+
artifacts: Object;
|
|
69
|
+
mediaType: MediaType;
|
|
70
|
+
mimeType: string;
|
|
71
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
72
|
+
representations?: MediaRepresentations;
|
|
73
|
+
createdAt?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface ErrorFileState {
|
|
76
|
+
status: 'error';
|
|
77
|
+
id: string;
|
|
78
|
+
occurrenceKey?: string;
|
|
79
|
+
message?: string;
|
|
80
|
+
}
|
|
81
|
+
export declare type FileState = UploadingFileState | ProcessingFileState | ProcessedFileState | ErrorFileState | ProcessingFailedState;
|
|
82
|
+
export declare type NonErrorFileState = Exclude<FileState, ErrorFileState>;
|
|
83
|
+
export declare const isUploadingFileState: (fileState: FileState) => fileState is UploadingFileState;
|
|
84
|
+
export declare const isProcessingFileState: (fileState: FileState) => fileState is ProcessingFileState;
|
|
85
|
+
export declare const isProcessedFileState: (fileState: FileState) => fileState is ProcessedFileState;
|
|
86
|
+
export declare const isErrorFileState: (fileState: FileState) => fileState is ErrorFileState;
|
|
87
|
+
export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState | ProcessingFileState | ProcessedFileState | ProcessingFailedState) & PreviewableFileState;
|
|
88
|
+
export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
|
|
89
|
+
export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
|
|
90
|
+
export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
|
|
91
|
+
export declare const mapMediaItemToFileState: (id: string, item: MediaCollectionItemFullDetails) => FileState;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MediaType } from './media';
|
|
2
|
+
export declare type MediaItemType = 'file' | 'external-image';
|
|
3
|
+
export interface FileItem {
|
|
4
|
+
type: 'file';
|
|
5
|
+
details: FileDetails;
|
|
6
|
+
}
|
|
7
|
+
export declare type FileProcessingStatus = 'pending' | 'running' | 'succeeded' | 'failed';
|
|
8
|
+
export interface MediaArtifact {
|
|
9
|
+
processingStatus?: FileProcessingStatus;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare type Artifacts = {
|
|
13
|
+
[name: string]: MediaArtifact;
|
|
14
|
+
};
|
|
15
|
+
export interface FileDetails {
|
|
16
|
+
id: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
size?: number;
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
mediaType?: MediaType;
|
|
21
|
+
creationDate?: number;
|
|
22
|
+
processingStatus?: FileProcessingStatus;
|
|
23
|
+
artifacts?: Artifacts;
|
|
24
|
+
createdAt?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MediaFeatureFlags, MediaType } from '@atlaskit/media-common';
|
|
2
|
+
import type { MediaFileArtifacts } from './artifacts';
|
|
3
|
+
export declare type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
|
|
4
|
+
export type { MediaType } from '@atlaskit/media-common';
|
|
5
|
+
export declare const isPreviewableType: (type: MediaType, featureFlags?: MediaFeatureFlags | undefined) => boolean;
|
|
6
|
+
export declare type MediaFile = {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly mediaType: MediaType;
|
|
9
|
+
readonly mimeType: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly processingStatus?: MediaFileProcessingStatus;
|
|
12
|
+
readonly size: number;
|
|
13
|
+
readonly artifacts: MediaFileArtifacts;
|
|
14
|
+
readonly representations: MediaRepresentations;
|
|
15
|
+
readonly createdAt?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare type MediaCollection = {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly createdAt: number;
|
|
20
|
+
};
|
|
21
|
+
export declare type MediaCollectionItems = {
|
|
22
|
+
readonly contents: MediaCollectionItem[];
|
|
23
|
+
readonly nextInclusiveStartKey?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type MediaCollectionItem = {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly insertedAt: number;
|
|
28
|
+
readonly occurrenceKey: string;
|
|
29
|
+
readonly details: MediaCollectionItemDetails;
|
|
30
|
+
};
|
|
31
|
+
export declare type MediaCollectionItemMinimalDetails = {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly size: number;
|
|
34
|
+
};
|
|
35
|
+
export declare type MediaCollectionItemFullDetails = {
|
|
36
|
+
readonly mediaType: MediaType;
|
|
37
|
+
readonly mimeType: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly processingStatus: MediaFileProcessingStatus;
|
|
40
|
+
readonly size: number;
|
|
41
|
+
readonly artifacts: MediaFileArtifacts;
|
|
42
|
+
readonly representations: MediaRepresentations;
|
|
43
|
+
readonly createdAt?: number;
|
|
44
|
+
};
|
|
45
|
+
export declare type MediaRepresentations = {
|
|
46
|
+
image?: Object;
|
|
47
|
+
};
|
|
48
|
+
export declare type MediaCollectionItemDetails = MediaCollectionItemMinimalDetails | MediaCollectionItemFullDetails;
|
|
49
|
+
export declare const isMediaCollectionItemFullDetails: (mediaCollectionItem: MediaCollectionItemDetails) => mediaCollectionItem is MediaCollectionItemFullDetails;
|
|
50
|
+
export declare type MediaUpload = {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly created: number;
|
|
53
|
+
readonly expires: number;
|
|
54
|
+
};
|
|
55
|
+
export declare type MediaChunksProbe = {
|
|
56
|
+
readonly results: {
|
|
57
|
+
readonly [etag: string]: {
|
|
58
|
+
readonly exists: boolean;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare enum DATA_UNIT {
|
|
63
|
+
MB = 1048576,
|
|
64
|
+
GB = 1073741824,
|
|
65
|
+
TB = 1099511627776
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FilePreview } from './file-state';
|
|
2
|
+
export declare type MobileUploadStartEvent = {
|
|
3
|
+
fileId: string;
|
|
4
|
+
collectionName?: string;
|
|
5
|
+
occurrenceKey?: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
fileSize: number;
|
|
8
|
+
fileMimetype: string;
|
|
9
|
+
preview?: FilePreview;
|
|
10
|
+
createdAt?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare type MobileUploadProgressEvent = {
|
|
13
|
+
fileId: string;
|
|
14
|
+
progress: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type MobileUploadEndEvent = {
|
|
17
|
+
fileId: string;
|
|
18
|
+
};
|
|
19
|
+
export declare type MobileUploadErrorEvent = {
|
|
20
|
+
fileId: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
export interface MobileUpload {
|
|
24
|
+
notifyUploadStart(event: MobileUploadStartEvent): void;
|
|
25
|
+
notifyUploadProgress(event: MobileUploadProgressEvent): void;
|
|
26
|
+
notifyUploadEnd(event: MobileUploadEndEvent): void;
|
|
27
|
+
notifyUploadError(event: MobileUploadErrorEvent): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const fileSizeError = "fileSizeExceedsLimit";
|
|
2
|
+
/**
|
|
3
|
+
* This is a helper to dynamically calculate the chunk size for a given file size.
|
|
4
|
+
*
|
|
5
|
+
* @param fileSize The size of a file to calculate the chunk size for.
|
|
6
|
+
* @returns A number of bytes per chunk or Throws an Error if the file size exceeds 2TB
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://product-fabric.atlassian.net/wiki/spaces/FIL/pages/3221881143/Rule+of+thumb+for+chunk+sizes#Given-the-following-conditions}
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare const calculateChunkSize: (fileSize: number) => number;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../models/errors';
|
|
2
|
+
export declare type UploaderErrorReason = 'fileSizeExceedsLimit';
|
|
3
|
+
export declare type UploaderErrorAttributes = {
|
|
4
|
+
readonly reason: UploaderErrorReason;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly metadata?: {
|
|
7
|
+
readonly collectionName?: string;
|
|
8
|
+
readonly occurrenceKey?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare class UploaderError extends BaseMediaClientError<UploaderErrorAttributes> {
|
|
12
|
+
readonly reason: UploaderErrorReason;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly metadata?: {
|
|
15
|
+
readonly collectionName?: string | undefined;
|
|
16
|
+
readonly occurrenceKey?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
constructor(reason: UploaderErrorReason, id: string, metadata?: {
|
|
19
|
+
readonly collectionName?: string | undefined;
|
|
20
|
+
readonly occurrenceKey?: string | undefined;
|
|
21
|
+
} | undefined);
|
|
22
|
+
get attributes(): {
|
|
23
|
+
reason: "fileSizeExceedsLimit";
|
|
24
|
+
id: string;
|
|
25
|
+
collectionName: string | undefined;
|
|
26
|
+
occurrenceKey: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function isUploaderError(err: Error): err is UploaderError;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChunkinatorFile } from '@atlaskit/chunkinator';
|
|
2
|
+
import { MediaStore } from '../client/media-store';
|
|
3
|
+
export declare type UploadableFile = {
|
|
4
|
+
content: ChunkinatorFile;
|
|
5
|
+
name?: string;
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
collection?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type UploadableFileUpfrontIds = {
|
|
10
|
+
id: string;
|
|
11
|
+
deferredUploadId: Promise<string>;
|
|
12
|
+
occurrenceKey?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare type UploadFileCallbacks = {
|
|
15
|
+
onProgress: (progress: number) => void;
|
|
16
|
+
onUploadFinish: (error?: any) => void;
|
|
17
|
+
};
|
|
18
|
+
export interface UploadFileResult {
|
|
19
|
+
cancel: () => void;
|
|
20
|
+
}
|
|
21
|
+
export declare const uploadFile: (file: UploadableFile, store: MediaStore, uploadableFileUpfrontIds: UploadableFileUpfrontIds, callbacks?: UploadFileCallbacks | undefined) => UploadFileResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const checkWebpSupport: () => Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertBase64ToBlob: (base64: string) => Blob;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'setimmediate';
|
|
2
|
+
import Dataloader from 'dataloader';
|
|
3
|
+
import { MediaStore, ResponseFileItem } from '../client/media-store';
|
|
4
|
+
import { MediaCollectionItemFullDetails } from '../models/media';
|
|
5
|
+
export declare const MAX_BATCH_SIZE = 100;
|
|
6
|
+
export declare type DataloaderKey = {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly collectionName?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type DataloaderResult = MediaCollectionItemFullDetails | null;
|
|
11
|
+
export declare type BatchLoadingErrorResult = {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly collection?: string;
|
|
14
|
+
readonly error: Error;
|
|
15
|
+
};
|
|
16
|
+
export declare const getItemsFromKeys: (dataloaderKeys: ReadonlyArray<DataloaderKey>, fileItems: Array<ResponseFileItem | BatchLoadingErrorResult>) => Array<DataloaderResult | Error>;
|
|
17
|
+
export declare type FileIdsByCollection = {
|
|
18
|
+
[collectionName: string]: string[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
|
|
22
|
+
* Such contract is formalised by Dataloader 1.0, @see https://github.com/graphql/dataloader
|
|
23
|
+
*
|
|
24
|
+
* If an Error is resolved in the results, it must be at same position then their corresponding key:
|
|
25
|
+
* - Dataloader will re-throw that Error when accessing/loading that particular key
|
|
26
|
+
*
|
|
27
|
+
* @param mediaStore instance of MediaStore
|
|
28
|
+
*/
|
|
29
|
+
export declare function createBatchLoadingFunc(mediaStore: MediaStore): (keys: ReadonlyArray<DataloaderKey>) => Promise<Array<DataloaderResult | Error>>;
|
|
30
|
+
export declare function createFileDataloader(mediaStore: MediaStore): Dataloader<DataloaderKey, DataloaderResult, DataloaderKey>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MediaCollectionItemFullDetails } from '../models/media';
|
|
2
|
+
/**
|
|
3
|
+
* EMPTY_FILE_HOURS_ELAPSED_TOLERANCE - how many hours since this file was
|
|
4
|
+
* created until we give up on expecting metadata?
|
|
5
|
+
*
|
|
6
|
+
* Yes, this is not an exact science. Any value under this tolerance will
|
|
7
|
+
* go undetected, however this is still suitable to catch the majority of
|
|
8
|
+
* cases where empty (files which never finished upload) are being reloaded.
|
|
9
|
+
*
|
|
10
|
+
* Continuous bad renders of empty files will eat our card render SLIs, so until
|
|
11
|
+
* there is a better response from backend we use this technique.
|
|
12
|
+
*
|
|
13
|
+
* Being encapsulated in this function, we can always improve the detection transparently.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EMPTY_FILE_HOURS_ELAPSED_TOLERANCE_MS: number;
|
|
16
|
+
export declare function isEmptyFile(fileDetails: MediaCollectionItemFullDetails, now?: number): Boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Hasher } from './hasher';
|
|
2
|
+
export interface Deferred {
|
|
3
|
+
resolve: (hash: string) => void;
|
|
4
|
+
reject: (error: any) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class WorkerHasher implements Hasher {
|
|
7
|
+
private workers;
|
|
8
|
+
private jobs;
|
|
9
|
+
constructor(numOfWorkers: number);
|
|
10
|
+
hash(chunk: Blob): Promise<string>;
|
|
11
|
+
private createWorker;
|
|
12
|
+
private handleWorkerMessage;
|
|
13
|
+
private calculateHashInWorker;
|
|
14
|
+
private dispatch;
|
|
15
|
+
private getMostRelaxedWorker;
|
|
16
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MediaStoreGetFileImageParams } from '../client/media-store';
|
|
2
|
+
export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
|
|
3
|
+
export declare const imageResizeModeToFileImageMode: (resizeMode?: ImageResizeMode | undefined) => MediaStoreGetFileImageParams['mode'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isImageRemote: (imageUrl: string, windowOrigin?: string) => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
+
import { MediaSubscribableItem } from '../../models/media-subscribable';
|
|
3
|
+
import { MediaSubscribable } from './types';
|
|
4
|
+
export declare function fromObservable<T>(observable: ReplaySubject<T>): MediaSubscribable<T>;
|
|
5
|
+
export declare function createMediaSubscribable<T extends MediaSubscribableItem>(mediaSubscribableItem?: T | Error): MediaSubscribable<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
+
import { MediaSubscribable } from './types';
|
|
3
|
+
import { MediaSubscribableItem } from '../../models/media-subscribable';
|
|
4
|
+
/**
|
|
5
|
+
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
6
|
+
*
|
|
7
|
+
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
8
|
+
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
9
|
+
*/
|
|
10
|
+
export declare const toPromise: <T extends MediaSubscribableItem>(mediaSubscribable: MediaSubscribable<T>, subscription?: Subscription) => Promise<T>;
|