@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.
Files changed (101) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/client/file-fetcher/index.js +3 -103
  3. package/dist/cjs/client/media-client.js +1 -1
  4. package/dist/cjs/client/media-store/index.js +13 -80
  5. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +0 -5
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/client/file-fetcher/index.js +3 -104
  8. package/dist/es2019/client/media-client.js +1 -1
  9. package/dist/es2019/client/media-store/index.js +5 -45
  10. package/dist/es2019/utils/shouldFetchRemoteFileStates.js +0 -4
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/esm/client/file-fetcher/index.js +4 -104
  13. package/dist/esm/client/media-client.js +1 -1
  14. package/dist/esm/client/media-store/index.js +13 -80
  15. package/dist/esm/utils/shouldFetchRemoteFileStates.js +0 -4
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/client/file-fetcher/error.d.ts +1 -1
  18. package/dist/types/client/file-fetcher/index.d.ts +4 -7
  19. package/dist/types/client/media-store/index.d.ts +1 -2
  20. package/dist/types/models/errors/types.d.ts +1 -1
  21. package/dist/types/utils/shouldFetchRemoteFileStates.d.ts +0 -2
  22. package/dist/types-ts4.5/client/__mocks__/collection-fetcher.d.ts +8 -0
  23. package/dist/types-ts4.5/client/__mocks__/file-fetcher.d.ts +10 -0
  24. package/dist/types-ts4.5/client/__mocks__/media-client.d.ts +11 -0
  25. package/dist/types-ts4.5/client/events.d.ts +14 -0
  26. package/dist/types-ts4.5/client/file-fetcher/error.d.ts +29 -0
  27. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +58 -0
  28. package/dist/types-ts4.5/client/media-client.d.ts +27 -0
  29. package/dist/types-ts4.5/client/media-store/error.d.ts +16 -0
  30. package/dist/types-ts4.5/client/media-store/index.d.ts +169 -0
  31. package/dist/types-ts4.5/client/media-store/resolveAuth.d.ts +4 -0
  32. package/dist/types-ts4.5/client/mobile-upload.d.ts +11 -0
  33. package/dist/types-ts4.5/client/stargate-client.d.ts +15 -0
  34. package/dist/types-ts4.5/constants.d.ts +6 -0
  35. package/dist/types-ts4.5/file-streams-cache.d.ts +15 -0
  36. package/dist/types-ts4.5/globalMediaEventEmitter.d.ts +6 -0
  37. package/dist/types-ts4.5/identifier.d.ts +15 -0
  38. package/dist/types-ts4.5/index.d.ts +87 -0
  39. package/dist/types-ts4.5/models/artifacts.d.ts +12 -0
  40. package/dist/types-ts4.5/models/auth-headers.d.ts +11 -0
  41. package/dist/types-ts4.5/models/auth-query-parameters.d.ts +11 -0
  42. package/dist/types-ts4.5/models/errors/helpers.d.ts +6 -0
  43. package/dist/types-ts4.5/models/errors/index.d.ts +11 -0
  44. package/dist/types-ts4.5/models/errors/types.d.ts +15 -0
  45. package/dist/types-ts4.5/models/file-state.d.ts +94 -0
  46. package/dist/types-ts4.5/models/item.d.ts +25 -0
  47. package/dist/types-ts4.5/models/media.d.ts +48 -0
  48. package/dist/types-ts4.5/models/mobile-upload.d.ts +28 -0
  49. package/dist/types-ts4.5/upload-controller.d.ts +7 -0
  50. package/dist/types-ts4.5/uploader/calculateChunkSize.d.ts +11 -0
  51. package/dist/types-ts4.5/uploader/error.d.ts +29 -0
  52. package/dist/types-ts4.5/uploader/index.d.ts +22 -0
  53. package/dist/types-ts4.5/utils/checkWebpSupport.d.ts +1 -0
  54. package/dist/types-ts4.5/utils/convertBase64ToBlob.d.ts +1 -0
  55. package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +30 -0
  56. package/dist/types-ts4.5/utils/createMediaSubject.d.ts +3 -0
  57. package/dist/types-ts4.5/utils/detectEmptyFile.d.ts +16 -0
  58. package/dist/types-ts4.5/utils/getDimensionsFromBlob.d.ts +6 -0
  59. package/dist/types-ts4.5/utils/getImageDimensionsFromBlob.d.ts +5 -0
  60. package/dist/types-ts4.5/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
  61. package/dist/types-ts4.5/utils/getVideoDimensionsFromBlob.d.ts +5 -0
  62. package/dist/types-ts4.5/utils/hashing/hasher.d.ts +3 -0
  63. package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +3 -0
  64. package/dist/types-ts4.5/utils/hashing/simpleHasher.d.ts +4 -0
  65. package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +16 -0
  66. package/dist/types-ts4.5/utils/imageResizeModeToFileImageMode.d.ts +3 -0
  67. package/dist/types-ts4.5/utils/isImageRemote.d.ts +1 -0
  68. package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +5 -0
  69. package/dist/types-ts4.5/utils/mediaSubscribable/index.d.ts +3 -0
  70. package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +10 -0
  71. package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +17 -0
  72. package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +29 -0
  73. package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +8 -0
  74. package/dist/types-ts4.5/utils/mobileUpload/index.d.ts +5 -0
  75. package/dist/types-ts4.5/utils/mobileUpload/servicesCache.d.ts +4 -0
  76. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +7 -0
  77. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
  78. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
  79. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
  80. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
  81. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
  82. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +69 -0
  83. package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
  84. package/dist/types-ts4.5/utils/polling/errors.d.ts +12 -0
  85. package/dist/types-ts4.5/utils/polling/index.d.ts +33 -0
  86. package/dist/types-ts4.5/utils/polling/types.d.ts +7 -0
  87. package/dist/types-ts4.5/utils/request/errors.d.ts +20 -0
  88. package/dist/types-ts4.5/utils/request/helpers.d.ts +46 -0
  89. package/dist/types-ts4.5/utils/request/index.d.ts +5 -0
  90. package/dist/types-ts4.5/utils/request/types.d.ts +46 -0
  91. package/dist/types-ts4.5/utils/safeUnsubscribe.d.ts +2 -0
  92. package/dist/types-ts4.5/utils/setTimeoutPromise.d.ts +2 -0
  93. package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +14 -0
  94. package/dist/types-ts4.5/utils/url.d.ts +17 -0
  95. package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +16 -0
  96. package/package.json +4 -4
  97. package/report.api.md +11 -15
  98. package/dist/cjs/utils/parseJwt.js +0 -52
  99. package/dist/es2019/utils/parseJwt.js +0 -46
  100. package/dist/esm/utils/parseJwt.js +0 -46
  101. package/dist/types/utils/parseJwt.d.ts +0 -1
@@ -0,0 +1,169 @@
1
+ import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
2
+ import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
3
+ import { MediaFileArtifacts } from '../../models/artifacts';
4
+ import { MediaChunksProbe, MediaItemDetails, MediaFile, MediaUpload } from '../../models/media';
5
+ import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata } from '../../utils/request/types';
6
+ export type { MediaStoreErrorReason, MediaStoreErrorAttributes } from './error';
7
+ export { MediaStoreError, isMediaStoreError } from './error';
8
+ export declare class MediaStore {
9
+ private readonly config;
10
+ readonly featureFlags?: MediaFeatureFlags | undefined;
11
+ constructor(config: MediaApiConfig, featureFlags?: MediaFeatureFlags | undefined);
12
+ removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
13
+ createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
14
+ uploadChunk(etag: string, blob: Blob, uploadId: string, partNumber: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
15
+ probeChunks(chunks: string[], uploadId: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
16
+ createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
17
+ getRejectedResponseFromDescriptor(descriptor: TouchFileDescriptor, limit: number): RejectedTouchFile;
18
+ touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<TouchedFiles>>;
19
+ getFile(fileId: string, params?: MediaStoreGetFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
20
+ getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
21
+ getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
22
+ private createFileImageURL;
23
+ getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
24
+ getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
25
+ getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
26
+ getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
27
+ getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
28
+ metadata: ImageMetadata;
29
+ }>;
30
+ appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
31
+ copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
32
+ request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
33
+ resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
34
+ resolveInitialAuth: () => Auth;
35
+ }
36
+ export declare const getMediaEnvironment: () => string | undefined;
37
+ export declare const getMediaRegion: () => string | undefined;
38
+ export interface ResponseFileItem {
39
+ id: string;
40
+ type: 'file';
41
+ details: MediaItemDetails;
42
+ collection?: string;
43
+ metadataTraceContext?: MediaTraceContext;
44
+ }
45
+ export interface ItemsPayload {
46
+ items: ResponseFileItem[];
47
+ }
48
+ export type ImageMetadataArtifact = {
49
+ url?: string;
50
+ width?: number;
51
+ height?: number;
52
+ size?: number;
53
+ };
54
+ export interface ImageMetadata {
55
+ pending: boolean;
56
+ preview?: ImageMetadataArtifact;
57
+ original?: ImageMetadataArtifact;
58
+ }
59
+ export interface MediaStoreResponse<Data> {
60
+ readonly data: Data;
61
+ }
62
+ export type MediaStoreRequestOptions = RequestMetadata & {
63
+ readonly method?: RequestMethod;
64
+ readonly authContext?: AuthContext;
65
+ readonly params?: RequestParams;
66
+ readonly headers?: RequestHeaders;
67
+ readonly body?: any;
68
+ readonly clientOptions?: ClientOptions;
69
+ readonly traceContext?: MediaTraceContext;
70
+ };
71
+ export type MediaStoreCreateFileFromUploadParams = {
72
+ readonly collection?: string;
73
+ readonly occurrenceKey?: string;
74
+ readonly expireAfter?: number;
75
+ readonly replaceFileId?: string;
76
+ readonly skipConversions?: boolean;
77
+ };
78
+ export type MediaStoreCreateFileParams = {
79
+ readonly occurrenceKey?: string;
80
+ readonly collection?: string;
81
+ };
82
+ export interface MediaStoreTouchFileParams {
83
+ readonly collection?: string;
84
+ }
85
+ export interface TouchFileDescriptor {
86
+ fileId: string;
87
+ collection?: string;
88
+ occurrenceKey?: string;
89
+ expireAfter?: number;
90
+ deletable?: boolean;
91
+ size?: number;
92
+ }
93
+ export interface MediaStoreTouchFileBody {
94
+ descriptors: TouchFileDescriptor[];
95
+ }
96
+ export type MediaStoreCreateFileFromBinaryParams = {
97
+ readonly replaceFileId?: string;
98
+ readonly collection?: string;
99
+ readonly occurrenceKey?: string;
100
+ readonly expireAfter?: number;
101
+ readonly skipConversions?: boolean;
102
+ readonly name?: string;
103
+ };
104
+ export type MediaStoreCreateFileFromUploadConditions = {
105
+ readonly hash: string;
106
+ readonly size: number;
107
+ };
108
+ export type MediaStoreCreateFileFromUploadBody = {
109
+ readonly uploadId: string;
110
+ readonly name?: string;
111
+ readonly mimeType?: string;
112
+ readonly conditions?: MediaStoreCreateFileFromUploadConditions;
113
+ };
114
+ export type MediaStoreGetFileParams = {
115
+ readonly version?: number;
116
+ readonly collection?: string;
117
+ };
118
+ export type MediaStoreGetFileImageParams = {
119
+ readonly allowAnimated?: boolean;
120
+ readonly version?: number;
121
+ readonly collection?: string;
122
+ readonly width?: number;
123
+ readonly height?: number;
124
+ readonly mode?: 'fit' | 'full-fit' | 'crop';
125
+ readonly upscale?: boolean;
126
+ readonly 'max-age'?: number;
127
+ };
128
+ export interface SourceFile {
129
+ id: string;
130
+ owner: ClientAltBasedAuth | AsapBasedAuth;
131
+ collection?: string;
132
+ version?: number;
133
+ }
134
+ export type MediaStoreCopyFileWithTokenBody = {
135
+ sourceFile: SourceFile;
136
+ };
137
+ export type MediaStoreCopyFileWithTokenParams = {
138
+ readonly collection?: string;
139
+ readonly replaceFileId?: string;
140
+ readonly occurrenceKey?: string;
141
+ };
142
+ export type AppendChunksToUploadRequestBody = {
143
+ readonly chunks: string[];
144
+ readonly hash?: string;
145
+ readonly offset?: number;
146
+ };
147
+ export interface CreatedTouchedFile {
148
+ fileId: string;
149
+ uploadId: string;
150
+ }
151
+ export interface RejectedTouchFile {
152
+ fileId: string;
153
+ error: RejectionError;
154
+ }
155
+ export type RejectionError = {
156
+ code: 'ExceedMaxFileSizeLimit';
157
+ title: string;
158
+ href: string;
159
+ limit: number;
160
+ size: number;
161
+ };
162
+ export type TouchedFiles = {
163
+ created: CreatedTouchedFile[];
164
+ rejected?: RejectedTouchFile[];
165
+ };
166
+ export interface EmptyFile {
167
+ readonly id: string;
168
+ readonly createdAt: number;
169
+ }
@@ -0,0 +1,4 @@
1
+ import { Auth, AuthContext, AuthProvider } from '@atlaskit/media-core';
2
+ export declare const DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
3
+ export declare const resolveAuth: (authProvider: AuthProvider, authContext?: AuthContext, authProviderTimeout?: number) => Promise<Auth>;
4
+ export declare const resolveInitialAuth: (auth?: Auth) => Auth;
@@ -0,0 +1,11 @@
1
+ import { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent } from '../models/mobile-upload';
2
+ import { MediaStore } from './media-store';
3
+ export declare class MobileUploadImpl implements MobileUpload {
4
+ private readonly dataloader;
5
+ private readonly servicesCache;
6
+ constructor(mediaStore: MediaStore);
7
+ notifyUploadStart(event: MobileUploadStartEvent): void;
8
+ notifyUploadProgress(event: MobileUploadProgressEvent): void;
9
+ notifyUploadEnd(event: MobileUploadEndEvent): void;
10
+ notifyUploadError(event: MobileUploadErrorEvent): void;
11
+ }
@@ -0,0 +1,15 @@
1
+ export interface EdgeData {
2
+ data: {
3
+ clientId: string;
4
+ token: string;
5
+ baseUrl: string;
6
+ expiresIn: number;
7
+ iat: number;
8
+ };
9
+ }
10
+ export declare class StargateClient {
11
+ private baseUrl;
12
+ constructor(baseUrl: string | undefined);
13
+ fetchToken(clientId: string): Promise<EdgeData>;
14
+ isTokenExpired(token: EdgeData): boolean;
15
+ }
@@ -0,0 +1,6 @@
1
+ export declare const RECENTS_COLLECTION = "recents";
2
+ export declare const FILE_CACHE_MAX_AGE: number;
3
+ export declare const MAX_RESOLUTION = 4096;
4
+ export declare const CHUNK_SIZE: number;
5
+ export declare const PROCESSING_BATCH_SIZE = 1000;
6
+ export declare const MAX_UPLOAD_FILE_SIZE: number;
@@ -0,0 +1,15 @@
1
+ import { LRUMap } from 'lru_map';
2
+ import { ReplaySubject } from 'rxjs/ReplaySubject';
3
+ import { FileState } from './models/file-state';
4
+ export declare class StreamsCache<T> {
5
+ private readonly streams;
6
+ constructor(streams: LRUMap<string, ReplaySubject<T>>);
7
+ has(id: string): boolean;
8
+ set(id: string, stream: ReplaySubject<T>): void;
9
+ get(id: string): ReplaySubject<T> | undefined;
10
+ getOrInsert(id: string, callback: () => ReplaySubject<T>): ReplaySubject<T>;
11
+ removeAll(): void;
12
+ remove(id: string): void;
13
+ get size(): number;
14
+ }
15
+ export declare const getFileStreamsCache: () => StreamsCache<FileState>;
@@ -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 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,87 @@
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, 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 } from './models/media';
7
+ export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaRepresentations, MediaItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
8
+ export { getArtifactUrl } from './models/artifacts';
9
+ export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
10
+ export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
11
+ export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
12
+ export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
13
+ export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
14
+ export type { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
15
+ export { uploadFile } from './uploader';
16
+ export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
17
+ export { request, RequestError, isRequestError, isRateLimitedError, } from './utils/request';
18
+ export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './utils/request';
19
+ export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, } from './utils/request/helpers';
20
+ export { PollingFunction } from './utils/polling';
21
+ export { isPollingError, PollingError } from './utils/polling/errors';
22
+ export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
23
+ export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
24
+ export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
25
+ export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
26
+ export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
27
+ export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
28
+ export { MediaClient } from './client/media-client';
29
+ export { StargateClient } from './client/stargate-client';
30
+ export type { EdgeData } from './client/stargate-client';
31
+ export { isImageRemote } from './utils/isImageRemote';
32
+ export { checkWebpSupport } from './utils/checkWebpSupport';
33
+ export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
34
+ export type { Dimensions } from './utils/getDimensionsFromBlob';
35
+ export { createMediaSubject } from './utils/createMediaSubject';
36
+ export { safeUnsubscribe } from './utils/safeUnsubscribe';
37
+ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } from './identifier';
38
+ export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
39
+ export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
40
+ export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
41
+ export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
42
+ export { globalMediaEventEmitter } from './globalMediaEventEmitter';
43
+ export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
44
+ export type { MediaBlobUrlAttrs } from './utils/url';
45
+ export { createMediaSubscribable, fromObservable, } from './utils/mediaSubscribable';
46
+ export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
47
+ export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
48
+ /**
49
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
50
+ */
51
+ export declare const getMediaTypeFromMimeType: (mimeType: string) => import("@atlaskit/media-common").MediaType;
52
+ /**
53
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
54
+ */
55
+ export declare const isImageMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
56
+ /**
57
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
58
+ */
59
+ export declare const isDocumentMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
60
+ /**
61
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
62
+ */
63
+ export declare const isMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
64
+ /**
65
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
66
+ */
67
+ export declare const isImageMimeTypeSupportedByServer: (mimeType: string) => boolean;
68
+ /**
69
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
70
+ */
71
+ export declare const isDocumentMimeTypeSupportedByServer: (mimeType: string) => boolean;
72
+ /**
73
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
74
+ */
75
+ export declare const isAudioMimeTypeSupportedByServer: (mimeType: string) => boolean;
76
+ /**
77
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
78
+ */
79
+ export declare const isVideoMimeTypeSupportedByServer: (mimeType: string) => boolean;
80
+ /**
81
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
82
+ */
83
+ export declare const isUnknownMimeTypeSupportedByServer: (mimeType: string) => boolean;
84
+ /**
85
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
86
+ */
87
+ export declare const isMimeTypeSupportedByServer: (mimeType: string) => boolean;
@@ -0,0 +1,12 @@
1
+ import type { MediaFileProcessingStatus } from './media';
2
+ export 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 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 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 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
+ 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,94 @@
1
+ import { FileStatus as CommonFileStatus, MediaTraceContext } from '@atlaskit/media-common';
2
+ import { MediaStoreResponse } from '../client/media-store';
3
+ import { MediaFileArtifacts } from './artifacts';
4
+ import { MediaItemDetails, MediaFile, MediaRepresentations, MediaType } from './media';
5
+ export type BaseFileState = {
6
+ metadataTraceContext?: MediaTraceContext;
7
+ };
8
+ export type FileStatus = CommonFileStatus;
9
+ export interface FilePreview {
10
+ value: Blob | string;
11
+ origin?: 'local' | 'remote';
12
+ originalDimensions?: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ }
17
+ export interface PreviewOptions {
18
+ }
19
+ export interface GetFileOptions {
20
+ preview?: PreviewOptions;
21
+ collectionName?: string;
22
+ occurrenceKey?: string;
23
+ }
24
+ export interface UploadingFileState extends BaseFileState {
25
+ status: 'uploading';
26
+ id: string;
27
+ occurrenceKey?: string;
28
+ name: string;
29
+ size: number;
30
+ progress: number;
31
+ mediaType: MediaType;
32
+ mimeType: string;
33
+ preview?: FilePreview | Promise<FilePreview>;
34
+ createdAt?: number;
35
+ }
36
+ export interface PreviewableFileState {
37
+ preview: FilePreview | Promise<FilePreview>;
38
+ }
39
+ export interface ProcessingFileState extends BaseFileState {
40
+ status: 'processing';
41
+ id: string;
42
+ occurrenceKey?: string;
43
+ name: string;
44
+ size: number;
45
+ artifacts?: MediaFileArtifacts;
46
+ mediaType: MediaType;
47
+ mimeType: string;
48
+ preview?: FilePreview | Promise<FilePreview>;
49
+ representations?: MediaRepresentations;
50
+ createdAt?: number;
51
+ }
52
+ export interface ProcessedFileState extends BaseFileState {
53
+ status: 'processed';
54
+ id: string;
55
+ occurrenceKey?: string;
56
+ name: string;
57
+ size: number;
58
+ artifacts: MediaFileArtifacts;
59
+ mediaType: MediaType;
60
+ mimeType: string;
61
+ preview?: FilePreview | Promise<FilePreview>;
62
+ representations?: MediaRepresentations;
63
+ createdAt?: number;
64
+ }
65
+ export interface ProcessingFailedState extends BaseFileState {
66
+ status: 'failed-processing';
67
+ id: string;
68
+ occurrenceKey?: string;
69
+ name: string;
70
+ size: number;
71
+ artifacts: Object;
72
+ mediaType: MediaType;
73
+ mimeType: string;
74
+ preview?: FilePreview | Promise<FilePreview>;
75
+ representations?: MediaRepresentations;
76
+ createdAt?: number;
77
+ }
78
+ export interface ErrorFileState extends BaseFileState {
79
+ status: 'error';
80
+ id: string;
81
+ occurrenceKey?: string;
82
+ message?: string;
83
+ }
84
+ export type FileState = UploadingFileState | ProcessingFileState | ProcessedFileState | ErrorFileState | ProcessingFailedState;
85
+ export type NonErrorFileState = Exclude<FileState, ErrorFileState>;
86
+ export declare const isUploadingFileState: (fileState: FileState) => fileState is UploadingFileState;
87
+ export declare const isProcessingFileState: (fileState: FileState) => fileState is ProcessingFileState;
88
+ export declare const isProcessedFileState: (fileState: FileState) => fileState is ProcessedFileState;
89
+ export declare const isErrorFileState: (fileState: FileState) => fileState is ErrorFileState;
90
+ export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState | ProcessingFileState | ProcessedFileState | ProcessingFailedState) & PreviewableFileState;
91
+ export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
92
+ export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
93
+ export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
94
+ export declare const mapMediaItemToFileState: (id: string, item: MediaItemDetails) => FileState;
@@ -0,0 +1,25 @@
1
+ import { MediaType } from './media';
2
+ export type MediaItemType = 'file' | 'external-image';
3
+ export interface FileItem {
4
+ type: 'file';
5
+ details: FileDetails;
6
+ }
7
+ export type FileProcessingStatus = 'pending' | 'running' | 'succeeded' | 'failed';
8
+ export interface MediaArtifact {
9
+ processingStatus?: FileProcessingStatus;
10
+ url?: string;
11
+ }
12
+ export 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,48 @@
1
+ import { MediaFeatureFlags, MediaTraceContext, MediaType } from '@atlaskit/media-common';
2
+ import type { MediaFileArtifacts } from './artifacts';
3
+ export type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
4
+ export type { MediaType } from '@atlaskit/media-common';
5
+ export declare const isPreviewableType: (type: MediaType, featureFlags?: MediaFeatureFlags) => boolean;
6
+ export 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
+ readonly metadataTraceContext?: MediaTraceContext;
17
+ };
18
+ export type MediaItemDetails = {
19
+ readonly mediaType: MediaType;
20
+ readonly mimeType: string;
21
+ readonly name: string;
22
+ readonly processingStatus: MediaFileProcessingStatus;
23
+ readonly size: number;
24
+ readonly artifacts: MediaFileArtifacts;
25
+ readonly representations: MediaRepresentations;
26
+ readonly createdAt?: number;
27
+ readonly metadataTraceContext?: MediaTraceContext;
28
+ };
29
+ export type MediaRepresentations = {
30
+ image?: Object;
31
+ };
32
+ export type MediaUpload = {
33
+ readonly id: string;
34
+ readonly created: number;
35
+ readonly expires: number;
36
+ };
37
+ export type MediaChunksProbe = {
38
+ readonly results: {
39
+ readonly [etag: string]: {
40
+ readonly exists: boolean;
41
+ };
42
+ };
43
+ };
44
+ export declare enum DATA_UNIT {
45
+ MB = 1048576,
46
+ GB = 1073741824,
47
+ TB = 1099511627776
48
+ }
@@ -0,0 +1,28 @@
1
+ import { FilePreview } from './file-state';
2
+ export 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 type MobileUploadProgressEvent = {
13
+ fileId: string;
14
+ progress: number;
15
+ };
16
+ export type MobileUploadEndEvent = {
17
+ fileId: string;
18
+ };
19
+ export 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,7 @@
1
+ export type AbortFunction = () => void;
2
+ export declare class UploadController {
3
+ abortFunction?: AbortFunction;
4
+ constructor();
5
+ setAbort(abortFunction: AbortFunction): void;
6
+ abort(): void;
7
+ }
@@ -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;