@atlaskit/media-client 24.0.1 → 24.0.2
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 +6 -0
- package/dist/types-ts4.5/client/__mocks__/collection-fetcher.d.ts +8 -0
- package/dist/types-ts4.5/client/__mocks__/file-fetcher.d.ts +10 -0
- package/dist/types-ts4.5/client/__mocks__/media-client.d.ts +11 -0
- package/dist/types-ts4.5/client/events.d.ts +14 -0
- package/dist/types-ts4.5/client/file-fetcher/error.d.ts +29 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +62 -0
- package/dist/types-ts4.5/client/media-client.d.ts +32 -0
- package/dist/types-ts4.5/client/media-store/error.d.ts +16 -0
- package/dist/types-ts4.5/client/media-store/index.d.ts +168 -0
- package/dist/types-ts4.5/client/media-store/resolveAuth.d.ts +4 -0
- package/dist/types-ts4.5/client/mobile-upload.d.ts +15 -0
- package/dist/types-ts4.5/client/stargate-client.d.ts +15 -0
- package/dist/types-ts4.5/constants.d.ts +6 -0
- package/dist/types-ts4.5/file-streams-cache.d.ts +15 -0
- package/dist/types-ts4.5/globalMediaEventEmitter.d.ts +6 -0
- package/dist/types-ts4.5/identifier.d.ts +15 -0
- package/dist/types-ts4.5/index.d.ts +89 -0
- package/dist/types-ts4.5/models/artifacts.d.ts +2 -0
- package/dist/types-ts4.5/models/auth-headers.d.ts +11 -0
- package/dist/types-ts4.5/models/auth-query-parameters.d.ts +11 -0
- package/dist/types-ts4.5/models/errors/helpers.d.ts +6 -0
- package/dist/types-ts4.5/models/errors/index.d.ts +11 -0
- package/dist/types-ts4.5/models/errors/types.d.ts +15 -0
- package/dist/types-ts4.5/models/file-state.d.ts +25 -0
- package/dist/types-ts4.5/models/item.d.ts +25 -0
- package/dist/types-ts4.5/models/media.d.ts +48 -0
- package/dist/types-ts4.5/models/mobile-upload.d.ts +28 -0
- package/dist/types-ts4.5/test-helpers/_numbers.d.ts +1 -0
- package/dist/types-ts4.5/test-helpers/authProvider.d.ts +6 -0
- package/dist/types-ts4.5/test-helpers/collectionNames.d.ts +5 -0
- package/dist/types-ts4.5/test-helpers/exampleMediaItems.d.ts +53 -0
- package/dist/types-ts4.5/test-helpers/fakeMediaClient.d.ts +4 -0
- package/dist/types-ts4.5/test-helpers/index.d.ts +7 -0
- package/dist/types-ts4.5/test-helpers/mediaClientProvider.d.ts +23 -0
- package/dist/types-ts4.5/test-helpers/mediaPickerAuthProvider.d.ts +5 -0
- package/dist/types-ts4.5/upload-controller.d.ts +7 -0
- package/dist/types-ts4.5/uploader/calculateChunkSize.d.ts +11 -0
- package/dist/types-ts4.5/uploader/error.d.ts +29 -0
- package/dist/types-ts4.5/uploader/index.d.ts +23 -0
- package/dist/types-ts4.5/utils/checkWebpSupport.d.ts +1 -0
- package/dist/types-ts4.5/utils/convertBase64ToBlob.d.ts +1 -0
- package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +30 -0
- package/dist/types-ts4.5/utils/createMediaSubject.d.ts +3 -0
- package/dist/types-ts4.5/utils/detectEmptyFile.d.ts +16 -0
- package/dist/types-ts4.5/utils/getDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.5/utils/getImageDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.5/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
- package/dist/types-ts4.5/utils/getVideoDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.5/utils/hashing/hasher.d.ts +3 -0
- package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +3 -0
- package/dist/types-ts4.5/utils/hashing/simpleHasher.d.ts +4 -0
- package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +16 -0
- package/dist/types-ts4.5/utils/imageResizeModeToFileImageMode.d.ts +3 -0
- package/dist/types-ts4.5/utils/isImageRemote.d.ts +1 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +5 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/index.d.ts +3 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +10 -0
- package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +17 -0
- package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +29 -0
- package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +8 -0
- package/dist/types-ts4.5/utils/mobileUpload/index.d.ts +5 -0
- package/dist/types-ts4.5/utils/mobileUpload/servicesCache.d.ts +4 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +7 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
- package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +69 -0
- package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
- package/dist/types-ts4.5/utils/polling/errors.d.ts +12 -0
- package/dist/types-ts4.5/utils/polling/index.d.ts +33 -0
- package/dist/types-ts4.5/utils/polling/types.d.ts +7 -0
- package/dist/types-ts4.5/utils/request/errors.d.ts +20 -0
- package/dist/types-ts4.5/utils/request/helpers.d.ts +46 -0
- package/dist/types-ts4.5/utils/request/index.d.ts +5 -0
- package/dist/types-ts4.5/utils/request/types.d.ts +46 -0
- package/dist/types-ts4.5/utils/safeUnsubscribe.d.ts +2 -0
- package/dist/types-ts4.5/utils/setTimeoutPromise.d.ts +2 -0
- package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +14 -0
- package/dist/types-ts4.5/utils/url.d.ts +17 -0
- package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +15 -0
- package/package.json +2 -2
- package/tmp/api-report-tmp.d.ts +1225 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 24.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41501](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41501) [`b3cb749dc67`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3cb749dc67) - Fix TS errors in AFM
|
|
8
|
+
|
|
3
9
|
## 24.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare class FileFetcher {
|
|
3
|
+
constructor();
|
|
4
|
+
getFileState: jest.Mock<any, any>;
|
|
5
|
+
getCurrentState: jest.Mock<any, any>;
|
|
6
|
+
getArtifactURL: jest.Mock<any, any>;
|
|
7
|
+
touchFiles: jest.Mock<any, any>;
|
|
8
|
+
upload: jest.Mock<any, any>;
|
|
9
|
+
downloadBinary: jest.Mock<any, any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
+
import { FileFetcher } from '../file-fetcher';
|
|
4
|
+
export declare class MediaClient {
|
|
5
|
+
readonly config: MediaClientConfig;
|
|
6
|
+
readonly file: FileFetcher;
|
|
7
|
+
constructor(config: MediaClientConfig);
|
|
8
|
+
getImage: jest.Mock<any, any>;
|
|
9
|
+
getImageUrl: jest.Mock<any, any>;
|
|
10
|
+
getImageMetadata: jest.Mock<any, any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FileState } from '@atlaskit/media-state';
|
|
2
|
+
export type EventPayloadMap<P> = {
|
|
3
|
+
readonly [event: string]: P;
|
|
4
|
+
};
|
|
5
|
+
export type EventPayloadListener<M extends EventPayloadMap<P>, E extends keyof M, P = any> = (payload: M[E]) => void;
|
|
6
|
+
export interface MediaViewedEventPayload {
|
|
7
|
+
fileId: string;
|
|
8
|
+
viewingLevel: 'minimal' | 'full' | 'download';
|
|
9
|
+
isUserCollection?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type UploadEventPayloadMap = {
|
|
12
|
+
'file-added': FileState;
|
|
13
|
+
'media-viewed': MediaViewedEventPayload;
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile' | 'emptyFileName';
|
|
3
|
+
export type FileFetcherErrorAttributes = {
|
|
4
|
+
readonly reason: FileFetcherErrorReason;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly metadata?: {
|
|
7
|
+
readonly collectionName?: string;
|
|
8
|
+
readonly occurrenceKey?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare class FileFetcherError extends BaseMediaClientError<FileFetcherErrorAttributes> {
|
|
12
|
+
readonly reason: FileFetcherErrorReason;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly metadata?: {
|
|
15
|
+
readonly collectionName?: string | undefined;
|
|
16
|
+
readonly occurrenceKey?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
constructor(reason: FileFetcherErrorReason, id: string, metadata?: {
|
|
19
|
+
readonly collectionName?: string | undefined;
|
|
20
|
+
readonly occurrenceKey?: string | undefined;
|
|
21
|
+
} | undefined);
|
|
22
|
+
get attributes(): {
|
|
23
|
+
reason: FileFetcherErrorReason;
|
|
24
|
+
id: string;
|
|
25
|
+
collectionName: string | undefined;
|
|
26
|
+
occurrenceKey: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function isFileFetcherError(err: Error): err is FileFetcherError;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import 'setimmediate';
|
|
2
|
+
import { AuthProvider } from '@atlaskit/media-core';
|
|
3
|
+
import { MediaFileArtifacts } from '@atlaskit/media-state';
|
|
4
|
+
import { MediaStore as MediaApi, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
|
|
5
|
+
import { GetFileOptions } from '../../models/file-state';
|
|
6
|
+
import { MediaFile } from '../../models/media';
|
|
7
|
+
import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
|
|
8
|
+
import { UploadController } from '../../upload-controller';
|
|
9
|
+
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
|
+
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
12
|
+
import { FilePreview, FileState, MediaStore } from '@atlaskit/media-state';
|
|
13
|
+
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
14
|
+
export { isFileFetcherError, FileFetcherError } from './error';
|
|
15
|
+
export interface CopySourceFile {
|
|
16
|
+
id: string;
|
|
17
|
+
collection?: string;
|
|
18
|
+
authProvider: AuthProvider;
|
|
19
|
+
}
|
|
20
|
+
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
21
|
+
authProvider: AuthProvider;
|
|
22
|
+
mediaStore?: MediaApi;
|
|
23
|
+
}
|
|
24
|
+
export interface CopyFileOptions {
|
|
25
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
26
|
+
mimeType?: string;
|
|
27
|
+
}
|
|
28
|
+
export type ExternalUploadPayload = {
|
|
29
|
+
uploadableFileUpfrontIds: UploadableFileUpfrontIds;
|
|
30
|
+
dimensions: Dimensions;
|
|
31
|
+
};
|
|
32
|
+
export interface FileFetcher {
|
|
33
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
34
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
35
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
36
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
37
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
38
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
39
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
40
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
41
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
42
|
+
}
|
|
43
|
+
export declare class FileFetcherImpl implements FileFetcher {
|
|
44
|
+
private readonly mediaApi;
|
|
45
|
+
private readonly store;
|
|
46
|
+
private readonly dataloader;
|
|
47
|
+
constructor(mediaApi: MediaApi, store?: MediaStore);
|
|
48
|
+
private getErrorFileState;
|
|
49
|
+
private setFileState;
|
|
50
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
51
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
52
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
53
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
54
|
+
private createDownloadFileStream;
|
|
55
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
56
|
+
private generateUploadableFileUpfrontIds;
|
|
57
|
+
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
58
|
+
private getUploadingFileStateBase;
|
|
59
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
|
|
60
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
61
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
2
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
+
import { MediaStore as MediaApi, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
|
|
4
|
+
import { FileFetcher } from './file-fetcher';
|
|
5
|
+
import { UploadEventPayloadMap, EventPayloadListener } from './events';
|
|
6
|
+
import { StargateClient } from './stargate-client';
|
|
7
|
+
import { MobileUpload } from '../models/mobile-upload';
|
|
8
|
+
import { MediaStore } from '@atlaskit/media-state';
|
|
9
|
+
export declare class MediaClient {
|
|
10
|
+
readonly mediaClientConfig: MediaClientConfig;
|
|
11
|
+
private readonly store;
|
|
12
|
+
readonly mediaStore: MediaApi;
|
|
13
|
+
readonly file: FileFetcher;
|
|
14
|
+
readonly stargate: StargateClient;
|
|
15
|
+
private readonly eventEmitter;
|
|
16
|
+
private mobileUpload?;
|
|
17
|
+
readonly config: MediaClientConfig;
|
|
18
|
+
constructor(mediaClientConfig: MediaClientConfig, store?: MediaStore, mediaApi?: MediaApi);
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
__DO_NOT_USE__getMediaStore(): MediaStore;
|
|
23
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
24
|
+
getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
25
|
+
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
26
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|
|
27
|
+
mobileUploadPromise(): Promise<MobileUpload>;
|
|
28
|
+
removeFileFromCollection(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
29
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
30
|
+
off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
31
|
+
emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export type MediaStoreErrorReason = 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut';
|
|
3
|
+
export type MediaStoreErrorAttributes = {
|
|
4
|
+
readonly reason: MediaStoreErrorReason;
|
|
5
|
+
readonly innerError?: Error;
|
|
6
|
+
};
|
|
7
|
+
export declare class MediaStoreError extends BaseMediaClientError<MediaStoreErrorAttributes> {
|
|
8
|
+
readonly reason: MediaStoreErrorReason;
|
|
9
|
+
readonly innerError?: Error | undefined;
|
|
10
|
+
constructor(reason: MediaStoreErrorReason, innerError?: Error | undefined);
|
|
11
|
+
get attributes(): {
|
|
12
|
+
reason: MediaStoreErrorReason;
|
|
13
|
+
innerError: Error | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function isMediaStoreError(err: Error): err is MediaStoreError;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
|
|
2
|
+
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
+
import { MediaFileArtifacts } from '@atlaskit/media-state';
|
|
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
|
+
constructor(config: MediaApiConfig);
|
|
11
|
+
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
12
|
+
createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
13
|
+
uploadChunk(etag: string, blob: Blob, uploadId: string, partNumber: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
14
|
+
probeChunks(chunks: string[], uploadId: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
15
|
+
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
16
|
+
getRejectedResponseFromDescriptor(descriptor: TouchFileDescriptor, limit: number): RejectedTouchFile;
|
|
17
|
+
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
18
|
+
getFile(fileId: string, params?: MediaStoreGetFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
19
|
+
getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
20
|
+
getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
21
|
+
private createFileImageURL;
|
|
22
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
23
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
24
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
|
|
25
|
+
getItems(ids: string[], collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
26
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext): Promise<{
|
|
27
|
+
metadata: ImageMetadata;
|
|
28
|
+
}>;
|
|
29
|
+
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
30
|
+
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
31
|
+
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
|
|
32
|
+
resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
|
|
33
|
+
resolveInitialAuth: () => Auth;
|
|
34
|
+
}
|
|
35
|
+
export declare const getMediaEnvironment: () => string | undefined;
|
|
36
|
+
export declare const getMediaRegion: () => string | undefined;
|
|
37
|
+
export interface ResponseFileItem {
|
|
38
|
+
id: string;
|
|
39
|
+
type: 'file';
|
|
40
|
+
details: MediaItemDetails;
|
|
41
|
+
collection?: string;
|
|
42
|
+
metadataTraceContext?: MediaTraceContext;
|
|
43
|
+
}
|
|
44
|
+
export interface ItemsPayload {
|
|
45
|
+
items: ResponseFileItem[];
|
|
46
|
+
}
|
|
47
|
+
export type ImageMetadataArtifact = {
|
|
48
|
+
url?: string;
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
51
|
+
size?: number;
|
|
52
|
+
};
|
|
53
|
+
export interface ImageMetadata {
|
|
54
|
+
pending: boolean;
|
|
55
|
+
preview?: ImageMetadataArtifact;
|
|
56
|
+
original?: ImageMetadataArtifact;
|
|
57
|
+
}
|
|
58
|
+
export interface MediaStoreResponse<Data> {
|
|
59
|
+
readonly data: Data;
|
|
60
|
+
}
|
|
61
|
+
export type MediaStoreRequestOptions = RequestMetadata & {
|
|
62
|
+
readonly method?: RequestMethod;
|
|
63
|
+
readonly authContext?: AuthContext;
|
|
64
|
+
readonly params?: RequestParams;
|
|
65
|
+
readonly headers?: RequestHeaders;
|
|
66
|
+
readonly body?: any;
|
|
67
|
+
readonly clientOptions?: ClientOptions;
|
|
68
|
+
readonly traceContext?: MediaTraceContext;
|
|
69
|
+
};
|
|
70
|
+
export type MediaStoreCreateFileFromUploadParams = {
|
|
71
|
+
readonly collection?: string;
|
|
72
|
+
readonly occurrenceKey?: string;
|
|
73
|
+
readonly expireAfter?: number;
|
|
74
|
+
readonly replaceFileId?: string;
|
|
75
|
+
readonly skipConversions?: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type MediaStoreCreateFileParams = {
|
|
78
|
+
readonly occurrenceKey?: string;
|
|
79
|
+
readonly collection?: string;
|
|
80
|
+
};
|
|
81
|
+
export interface MediaStoreTouchFileParams {
|
|
82
|
+
readonly collection?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface TouchFileDescriptor {
|
|
85
|
+
fileId: string;
|
|
86
|
+
collection?: string;
|
|
87
|
+
occurrenceKey?: string;
|
|
88
|
+
expireAfter?: number;
|
|
89
|
+
deletable?: boolean;
|
|
90
|
+
size?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface MediaStoreTouchFileBody {
|
|
93
|
+
descriptors: TouchFileDescriptor[];
|
|
94
|
+
}
|
|
95
|
+
export type MediaStoreCreateFileFromBinaryParams = {
|
|
96
|
+
readonly replaceFileId?: string;
|
|
97
|
+
readonly collection?: string;
|
|
98
|
+
readonly occurrenceKey?: string;
|
|
99
|
+
readonly expireAfter?: number;
|
|
100
|
+
readonly skipConversions?: boolean;
|
|
101
|
+
readonly name?: string;
|
|
102
|
+
};
|
|
103
|
+
export type MediaStoreCreateFileFromUploadConditions = {
|
|
104
|
+
readonly hash?: string;
|
|
105
|
+
readonly size?: number;
|
|
106
|
+
};
|
|
107
|
+
export type MediaStoreCreateFileFromUploadBody = {
|
|
108
|
+
readonly uploadId: string;
|
|
109
|
+
readonly name?: string;
|
|
110
|
+
readonly mimeType?: string;
|
|
111
|
+
readonly conditions?: MediaStoreCreateFileFromUploadConditions;
|
|
112
|
+
};
|
|
113
|
+
export type MediaStoreGetFileParams = {
|
|
114
|
+
readonly version?: number;
|
|
115
|
+
readonly collection?: string;
|
|
116
|
+
};
|
|
117
|
+
export type MediaStoreGetFileImageParams = {
|
|
118
|
+
readonly allowAnimated?: boolean;
|
|
119
|
+
readonly version?: number;
|
|
120
|
+
readonly collection?: string;
|
|
121
|
+
readonly width?: number;
|
|
122
|
+
readonly height?: number;
|
|
123
|
+
readonly mode?: 'fit' | 'full-fit' | 'crop';
|
|
124
|
+
readonly upscale?: boolean;
|
|
125
|
+
readonly 'max-age'?: number;
|
|
126
|
+
};
|
|
127
|
+
export interface SourceFile {
|
|
128
|
+
id: string;
|
|
129
|
+
owner: ClientAltBasedAuth | AsapBasedAuth;
|
|
130
|
+
collection?: string;
|
|
131
|
+
version?: number;
|
|
132
|
+
}
|
|
133
|
+
export type MediaStoreCopyFileWithTokenBody = {
|
|
134
|
+
sourceFile: SourceFile;
|
|
135
|
+
};
|
|
136
|
+
export type MediaStoreCopyFileWithTokenParams = {
|
|
137
|
+
readonly collection?: string;
|
|
138
|
+
readonly replaceFileId?: string;
|
|
139
|
+
readonly occurrenceKey?: string;
|
|
140
|
+
};
|
|
141
|
+
export type AppendChunksToUploadRequestBody = {
|
|
142
|
+
readonly chunks: string[];
|
|
143
|
+
readonly hash?: string;
|
|
144
|
+
readonly offset?: number;
|
|
145
|
+
};
|
|
146
|
+
export interface CreatedTouchedFile {
|
|
147
|
+
fileId: string;
|
|
148
|
+
uploadId: string;
|
|
149
|
+
}
|
|
150
|
+
export interface RejectedTouchFile {
|
|
151
|
+
fileId: string;
|
|
152
|
+
error: RejectionError;
|
|
153
|
+
}
|
|
154
|
+
export type RejectionError = {
|
|
155
|
+
code: 'ExceedMaxFileSizeLimit';
|
|
156
|
+
title: string;
|
|
157
|
+
href: string;
|
|
158
|
+
limit: number;
|
|
159
|
+
size: number;
|
|
160
|
+
};
|
|
161
|
+
export type TouchedFiles = {
|
|
162
|
+
created: CreatedTouchedFile[];
|
|
163
|
+
rejected?: RejectedTouchFile[];
|
|
164
|
+
};
|
|
165
|
+
export interface EmptyFile {
|
|
166
|
+
readonly id: string;
|
|
167
|
+
readonly createdAt: number;
|
|
168
|
+
}
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { MediaStore } from '@atlaskit/media-state';
|
|
2
|
+
import { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent } from '../models/mobile-upload';
|
|
3
|
+
import { MediaStore as MediaApi } from './media-store';
|
|
4
|
+
export declare class MobileUploadImpl implements MobileUpload {
|
|
5
|
+
private readonly store;
|
|
6
|
+
private readonly dataloader;
|
|
7
|
+
private readonly servicesCache;
|
|
8
|
+
constructor(mediaApi: MediaApi, store?: MediaStore);
|
|
9
|
+
notifyUploadStart(event: MobileUploadStartEvent): void;
|
|
10
|
+
notifyUploadProgress(event: MobileUploadProgressEvent): void;
|
|
11
|
+
notifyUploadEnd(event: MobileUploadEndEvent): void;
|
|
12
|
+
notifyUploadError(event: MobileUploadErrorEvent): void;
|
|
13
|
+
private getErrorFileState;
|
|
14
|
+
private setFileState;
|
|
15
|
+
}
|
|
@@ -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 '@atlaskit/media-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,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, 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 { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
10
|
+
export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
|
|
11
|
+
export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
|
|
12
|
+
export type { FileStatus, PreviewOptions, GetFileOptions, NonErrorFileState, PreviewableFileState, } from './models/file-state';
|
|
13
|
+
export type { FileState, FilePreview, ErrorFileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, MediaFileArtifact, MediaFileArtifacts, } from '@atlaskit/media-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, createRequestErrorReason, } 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 type { MediaClientConfig } from '@atlaskit/media-core';
|
|
43
|
+
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
44
|
+
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
|
|
45
|
+
export type { MediaBlobUrlAttrs } from './utils/url';
|
|
46
|
+
export { createMediaSubscribable, fromObservable, } from './utils/mediaSubscribable';
|
|
47
|
+
export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
|
|
48
|
+
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
49
|
+
export { getFileStreamsCache } from './file-streams-cache';
|
|
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,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
|
+
}
|