@atlaskit/media-client 18.1.0 → 19.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 +23 -0
- package/dist/cjs/client/collection-fetcher.js +8 -8
- package/dist/cjs/client/file-fetcher/index.js +40 -36
- package/dist/cjs/client/media-client.js +2 -2
- package/dist/cjs/client/media-store/index.js +69 -52
- package/dist/cjs/models/file-state.js +4 -2
- package/dist/cjs/uploader/index.js +40 -70
- package/dist/cjs/utils/createFileDataLoader.js +32 -15
- package/dist/cjs/utils/request/helpers.js +39 -22
- package/dist/cjs/utils/request/index.js +5 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/collection-fetcher.js +6 -6
- package/dist/es2019/client/file-fetcher/index.js +16 -14
- package/dist/es2019/client/media-client.js +2 -2
- package/dist/es2019/client/media-store/index.js +50 -41
- package/dist/es2019/models/file-state.js +4 -2
- package/dist/es2019/uploader/index.js +17 -21
- package/dist/es2019/utils/createFileDataLoader.js +13 -3
- package/dist/es2019/utils/request/helpers.js +26 -8
- package/dist/es2019/utils/request/index.js +6 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/collection-fetcher.js +8 -8
- package/dist/esm/client/file-fetcher/index.js +40 -36
- package/dist/esm/client/media-client.js +2 -2
- package/dist/esm/client/media-store/index.js +68 -50
- package/dist/esm/models/file-state.js +4 -2
- package/dist/esm/uploader/index.js +40 -69
- package/dist/esm/utils/createFileDataLoader.js +31 -13
- package/dist/esm/utils/request/helpers.js +36 -20
- package/dist/esm/utils/request/index.js +6 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/client/collection-fetcher.d.ts +4 -3
- package/dist/types/client/file-fetcher/index.d.ts +9 -8
- package/dist/types/client/media-client.d.ts +2 -2
- package/dist/types/client/media-store/index.d.ts +16 -21
- package/dist/types/models/file-state.d.ts +9 -6
- package/dist/types/models/media.d.ts +3 -1
- package/dist/types/uploader/index.d.ts +2 -1
- package/dist/types/utils/request/helpers.d.ts +10 -2
- package/dist/types/utils/request/types.d.ts +3 -0
- package/package.json +7 -15
- package/report.api.md +116 -75
- package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +0 -8
- package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +0 -10
- package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +0 -13
- package/dist/types-ts4.0/client/collection-fetcher.d.ts +0 -35
- package/dist/types-ts4.0/client/events.d.ts +0 -14
- package/dist/types-ts4.0/client/file-fetcher/error.d.ts +0 -29
- package/dist/types-ts4.0/client/file-fetcher/index.d.ts +0 -56
- package/dist/types-ts4.0/client/media-client.d.ts +0 -28
- package/dist/types-ts4.0/client/media-store/error.d.ts +0 -16
- package/dist/types-ts4.0/client/media-store/index.d.ts +0 -174
- package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +0 -4
- package/dist/types-ts4.0/client/mobile-upload.d.ts +0 -11
- package/dist/types-ts4.0/client/stargate-client.d.ts +0 -15
- package/dist/types-ts4.0/constants.d.ts +0 -6
- package/dist/types-ts4.0/file-streams-cache.d.ts +0 -15
- package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +0 -6
- package/dist/types-ts4.0/identifier.d.ts +0 -15
- package/dist/types-ts4.0/index.d.ts +0 -89
- package/dist/types-ts4.0/models/artifacts.d.ts +0 -12
- package/dist/types-ts4.0/models/auth-headers.d.ts +0 -11
- package/dist/types-ts4.0/models/auth-query-parameters.d.ts +0 -11
- package/dist/types-ts4.0/models/errors/helpers.d.ts +0 -6
- package/dist/types-ts4.0/models/errors/index.d.ts +0 -11
- package/dist/types-ts4.0/models/errors/types.d.ts +0 -15
- package/dist/types-ts4.0/models/file-state.d.ts +0 -91
- package/dist/types-ts4.0/models/item.d.ts +0 -25
- package/dist/types-ts4.0/models/media-subscribable.d.ts +0 -3
- package/dist/types-ts4.0/models/media.d.ts +0 -66
- package/dist/types-ts4.0/models/mobile-upload.d.ts +0 -28
- package/dist/types-ts4.0/upload-controller.d.ts +0 -7
- package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +0 -11
- package/dist/types-ts4.0/uploader/error.d.ts +0 -29
- package/dist/types-ts4.0/uploader/index.d.ts +0 -21
- package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +0 -1
- package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +0 -1
- package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +0 -30
- package/dist/types-ts4.0/utils/createMediaSubject.d.ts +0 -3
- package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +0 -16
- package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +0 -6
- package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +0 -5
- package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +0 -3
- package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +0 -5
- package/dist/types-ts4.0/utils/hashing/hasher.d.ts +0 -3
- package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +0 -3
- package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +0 -4
- package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +0 -16
- package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +0 -3
- package/dist/types-ts4.0/utils/isImageRemote.d.ts +0 -1
- package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +0 -5
- package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +0 -3
- package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +0 -10
- package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +0 -16
- package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +0 -29
- package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +0 -8
- package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +0 -5
- package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +0 -4
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +0 -7
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +0 -3
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +0 -69
- package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +0 -5
- package/dist/types-ts4.0/utils/polling/errors.d.ts +0 -12
- package/dist/types-ts4.0/utils/polling/index.d.ts +0 -33
- package/dist/types-ts4.0/utils/polling/types.d.ts +0 -7
- package/dist/types-ts4.0/utils/request/errors.d.ts +0 -20
- package/dist/types-ts4.0/utils/request/helpers.d.ts +0 -38
- package/dist/types-ts4.0/utils/request/index.d.ts +0 -5
- package/dist/types-ts4.0/utils/request/types.d.ts +0 -43
- package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +0 -2
- package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +0 -2
- package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +0 -16
- package/dist/types-ts4.0/utils/url.d.ts +0 -17
- package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +0 -16
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Executor } from './types';
|
|
2
|
-
export interface PollingOptions {
|
|
3
|
-
poll_intervalMs: number;
|
|
4
|
-
poll_maxAttempts: number;
|
|
5
|
-
poll_backoffFactor: number;
|
|
6
|
-
poll_maxIntervalMs: number;
|
|
7
|
-
}
|
|
8
|
-
export declare const defaultPollingOptions: PollingOptions;
|
|
9
|
-
/**
|
|
10
|
-
* This class encapsulates polling functionality with the following features:
|
|
11
|
-
*
|
|
12
|
-
* - async executor function provides each attempt
|
|
13
|
-
* - executor will only repeat defined max amount of times (options)
|
|
14
|
-
* - each attempt uses a timeout to the next attempt by an interval (ms)
|
|
15
|
-
* - each attempt increases the timeout interval by a "poll_backoffFactor"
|
|
16
|
-
* - if max attempts are exceeded or executor has exception then onError handler is called
|
|
17
|
-
*
|
|
18
|
-
* IMPORTANT! the executor function must explicitly call ".next()" for the next iteration to run
|
|
19
|
-
*/
|
|
20
|
-
export declare class PollingFunction {
|
|
21
|
-
options: PollingOptions;
|
|
22
|
-
poll_intervalMs: number;
|
|
23
|
-
attempt: number;
|
|
24
|
-
shouldIterate: boolean;
|
|
25
|
-
onError?: (error: Error) => void;
|
|
26
|
-
timeoutId: number;
|
|
27
|
-
constructor(options?: Partial<PollingOptions>);
|
|
28
|
-
execute(executor: Executor): Promise<void>;
|
|
29
|
-
private fail;
|
|
30
|
-
getIntervalMsForIteration(iteration: number): number;
|
|
31
|
-
next(): void;
|
|
32
|
-
cancel(): void;
|
|
33
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare type Executor = () => Promise<void>;
|
|
2
|
-
export declare type PollingErrorReason = 'pollingMaxAttemptsExceeded';
|
|
3
|
-
export declare type PollingErrorAttributes = {
|
|
4
|
-
readonly reason: PollingErrorReason;
|
|
5
|
-
readonly attempts: number;
|
|
6
|
-
readonly innerError?: Error;
|
|
7
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
-
import { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes } from './types';
|
|
3
|
-
export declare class RequestError extends BaseMediaClientError<RequestErrorAttributes> {
|
|
4
|
-
readonly reason: RequestErrorReason;
|
|
5
|
-
readonly metadata?: RequestErrorMetadata | undefined;
|
|
6
|
-
readonly innerError?: Error | undefined;
|
|
7
|
-
constructor(reason: RequestErrorReason, metadata?: RequestErrorMetadata | undefined, innerError?: Error | undefined);
|
|
8
|
-
get attributes(): {
|
|
9
|
-
reason: RequestErrorReason;
|
|
10
|
-
method: import("./types").RequestMethod | undefined;
|
|
11
|
-
endpoint: string | undefined;
|
|
12
|
-
mediaRegion: string | undefined;
|
|
13
|
-
mediaEnv: string | undefined;
|
|
14
|
-
attempts: number | undefined;
|
|
15
|
-
clientExhaustedRetries: boolean | undefined;
|
|
16
|
-
statusCode: number | undefined;
|
|
17
|
-
innerError: Error | undefined;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export declare function isRequestError(err: Error): err is RequestError;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Auth } from '@atlaskit/media-core';
|
|
2
|
-
import { RequestError } from './errors';
|
|
3
|
-
import { CreateUrlOptions, RequestErrorReason, RequestErrorMetadata, RequestHeaders, RequestMetadata, RetryOptions } from './types';
|
|
4
|
-
export declare function clientTimeoutPromise(timeout: number): Promise<Response>;
|
|
5
|
-
export declare function waitPromise(timeout: number): Promise<void>;
|
|
6
|
-
export declare function isAbortedRequestError(err: any): boolean;
|
|
7
|
-
export declare function isFetchNetworkError(err: any): err is TypeError;
|
|
8
|
-
export declare function isRateLimitedError(error: Error | undefined): boolean;
|
|
9
|
-
export declare function mapAuthToRequestHeaders(auth: Auth): RequestHeaders;
|
|
10
|
-
export declare function createUrl(url: string, { params, auth }: CreateUrlOptions): string;
|
|
11
|
-
export declare function withAuth(auth?: Auth): (headers?: RequestHeaders | undefined) => Record<string, string> | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
14
|
-
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
15
|
-
*/
|
|
16
|
-
export declare function mapResponseToJson(response: Response): Promise<any>;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
19
|
-
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
20
|
-
*/
|
|
21
|
-
export declare function mapResponseToBlob(response: Response): Promise<Blob>;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Helper is deprecated and will be removed in the next major version.
|
|
24
|
-
* TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
|
|
25
|
-
*/
|
|
26
|
-
export declare function mapResponseToVoid(): Promise<void>;
|
|
27
|
-
export declare function createMapResponseToJson(metadata: RequestMetadata): (response: Response) => Promise<any>;
|
|
28
|
-
export declare function createMapResponseToBlob(metadata: RequestMetadata): (response: Response) => Promise<Blob>;
|
|
29
|
-
export declare const DEFAULT_RETRY_OPTIONS: RetryOptions;
|
|
30
|
-
export declare function cloneRequestError(error: RequestError, extraMetadata: Partial<RequestErrorMetadata>): RequestError;
|
|
31
|
-
export declare function fetchRetry(functionToRetry: () => Promise<Response>, metadata: RequestMetadata, overwriteOptions?: Partial<RetryOptions>): Promise<Response>;
|
|
32
|
-
export declare function createRequestErrorReason(statusCode: number): RequestErrorReason;
|
|
33
|
-
export declare function createRequestErrorFromResponse(metadata: RequestErrorMetadata, response: Response): RequestError;
|
|
34
|
-
export declare function createProcessFetchResponse(metadata: RequestMetadata): (response: Response) => Response;
|
|
35
|
-
export declare function extractMediaHeaders(response: Response): {
|
|
36
|
-
mediaRegion: string;
|
|
37
|
-
mediaEnv: string;
|
|
38
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RequestOptions } from './types';
|
|
2
|
-
export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './types';
|
|
3
|
-
export { RequestError, isRequestError } from './errors';
|
|
4
|
-
export { isRateLimitedError } from './helpers';
|
|
5
|
-
export declare function request(url: string, options?: RequestOptions, controller?: AbortController): Promise<Response>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Auth } from '@atlaskit/media-core';
|
|
2
|
-
export declare type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
3
|
-
export declare type RequestParams = {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
};
|
|
6
|
-
export declare type RequestHeaders = {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type RetryOptions = {
|
|
10
|
-
readonly startTimeoutInMs: number;
|
|
11
|
-
readonly maxAttempts: number;
|
|
12
|
-
readonly factor: number;
|
|
13
|
-
};
|
|
14
|
-
export declare type ClientOptions = {
|
|
15
|
-
readonly retryOptions?: Partial<RetryOptions>;
|
|
16
|
-
readonly clientTimeout?: number;
|
|
17
|
-
};
|
|
18
|
-
export declare type RequestMetadata = {
|
|
19
|
-
readonly method?: RequestMethod;
|
|
20
|
-
readonly endpoint?: string;
|
|
21
|
-
readonly mediaRegion?: string;
|
|
22
|
-
readonly mediaEnv?: string;
|
|
23
|
-
};
|
|
24
|
-
export declare type RequestOptions = RequestMetadata & {
|
|
25
|
-
readonly auth?: Auth;
|
|
26
|
-
readonly params?: RequestParams;
|
|
27
|
-
readonly headers?: RequestHeaders;
|
|
28
|
-
readonly body?: any;
|
|
29
|
-
readonly clientOptions?: ClientOptions;
|
|
30
|
-
};
|
|
31
|
-
export declare type CreateUrlOptions = {
|
|
32
|
-
readonly params?: RequestParams;
|
|
33
|
-
readonly auth?: Auth;
|
|
34
|
-
};
|
|
35
|
-
export declare type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError';
|
|
36
|
-
export declare type RequestErrorMetadata = RequestMetadata & {
|
|
37
|
-
readonly attempts?: number;
|
|
38
|
-
readonly clientExhaustedRetries?: boolean;
|
|
39
|
-
readonly statusCode?: number;
|
|
40
|
-
};
|
|
41
|
-
export declare type RequestErrorAttributes = RequestErrorMetadata & {
|
|
42
|
-
readonly reason: RequestErrorReason;
|
|
43
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs/Observable';
|
|
2
|
-
import { FilePreview } from '../models/file-state';
|
|
3
|
-
import { MediaType } from '../models/media';
|
|
4
|
-
/**
|
|
5
|
-
* Async helper determining if we should fetch remote fileStates from the backend:
|
|
6
|
-
* - we poll the backend for all supported documents,
|
|
7
|
-
* - we poll the backend is mimeType isn't natively supported by the browser,
|
|
8
|
-
* - we poll the backend if we don't have a local preview available.
|
|
9
|
-
* - we poll the backend if we have a video with which we can't extract dimensions,
|
|
10
|
-
*
|
|
11
|
-
* Polling the backend periodically refreshes the cached fileState until the file is processed.
|
|
12
|
-
* Polling is needed for the use cases above to properly render the file in our components.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export declare function shouldFetchRemoteFileStates(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Promise<boolean>;
|
|
16
|
-
export declare function shouldFetchRemoteFileStatesObservable(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Observable<boolean>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const isMediaBlobUrl: (url: string) => boolean;
|
|
2
|
-
export interface MediaBlobUrlAttrs {
|
|
3
|
-
id: string;
|
|
4
|
-
contextId: string;
|
|
5
|
-
collection?: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
name?: string;
|
|
8
|
-
mimeType?: string;
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
alt?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const getAttrsFromUrl: (blobUrl: string) => MediaBlobUrlAttrs | undefined;
|
|
14
|
-
export declare const objectToQueryString: (json: {
|
|
15
|
-
[key: string]: string | number | boolean | null | undefined;
|
|
16
|
-
}) => string;
|
|
17
|
-
export declare const addFileAttrsToUrl: (url: string, fileAttrs: MediaBlobUrlAttrs) => string;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
-
import { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaClient } from '../client/media-client';
|
|
5
|
-
import { Identifier } from '../identifier';
|
|
6
|
-
export interface WithMediaClientConfig {
|
|
7
|
-
mediaClientConfig: MediaClientConfig;
|
|
8
|
-
}
|
|
9
|
-
export interface WithMediaClient {
|
|
10
|
-
mediaClient: MediaClient;
|
|
11
|
-
identifier?: Identifier;
|
|
12
|
-
}
|
|
13
|
-
export declare const getMediaClient: (mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined) => MediaClient;
|
|
14
|
-
export declare type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<P, 'mediaClient'> & WithMediaClientConfig;
|
|
15
|
-
export declare type WithMediaClientFunction = <P extends WithMediaClient>(Component: React.ComponentType<P>, featureFlags?: MediaFeatureFlags) => React.ComponentType<WithMediaClientConfigProps<P>>;
|
|
16
|
-
export declare const withMediaClient: WithMediaClientFunction;
|