@atlaskit/media-client 18.1.0 → 19.0.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 +10 -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/uploader/index.js +22 -20
- package/dist/cjs/utils/request/helpers.js +39 -22
- package/dist/cjs/utils/request/index.js +3 -2
- 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/uploader/index.js +13 -13
- package/dist/es2019/utils/request/helpers.js +26 -8
- package/dist/es2019/utils/request/index.js +4 -3
- 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/uploader/index.js +22 -20
- package/dist/esm/utils/request/helpers.js +36 -20
- package/dist/esm/utils/request/index.js +4 -3
- 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 +15 -21
- 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 +2 -0
- package/package.json +4 -12
- package/report.api.md +101 -70
- 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,66 +0,0 @@
|
|
|
1
|
-
import { MediaFeatureFlags, MediaType } from '@atlaskit/media-common';
|
|
2
|
-
import type { MediaFileArtifacts } from './artifacts';
|
|
3
|
-
export declare type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
|
|
4
|
-
export type { MediaType } from '@atlaskit/media-common';
|
|
5
|
-
export declare const isPreviewableType: (type: MediaType, featureFlags?: MediaFeatureFlags | undefined) => boolean;
|
|
6
|
-
export declare type MediaFile = {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly mediaType: MediaType;
|
|
9
|
-
readonly mimeType: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly processingStatus?: MediaFileProcessingStatus;
|
|
12
|
-
readonly size: number;
|
|
13
|
-
readonly artifacts: MediaFileArtifacts;
|
|
14
|
-
readonly representations: MediaRepresentations;
|
|
15
|
-
readonly createdAt?: number;
|
|
16
|
-
};
|
|
17
|
-
export declare type MediaCollection = {
|
|
18
|
-
readonly name: string;
|
|
19
|
-
readonly createdAt: number;
|
|
20
|
-
};
|
|
21
|
-
export declare type MediaCollectionItems = {
|
|
22
|
-
readonly contents: MediaCollectionItem[];
|
|
23
|
-
readonly nextInclusiveStartKey?: string;
|
|
24
|
-
};
|
|
25
|
-
export declare type MediaCollectionItem = {
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly insertedAt: number;
|
|
28
|
-
readonly occurrenceKey: string;
|
|
29
|
-
readonly details: MediaCollectionItemDetails;
|
|
30
|
-
};
|
|
31
|
-
export declare type MediaCollectionItemMinimalDetails = {
|
|
32
|
-
readonly name: string;
|
|
33
|
-
readonly size: number;
|
|
34
|
-
};
|
|
35
|
-
export declare type MediaCollectionItemFullDetails = {
|
|
36
|
-
readonly mediaType: MediaType;
|
|
37
|
-
readonly mimeType: string;
|
|
38
|
-
readonly name: string;
|
|
39
|
-
readonly processingStatus: MediaFileProcessingStatus;
|
|
40
|
-
readonly size: number;
|
|
41
|
-
readonly artifacts: MediaFileArtifacts;
|
|
42
|
-
readonly representations: MediaRepresentations;
|
|
43
|
-
readonly createdAt?: number;
|
|
44
|
-
};
|
|
45
|
-
export declare type MediaRepresentations = {
|
|
46
|
-
image?: Object;
|
|
47
|
-
};
|
|
48
|
-
export declare type MediaCollectionItemDetails = MediaCollectionItemMinimalDetails | MediaCollectionItemFullDetails;
|
|
49
|
-
export declare const isMediaCollectionItemFullDetails: (mediaCollectionItem: MediaCollectionItemDetails) => mediaCollectionItem is MediaCollectionItemFullDetails;
|
|
50
|
-
export declare type MediaUpload = {
|
|
51
|
-
readonly id: string;
|
|
52
|
-
readonly created: number;
|
|
53
|
-
readonly expires: number;
|
|
54
|
-
};
|
|
55
|
-
export declare type MediaChunksProbe = {
|
|
56
|
-
readonly results: {
|
|
57
|
-
readonly [etag: string]: {
|
|
58
|
-
readonly exists: boolean;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export declare enum DATA_UNIT {
|
|
63
|
-
MB = 1048576,
|
|
64
|
-
GB = 1073741824,
|
|
65
|
-
TB = 1099511627776
|
|
66
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FilePreview } from './file-state';
|
|
2
|
-
export declare type MobileUploadStartEvent = {
|
|
3
|
-
fileId: string;
|
|
4
|
-
collectionName?: string;
|
|
5
|
-
occurrenceKey?: string;
|
|
6
|
-
fileName: string;
|
|
7
|
-
fileSize: number;
|
|
8
|
-
fileMimetype: string;
|
|
9
|
-
preview?: FilePreview;
|
|
10
|
-
createdAt?: number;
|
|
11
|
-
};
|
|
12
|
-
export declare type MobileUploadProgressEvent = {
|
|
13
|
-
fileId: string;
|
|
14
|
-
progress: number;
|
|
15
|
-
};
|
|
16
|
-
export declare type MobileUploadEndEvent = {
|
|
17
|
-
fileId: string;
|
|
18
|
-
};
|
|
19
|
-
export declare type MobileUploadErrorEvent = {
|
|
20
|
-
fileId: string;
|
|
21
|
-
message: string;
|
|
22
|
-
};
|
|
23
|
-
export interface MobileUpload {
|
|
24
|
-
notifyUploadStart(event: MobileUploadStartEvent): void;
|
|
25
|
-
notifyUploadProgress(event: MobileUploadProgressEvent): void;
|
|
26
|
-
notifyUploadEnd(event: MobileUploadEndEvent): void;
|
|
27
|
-
notifyUploadError(event: MobileUploadErrorEvent): void;
|
|
28
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const fileSizeError = "fileSizeExceedsLimit";
|
|
2
|
-
/**
|
|
3
|
-
* This is a helper to dynamically calculate the chunk size for a given file size.
|
|
4
|
-
*
|
|
5
|
-
* @param fileSize The size of a file to calculate the chunk size for.
|
|
6
|
-
* @returns A number of bytes per chunk or Throws an Error if the file size exceeds 2TB
|
|
7
|
-
*
|
|
8
|
-
* @see {@link https://product-fabric.atlassian.net/wiki/spaces/FIL/pages/3221881143/Rule+of+thumb+for+chunk+sizes#Given-the-following-conditions}
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export declare const calculateChunkSize: (fileSize: number) => number;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../models/errors';
|
|
2
|
-
export declare type UploaderErrorReason = 'fileSizeExceedsLimit';
|
|
3
|
-
export declare type UploaderErrorAttributes = {
|
|
4
|
-
readonly reason: UploaderErrorReason;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly metadata?: {
|
|
7
|
-
readonly collectionName?: string;
|
|
8
|
-
readonly occurrenceKey?: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare class UploaderError extends BaseMediaClientError<UploaderErrorAttributes> {
|
|
12
|
-
readonly reason: UploaderErrorReason;
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly metadata?: {
|
|
15
|
-
readonly collectionName?: string | undefined;
|
|
16
|
-
readonly occurrenceKey?: string | undefined;
|
|
17
|
-
} | undefined;
|
|
18
|
-
constructor(reason: UploaderErrorReason, id: string, metadata?: {
|
|
19
|
-
readonly collectionName?: string | undefined;
|
|
20
|
-
readonly occurrenceKey?: string | undefined;
|
|
21
|
-
} | undefined);
|
|
22
|
-
get attributes(): {
|
|
23
|
-
reason: "fileSizeExceedsLimit";
|
|
24
|
-
id: string;
|
|
25
|
-
collectionName: string | undefined;
|
|
26
|
-
occurrenceKey: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function isUploaderError(err: Error): err is UploaderError;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ChunkinatorFile } from '@atlaskit/chunkinator';
|
|
2
|
-
import { MediaStore } from '../client/media-store';
|
|
3
|
-
export declare type UploadableFile = {
|
|
4
|
-
content: ChunkinatorFile;
|
|
5
|
-
name?: string;
|
|
6
|
-
mimeType?: string;
|
|
7
|
-
collection?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type UploadableFileUpfrontIds = {
|
|
10
|
-
id: string;
|
|
11
|
-
deferredUploadId: Promise<string>;
|
|
12
|
-
occurrenceKey?: string;
|
|
13
|
-
};
|
|
14
|
-
export declare type UploadFileCallbacks = {
|
|
15
|
-
onProgress: (progress: number) => void;
|
|
16
|
-
onUploadFinish: (error?: any) => void;
|
|
17
|
-
};
|
|
18
|
-
export interface UploadFileResult {
|
|
19
|
-
cancel: () => void;
|
|
20
|
-
}
|
|
21
|
-
export declare const uploadFile: (file: UploadableFile, store: MediaStore, uploadableFileUpfrontIds: UploadableFileUpfrontIds, callbacks?: UploadFileCallbacks | undefined) => UploadFileResult;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const checkWebpSupport: () => Promise<boolean>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const convertBase64ToBlob: (base64: string) => Blob;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import 'setimmediate';
|
|
2
|
-
import Dataloader from 'dataloader';
|
|
3
|
-
import { MediaStore, ResponseFileItem } from '../client/media-store';
|
|
4
|
-
import { MediaCollectionItemFullDetails } from '../models/media';
|
|
5
|
-
export declare const MAX_BATCH_SIZE = 100;
|
|
6
|
-
export declare type DataloaderKey = {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly collectionName?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare type DataloaderResult = MediaCollectionItemFullDetails | null;
|
|
11
|
-
export declare type BatchLoadingErrorResult = {
|
|
12
|
-
readonly id: string;
|
|
13
|
-
readonly collection?: string;
|
|
14
|
-
readonly error: Error;
|
|
15
|
-
};
|
|
16
|
-
export declare const getItemsFromKeys: (dataloaderKeys: ReadonlyArray<DataloaderKey>, fileItems: Array<ResponseFileItem | BatchLoadingErrorResult>) => Array<DataloaderResult | Error>;
|
|
17
|
-
export declare type FileIdsByCollection = {
|
|
18
|
-
[collectionName: string]: string[];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
|
|
22
|
-
* Such contract is formalised by Dataloader 1.0, @see https://github.com/graphql/dataloader
|
|
23
|
-
*
|
|
24
|
-
* If an Error is resolved in the results, it must be at same position then their corresponding key:
|
|
25
|
-
* - Dataloader will re-throw that Error when accessing/loading that particular key
|
|
26
|
-
*
|
|
27
|
-
* @param mediaStore instance of MediaStore
|
|
28
|
-
*/
|
|
29
|
-
export declare function createBatchLoadingFunc(mediaStore: MediaStore): (keys: ReadonlyArray<DataloaderKey>) => Promise<Array<DataloaderResult | Error>>;
|
|
30
|
-
export declare function createFileDataloader(mediaStore: MediaStore): Dataloader<DataloaderKey, DataloaderResult, DataloaderKey>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MediaCollectionItemFullDetails } from '../models/media';
|
|
2
|
-
/**
|
|
3
|
-
* EMPTY_FILE_HOURS_ELAPSED_TOLERANCE - how many hours since this file was
|
|
4
|
-
* created until we give up on expecting metadata?
|
|
5
|
-
*
|
|
6
|
-
* Yes, this is not an exact science. Any value under this tolerance will
|
|
7
|
-
* go undetected, however this is still suitable to catch the majority of
|
|
8
|
-
* cases where empty (files which never finished upload) are being reloaded.
|
|
9
|
-
*
|
|
10
|
-
* Continuous bad renders of empty files will eat our card render SLIs, so until
|
|
11
|
-
* there is a better response from backend we use this technique.
|
|
12
|
-
*
|
|
13
|
-
* Being encapsulated in this function, we can always improve the detection transparently.
|
|
14
|
-
*/
|
|
15
|
-
export declare const EMPTY_FILE_HOURS_ELAPSED_TOLERANCE_MS: number;
|
|
16
|
-
export declare function isEmptyFile(fileDetails: MediaCollectionItemFullDetails, now?: number): Boolean;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Hasher } from './hasher';
|
|
2
|
-
export interface Deferred {
|
|
3
|
-
resolve: (hash: string) => void;
|
|
4
|
-
reject: (error: any) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare class WorkerHasher implements Hasher {
|
|
7
|
-
private workers;
|
|
8
|
-
private jobs;
|
|
9
|
-
constructor(numOfWorkers: number);
|
|
10
|
-
hash(chunk: Blob): Promise<string>;
|
|
11
|
-
private createWorker;
|
|
12
|
-
private handleWorkerMessage;
|
|
13
|
-
private calculateHashInWorker;
|
|
14
|
-
private dispatch;
|
|
15
|
-
private getMostRelaxedWorker;
|
|
16
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { MediaStoreGetFileImageParams } from '../client/media-store';
|
|
2
|
-
export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
|
|
3
|
-
export declare const imageResizeModeToFileImageMode: (resizeMode?: ImageResizeMode | undefined) => MediaStoreGetFileImageParams['mode'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isImageRemote: (imageUrl: string, windowOrigin?: string) => boolean;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
import { MediaSubscribableItem } from '../../models/media-subscribable';
|
|
3
|
-
import { MediaSubscribable } from './types';
|
|
4
|
-
export declare function fromObservable<T>(observable: ReplaySubject<T>): MediaSubscribable<T>;
|
|
5
|
-
export declare function createMediaSubscribable<T extends MediaSubscribableItem>(mediaSubscribableItem?: T | Error): MediaSubscribable<T>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
-
import { MediaSubscribable } from './types';
|
|
3
|
-
import { MediaSubscribableItem } from '../../models/media-subscribable';
|
|
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: <T extends MediaSubscribableItem>(mediaSubscribable: MediaSubscribable<T>, subscription?: Subscription) => Promise<T>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare type MediaSubscription = {
|
|
2
|
-
unsubscribe: () => void;
|
|
3
|
-
};
|
|
4
|
-
declare type PartialObserver<T> = {
|
|
5
|
-
next?: (value: T) => void;
|
|
6
|
-
error?: (err: any) => void;
|
|
7
|
-
complete?: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare type NextObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'next'>>;
|
|
10
|
-
export declare type ErrorObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'error'>>;
|
|
11
|
-
export declare type CompletionObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'complete'>>;
|
|
12
|
-
export declare type MediaObserver<T> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T> | ((value: T) => void);
|
|
13
|
-
export declare type MediaSubscribable<T> = {
|
|
14
|
-
subscribe(observer?: MediaObserver<T>): MediaSubscription;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
-
export declare type MobileUploadErrorReason = 'emptyItems' | 'zeroVersionFile';
|
|
3
|
-
export declare 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;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import Dataloader from 'dataloader';
|
|
2
|
-
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
3
|
-
import { Interpreter } from 'xstate';
|
|
4
|
-
import { FileState } from '../../models/file-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 | undefined, occurrenceKey?: string | undefined) => ReplaySubject<FileState>;
|
|
@@ -1,5 +0,0 @@
|
|
|
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';
|
|
@@ -1,4 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import DataLoader from 'dataloader';
|
|
2
|
-
import { Interpreter, StateMachine } from 'xstate';
|
|
3
|
-
import { UploadingFileState } from '../../../models/file-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 | undefined) => StateMachine<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>;
|
|
7
|
-
export declare function createMobileUploadService(machine: StateMachine<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>): Interpreter<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { StateSchema } from 'xstate';
|
|
2
|
-
import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '../../../models/file-state';
|
|
3
|
-
export declare type StateMachineContext = {
|
|
4
|
-
currentFileState: FileState;
|
|
5
|
-
};
|
|
6
|
-
export declare 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 declare type ProcessingStateMachineSchema = StateSchema<StateMachineContext> & {
|
|
29
|
-
states: {
|
|
30
|
-
loading: StateSchema<StateMachineContext>;
|
|
31
|
-
fetchingRemoteFileStates: StateSchema<StateMachineContext>;
|
|
32
|
-
idle: StateSchema<StateMachineContext>;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export declare 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 declare 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,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 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>;
|