@atlaskit/media-client 23.2.0 → 24.0.1

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 (183) hide show
  1. package/CHANGELOG.md +93 -74
  2. package/dist/cjs/client/file-fetcher/error.js +1 -2
  3. package/dist/cjs/client/file-fetcher/index.js +113 -38
  4. package/dist/cjs/client/media-client.js +20 -9
  5. package/dist/cjs/client/media-store/error.js +1 -2
  6. package/dist/cjs/client/media-store/index.js +5 -9
  7. package/dist/cjs/client/media-store/resolveAuth.js +4 -7
  8. package/dist/cjs/client/mobile-upload.js +40 -5
  9. package/dist/cjs/client/stargate-client.js +2 -3
  10. package/dist/cjs/constants.js +6 -12
  11. package/dist/cjs/file-streams-cache.js +3 -5
  12. package/dist/cjs/globalMediaEventEmitter.js +2 -3
  13. package/dist/cjs/identifier.js +4 -7
  14. package/dist/cjs/index.js +17 -20
  15. package/dist/cjs/models/artifacts.js +2 -3
  16. package/dist/cjs/models/errors/index.js +2 -3
  17. package/dist/cjs/models/file-state.js +10 -19
  18. package/dist/cjs/models/media.js +3 -5
  19. package/dist/cjs/test-helpers/authProvider.js +2 -3
  20. package/dist/cjs/test-helpers/collectionNames.js +5 -10
  21. package/dist/cjs/test-helpers/exampleMediaItems.js +48 -91
  22. package/dist/cjs/test-helpers/fakeMediaClient.js +3 -5
  23. package/dist/cjs/test-helpers/index.js +1 -2
  24. package/dist/cjs/test-helpers/mediaClientProvider.js +7 -13
  25. package/dist/cjs/test-helpers/mediaPickerAuthProvider.js +4 -7
  26. package/dist/cjs/upload-controller.js +2 -3
  27. package/dist/cjs/uploader/calculateChunkSize.js +4 -5
  28. package/dist/cjs/uploader/error.js +1 -2
  29. package/dist/cjs/uploader/index.js +3 -4
  30. package/dist/cjs/utils/checkWebpSupport.js +2 -3
  31. package/dist/cjs/utils/convertBase64ToBlob.js +2 -3
  32. package/dist/cjs/utils/createFileDataLoader.js +2 -4
  33. package/dist/cjs/utils/detectEmptyFile.js +2 -2
  34. package/dist/cjs/utils/getDimensionsFromBlob.js +2 -3
  35. package/dist/cjs/utils/getImageDimensionsFromBlob.js +2 -3
  36. package/dist/cjs/utils/getMediaTypeFromUploadableFile.js +2 -3
  37. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +2 -3
  38. package/dist/cjs/utils/hashing/hasherCreator.js +3 -5
  39. package/dist/cjs/utils/hashing/simpleHasher.js +4 -4
  40. package/dist/cjs/utils/hashing/workerHasher.js +2 -3
  41. package/dist/cjs/utils/imageResizeModeToFileImageMode.js +2 -3
  42. package/dist/cjs/utils/isImageRemote.js +2 -3
  43. package/dist/cjs/utils/mediaSubscribable/toPromise.js +2 -3
  44. package/dist/cjs/utils/mobileUpload/error.js +1 -2
  45. package/dist/cjs/utils/mobileUpload/helpers.js +3 -5
  46. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +1 -2
  47. package/dist/cjs/utils/mobileUpload/stateMachine/states/error.js +2 -3
  48. package/dist/cjs/utils/mobileUpload/stateMachine/states/processed.js +2 -3
  49. package/dist/cjs/utils/mobileUpload/stateMachine/states/processing.js +2 -3
  50. package/dist/cjs/utils/mobileUpload/stateMachine/states/processingFailed.js +2 -3
  51. package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +2 -3
  52. package/dist/cjs/utils/overrideMediaTypeIfUnknown.js +2 -3
  53. package/dist/cjs/utils/polling/errors.js +1 -2
  54. package/dist/cjs/utils/polling/index.js +3 -5
  55. package/dist/cjs/utils/request/errors.js +1 -2
  56. package/dist/cjs/utils/request/helpers.js +4 -5
  57. package/dist/cjs/utils/safeUnsubscribe.js +2 -3
  58. package/dist/cjs/utils/setTimeoutPromise.js +3 -5
  59. package/dist/cjs/utils/url.js +5 -9
  60. package/dist/cjs/utils/with-media-client-hoc.js +9 -19
  61. package/dist/es2019/client/file-fetcher/index.js +101 -28
  62. package/dist/es2019/client/media-client.js +15 -7
  63. package/dist/es2019/client/media-store/index.js +1 -2
  64. package/dist/es2019/client/mobile-upload.js +33 -2
  65. package/dist/es2019/index.js +1 -0
  66. package/dist/es2019/utils/hashing/simpleHasher.js +2 -1
  67. package/dist/es2019/utils/request/helpers.js +1 -1
  68. package/dist/es2019/utils/with-media-client-hoc.js +8 -16
  69. package/dist/esm/client/file-fetcher/index.js +107 -31
  70. package/dist/esm/client/media-client.js +19 -7
  71. package/dist/esm/client/media-store/index.js +1 -2
  72. package/dist/esm/client/mobile-upload.js +38 -2
  73. package/dist/esm/index.js +1 -0
  74. package/dist/esm/uploader/index.js +2 -2
  75. package/dist/esm/utils/hashing/simpleHasher.js +2 -1
  76. package/dist/esm/utils/request/helpers.js +1 -1
  77. package/dist/esm/utils/with-media-client-hoc.js +8 -16
  78. package/dist/types/client/events.d.ts +1 -1
  79. package/dist/types/client/file-fetcher/index.d.ts +10 -6
  80. package/dist/types/client/media-client.d.ts +10 -5
  81. package/dist/types/client/media-store/index.d.ts +3 -4
  82. package/dist/types/client/mobile-upload.d.ts +6 -2
  83. package/dist/types/file-streams-cache.d.ts +1 -1
  84. package/dist/types/index.d.ts +4 -2
  85. package/dist/types/models/artifacts.d.ts +1 -14
  86. package/dist/types/models/file-state.d.ts +4 -73
  87. package/dist/types/models/media.d.ts +1 -1
  88. package/dist/types/models/mobile-upload.d.ts +1 -1
  89. package/dist/types/utils/createMediaSubject.d.ts +1 -1
  90. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +1 -1
  91. package/dist/types/utils/mediaSubscribable/toPromise.d.ts +1 -1
  92. package/dist/types/utils/mediaSubscribable/types.d.ts +1 -1
  93. package/dist/types/utils/mobileUpload/helpers.d.ts +1 -1
  94. package/dist/types/utils/mobileUpload/stateMachine/index.d.ts +1 -1
  95. package/dist/types/utils/mobileUpload/stateMachine/types.d.ts +1 -1
  96. package/dist/types/utils/overrideMediaTypeIfUnknown.d.ts +1 -1
  97. package/dist/types/utils/shouldFetchRemoteFileStates.d.ts +1 -1
  98. package/dist/types/utils/with-media-client-hoc.d.ts +2 -3
  99. package/package.json +5 -3
  100. package/report.api.md +51 -168
  101. package/dist/types-ts4.5/client/__mocks__/collection-fetcher.d.ts +0 -8
  102. package/dist/types-ts4.5/client/__mocks__/file-fetcher.d.ts +0 -10
  103. package/dist/types-ts4.5/client/__mocks__/media-client.d.ts +0 -11
  104. package/dist/types-ts4.5/client/events.d.ts +0 -14
  105. package/dist/types-ts4.5/client/file-fetcher/error.d.ts +0 -29
  106. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +0 -58
  107. package/dist/types-ts4.5/client/media-client.d.ts +0 -27
  108. package/dist/types-ts4.5/client/media-store/error.d.ts +0 -16
  109. package/dist/types-ts4.5/client/media-store/index.d.ts +0 -169
  110. package/dist/types-ts4.5/client/media-store/resolveAuth.d.ts +0 -4
  111. package/dist/types-ts4.5/client/mobile-upload.d.ts +0 -11
  112. package/dist/types-ts4.5/client/stargate-client.d.ts +0 -15
  113. package/dist/types-ts4.5/constants.d.ts +0 -6
  114. package/dist/types-ts4.5/file-streams-cache.d.ts +0 -15
  115. package/dist/types-ts4.5/globalMediaEventEmitter.d.ts +0 -6
  116. package/dist/types-ts4.5/identifier.d.ts +0 -15
  117. package/dist/types-ts4.5/index.d.ts +0 -87
  118. package/dist/types-ts4.5/models/artifacts.d.ts +0 -15
  119. package/dist/types-ts4.5/models/auth-headers.d.ts +0 -11
  120. package/dist/types-ts4.5/models/auth-query-parameters.d.ts +0 -11
  121. package/dist/types-ts4.5/models/errors/helpers.d.ts +0 -6
  122. package/dist/types-ts4.5/models/errors/index.d.ts +0 -11
  123. package/dist/types-ts4.5/models/errors/types.d.ts +0 -15
  124. package/dist/types-ts4.5/models/file-state.d.ts +0 -94
  125. package/dist/types-ts4.5/models/item.d.ts +0 -25
  126. package/dist/types-ts4.5/models/media.d.ts +0 -48
  127. package/dist/types-ts4.5/models/mobile-upload.d.ts +0 -28
  128. package/dist/types-ts4.5/test-helpers/_numbers.d.ts +0 -1
  129. package/dist/types-ts4.5/test-helpers/authProvider.d.ts +0 -6
  130. package/dist/types-ts4.5/test-helpers/collectionNames.d.ts +0 -5
  131. package/dist/types-ts4.5/test-helpers/exampleMediaItems.d.ts +0 -53
  132. package/dist/types-ts4.5/test-helpers/fakeMediaClient.d.ts +0 -4
  133. package/dist/types-ts4.5/test-helpers/index.d.ts +0 -7
  134. package/dist/types-ts4.5/test-helpers/mediaClientProvider.d.ts +0 -23
  135. package/dist/types-ts4.5/test-helpers/mediaPickerAuthProvider.d.ts +0 -5
  136. package/dist/types-ts4.5/upload-controller.d.ts +0 -7
  137. package/dist/types-ts4.5/uploader/calculateChunkSize.d.ts +0 -11
  138. package/dist/types-ts4.5/uploader/error.d.ts +0 -29
  139. package/dist/types-ts4.5/uploader/index.d.ts +0 -23
  140. package/dist/types-ts4.5/utils/checkWebpSupport.d.ts +0 -1
  141. package/dist/types-ts4.5/utils/convertBase64ToBlob.d.ts +0 -1
  142. package/dist/types-ts4.5/utils/createFileDataLoader.d.ts +0 -30
  143. package/dist/types-ts4.5/utils/createMediaSubject.d.ts +0 -3
  144. package/dist/types-ts4.5/utils/detectEmptyFile.d.ts +0 -16
  145. package/dist/types-ts4.5/utils/getDimensionsFromBlob.d.ts +0 -6
  146. package/dist/types-ts4.5/utils/getImageDimensionsFromBlob.d.ts +0 -5
  147. package/dist/types-ts4.5/utils/getMediaTypeFromUploadableFile.d.ts +0 -3
  148. package/dist/types-ts4.5/utils/getVideoDimensionsFromBlob.d.ts +0 -5
  149. package/dist/types-ts4.5/utils/hashing/hasher.d.ts +0 -3
  150. package/dist/types-ts4.5/utils/hashing/hasherCreator.d.ts +0 -3
  151. package/dist/types-ts4.5/utils/hashing/simpleHasher.d.ts +0 -4
  152. package/dist/types-ts4.5/utils/hashing/workerHasher.d.ts +0 -16
  153. package/dist/types-ts4.5/utils/imageResizeModeToFileImageMode.d.ts +0 -3
  154. package/dist/types-ts4.5/utils/isImageRemote.d.ts +0 -1
  155. package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +0 -5
  156. package/dist/types-ts4.5/utils/mediaSubscribable/index.d.ts +0 -3
  157. package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +0 -10
  158. package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +0 -17
  159. package/dist/types-ts4.5/utils/mobileUpload/error.d.ts +0 -29
  160. package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +0 -8
  161. package/dist/types-ts4.5/utils/mobileUpload/index.d.ts +0 -5
  162. package/dist/types-ts4.5/utils/mobileUpload/servicesCache.d.ts +0 -4
  163. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +0 -7
  164. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/error.d.ts +0 -3
  165. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processed.d.ts +0 -3
  166. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processing.d.ts +0 -3
  167. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +0 -3
  168. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/states/uploading.d.ts +0 -3
  169. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +0 -69
  170. package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +0 -5
  171. package/dist/types-ts4.5/utils/polling/errors.d.ts +0 -12
  172. package/dist/types-ts4.5/utils/polling/index.d.ts +0 -33
  173. package/dist/types-ts4.5/utils/polling/types.d.ts +0 -7
  174. package/dist/types-ts4.5/utils/request/errors.d.ts +0 -20
  175. package/dist/types-ts4.5/utils/request/helpers.d.ts +0 -46
  176. package/dist/types-ts4.5/utils/request/index.d.ts +0 -5
  177. package/dist/types-ts4.5/utils/request/types.d.ts +0 -46
  178. package/dist/types-ts4.5/utils/safeUnsubscribe.d.ts +0 -2
  179. package/dist/types-ts4.5/utils/setTimeoutPromise.d.ts +0 -2
  180. package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +0 -14
  181. package/dist/types-ts4.5/utils/url.d.ts +0 -17
  182. package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +0 -16
  183. package/tmp/api-report-tmp.d.ts +0 -1334
@@ -1,3 +0,0 @@
1
- import { StateNodeConfig } from 'xstate';
2
- import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
- export declare const machineProcessedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -1,3 +0,0 @@
1
- import { StateNodeConfig } from 'xstate';
2
- import { ProcessingStateMachineSchema, StateMachineContext, StateMachineEvent } from '../types';
3
- export declare const machineProcessingState: StateNodeConfig<StateMachineContext, ProcessingStateMachineSchema, StateMachineEvent>;
@@ -1,3 +0,0 @@
1
- import { StateNodeConfig } from 'xstate';
2
- import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
- export declare const machineProcessingFailedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -1,3 +0,0 @@
1
- import { StateNodeConfig } from 'xstate';
2
- import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
- export declare const machineUploadingState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -1,69 +0,0 @@
1
- import { StateSchema } from 'xstate';
2
- import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '../../../models/file-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
- };
@@ -1,5 +0,0 @@
1
- import { FileState } from '../models/file-state';
2
- import { MediaType } from '../models/media';
3
- export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?: MediaType) => {
4
- mediaType?: MediaType | undefined;
5
- };
@@ -1,12 +0,0 @@
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;
@@ -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 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
- };
@@ -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,46 +0,0 @@
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
- };
@@ -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, createRequestErrorReason } from './helpers';
5
- export declare function request(url: string, options?: RequestOptions, controller?: AbortController): Promise<Response>;
@@ -1,46 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- import { MediaSubscription } from './mediaSubscribable';
2
- export declare const safeUnsubscribe: (subscription: MediaSubscription) => void;
@@ -1,2 +0,0 @@
1
- export declare const resolveTimeout: <T>(timeout: number, resolveWith: T) => Promise<T>;
2
- export declare const rejectTimeout: (timeout: number, rejectWith: Error) => Promise<undefined>;
@@ -1,14 +0,0 @@
1
- import { FilePreview } from '../models/file-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>;
@@ -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) => MediaClient;
14
- export type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<P, 'mediaClient'> & WithMediaClientConfig;
15
- export type WithMediaClientFunction = <P extends WithMediaClient>(Component: React.ComponentType<P>, featureFlags?: MediaFeatureFlags) => React.ComponentType<WithMediaClientConfigProps<P>>;
16
- export declare const withMediaClient: WithMediaClientFunction;