@atlaskit/media-client 17.1.2 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/constants/package.json +8 -1
  3. package/dist/cjs/client/media-store/resolveAuth.js +1 -1
  4. package/dist/cjs/client/mobile-upload.js +1 -1
  5. package/dist/cjs/file-streams-cache.js +2 -2
  6. package/dist/cjs/index.js +0 -9
  7. package/dist/cjs/utils/mobileUpload/servicesCache.js +2 -2
  8. package/dist/cjs/utils/request/helpers.js +4 -4
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/client/media-store/resolveAuth.js +1 -1
  11. package/dist/es2019/client/mobile-upload.js +1 -1
  12. package/dist/es2019/file-streams-cache.js +2 -2
  13. package/dist/es2019/index.js +0 -2
  14. package/dist/es2019/utils/mobileUpload/servicesCache.js +2 -2
  15. package/dist/es2019/utils/request/helpers.js +4 -4
  16. package/dist/es2019/version.json +1 -1
  17. package/dist/esm/client/media-store/resolveAuth.js +1 -1
  18. package/dist/esm/client/mobile-upload.js +1 -1
  19. package/dist/esm/file-streams-cache.js +2 -2
  20. package/dist/esm/index.js +0 -2
  21. package/dist/esm/utils/mobileUpload/servicesCache.js +2 -2
  22. package/dist/esm/utils/request/helpers.js +4 -4
  23. package/dist/esm/version.json +1 -1
  24. package/dist/types/file-streams-cache.d.ts +2 -2
  25. package/dist/types/index.d.ts +0 -1
  26. package/dist/types/utils/mobileUpload/servicesCache.d.ts +2 -2
  27. package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +8 -0
  28. package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +10 -0
  29. package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +13 -0
  30. package/dist/types-ts4.0/client/collection-fetcher.d.ts +35 -0
  31. package/dist/types-ts4.0/client/events.d.ts +14 -0
  32. package/dist/types-ts4.0/client/file-fetcher/error.d.ts +29 -0
  33. package/dist/types-ts4.0/client/file-fetcher/index.d.ts +56 -0
  34. package/dist/types-ts4.0/client/media-client.d.ts +28 -0
  35. package/dist/types-ts4.0/client/media-store/error.d.ts +16 -0
  36. package/dist/types-ts4.0/client/media-store/index.d.ts +167 -0
  37. package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +4 -0
  38. package/dist/types-ts4.0/client/mobile-upload.d.ts +11 -0
  39. package/dist/types-ts4.0/client/stargate-client.d.ts +15 -0
  40. package/dist/types-ts4.0/constants.d.ts +6 -0
  41. package/dist/types-ts4.0/file-streams-cache.d.ts +15 -0
  42. package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +6 -0
  43. package/dist/types-ts4.0/identifier.d.ts +15 -0
  44. package/dist/types-ts4.0/index.d.ts +89 -0
  45. package/dist/types-ts4.0/models/artifacts.d.ts +12 -0
  46. package/dist/types-ts4.0/models/auth-headers.d.ts +11 -0
  47. package/dist/types-ts4.0/models/auth-query-parameters.d.ts +11 -0
  48. package/dist/types-ts4.0/models/errors/helpers.d.ts +6 -0
  49. package/dist/types-ts4.0/models/errors/index.d.ts +11 -0
  50. package/dist/types-ts4.0/models/errors/types.d.ts +15 -0
  51. package/dist/types-ts4.0/models/file-state.d.ts +91 -0
  52. package/dist/types-ts4.0/models/item.d.ts +25 -0
  53. package/dist/types-ts4.0/models/media-subscribable.d.ts +3 -0
  54. package/dist/types-ts4.0/models/media.d.ts +66 -0
  55. package/dist/types-ts4.0/models/mobile-upload.d.ts +28 -0
  56. package/dist/types-ts4.0/upload-controller.d.ts +7 -0
  57. package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +11 -0
  58. package/dist/types-ts4.0/uploader/error.d.ts +29 -0
  59. package/dist/types-ts4.0/uploader/index.d.ts +21 -0
  60. package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +1 -0
  61. package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +1 -0
  62. package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +30 -0
  63. package/dist/types-ts4.0/utils/createMediaSubject.d.ts +3 -0
  64. package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +16 -0
  65. package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +6 -0
  66. package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +5 -0
  67. package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
  68. package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +6 -0
  69. package/dist/types-ts4.0/utils/hashing/hasher.d.ts +3 -0
  70. package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +3 -0
  71. package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +4 -0
  72. package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +16 -0
  73. package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +3 -0
  74. package/dist/types-ts4.0/utils/isImageRemote.d.ts +1 -0
  75. package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +5 -0
  76. package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +3 -0
  77. package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +10 -0
  78. package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +16 -0
  79. package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +29 -0
  80. package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +8 -0
  81. package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +5 -0
  82. package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +4 -0
  83. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +7 -0
  84. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
  85. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
  86. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
  87. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
  88. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
  89. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +69 -0
  90. package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
  91. package/dist/types-ts4.0/utils/polling/errors.d.ts +12 -0
  92. package/dist/types-ts4.0/utils/polling/index.d.ts +33 -0
  93. package/dist/types-ts4.0/utils/polling/types.d.ts +7 -0
  94. package/dist/types-ts4.0/utils/request/errors.d.ts +20 -0
  95. package/dist/types-ts4.0/utils/request/helpers.d.ts +38 -0
  96. package/dist/types-ts4.0/utils/request/index.d.ts +5 -0
  97. package/dist/types-ts4.0/utils/request/types.d.ts +43 -0
  98. package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +2 -0
  99. package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +2 -0
  100. package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +16 -0
  101. package/dist/types-ts4.0/utils/url.d.ts +17 -0
  102. package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +16 -0
  103. package/package.json +13 -8
  104. package/report.api.md +12 -28
@@ -0,0 +1,167 @@
1
+ import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
2
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
3
+ import { MediaFileArtifacts } from '../../models/artifacts';
4
+ import { MediaChunksProbe, MediaCollectionItemFullDetails, MediaCollectionItems, 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
+ getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<MediaStoreResponse<MediaCollectionItems>>;
13
+ removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
14
+ createUpload(createUpTo?: number, collectionName?: string): Promise<MediaStoreResponse<MediaUpload[]>>;
15
+ uploadChunk(etag: string, blob: Blob, { collectionName, uploadId, partNumber, }?: {
16
+ collectionName?: string;
17
+ uploadId?: string;
18
+ partNumber?: number;
19
+ }): Promise<void>;
20
+ probeChunks(chunks: string[], { collectionName, uploadId, }?: {
21
+ collectionName?: string;
22
+ uploadId?: string;
23
+ }): Promise<MediaStoreResponse<MediaChunksProbe>>;
24
+ createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams): Promise<MediaStoreResponse<MediaFile>>;
25
+ touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams): Promise<MediaStoreResponse<TouchedFiles>>;
26
+ getFile(fileId: string, params?: MediaStoreGetFileParams): Promise<MediaStoreResponse<MediaFile>>;
27
+ getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
28
+ getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
29
+ private createFileImageURL;
30
+ getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
31
+ getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
32
+ getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
33
+ getItems(ids: string[], collectionName?: string): Promise<MediaStoreResponse<ItemsPayload>>;
34
+ getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<{
35
+ metadata: ImageMetadata;
36
+ }>;
37
+ appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string): Promise<void>;
38
+ copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams): Promise<MediaStoreResponse<MediaFile>>;
39
+ request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
40
+ resolveAuth: (authContext?: AuthContext | undefined) => Promise<Auth>;
41
+ resolveInitialAuth: () => Auth;
42
+ }
43
+ export declare const getMediaEnvironment: () => string | undefined;
44
+ export declare const getMediaRegion: () => string | undefined;
45
+ export interface ResponseFileItem {
46
+ id: string;
47
+ type: 'file';
48
+ details: MediaCollectionItemFullDetails;
49
+ collection?: string;
50
+ }
51
+ export interface ItemsPayload {
52
+ items: ResponseFileItem[];
53
+ }
54
+ export declare type ImageMetadataArtifact = {
55
+ url?: string;
56
+ width?: number;
57
+ height?: number;
58
+ size?: number;
59
+ };
60
+ export interface ImageMetadata {
61
+ pending: boolean;
62
+ preview?: ImageMetadataArtifact;
63
+ original?: ImageMetadataArtifact;
64
+ }
65
+ export interface MediaStoreResponse<Data> {
66
+ readonly data: Data;
67
+ }
68
+ export declare type MediaStoreRequestOptions = RequestMetadata & {
69
+ readonly method?: RequestMethod;
70
+ readonly authContext?: AuthContext;
71
+ readonly params?: RequestParams;
72
+ readonly headers?: RequestHeaders;
73
+ readonly body?: any;
74
+ readonly clientOptions?: ClientOptions;
75
+ };
76
+ export declare type MediaStoreCreateFileFromUploadParams = {
77
+ readonly collection?: string;
78
+ readonly occurrenceKey?: string;
79
+ readonly expireAfter?: number;
80
+ readonly replaceFileId?: string;
81
+ readonly skipConversions?: boolean;
82
+ };
83
+ export declare type MediaStoreCreateFileParams = {
84
+ readonly occurrenceKey?: string;
85
+ readonly collection?: string;
86
+ };
87
+ export interface MediaStoreTouchFileParams {
88
+ readonly collection?: string;
89
+ }
90
+ export interface TouchFileDescriptor {
91
+ fileId: string;
92
+ collection?: string;
93
+ occurrenceKey?: string;
94
+ expireAfter?: number;
95
+ deletable?: boolean;
96
+ }
97
+ export interface MediaStoreTouchFileBody {
98
+ descriptors: TouchFileDescriptor[];
99
+ }
100
+ export declare type MediaStoreCreateFileFromBinaryParams = {
101
+ readonly replaceFileId?: string;
102
+ readonly collection?: string;
103
+ readonly occurrenceKey?: string;
104
+ readonly expireAfter?: number;
105
+ readonly skipConversions?: boolean;
106
+ readonly name?: string;
107
+ };
108
+ export declare type MediaStoreCreateFileFromUploadConditions = {
109
+ readonly hash: string;
110
+ readonly size: number;
111
+ };
112
+ export declare type MediaStoreCreateFileFromUploadBody = {
113
+ readonly uploadId: string;
114
+ readonly name?: string;
115
+ readonly mimeType?: string;
116
+ readonly conditions?: MediaStoreCreateFileFromUploadConditions;
117
+ };
118
+ export declare type MediaStoreGetFileParams = {
119
+ readonly version?: number;
120
+ readonly collection?: string;
121
+ };
122
+ export declare type MediaStoreGetFileImageParams = {
123
+ readonly allowAnimated?: boolean;
124
+ readonly version?: number;
125
+ readonly collection?: string;
126
+ readonly width?: number;
127
+ readonly height?: number;
128
+ readonly mode?: 'fit' | 'full-fit' | 'crop';
129
+ readonly upscale?: boolean;
130
+ readonly 'max-age'?: number;
131
+ };
132
+ export declare type MediaStoreGetCollectionItemsParams = {
133
+ readonly limit?: number;
134
+ readonly inclusiveStartKey?: string;
135
+ readonly sortDirection?: 'asc' | 'desc';
136
+ readonly details?: 'minimal' | 'full';
137
+ };
138
+ export interface SourceFile {
139
+ id: string;
140
+ owner: ClientAltBasedAuth | AsapBasedAuth;
141
+ collection?: string;
142
+ version?: number;
143
+ }
144
+ export declare type MediaStoreCopyFileWithTokenBody = {
145
+ sourceFile: SourceFile;
146
+ };
147
+ export declare type MediaStoreCopyFileWithTokenParams = {
148
+ readonly collection?: string;
149
+ readonly replaceFileId?: string;
150
+ readonly occurrenceKey?: string;
151
+ };
152
+ export declare type AppendChunksToUploadRequestBody = {
153
+ readonly chunks: string[];
154
+ readonly hash?: string;
155
+ readonly offset?: number;
156
+ };
157
+ export interface CreatedTouchedFile {
158
+ fileId: string;
159
+ uploadId: string;
160
+ }
161
+ export declare type TouchedFiles = {
162
+ created: CreatedTouchedFile[];
163
+ };
164
+ export interface EmptyFile {
165
+ readonly id: string;
166
+ readonly createdAt: number;
167
+ }
@@ -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 | undefined, authProviderTimeout?: number) => Promise<Auth>;
4
+ export declare const resolveInitialAuth: (auth?: Auth | undefined) => 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 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,89 @@
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 { uploadFile } from './uploader';
17
+ export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
18
+ export { request, RequestError, isRequestError, isRateLimitedError, } from './utils/request';
19
+ export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './utils/request';
20
+ export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl, } from './utils/request/helpers';
21
+ export { PollingFunction } from './utils/polling';
22
+ export { isPollingError, PollingError } from './utils/polling/errors';
23
+ export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
24
+ export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
25
+ export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
26
+ export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
27
+ export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
28
+ export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
29
+ export { CollectionFetcher } from './client/collection-fetcher';
30
+ export { MediaClient } from './client/media-client';
31
+ export { StargateClient } from './client/stargate-client';
32
+ export type { EdgeData } from './client/stargate-client';
33
+ export { isImageRemote } from './utils/isImageRemote';
34
+ export { checkWebpSupport } from './utils/checkWebpSupport';
35
+ export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
36
+ export type { Dimensions } from './utils/getDimensionsFromBlob';
37
+ export { createMediaSubject } from './utils/createMediaSubject';
38
+ export { safeUnsubscribe } from './utils/safeUnsubscribe';
39
+ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } from './identifier';
40
+ export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
41
+ export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
42
+ export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
43
+ export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
44
+ export { globalMediaEventEmitter } from './globalMediaEventEmitter';
45
+ export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
46
+ export type { MediaBlobUrlAttrs } from './utils/url';
47
+ export { createMediaSubscribable } from './utils/mediaSubscribable';
48
+ export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
49
+ export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
50
+ /**
51
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
52
+ */
53
+ export declare const getMediaTypeFromMimeType: (mimeType: string) => import("@atlaskit/media-common").MediaType;
54
+ /**
55
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
56
+ */
57
+ export declare const isImageMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
58
+ /**
59
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
60
+ */
61
+ export declare const isDocumentMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
62
+ /**
63
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
64
+ */
65
+ export declare const isMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
66
+ /**
67
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
68
+ */
69
+ export declare const isImageMimeTypeSupportedByServer: (mimeType: string) => boolean;
70
+ /**
71
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
72
+ */
73
+ export declare const isDocumentMimeTypeSupportedByServer: (mimeType: string) => boolean;
74
+ /**
75
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
76
+ */
77
+ export declare const isAudioMimeTypeSupportedByServer: (mimeType: string) => boolean;
78
+ /**
79
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
80
+ */
81
+ export declare const isVideoMimeTypeSupportedByServer: (mimeType: string) => boolean;
82
+ /**
83
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
84
+ */
85
+ export declare const isUnknownMimeTypeSupportedByServer: (mimeType: string) => boolean;
86
+ /**
87
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
88
+ */
89
+ 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,3 @@
1
+ import { FileState } from './file-state';
2
+ import { MediaCollectionItem } from './media';
3
+ export declare type MediaSubscribableItem = FileState | MediaCollectionItem[];
@@ -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,7 @@
1
+ export declare 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;