@atlaskit/media-client 20.2.1 → 21.1.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.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +275 -287
- package/dist/cjs/client/media-client.js +48 -34
- package/dist/cjs/client/media-store/index.js +367 -314
- package/dist/cjs/client/media-store/resolveAuth.js +30 -32
- package/dist/cjs/client/stargate-client.js +14 -16
- package/dist/cjs/index.js +6 -13
- package/dist/cjs/models/media.js +8 -9
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +88 -96
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +67 -70
- package/dist/cjs/utils/getDimensionsFromBlob.js +23 -25
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/cjs/utils/hashing/hasherCreator.js +32 -34
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +41 -43
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +40 -42
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +143 -155
- package/dist/cjs/utils/request/index.js +24 -26
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-client.js +3 -2
- package/dist/es2019/client/media-store/index.js +58 -15
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/models/media.js +6 -4
- package/dist/es2019/uploader/index.js +3 -0
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +273 -286
- package/dist/esm/client/media-client.js +46 -32
- package/dist/esm/client/media-store/index.js +367 -314
- package/dist/esm/client/media-store/resolveAuth.js +30 -32
- package/dist/esm/client/stargate-client.js +14 -16
- package/dist/esm/index.js +2 -3
- package/dist/esm/models/media.js +6 -6
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +89 -96
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +65 -69
- package/dist/esm/utils/getDimensionsFromBlob.js +23 -25
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/esm/utils/hashing/hasherCreator.js +28 -30
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +41 -43
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +40 -42
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +143 -155
- package/dist/esm/utils/request/index.js +24 -26
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/esm/version.json +1 -1
- package/dist/types/client/__mocks__/media-client.d.ts +0 -2
- package/dist/types/client/file-fetcher/index.d.ts +4 -4
- package/dist/types/client/media-client.d.ts +1 -2
- package/dist/types/client/media-store/index.d.ts +17 -13
- package/dist/types/index.d.ts +4 -6
- package/dist/types/models/file-state.d.ts +2 -2
- package/dist/types/models/media.d.ts +1 -21
- package/dist/types/utils/createFileDataLoader.d.ts +2 -2
- package/dist/types/utils/createMediaSubject.d.ts +2 -2
- package/dist/types/utils/detectEmptyFile.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
- package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +77 -126
- package/dist/cjs/client/collection-fetcher.js +0 -98
- package/dist/cjs/models/media-subscribable.js +0 -5
- package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
- package/dist/es2019/client/collection-fetcher.js +0 -38
- package/dist/es2019/models/media-subscribable.js +0 -1
- package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
- package/dist/esm/client/collection-fetcher.js +0 -89
- package/dist/esm/models/media-subscribable.js +0 -1
- package/dist/esm/utils/deprecatedEndpointError.js +0 -34
- package/dist/types/client/collection-fetcher.d.ts +0 -42
- package/dist/types/models/media-subscribable.d.ts +0 -3
- package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
|
|
2
2
|
import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
4
|
-
import { MediaChunksProbe,
|
|
4
|
+
import { MediaChunksProbe, MediaItemDetails, MediaFile, MediaUpload } from '../../models/media';
|
|
5
5
|
import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata } from '../../utils/request/types';
|
|
6
6
|
export type { MediaStoreErrorReason, MediaStoreErrorAttributes } from './error';
|
|
7
7
|
export { MediaStoreError, isMediaStoreError } from './error';
|
|
@@ -9,16 +9,12 @@ export declare class MediaStore {
|
|
|
9
9
|
private readonly config;
|
|
10
10
|
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
11
11
|
constructor(config: MediaApiConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-170 Internal documentation for deprecation (no external access)}
|
|
14
|
-
* This method is no longer working. Will be removed in the next release
|
|
15
|
-
*/
|
|
16
|
-
getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
17
12
|
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
18
13
|
createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
19
14
|
uploadChunk(etag: string, blob: Blob, uploadId: string, partNumber: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
20
15
|
probeChunks(chunks: string[], uploadId: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
21
16
|
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
17
|
+
getRejectedResponseFromDescriptor(descriptor: TouchFileDescriptor, limit: number): RejectedTouchFile;
|
|
22
18
|
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
23
19
|
getFile(fileId: string, params?: MediaStoreGetFileParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
|
|
24
20
|
getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
@@ -42,7 +38,7 @@ export declare const getMediaRegion: () => string | undefined;
|
|
|
42
38
|
export interface ResponseFileItem {
|
|
43
39
|
id: string;
|
|
44
40
|
type: 'file';
|
|
45
|
-
details:
|
|
41
|
+
details: MediaItemDetails;
|
|
46
42
|
collection?: string;
|
|
47
43
|
metadataTraceContext?: MediaTraceContext;
|
|
48
44
|
}
|
|
@@ -71,6 +67,7 @@ export declare type MediaStoreRequestOptions = RequestMetadata & {
|
|
|
71
67
|
readonly body?: any;
|
|
72
68
|
readonly clientOptions?: ClientOptions;
|
|
73
69
|
readonly traceContext?: MediaTraceContext;
|
|
70
|
+
readonly resolvedAuth?: Auth;
|
|
74
71
|
};
|
|
75
72
|
export declare type MediaStoreCreateFileFromUploadParams = {
|
|
76
73
|
readonly collection?: string;
|
|
@@ -92,6 +89,7 @@ export interface TouchFileDescriptor {
|
|
|
92
89
|
occurrenceKey?: string;
|
|
93
90
|
expireAfter?: number;
|
|
94
91
|
deletable?: boolean;
|
|
92
|
+
size?: number;
|
|
95
93
|
}
|
|
96
94
|
export interface MediaStoreTouchFileBody {
|
|
97
95
|
descriptors: TouchFileDescriptor[];
|
|
@@ -128,12 +126,6 @@ export declare type MediaStoreGetFileImageParams = {
|
|
|
128
126
|
readonly upscale?: boolean;
|
|
129
127
|
readonly 'max-age'?: number;
|
|
130
128
|
};
|
|
131
|
-
export declare type MediaStoreGetCollectionItemsParams = {
|
|
132
|
-
readonly limit?: number;
|
|
133
|
-
readonly inclusiveStartKey?: string;
|
|
134
|
-
readonly sortDirection?: 'asc' | 'desc';
|
|
135
|
-
readonly details?: 'minimal' | 'full';
|
|
136
|
-
};
|
|
137
129
|
export interface SourceFile {
|
|
138
130
|
id: string;
|
|
139
131
|
owner: ClientAltBasedAuth | AsapBasedAuth;
|
|
@@ -157,8 +149,20 @@ export interface CreatedTouchedFile {
|
|
|
157
149
|
fileId: string;
|
|
158
150
|
uploadId: string;
|
|
159
151
|
}
|
|
152
|
+
export interface RejectedTouchFile {
|
|
153
|
+
fileId: string;
|
|
154
|
+
error: RejectionError;
|
|
155
|
+
}
|
|
156
|
+
export declare type RejectionError = {
|
|
157
|
+
code: 'ExceedMaxFileSizeLimit';
|
|
158
|
+
title: string;
|
|
159
|
+
href: string;
|
|
160
|
+
limit: number;
|
|
161
|
+
size: number;
|
|
162
|
+
};
|
|
160
163
|
export declare type TouchedFiles = {
|
|
161
164
|
created: CreatedTouchedFile[];
|
|
165
|
+
rejected: RejectedTouchFile[];
|
|
162
166
|
};
|
|
163
167
|
export interface EmptyFile {
|
|
164
168
|
readonly id: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
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,
|
|
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
3
|
export { UploadController } from './upload-controller';
|
|
4
4
|
export type { AbortFunction } from './upload-controller';
|
|
5
5
|
export type { MediaItemType, FileItem, FileProcessingStatus, MediaArtifact, Artifacts, FileDetails, } from './models/item';
|
|
6
|
-
export { isPreviewableType
|
|
7
|
-
export type { MediaFileProcessingStatus, MediaType, MediaFile,
|
|
8
|
-
export type { MediaSubscribableItem } from './models/media-subscribable';
|
|
6
|
+
export { isPreviewableType } from './models/media';
|
|
7
|
+
export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaRepresentations, MediaItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
|
|
9
8
|
export { getArtifactUrl } from './models/artifacts';
|
|
10
9
|
export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
|
|
11
10
|
export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
@@ -26,7 +25,6 @@ export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
|
|
|
26
25
|
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
27
26
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
|
|
28
27
|
export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
|
|
29
|
-
export { CollectionFetcher } from './client/collection-fetcher';
|
|
30
28
|
export { MediaClient } from './client/media-client';
|
|
31
29
|
export { StargateClient } from './client/stargate-client';
|
|
32
30
|
export type { EdgeData } from './client/stargate-client';
|
|
@@ -44,7 +42,7 @@ export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClient
|
|
|
44
42
|
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
45
43
|
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
|
|
46
44
|
export type { MediaBlobUrlAttrs } from './utils/url';
|
|
47
|
-
export { createMediaSubscribable } from './utils/mediaSubscribable';
|
|
45
|
+
export { createMediaSubscribable, fromObservable, } from './utils/mediaSubscribable';
|
|
48
46
|
export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
|
|
49
47
|
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
50
48
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileStatus as CommonFileStatus, MediaTraceContext } from '@atlaskit/media-common';
|
|
2
2
|
import { MediaStoreResponse } from '../client/media-store';
|
|
3
3
|
import { MediaFileArtifacts } from './artifacts';
|
|
4
|
-
import {
|
|
4
|
+
import { MediaItemDetails, MediaFile, MediaRepresentations, MediaType } from './media';
|
|
5
5
|
export declare type BaseFileState = {
|
|
6
6
|
metadataTraceContext?: MediaTraceContext;
|
|
7
7
|
};
|
|
@@ -91,4 +91,4 @@ export declare const isPreviewableFileState: (fileState: FileState) => fileState
|
|
|
91
91
|
export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
|
|
92
92
|
export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
|
|
93
93
|
export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
|
|
94
|
-
export declare const mapMediaItemToFileState: (id: string, item:
|
|
94
|
+
export declare const mapMediaItemToFileState: (id: string, item: MediaItemDetails) => FileState;
|
|
@@ -15,25 +15,7 @@ export declare type MediaFile = {
|
|
|
15
15
|
readonly createdAt?: number;
|
|
16
16
|
readonly metadataTraceContext?: MediaTraceContext;
|
|
17
17
|
};
|
|
18
|
-
export declare type
|
|
19
|
-
readonly name: string;
|
|
20
|
-
readonly createdAt: number;
|
|
21
|
-
};
|
|
22
|
-
export declare type MediaCollectionItems = {
|
|
23
|
-
readonly contents: MediaCollectionItem[];
|
|
24
|
-
readonly nextInclusiveStartKey?: string;
|
|
25
|
-
};
|
|
26
|
-
export declare type MediaCollectionItem = {
|
|
27
|
-
readonly id: string;
|
|
28
|
-
readonly insertedAt: number;
|
|
29
|
-
readonly occurrenceKey: string;
|
|
30
|
-
readonly details: MediaCollectionItemDetails;
|
|
31
|
-
};
|
|
32
|
-
export declare type MediaCollectionItemMinimalDetails = {
|
|
33
|
-
readonly name: string;
|
|
34
|
-
readonly size: number;
|
|
35
|
-
};
|
|
36
|
-
export declare type MediaCollectionItemFullDetails = {
|
|
18
|
+
export declare type MediaItemDetails = {
|
|
37
19
|
readonly mediaType: MediaType;
|
|
38
20
|
readonly mimeType: string;
|
|
39
21
|
readonly name: string;
|
|
@@ -47,8 +29,6 @@ export declare type MediaCollectionItemFullDetails = {
|
|
|
47
29
|
export declare type MediaRepresentations = {
|
|
48
30
|
image?: Object;
|
|
49
31
|
};
|
|
50
|
-
export declare type MediaCollectionItemDetails = MediaCollectionItemMinimalDetails | MediaCollectionItemFullDetails;
|
|
51
|
-
export declare const isMediaCollectionItemFullDetails: (mediaCollectionItem: MediaCollectionItemDetails) => mediaCollectionItem is MediaCollectionItemFullDetails;
|
|
52
32
|
export declare type MediaUpload = {
|
|
53
33
|
readonly id: string;
|
|
54
34
|
readonly created: number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import 'setimmediate';
|
|
2
2
|
import Dataloader from 'dataloader';
|
|
3
3
|
import { MediaStore, ResponseFileItem } from '../client/media-store';
|
|
4
|
-
import {
|
|
4
|
+
import { MediaItemDetails } from '../models/media';
|
|
5
5
|
export declare const MAX_BATCH_SIZE = 100;
|
|
6
6
|
export declare type DataloaderKey = {
|
|
7
7
|
readonly id: string;
|
|
8
8
|
readonly collectionName?: string;
|
|
9
9
|
};
|
|
10
|
-
export declare type DataloaderResult =
|
|
10
|
+
export declare type DataloaderResult = MediaItemDetails | null;
|
|
11
11
|
export declare type BatchLoadingErrorResult = {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly collection?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
import {
|
|
3
|
-
export declare function createMediaSubject<T extends
|
|
2
|
+
import { FileState } from '../models/file-state';
|
|
3
|
+
export declare function createMediaSubject<T extends FileState>(initialState?: T | Error): ReplaySubject<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MediaItemDetails } from '../models/media';
|
|
2
2
|
/**
|
|
3
3
|
* EMPTY_FILE_HOURS_ELAPSED_TOLERANCE - how many hours since this file was
|
|
4
4
|
* created until we give up on expecting metadata?
|
|
@@ -13,4 +13,4 @@ import { MediaCollectionItemFullDetails } from '../models/media';
|
|
|
13
13
|
* Being encapsulated in this function, we can always improve the detection transparently.
|
|
14
14
|
*/
|
|
15
15
|
export declare const EMPTY_FILE_HOURS_ELAPSED_TOLERANCE_MS: number;
|
|
16
|
-
export declare function isEmptyFile(fileDetails:
|
|
16
|
+
export declare function isEmptyFile(fileDetails: MediaItemDetails, now?: number): Boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
import {
|
|
2
|
+
import { FileState } from '../../models/file-state';
|
|
3
3
|
import { MediaSubscribable } from './types';
|
|
4
|
-
export declare function fromObservable
|
|
5
|
-
export declare function createMediaSubscribable
|
|
4
|
+
export declare function fromObservable(observable: ReplaySubject<FileState>): MediaSubscribable;
|
|
5
|
+
export declare function createMediaSubscribable(item?: FileState | Error): MediaSubscribable;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Subscription } from 'rxjs/Subscription';
|
|
2
2
|
import { MediaSubscribable } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { FileState } from '../../models/file-state';
|
|
4
4
|
/**
|
|
5
5
|
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
6
6
|
*
|
|
7
7
|
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
8
8
|
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
9
9
|
*/
|
|
10
|
-
export declare const toPromise:
|
|
10
|
+
export declare const toPromise: (mediaSubscribable: MediaSubscribable, subscription?: Subscription) => Promise<FileState>;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { FileState } from '../../models/file-state';
|
|
1
2
|
export declare type MediaSubscription = {
|
|
2
3
|
unsubscribe: () => void;
|
|
3
4
|
};
|
|
4
|
-
declare type PartialObserver
|
|
5
|
-
next?: (value:
|
|
5
|
+
declare type PartialObserver = {
|
|
6
|
+
next?: (value: FileState) => void;
|
|
6
7
|
error?: (err: any) => void;
|
|
7
8
|
complete?: () => void;
|
|
8
9
|
};
|
|
9
|
-
export declare type NextObserver
|
|
10
|
-
export declare type ErrorObserver
|
|
11
|
-
export declare type CompletionObserver
|
|
12
|
-
export declare type MediaObserver
|
|
13
|
-
export declare type MediaSubscribable
|
|
14
|
-
subscribe(observer?: MediaObserver
|
|
10
|
+
export declare type NextObserver = PartialObserver & Required<Pick<PartialObserver, 'next'>>;
|
|
11
|
+
export declare type ErrorObserver = PartialObserver & Required<Pick<PartialObserver, 'error'>>;
|
|
12
|
+
export declare type CompletionObserver = PartialObserver & Required<Pick<PartialObserver, 'complete'>>;
|
|
13
|
+
export declare type MediaObserver = NextObserver | ErrorObserver | CompletionObserver | ((value: FileState) => void);
|
|
14
|
+
export declare type MediaSubscribable = {
|
|
15
|
+
subscribe(observer?: MediaObserver): MediaSubscription;
|
|
15
16
|
};
|
|
16
17
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (token: string): unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.1.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/docs": "*",
|
|
52
52
|
"@atlaskit/media-card": "^74.7.0",
|
|
53
53
|
"@atlaskit/media-core": "^34.0.0",
|
|
54
|
-
"@atlaskit/media-test-helpers": "^
|
|
54
|
+
"@atlaskit/media-test-helpers": "^32.1.0",
|
|
55
55
|
"@atlaskit/ssr": "*",
|
|
56
56
|
"@atlaskit/tokens": "^1.2.0",
|
|
57
57
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
package/report.api.md
CHANGED
|
@@ -80,34 +80,8 @@ export type ClientOptions = {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
// @public (undocumented)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// @deprecated (undocumented)
|
|
86
|
-
getItems(
|
|
87
|
-
collectionName: string,
|
|
88
|
-
params?: MediaStoreGetCollectionItemsParams,
|
|
89
|
-
traceContext?: MediaTraceContext,
|
|
90
|
-
): MediaSubscribable<MediaCollectionItem[]>;
|
|
91
|
-
// @deprecated (undocumented)
|
|
92
|
-
loadNextPage(
|
|
93
|
-
collectionName: string,
|
|
94
|
-
params?: MediaStoreGetCollectionItemsParams,
|
|
95
|
-
traceContext?: MediaTraceContext,
|
|
96
|
-
): Promise<void>;
|
|
97
|
-
// (undocumented)
|
|
98
|
-
readonly mediaStore: MediaStore;
|
|
99
|
-
// (undocumented)
|
|
100
|
-
removeFile(
|
|
101
|
-
id: string,
|
|
102
|
-
collectionName: string,
|
|
103
|
-
occurrenceKey?: string,
|
|
104
|
-
traceContext?: MediaTraceContext,
|
|
105
|
-
): Promise<void>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// @public (undocumented)
|
|
109
|
-
type CompletionObserver<T> = PartialObserver<T> &
|
|
110
|
-
Required<Pick<PartialObserver<T>, 'complete'>>;
|
|
83
|
+
type CompletionObserver = PartialObserver &
|
|
84
|
+
Required<Pick<PartialObserver, 'complete'>>;
|
|
111
85
|
|
|
112
86
|
// @public (undocumented)
|
|
113
87
|
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
@@ -144,14 +118,14 @@ export interface CreatedTouchedFile {
|
|
|
144
118
|
}
|
|
145
119
|
|
|
146
120
|
// @public (undocumented)
|
|
147
|
-
export function createMediaSubject<T extends
|
|
121
|
+
export function createMediaSubject<T extends FileState>(
|
|
148
122
|
initialState?: Error | T,
|
|
149
123
|
): ReplaySubject<T>;
|
|
150
124
|
|
|
151
125
|
// @public (undocumented)
|
|
152
|
-
export function createMediaSubscribable
|
|
153
|
-
|
|
154
|
-
): MediaSubscribable
|
|
126
|
+
export function createMediaSubscribable(
|
|
127
|
+
item?: Error | FileState,
|
|
128
|
+
): MediaSubscribable;
|
|
155
129
|
|
|
156
130
|
// @public (undocumented)
|
|
157
131
|
export function createUrl(
|
|
@@ -204,8 +178,7 @@ export interface ErrorFileState extends BaseFileState {
|
|
|
204
178
|
}
|
|
205
179
|
|
|
206
180
|
// @public (undocumented)
|
|
207
|
-
type ErrorObserver
|
|
208
|
-
Required<Pick<PartialObserver<T>, 'error'>>;
|
|
181
|
+
type ErrorObserver = PartialObserver & Required<Pick<PartialObserver, 'error'>>;
|
|
209
182
|
|
|
210
183
|
// @public (undocumented)
|
|
211
184
|
export type EventPayloadListener<
|
|
@@ -286,10 +259,7 @@ export interface FileFetcher {
|
|
|
286
259
|
// (undocumented)
|
|
287
260
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
288
261
|
// (undocumented)
|
|
289
|
-
getFileState(
|
|
290
|
-
id: string,
|
|
291
|
-
options?: GetFileOptions,
|
|
292
|
-
): MediaSubscribable<FileState>;
|
|
262
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
293
263
|
// (undocumented)
|
|
294
264
|
touchFiles(
|
|
295
265
|
descriptors: TouchFileDescriptor[],
|
|
@@ -302,7 +272,8 @@ export interface FileFetcher {
|
|
|
302
272
|
controller?: UploadController,
|
|
303
273
|
uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
|
|
304
274
|
traceContext?: MediaTraceContext,
|
|
305
|
-
|
|
275
|
+
featureFlags?: MediaFeatureFlags,
|
|
276
|
+
): MediaSubscribable;
|
|
306
277
|
// (undocumented)
|
|
307
278
|
uploadExternal(
|
|
308
279
|
url: string,
|
|
@@ -389,10 +360,7 @@ export class FileFetcherImpl implements FileFetcher {
|
|
|
389
360
|
// (undocumented)
|
|
390
361
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
391
362
|
// (undocumented)
|
|
392
|
-
getFileState(
|
|
393
|
-
id: string,
|
|
394
|
-
options?: GetFileOptions,
|
|
395
|
-
): MediaSubscribable<FileState>;
|
|
363
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
396
364
|
// (undocumented)
|
|
397
365
|
touchFiles(
|
|
398
366
|
descriptors: TouchFileDescriptor[],
|
|
@@ -405,7 +373,8 @@ export class FileFetcherImpl implements FileFetcher {
|
|
|
405
373
|
controller?: UploadController,
|
|
406
374
|
uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
|
|
407
375
|
traceContext?: MediaTraceContext,
|
|
408
|
-
|
|
376
|
+
featureFlags?: MediaFeatureFlags,
|
|
377
|
+
): MediaSubscribable;
|
|
409
378
|
// (undocumented)
|
|
410
379
|
uploadExternal(
|
|
411
380
|
url: string,
|
|
@@ -465,6 +434,11 @@ export type FileState =
|
|
|
465
434
|
// @public (undocumented)
|
|
466
435
|
export type FileStatus = FileStatus_2;
|
|
467
436
|
|
|
437
|
+
// @public (undocumented)
|
|
438
|
+
export function fromObservable(
|
|
439
|
+
observable: ReplaySubject<FileState>,
|
|
440
|
+
): MediaSubscribable;
|
|
441
|
+
|
|
468
442
|
// @public (undocumented)
|
|
469
443
|
export const getArtifactUrl: (
|
|
470
444
|
artifacts: MediaFileArtifacts,
|
|
@@ -620,11 +594,6 @@ export function isMediaClientError(error: any): error is MediaClientError<{
|
|
|
620
594
|
reason: MediaClientErrorReason;
|
|
621
595
|
}>;
|
|
622
596
|
|
|
623
|
-
// @public (undocumented)
|
|
624
|
-
export const isMediaCollectionItemFullDetails: (
|
|
625
|
-
mediaCollectionItem: MediaCollectionItemDetails,
|
|
626
|
-
) => mediaCollectionItem is MediaCollectionItemFullDetails;
|
|
627
|
-
|
|
628
597
|
// @public (undocumented)
|
|
629
598
|
export function isMediaStoreError(err: Error): err is MediaStoreError;
|
|
630
599
|
|
|
@@ -695,7 +664,7 @@ export const mapMediaFileToFileState: (
|
|
|
695
664
|
// @public (undocumented)
|
|
696
665
|
export const mapMediaItemToFileState: (
|
|
697
666
|
id: string,
|
|
698
|
-
item:
|
|
667
|
+
item: MediaItemDetails,
|
|
699
668
|
) => FileState;
|
|
700
669
|
|
|
701
670
|
// @public @deprecated (undocumented)
|
|
@@ -756,8 +725,6 @@ export class MediaClient {
|
|
|
756
725
|
featureFlags?: MediaFeatureFlags | undefined,
|
|
757
726
|
);
|
|
758
727
|
// (undocumented)
|
|
759
|
-
readonly collection: CollectionFetcher;
|
|
760
|
-
// (undocumented)
|
|
761
728
|
readonly config: MediaClientConfig;
|
|
762
729
|
// (undocumented)
|
|
763
730
|
emit<E extends keyof UploadEventPayloadMap>(
|
|
@@ -805,6 +772,13 @@ export class MediaClient {
|
|
|
805
772
|
listener: EventPayloadListener<UploadEventPayloadMap, E>,
|
|
806
773
|
): void;
|
|
807
774
|
// (undocumented)
|
|
775
|
+
removeFileFromCollection(
|
|
776
|
+
id: string,
|
|
777
|
+
collectionName: string,
|
|
778
|
+
occurrenceKey?: string,
|
|
779
|
+
traceContext?: MediaTraceContext,
|
|
780
|
+
): Promise<void>;
|
|
781
|
+
// (undocumented)
|
|
808
782
|
readonly stargate: StargateClient;
|
|
809
783
|
}
|
|
810
784
|
|
|
@@ -847,50 +821,6 @@ export type MediaClientErrorReason =
|
|
|
847
821
|
| 'tokenExpired'
|
|
848
822
|
| 'zeroVersionFile';
|
|
849
823
|
|
|
850
|
-
// @public (undocumented)
|
|
851
|
-
export type MediaCollection = {
|
|
852
|
-
readonly name: string;
|
|
853
|
-
readonly createdAt: number;
|
|
854
|
-
};
|
|
855
|
-
|
|
856
|
-
// @public (undocumented)
|
|
857
|
-
export type MediaCollectionItem = {
|
|
858
|
-
readonly id: string;
|
|
859
|
-
readonly insertedAt: number;
|
|
860
|
-
readonly occurrenceKey: string;
|
|
861
|
-
readonly details: MediaCollectionItemDetails;
|
|
862
|
-
};
|
|
863
|
-
|
|
864
|
-
// @public (undocumented)
|
|
865
|
-
export type MediaCollectionItemDetails =
|
|
866
|
-
| MediaCollectionItemFullDetails
|
|
867
|
-
| MediaCollectionItemMinimalDetails;
|
|
868
|
-
|
|
869
|
-
// @public (undocumented)
|
|
870
|
-
export type MediaCollectionItemFullDetails = {
|
|
871
|
-
readonly mediaType: MediaType;
|
|
872
|
-
readonly mimeType: string;
|
|
873
|
-
readonly name: string;
|
|
874
|
-
readonly processingStatus: MediaFileProcessingStatus;
|
|
875
|
-
readonly size: number;
|
|
876
|
-
readonly artifacts: MediaFileArtifacts;
|
|
877
|
-
readonly representations: MediaRepresentations;
|
|
878
|
-
readonly createdAt?: number;
|
|
879
|
-
readonly metadataTraceContext?: MediaTraceContext;
|
|
880
|
-
};
|
|
881
|
-
|
|
882
|
-
// @public (undocumented)
|
|
883
|
-
export type MediaCollectionItemMinimalDetails = {
|
|
884
|
-
readonly name: string;
|
|
885
|
-
readonly size: number;
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
// @public (undocumented)
|
|
889
|
-
export type MediaCollectionItems = {
|
|
890
|
-
readonly contents: MediaCollectionItem[];
|
|
891
|
-
readonly nextInclusiveStartKey?: string;
|
|
892
|
-
};
|
|
893
|
-
|
|
894
824
|
// @public (undocumented)
|
|
895
825
|
export type MediaFile = {
|
|
896
826
|
readonly id: string;
|
|
@@ -926,15 +856,28 @@ export interface MediaFileArtifacts {
|
|
|
926
856
|
// @public (undocumented)
|
|
927
857
|
export type MediaFileProcessingStatus = 'failed' | 'pending' | 'succeeded';
|
|
928
858
|
|
|
859
|
+
// @public (undocumented)
|
|
860
|
+
export type MediaItemDetails = {
|
|
861
|
+
readonly mediaType: MediaType;
|
|
862
|
+
readonly mimeType: string;
|
|
863
|
+
readonly name: string;
|
|
864
|
+
readonly processingStatus: MediaFileProcessingStatus;
|
|
865
|
+
readonly size: number;
|
|
866
|
+
readonly artifacts: MediaFileArtifacts;
|
|
867
|
+
readonly representations: MediaRepresentations;
|
|
868
|
+
readonly createdAt?: number;
|
|
869
|
+
readonly metadataTraceContext?: MediaTraceContext;
|
|
870
|
+
};
|
|
871
|
+
|
|
929
872
|
// @public (undocumented)
|
|
930
873
|
export type MediaItemType = 'external-image' | 'file';
|
|
931
874
|
|
|
932
875
|
// @public (undocumented)
|
|
933
|
-
export type MediaObserver
|
|
934
|
-
| ((value:
|
|
935
|
-
| CompletionObserver
|
|
936
|
-
| ErrorObserver
|
|
937
|
-
| NextObserver
|
|
876
|
+
export type MediaObserver =
|
|
877
|
+
| ((value: FileState) => void)
|
|
878
|
+
| CompletionObserver
|
|
879
|
+
| ErrorObserver
|
|
880
|
+
| NextObserver;
|
|
938
881
|
|
|
939
882
|
// @public (undocumented)
|
|
940
883
|
export type MediaRepresentations = {
|
|
@@ -980,12 +923,6 @@ export class MediaStore {
|
|
|
980
923
|
artifactName: keyof MediaFileArtifacts,
|
|
981
924
|
collectionName?: string,
|
|
982
925
|
): Promise<string>;
|
|
983
|
-
// @deprecated (undocumented)
|
|
984
|
-
getCollectionItems(
|
|
985
|
-
collectionName: string,
|
|
986
|
-
params?: MediaStoreGetCollectionItemsParams,
|
|
987
|
-
traceContext?: MediaTraceContext,
|
|
988
|
-
): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
989
926
|
// (undocumented)
|
|
990
927
|
getFile(
|
|
991
928
|
fileId: string,
|
|
@@ -1027,6 +964,11 @@ export class MediaStore {
|
|
|
1027
964
|
traceContext?: MediaTraceContext,
|
|
1028
965
|
): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
1029
966
|
// (undocumented)
|
|
967
|
+
getRejectedResponseFromDescriptor(
|
|
968
|
+
descriptor: TouchFileDescriptor,
|
|
969
|
+
limit: number,
|
|
970
|
+
): RejectedTouchFile;
|
|
971
|
+
// (undocumented)
|
|
1030
972
|
probeChunks(
|
|
1031
973
|
chunks: string[],
|
|
1032
974
|
uploadId: string,
|
|
@@ -1146,14 +1088,6 @@ export type MediaStoreErrorReason =
|
|
|
1146
1088
|
| 'missingInitialAuth'
|
|
1147
1089
|
| 'tokenExpired';
|
|
1148
1090
|
|
|
1149
|
-
// @public (undocumented)
|
|
1150
|
-
export type MediaStoreGetCollectionItemsParams = {
|
|
1151
|
-
readonly limit?: number;
|
|
1152
|
-
readonly inclusiveStartKey?: string;
|
|
1153
|
-
readonly sortDirection?: 'asc' | 'desc';
|
|
1154
|
-
readonly details?: 'full' | 'minimal';
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1157
1091
|
// @public (undocumented)
|
|
1158
1092
|
export type MediaStoreGetFileImageParams = {
|
|
1159
1093
|
readonly allowAnimated?: boolean;
|
|
@@ -1181,6 +1115,7 @@ export type MediaStoreRequestOptions = RequestMetadata & {
|
|
|
1181
1115
|
readonly body?: any;
|
|
1182
1116
|
readonly clientOptions?: ClientOptions;
|
|
1183
1117
|
readonly traceContext?: MediaTraceContext;
|
|
1118
|
+
readonly resolvedAuth?: Auth;
|
|
1184
1119
|
};
|
|
1185
1120
|
|
|
1186
1121
|
// @public (undocumented)
|
|
@@ -1202,13 +1137,10 @@ export interface MediaStoreTouchFileParams {
|
|
|
1202
1137
|
}
|
|
1203
1138
|
|
|
1204
1139
|
// @public (undocumented)
|
|
1205
|
-
export type MediaSubscribable
|
|
1206
|
-
subscribe(observer?: MediaObserver
|
|
1140
|
+
export type MediaSubscribable = {
|
|
1141
|
+
subscribe(observer?: MediaObserver): MediaSubscription;
|
|
1207
1142
|
};
|
|
1208
1143
|
|
|
1209
|
-
// @public (undocumented)
|
|
1210
|
-
export type MediaSubscribableItem = FileState | MediaCollectionItem[];
|
|
1211
|
-
|
|
1212
1144
|
// @public (undocumented)
|
|
1213
1145
|
export type MediaSubscription = {
|
|
1214
1146
|
unsubscribe: () => void;
|
|
@@ -1275,8 +1207,7 @@ export type MobileUploadStartEvent = {
|
|
|
1275
1207
|
};
|
|
1276
1208
|
|
|
1277
1209
|
// @public (undocumented)
|
|
1278
|
-
type NextObserver
|
|
1279
|
-
Required<Pick<PartialObserver<T>, 'next'>>;
|
|
1210
|
+
type NextObserver = PartialObserver & Required<Pick<PartialObserver, 'next'>>;
|
|
1280
1211
|
|
|
1281
1212
|
// @public (undocumented)
|
|
1282
1213
|
export type NonErrorFileState = Exclude<FileState, ErrorFileState>;
|
|
@@ -1287,8 +1218,8 @@ export const objectToQueryString: (json: {
|
|
|
1287
1218
|
}) => string;
|
|
1288
1219
|
|
|
1289
1220
|
// @public (undocumented)
|
|
1290
|
-
type PartialObserver
|
|
1291
|
-
next?: (value:
|
|
1221
|
+
type PartialObserver = {
|
|
1222
|
+
next?: (value: FileState) => void;
|
|
1292
1223
|
error?: (err: any) => void;
|
|
1293
1224
|
complete?: () => void;
|
|
1294
1225
|
};
|
|
@@ -1444,6 +1375,23 @@ export interface ProcessingFileState extends BaseFileState {
|
|
|
1444
1375
|
// @public (undocumented)
|
|
1445
1376
|
export const RECENTS_COLLECTION = 'recents';
|
|
1446
1377
|
|
|
1378
|
+
// @public (undocumented)
|
|
1379
|
+
interface RejectedTouchFile {
|
|
1380
|
+
// (undocumented)
|
|
1381
|
+
error: RejectionError;
|
|
1382
|
+
// (undocumented)
|
|
1383
|
+
fileId: string;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// @public (undocumented)
|
|
1387
|
+
type RejectionError = {
|
|
1388
|
+
code: 'ExceedMaxFileSizeLimit';
|
|
1389
|
+
title: string;
|
|
1390
|
+
href: string;
|
|
1391
|
+
limit: number;
|
|
1392
|
+
size: number;
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1447
1395
|
// @public (undocumented)
|
|
1448
1396
|
export function request(
|
|
1449
1397
|
url: string,
|
|
@@ -1542,7 +1490,7 @@ export interface ResponseFileItem {
|
|
|
1542
1490
|
// (undocumented)
|
|
1543
1491
|
collection?: string;
|
|
1544
1492
|
// (undocumented)
|
|
1545
|
-
details:
|
|
1493
|
+
details: MediaItemDetails;
|
|
1546
1494
|
// (undocumented)
|
|
1547
1495
|
id: string;
|
|
1548
1496
|
// (undocumented)
|
|
@@ -1585,6 +1533,7 @@ export class StargateClient {
|
|
|
1585
1533
|
// @public (undocumented)
|
|
1586
1534
|
export type TouchedFiles = {
|
|
1587
1535
|
created: CreatedTouchedFile[];
|
|
1536
|
+
rejected: RejectedTouchFile[];
|
|
1588
1537
|
};
|
|
1589
1538
|
|
|
1590
1539
|
// @public (undocumented)
|
|
@@ -1599,6 +1548,8 @@ export interface TouchFileDescriptor {
|
|
|
1599
1548
|
fileId: string;
|
|
1600
1549
|
// (undocumented)
|
|
1601
1550
|
occurrenceKey?: string;
|
|
1551
|
+
// (undocumented)
|
|
1552
|
+
size?: number;
|
|
1602
1553
|
}
|
|
1603
1554
|
|
|
1604
1555
|
// @public (undocumented)
|
|
@@ -1719,7 +1670,7 @@ export type WithMediaClientFunction = <P extends WithMediaClient>(
|
|
|
1719
1670
|
|
|
1720
1671
|
```json
|
|
1721
1672
|
{
|
|
1722
|
-
"@atlaskit/media-core": "^34.0.
|
|
1673
|
+
"@atlaskit/media-core": "^34.0.2",
|
|
1723
1674
|
"@emotion/react": "^11.7.1",
|
|
1724
1675
|
"react": "^16.8.0"
|
|
1725
1676
|
}
|