@atlaskit/media-client 24.0.1 → 24.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/utils/with-media-client-hoc.js +24 -0
  3. package/dist/es2019/utils/with-media-client-hoc.js +25 -0
  4. package/dist/esm/utils/with-media-client-hoc.js +25 -0
  5. package/dist/types/utils/with-media-client-hoc.d.ts +18 -0
  6. package/dist/types-ts4.5/client/__mocks__/collection-fetcher.d.ts +8 -0
  7. package/dist/types-ts4.5/client/__mocks__/file-fetcher.d.ts +10 -0
  8. package/dist/types-ts4.5/client/__mocks__/media-client.d.ts +11 -0
  9. package/dist/types-ts4.5/client/events.d.ts +14 -0
  10. package/dist/types-ts4.5/client/file-fetcher/error.d.ts +29 -0
  11. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +62 -0
  12. package/dist/types-ts4.5/client/media-client.d.ts +32 -0
  13. package/dist/types-ts4.5/client/media-store/error.d.ts +16 -0
  14. package/dist/types-ts4.5/client/media-store/index.d.ts +168 -0
  15. package/dist/types-ts4.5/client/media-store/resolveAuth.d.ts +4 -0
  16. package/dist/types-ts4.5/client/mobile-upload.d.ts +15 -0
  17. package/dist/types-ts4.5/client/stargate-client.d.ts +15 -0
  18. package/dist/types-ts4.5/constants.d.ts +6 -0
  19. package/dist/types-ts4.5/file-streams-cache.d.ts +15 -0
  20. package/dist/types-ts4.5/globalMediaEventEmitter.d.ts +6 -0
  21. package/dist/types-ts4.5/identifier.d.ts +15 -0
  22. package/dist/types-ts4.5/index.d.ts +89 -0
  23. package/dist/types-ts4.5/models/artifacts.d.ts +2 -0
  24. package/dist/types-ts4.5/models/auth-headers.d.ts +11 -0
  25. package/dist/types-ts4.5/models/auth-query-parameters.d.ts +11 -0
  26. package/dist/types-ts4.5/models/errors/helpers.d.ts +6 -0
  27. package/dist/types-ts4.5/models/errors/index.d.ts +11 -0
  28. package/dist/types-ts4.5/models/errors/types.d.ts +15 -0
  29. package/dist/types-ts4.5/models/file-state.d.ts +25 -0
  30. package/dist/types-ts4.5/models/item.d.ts +25 -0
  31. package/dist/types-ts4.5/models/media.d.ts +48 -0
  32. package/dist/types-ts4.5/models/mobile-upload.d.ts +28 -0
  33. package/dist/types-ts4.5/test-helpers/_numbers.d.ts +1 -0
  34. package/dist/types-ts4.5/test-helpers/authProvider.d.ts +6 -0
  35. package/dist/types-ts4.5/test-helpers/collectionNames.d.ts +5 -0
  36. package/dist/types-ts4.5/test-helpers/exampleMediaItems.d.ts +53 -0
  37. package/dist/types-ts4.5/test-helpers/fakeMediaClient.d.ts +4 -0
  38. package/dist/types-ts4.5/test-helpers/index.d.ts +7 -0
  39. package/dist/types-ts4.5/test-helpers/mediaClientProvider.d.ts +23 -0
  40. package/dist/types-ts4.5/test-helpers/mediaPickerAuthProvider.d.ts +5 -0
  41. package/dist/types-ts4.5/upload-controller.d.ts +7 -0
  42. package/dist/types-ts4.5/uploader/calculateChunkSize.d.ts +11 -0
  43. package/dist/types-ts4.5/uploader/error.d.ts +29 -0
  44. package/dist/types-ts4.5/uploader/index.d.ts +23 -0
  45. package/dist/types-ts4.5/utils/checkWebpSupport.d.ts +1 -0
  46. package/dist/types-ts4.5/utils/convertBase64ToBlob.d.ts +1 -0
  47. package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +30 -0
  48. package/dist/types-ts4.5/utils/createMediaSubject.d.ts +3 -0
  49. package/dist/types-ts4.5/utils/detectEmptyFile.d.ts +16 -0
  50. package/dist/types-ts4.5/utils/getDimensionsFromBlob.d.ts +6 -0
  51. package/dist/types-ts4.5/utils/getImageDimensionsFromBlob.d.ts +5 -0
  52. package/dist/types-ts4.5/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
  53. package/dist/types-ts4.5/utils/getVideoDimensionsFromBlob.d.ts +5 -0
  54. package/dist/types-ts4.5/utils/hashing/hasher.d.ts +3 -0
  55. package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +3 -0
  56. package/dist/types-ts4.5/utils/hashing/simpleHasher.d.ts +4 -0
  57. package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +16 -0
  58. package/dist/types-ts4.5/utils/imageResizeModeToFileImageMode.d.ts +3 -0
  59. package/dist/types-ts4.5/utils/isImageRemote.d.ts +1 -0
  60. package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +5 -0
  61. package/dist/types-ts4.5/utils/mediaSubscribable/index.d.ts +3 -0
  62. package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +10 -0
  63. package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +17 -0
  64. package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +29 -0
  65. package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +8 -0
  66. package/dist/types-ts4.5/utils/mobileUpload/index.d.ts +5 -0
  67. package/dist/types-ts4.5/utils/mobileUpload/servicesCache.d.ts +4 -0
  68. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +7 -0
  69. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
  70. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
  71. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
  72. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
  73. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
  74. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +69 -0
  75. package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
  76. package/dist/types-ts4.5/utils/polling/errors.d.ts +12 -0
  77. package/dist/types-ts4.5/utils/polling/index.d.ts +33 -0
  78. package/dist/types-ts4.5/utils/polling/types.d.ts +7 -0
  79. package/dist/types-ts4.5/utils/request/errors.d.ts +20 -0
  80. package/dist/types-ts4.5/utils/request/helpers.d.ts +46 -0
  81. package/dist/types-ts4.5/utils/request/index.d.ts +5 -0
  82. package/dist/types-ts4.5/utils/request/types.d.ts +46 -0
  83. package/dist/types-ts4.5/utils/safeUnsubscribe.d.ts +2 -0
  84. package/dist/types-ts4.5/utils/setTimeoutPromise.d.ts +2 -0
  85. package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +14 -0
  86. package/dist/types-ts4.5/utils/url.d.ts +17 -0
  87. package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +33 -0
  88. package/package.json +2 -2
  89. package/report.api.md +6 -6
  90. package/tmp/api-report-tmp.d.ts +1225 -0
@@ -0,0 +1,10 @@
1
+ import { Subscription } from 'rxjs/Subscription';
2
+ import { MediaSubscribable } from './types';
3
+ import { FileState } from '@atlaskit/media-state';
4
+ /**
5
+ * This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
6
+ *
7
+ * @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
8
+ * @param subscription a default Subscription (this parameter exists for testing purpose)
9
+ */
10
+ export declare const toPromise: (mediaSubscribable: MediaSubscribable, subscription?: Subscription) => Promise<FileState>;
@@ -0,0 +1,17 @@
1
+ import { FileState } from '@atlaskit/media-state';
2
+ export type MediaSubscription = {
3
+ unsubscribe: () => void;
4
+ };
5
+ type PartialObserver = {
6
+ next?: (value: FileState) => void;
7
+ error?: (err: any) => void;
8
+ complete?: () => void;
9
+ };
10
+ export type NextObserver = PartialObserver & Required<Pick<PartialObserver, 'next'>>;
11
+ export type ErrorObserver = PartialObserver & Required<Pick<PartialObserver, 'error'>>;
12
+ export type CompletionObserver = PartialObserver & Required<Pick<PartialObserver, 'complete'>>;
13
+ export type MediaObserver = NextObserver | ErrorObserver | CompletionObserver | ((value: FileState) => void);
14
+ export type MediaSubscribable = {
15
+ subscribe(observer?: MediaObserver): MediaSubscription;
16
+ };
17
+ export {};
@@ -0,0 +1,29 @@
1
+ import { BaseMediaClientError } from '../../models/errors';
2
+ export type MobileUploadErrorReason = 'emptyItems' | 'zeroVersionFile';
3
+ export type MobileUploadErrorAttributes = {
4
+ readonly reason: MobileUploadErrorReason;
5
+ readonly id: string;
6
+ readonly metadata?: {
7
+ readonly collectionName?: string;
8
+ readonly occurrenceKey?: string;
9
+ };
10
+ };
11
+ export declare class MobileUploadError extends BaseMediaClientError<MobileUploadErrorAttributes> {
12
+ readonly reason: MobileUploadErrorReason;
13
+ readonly id: string;
14
+ readonly metadata?: {
15
+ readonly collectionName?: string | undefined;
16
+ readonly occurrenceKey?: string | undefined;
17
+ } | undefined;
18
+ constructor(reason: MobileUploadErrorReason, id: string, metadata?: {
19
+ readonly collectionName?: string | undefined;
20
+ readonly occurrenceKey?: string | undefined;
21
+ } | undefined);
22
+ get attributes(): {
23
+ reason: MobileUploadErrorReason;
24
+ id: string;
25
+ collectionName: string | undefined;
26
+ occurrenceKey: string | undefined;
27
+ };
28
+ }
29
+ export declare function isMobileUploadError(err: Error): err is MobileUploadError;
@@ -0,0 +1,8 @@
1
+ import Dataloader from 'dataloader';
2
+ import { ReplaySubject } from 'rxjs/ReplaySubject';
3
+ import { Interpreter } from 'xstate';
4
+ import { FileState } from '@atlaskit/media-state';
5
+ import { DataloaderKey, DataloaderResult } from '../createFileDataLoader';
6
+ import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
7
+ export declare const createMobileFileStateSubject: (service: Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>) => ReplaySubject<FileState>;
8
+ export declare const createMobileDownloadFileStream: (dataloader: Dataloader<DataloaderKey, DataloaderResult>, id: string, collectionName?: string, occurrenceKey?: string) => ReplaySubject<FileState>;
@@ -0,0 +1,5 @@
1
+ export { isMobileUploadError, MobileUploadError } from './error';
2
+ export { createServicesCache } from './servicesCache';
3
+ export { createMobileUploadService, createMobileUploadStateMachine, } from './stateMachine';
4
+ export { createMobileFileStateSubject } from './helpers';
5
+ export type { StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate, } from './stateMachine/types';
@@ -0,0 +1,4 @@
1
+ import { LRUMap } from 'lru_map';
2
+ import { Interpreter } from 'xstate';
3
+ import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
4
+ export declare function createServicesCache(): LRUMap<string, Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>>;
@@ -0,0 +1,7 @@
1
+ import DataLoader from 'dataloader';
2
+ import { Interpreter, StateMachine } from 'xstate';
3
+ import { UploadingFileState } from '@atlaskit/media-state';
4
+ import { DataloaderKey, DataloaderResult } from '../../createFileDataLoader';
5
+ import { StateMachineContext, StateMachineEvent, StateMachineSchema, StateMachineTypestate } from './types';
6
+ export declare const createMobileUploadStateMachine: (dataloader: DataLoader<DataloaderKey, DataloaderResult>, initialState: UploadingFileState, collectionName?: string) => StateMachine<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>;
7
+ export declare function createMobileUploadService(machine: StateMachine<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>): Interpreter<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineErrorState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineProcessedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { ProcessingStateMachineSchema, StateMachineContext, StateMachineEvent } from '../types';
3
+ export declare const machineProcessingState: StateNodeConfig<StateMachineContext, ProcessingStateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineProcessingFailedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineUploadingState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,69 @@
1
+ import { StateSchema } from 'xstate';
2
+ import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '@atlaskit/media-state';
3
+ export type StateMachineContext = {
4
+ currentFileState: FileState;
5
+ };
6
+ export type StateMachineEvent = {
7
+ type: 'UPLOAD_PROGRESS';
8
+ progress: number;
9
+ } | {
10
+ type: 'UPLOAD_END';
11
+ } | {
12
+ type: 'UPLOAD_ERROR';
13
+ message: string;
14
+ } | {
15
+ type: 'REMOTE_FILESTATE_FETCH';
16
+ } | {
17
+ type: 'REMOTE_FILESTATE_BYPASS';
18
+ } | {
19
+ type: 'REMOTE_FILESTATE_RESULT';
20
+ fileState: FileState;
21
+ } | {
22
+ type: 'REMOTE_FILESTATE_PROCESSED';
23
+ } | {
24
+ type: 'REMOTE_FILESTATE_PROCESSING_FAILED';
25
+ } | {
26
+ type: 'REMOTE_FILESTATE_ERROR';
27
+ };
28
+ export type ProcessingStateMachineSchema = StateSchema<StateMachineContext> & {
29
+ states: {
30
+ loading: StateSchema<StateMachineContext>;
31
+ fetchingRemoteFileStates: StateSchema<StateMachineContext>;
32
+ idle: StateSchema<StateMachineContext>;
33
+ };
34
+ };
35
+ export type StateMachineSchema = StateSchema<StateMachineContext> & {
36
+ states: {
37
+ uploading: StateSchema<StateMachineContext>;
38
+ processing: ProcessingStateMachineSchema;
39
+ processed: StateSchema<StateMachineContext>;
40
+ processingFailed: StateSchema<StateMachineContext>;
41
+ error: StateSchema<StateMachineContext>;
42
+ };
43
+ };
44
+ export type StateMachineTypestate = {
45
+ value: 'uploading';
46
+ context: {
47
+ currentFileState: UploadingFileState;
48
+ };
49
+ } | {
50
+ value: 'processing';
51
+ context: {
52
+ currentFileState: ProcessingFileState;
53
+ };
54
+ } | {
55
+ value: 'processed';
56
+ context: {
57
+ currentFileState: ProcessedFileState;
58
+ };
59
+ } | {
60
+ value: 'processingFailed';
61
+ context: {
62
+ currentFileState: ProcessingFailedState;
63
+ };
64
+ } | {
65
+ value: 'error';
66
+ context: {
67
+ currentFileState: ErrorFileState;
68
+ };
69
+ };
@@ -0,0 +1,5 @@
1
+ import { FileState } from '@atlaskit/media-state';
2
+ import { MediaType } from '../models/media';
3
+ export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?: MediaType) => {
4
+ mediaType?: MediaType | undefined;
5
+ };
@@ -0,0 +1,12 @@
1
+ import { BaseMediaClientError } from '../../models/errors';
2
+ import { PollingErrorReason, PollingErrorAttributes } from './types';
3
+ export declare class PollingError extends BaseMediaClientError<PollingErrorAttributes> {
4
+ readonly reason: PollingErrorReason;
5
+ readonly attempts: number;
6
+ constructor(reason: PollingErrorReason, attempts: number);
7
+ get attributes(): {
8
+ reason: "pollingMaxAttemptsExceeded";
9
+ attempts: number;
10
+ };
11
+ }
12
+ export declare function isPollingError(err?: Error): err is PollingError;
@@ -0,0 +1,33 @@
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
+ }
@@ -0,0 +1,7 @@
1
+ export type Executor = () => Promise<void>;
2
+ export type PollingErrorReason = 'pollingMaxAttemptsExceeded';
3
+ export type PollingErrorAttributes = {
4
+ readonly reason: PollingErrorReason;
5
+ readonly attempts: number;
6
+ readonly innerError?: Error;
7
+ };
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,46 @@
1
+ import { Auth } from '@atlaskit/media-core';
2
+ import { MediaTraceContext } from '@atlaskit/media-common';
3
+ import { RequestError } from './errors';
4
+ import { CreateUrlOptions, RequestErrorReason, RequestErrorMetadata, RequestHeaders, RequestMetadata, RetryOptions } from './types';
5
+ export declare function clientTimeoutPromise(timeout: number): Promise<Response>;
6
+ export declare function waitPromise(timeout: number): Promise<void>;
7
+ export declare function isAbortedRequestError(err: any): boolean;
8
+ export declare function isFetchNetworkError(err: any): err is TypeError;
9
+ export declare function isRateLimitedError(error: Error | undefined): boolean;
10
+ export declare const ZipkinHeaderKeys: {
11
+ traceId: string;
12
+ spanId: string;
13
+ parentSpanId: string;
14
+ sampled: string;
15
+ flags: string;
16
+ };
17
+ export declare function mapAuthToRequestHeaders(auth?: Auth): RequestHeaders;
18
+ export declare function createUrl(url: string, { params, auth }: CreateUrlOptions): string;
19
+ export declare function extendHeaders(headers?: RequestHeaders, auth?: Auth, traceContext?: Required<MediaTraceContext>): RequestHeaders | undefined;
20
+ /**
21
+ * @deprecated Helper is deprecated and will be removed in the next major version.
22
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
23
+ */
24
+ export declare function mapResponseToJson(response: Response): Promise<any>;
25
+ /**
26
+ * @deprecated Helper is deprecated and will be removed in the next major version.
27
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
28
+ */
29
+ export declare function mapResponseToBlob(response: Response): Promise<Blob>;
30
+ /**
31
+ * @deprecated Helper is deprecated and will be removed in the next major version.
32
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
33
+ */
34
+ export declare function mapResponseToVoid(): Promise<void>;
35
+ export declare function createMapResponseToJson(metadata: RequestMetadata): (response: Response) => Promise<any>;
36
+ export declare function createMapResponseToBlob(metadata: RequestMetadata): (response: Response) => Promise<Blob>;
37
+ export declare const DEFAULT_RETRY_OPTIONS: RetryOptions;
38
+ export declare function cloneRequestError(error: RequestError, extraMetadata: Partial<RequestErrorMetadata>): RequestError;
39
+ export declare function fetchRetry(functionToRetry: () => Promise<Response>, metadata: RequestMetadata, overwriteOptions?: Partial<RetryOptions>): Promise<Response>;
40
+ export declare function createRequestErrorReason(statusCode: number): RequestErrorReason;
41
+ export declare function createRequestErrorFromResponse(metadata: RequestErrorMetadata, response: Response): RequestError;
42
+ export declare function createProcessFetchResponse(metadata: RequestMetadata): (response: Response) => Response;
43
+ export declare function extractMediaHeaders(response: Response): {
44
+ mediaRegion: string;
45
+ mediaEnv: string;
46
+ };
@@ -0,0 +1,5 @@
1
+ import { RequestOptions } from './types';
2
+ export type { RequestErrorReason, RequestErrorMetadata, RequestErrorAttributes, } from './types';
3
+ export { RequestError, isRequestError } from './errors';
4
+ export { isRateLimitedError, createRequestErrorReason } from './helpers';
5
+ export declare function request(url: string, options?: RequestOptions, controller?: AbortController): Promise<Response>;
@@ -0,0 +1,46 @@
1
+ import { Auth } from '@atlaskit/media-core';
2
+ import type { MediaTraceContext } from '@atlaskit/media-common';
3
+ export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
4
+ export type RequestParams = {
5
+ [key: string]: any;
6
+ };
7
+ export type RequestHeaders = {
8
+ [key: string]: string;
9
+ };
10
+ export type RetryOptions = {
11
+ readonly startTimeoutInMs: number;
12
+ readonly maxAttempts: number;
13
+ readonly factor: number;
14
+ };
15
+ export type ClientOptions = {
16
+ readonly retryOptions?: Partial<RetryOptions>;
17
+ readonly clientTimeout?: number;
18
+ };
19
+ export type RequestMetadata = {
20
+ readonly method?: RequestMethod;
21
+ readonly endpoint?: string;
22
+ readonly mediaRegion?: string;
23
+ readonly mediaEnv?: string;
24
+ readonly traceContext?: MediaTraceContext;
25
+ };
26
+ export type RequestOptions = RequestMetadata & {
27
+ readonly auth?: Auth;
28
+ readonly traceContext?: Required<MediaTraceContext>;
29
+ readonly params?: RequestParams;
30
+ readonly headers?: RequestHeaders;
31
+ readonly body?: any;
32
+ readonly clientOptions?: ClientOptions;
33
+ };
34
+ export type CreateUrlOptions = {
35
+ readonly params?: RequestParams;
36
+ readonly auth?: Auth;
37
+ };
38
+ export type RequestErrorReason = 'clientOffline' | 'clientAbortedRequest' | 'clientTimeoutRequest' | 'serverInvalidBody' | 'serverBadRequest' | 'serverUnauthorized' | 'serverForbidden' | 'serverNotFound' | 'serverRateLimited' | 'serverInternalError' | 'serverBadGateway' | 'serverUnexpectedError';
39
+ export type RequestErrorMetadata = RequestMetadata & {
40
+ readonly attempts?: number;
41
+ readonly clientExhaustedRetries?: boolean;
42
+ readonly statusCode?: number;
43
+ };
44
+ export type RequestErrorAttributes = RequestErrorMetadata & {
45
+ readonly reason: RequestErrorReason;
46
+ };
@@ -0,0 +1,2 @@
1
+ import { MediaSubscription } from './mediaSubscribable';
2
+ export declare const safeUnsubscribe: (subscription: MediaSubscription) => void;
@@ -0,0 +1,2 @@
1
+ export declare const resolveTimeout: <T>(timeout: number, resolveWith: T) => Promise<T>;
2
+ export declare const rejectTimeout: (timeout: number, rejectWith: Error) => Promise<undefined>;
@@ -0,0 +1,14 @@
1
+ import { FilePreview } from '@atlaskit/media-state';
2
+ import { MediaType } from '../models/media';
3
+ /**
4
+ * Async helper determining if we should fetch remote fileStates from the backend:
5
+ * - we poll the backend for all supported documents,
6
+ * - we poll the backend is mimeType isn't natively supported by the browser,
7
+ * - we poll the backend if we don't have a local preview available.
8
+ * - we poll the backend if we have a video with which we can't extract dimensions,
9
+ *
10
+ * Polling the backend periodically refreshes the cached fileState until the file is processed.
11
+ * Polling is needed for the use cases above to properly render the file in our components.
12
+ *
13
+ */
14
+ export declare function shouldFetchRemoteFileStates(mediaType: MediaType, mimeType: string, preview?: FilePreview | Promise<FilePreview>): Promise<boolean>;
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { MediaClientConfig } from '@atlaskit/media-core';
3
+ import { MediaClient } from '../client/media-client';
4
+ import { Identifier } from '../identifier';
5
+ /**
6
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
7
+ */
8
+ export interface WithMediaClientConfig {
9
+ mediaClientConfig: MediaClientConfig;
10
+ }
11
+ /**
12
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
13
+ */
14
+ export interface WithMediaClient {
15
+ mediaClient: MediaClient;
16
+ identifier?: Identifier;
17
+ }
18
+ /**
19
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
20
+ */
21
+ export declare const getMediaClient: (mediaClientConfig: MediaClientConfig) => MediaClient;
22
+ /**
23
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
24
+ */
25
+ export type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<P, 'mediaClient'> & WithMediaClientConfig;
26
+ /**
27
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
28
+ */
29
+ export type WithMediaClientFunction = <P extends WithMediaClient>(Component: React.ComponentType<P>) => React.ComponentType<WithMediaClientConfigProps<P>>;
30
+ /**
31
+ * @deprecated This export will be removed. Please use one from `@atlaskit/media-client-react`
32
+ */
33
+ export declare const withMediaClient: WithMediaClientFunction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "24.0.1",
3
+ "version": "24.0.3",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -67,7 +67,7 @@
67
67
  "@atlaskit/media-core": "^34.1.0",
68
68
  "@atlaskit/media-state": "^1.0.0",
69
69
  "@atlaskit/ssr": "*",
70
- "@atlaskit/tokens": "^1.25.0",
70
+ "@atlaskit/tokens": "^1.28.0",
71
71
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
72
72
  "@emotion/react": "^11.7.1",
73
73
  "@types/deep-equal": "^1.0.1",
package/report.api.md CHANGED
@@ -448,7 +448,7 @@ export interface GetFileOptions {
448
448
  // @public (undocumented)
449
449
  export const getFileStreamsCache: () => StreamsCache<FileState>;
450
450
 
451
- // @public (undocumented)
451
+ // @public @deprecated (undocumented)
452
452
  export const getMediaClient: (
453
453
  mediaClientConfig: MediaClientConfig,
454
454
  ) => MediaClient;
@@ -1517,7 +1517,7 @@ export interface UploadFileResult {
1517
1517
 
1518
1518
  export { UploadingFileState };
1519
1519
 
1520
- // @public (undocumented)
1520
+ // @public @deprecated (undocumented)
1521
1521
  export interface WithMediaClient {
1522
1522
  // (undocumented)
1523
1523
  identifier?: Identifier;
@@ -1525,23 +1525,23 @@ export interface WithMediaClient {
1525
1525
  mediaClient: MediaClient;
1526
1526
  }
1527
1527
 
1528
- // @public (undocumented)
1528
+ // @public @deprecated (undocumented)
1529
1529
  export const withMediaClient: WithMediaClientFunction;
1530
1530
 
1531
- // @public (undocumented)
1531
+ // @public @deprecated (undocumented)
1532
1532
  export interface WithMediaClientConfig {
1533
1533
  // (undocumented)
1534
1534
  mediaClientConfig: MediaClientConfig;
1535
1535
  }
1536
1536
 
1537
- // @public (undocumented)
1537
+ // @public @deprecated (undocumented)
1538
1538
  export type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<
1539
1539
  P,
1540
1540
  'mediaClient'
1541
1541
  > &
1542
1542
  WithMediaClientConfig;
1543
1543
 
1544
- // @public (undocumented)
1544
+ // @public @deprecated (undocumented)
1545
1545
  export type WithMediaClientFunction = <P extends WithMediaClient>(
1546
1546
  Component: React_2.ComponentType<P>,
1547
1547
  ) => React_2.ComponentType<WithMediaClientConfigProps<P>>;