@atlaskit/media-client 17.1.2 → 17.1.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.
- package/CHANGELOG.md +7 -0
- package/constants/package.json +8 -1
- package/dist/cjs/client/media-store/resolveAuth.js +1 -1
- package/dist/cjs/utils/request/helpers.js +4 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/media-store/resolveAuth.js +1 -1
- package/dist/es2019/utils/request/helpers.js +4 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/media-store/resolveAuth.js +1 -1
- package/dist/esm/utils/request/helpers.js +4 -4
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +8 -0
- package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +10 -0
- package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +13 -0
- package/dist/types-ts4.0/client/collection-fetcher.d.ts +35 -0
- package/dist/types-ts4.0/client/events.d.ts +14 -0
- package/dist/types-ts4.0/client/file-fetcher/error.d.ts +29 -0
- package/dist/types-ts4.0/client/file-fetcher/index.d.ts +56 -0
- package/dist/types-ts4.0/client/media-client.d.ts +28 -0
- package/dist/types-ts4.0/client/media-store/error.d.ts +16 -0
- package/dist/types-ts4.0/client/media-store/index.d.ts +167 -0
- package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +4 -0
- package/dist/types-ts4.0/client/mobile-upload.d.ts +11 -0
- package/dist/types-ts4.0/client/stargate-client.d.ts +15 -0
- package/dist/types-ts4.0/constants.d.ts +6 -0
- package/dist/types-ts4.0/file-streams-cache.d.ts +15 -0
- package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +6 -0
- package/dist/types-ts4.0/identifier.d.ts +15 -0
- package/dist/types-ts4.0/index.d.ts +90 -0
- package/dist/types-ts4.0/models/artifacts.d.ts +12 -0
- package/dist/types-ts4.0/models/auth-headers.d.ts +11 -0
- package/dist/types-ts4.0/models/auth-query-parameters.d.ts +11 -0
- package/dist/types-ts4.0/models/errors/helpers.d.ts +6 -0
- package/dist/types-ts4.0/models/errors/index.d.ts +11 -0
- package/dist/types-ts4.0/models/errors/types.d.ts +15 -0
- package/dist/types-ts4.0/models/file-state.d.ts +91 -0
- package/dist/types-ts4.0/models/item.d.ts +25 -0
- package/dist/types-ts4.0/models/media-subscribable.d.ts +3 -0
- package/dist/types-ts4.0/models/media.d.ts +66 -0
- package/dist/types-ts4.0/models/mobile-upload.d.ts +28 -0
- package/dist/types-ts4.0/upload-controller.d.ts +7 -0
- package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +11 -0
- package/dist/types-ts4.0/uploader/error.d.ts +29 -0
- package/dist/types-ts4.0/uploader/index.d.ts +21 -0
- package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +1 -0
- package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +1 -0
- package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +30 -0
- package/dist/types-ts4.0/utils/createMediaSubject.d.ts +3 -0
- package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +16 -0
- package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +5 -0
- package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +3 -0
- package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +6 -0
- package/dist/types-ts4.0/utils/hashing/hasher.d.ts +3 -0
- package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +3 -0
- package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +4 -0
- package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +16 -0
- package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +3 -0
- package/dist/types-ts4.0/utils/isImageRemote.d.ts +1 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +5 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +3 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +10 -0
- package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +16 -0
- package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +29 -0
- package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +8 -0
- package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +5 -0
- package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +4 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +7 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
- package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +69 -0
- package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +5 -0
- package/dist/types-ts4.0/utils/polling/errors.d.ts +12 -0
- package/dist/types-ts4.0/utils/polling/index.d.ts +33 -0
- package/dist/types-ts4.0/utils/polling/types.d.ts +7 -0
- package/dist/types-ts4.0/utils/request/errors.d.ts +20 -0
- package/dist/types-ts4.0/utils/request/helpers.d.ts +38 -0
- package/dist/types-ts4.0/utils/request/index.d.ts +5 -0
- package/dist/types-ts4.0/utils/request/types.d.ts +43 -0
- package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +2 -0
- package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +2 -0
- package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +16 -0
- package/dist/types-ts4.0/utils/url.d.ts +17 -0
- package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +16 -0
- package/package.json +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 17.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 17.1.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/constants/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/constants.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/constants.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/constants.d.ts"
|
|
7
|
+
"types": "../dist/types/constants.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/constants.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
|
@@ -49,7 +49,7 @@ var resolveAuth = /*#__PURE__*/function () {
|
|
|
49
49
|
throw _context.t0;
|
|
50
50
|
|
|
51
51
|
case 11:
|
|
52
|
-
throw new _error.MediaStoreError('failedAuthProvider', _context.t0);
|
|
52
|
+
throw new _error.MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
53
53
|
|
|
54
54
|
case 12:
|
|
55
55
|
if (auth) {
|
|
@@ -152,7 +152,7 @@ function _mapResponseToJson() {
|
|
|
152
152
|
_context3.t0 = _context3["catch"](1);
|
|
153
153
|
throw new _errors.RequestError('serverInvalidBody', {
|
|
154
154
|
statusCode: response.status
|
|
155
|
-
}, _context3.t0);
|
|
155
|
+
}, _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
156
156
|
|
|
157
157
|
case 10:
|
|
158
158
|
case "end":
|
|
@@ -193,7 +193,7 @@ function _mapResponseToBlob() {
|
|
|
193
193
|
_context4.t0 = _context4["catch"](1);
|
|
194
194
|
throw new _errors.RequestError('serverInvalidBody', {
|
|
195
195
|
statusCode: response.status
|
|
196
|
-
}, _context4.t0);
|
|
196
|
+
}, _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
197
197
|
|
|
198
198
|
case 10:
|
|
199
199
|
case "end":
|
|
@@ -230,7 +230,7 @@ function createMapResponseToJson(metadata) {
|
|
|
230
230
|
_context.t0 = _context["catch"](0);
|
|
231
231
|
throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
232
232
|
statusCode: response.status
|
|
233
|
-
}), _context.t0);
|
|
233
|
+
}), _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
234
234
|
|
|
235
235
|
case 9:
|
|
236
236
|
case "end":
|
|
@@ -265,7 +265,7 @@ function createMapResponseToBlob(metadata) {
|
|
|
265
265
|
_context2.t0 = _context2["catch"](0);
|
|
266
266
|
throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
267
267
|
statusCode: response.status
|
|
268
|
-
}), _context2.t0);
|
|
268
|
+
}), _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
269
269
|
|
|
270
270
|
case 9:
|
|
271
271
|
case "end":
|
package/dist/cjs/version.json
CHANGED
|
@@ -11,7 +11,7 @@ export const resolveAuth = async (authProvider, authContext, authProviderTimeout
|
|
|
11
11
|
throw err;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
throw new MediaStoreError('failedAuthProvider', err);
|
|
14
|
+
throw new MediaStoreError('failedAuthProvider', err instanceof Error ? err : undefined);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (!auth) {
|
|
@@ -72,7 +72,7 @@ export async function mapResponseToJson(response) {
|
|
|
72
72
|
} catch (err) {
|
|
73
73
|
throw new RequestError('serverInvalidBody', {
|
|
74
74
|
statusCode: response.status
|
|
75
|
-
}, err);
|
|
75
|
+
}, err instanceof Error ? err : undefined);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -89,7 +89,7 @@ export async function mapResponseToBlob(response) {
|
|
|
89
89
|
} catch (err) {
|
|
90
90
|
throw new RequestError('serverInvalidBody', {
|
|
91
91
|
statusCode: response.status
|
|
92
|
-
}, err);
|
|
92
|
+
}, err instanceof Error ? err : undefined);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
@@ -110,7 +110,7 @@ export function createMapResponseToJson(metadata) {
|
|
|
110
110
|
throw new RequestError('serverInvalidBody', { ...metadata,
|
|
111
111
|
...extractMediaHeaders(response),
|
|
112
112
|
statusCode: response.status
|
|
113
|
-
}, err);
|
|
113
|
+
}, err instanceof Error ? err : undefined);
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
}
|
|
@@ -122,7 +122,7 @@ export function createMapResponseToBlob(metadata) {
|
|
|
122
122
|
throw new RequestError('serverInvalidBody', { ...metadata,
|
|
123
123
|
...extractMediaHeaders(response),
|
|
124
124
|
statusCode: response.status
|
|
125
|
-
}, err);
|
|
125
|
+
}, err instanceof Error ? err : undefined);
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -34,7 +34,7 @@ export var resolveAuth = /*#__PURE__*/function () {
|
|
|
34
34
|
throw _context.t0;
|
|
35
35
|
|
|
36
36
|
case 11:
|
|
37
|
-
throw new MediaStoreError('failedAuthProvider', _context.t0);
|
|
37
|
+
throw new MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
38
38
|
|
|
39
39
|
case 12:
|
|
40
40
|
if (auth) {
|
|
@@ -108,7 +108,7 @@ function _mapResponseToJson() {
|
|
|
108
108
|
_context3.t0 = _context3["catch"](1);
|
|
109
109
|
throw new RequestError('serverInvalidBody', {
|
|
110
110
|
statusCode: response.status
|
|
111
|
-
}, _context3.t0);
|
|
111
|
+
}, _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
112
112
|
|
|
113
113
|
case 10:
|
|
114
114
|
case "end":
|
|
@@ -148,7 +148,7 @@ function _mapResponseToBlob() {
|
|
|
148
148
|
_context4.t0 = _context4["catch"](1);
|
|
149
149
|
throw new RequestError('serverInvalidBody', {
|
|
150
150
|
statusCode: response.status
|
|
151
|
-
}, _context4.t0);
|
|
151
|
+
}, _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
152
152
|
|
|
153
153
|
case 10:
|
|
154
154
|
case "end":
|
|
@@ -184,7 +184,7 @@ export function createMapResponseToJson(metadata) {
|
|
|
184
184
|
_context.t0 = _context["catch"](0);
|
|
185
185
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
186
186
|
statusCode: response.status
|
|
187
|
-
}), _context.t0);
|
|
187
|
+
}), _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
188
188
|
|
|
189
189
|
case 9:
|
|
190
190
|
case "end":
|
|
@@ -218,7 +218,7 @@ export function createMapResponseToBlob(metadata) {
|
|
|
218
218
|
_context2.t0 = _context2["catch"](0);
|
|
219
219
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
220
220
|
statusCode: response.status
|
|
221
|
-
}), _context2.t0);
|
|
221
|
+
}), _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
222
222
|
|
|
223
223
|
case 9:
|
|
224
224
|
case "end":
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare class FileFetcher {
|
|
3
|
+
constructor();
|
|
4
|
+
getFileState: jest.Mock<any, any>;
|
|
5
|
+
getCurrentState: jest.Mock<any, any>;
|
|
6
|
+
getArtifactURL: jest.Mock<any, any>;
|
|
7
|
+
touchFiles: jest.Mock<any, any>;
|
|
8
|
+
upload: jest.Mock<any, any>;
|
|
9
|
+
downloadBinary: jest.Mock<any, any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
+
import { CollectionFetcher } from '../collection-fetcher';
|
|
4
|
+
import { FileFetcher } from '../file-fetcher';
|
|
5
|
+
export declare class MediaClient {
|
|
6
|
+
readonly config: MediaClientConfig;
|
|
7
|
+
readonly collection: CollectionFetcher;
|
|
8
|
+
readonly file: FileFetcher;
|
|
9
|
+
constructor(config: MediaClientConfig);
|
|
10
|
+
getImage: jest.Mock<any, any>;
|
|
11
|
+
getImageUrl: jest.Mock<any, any>;
|
|
12
|
+
getImageMetadata: jest.Mock<any, any>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
+
import { FileDetails, FileItem } from '../models/item';
|
|
3
|
+
import { MediaCollectionItem } from '../models/media';
|
|
4
|
+
import { MediaStore, MediaStoreGetCollectionItemsParams } from './media-store';
|
|
5
|
+
import { MediaSubscribable } from '../utils/mediaSubscribable';
|
|
6
|
+
export interface MediaCollectionFileItemDetails extends FileDetails {
|
|
7
|
+
occurrenceKey: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MediaCollectionFileItem extends FileItem {
|
|
10
|
+
details: MediaCollectionFileItemDetails;
|
|
11
|
+
}
|
|
12
|
+
export interface MediaCollection {
|
|
13
|
+
id: string;
|
|
14
|
+
items: Array<MediaCollectionItem>;
|
|
15
|
+
}
|
|
16
|
+
export interface CollectionCacheEntry {
|
|
17
|
+
items: MediaCollectionItem[];
|
|
18
|
+
subject: ReplaySubject<MediaCollectionItem[]>;
|
|
19
|
+
isLoadingNextPage: boolean;
|
|
20
|
+
nextInclusiveStartKey?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare type CollectionCache = {
|
|
23
|
+
[collectionName: string]: CollectionCacheEntry;
|
|
24
|
+
};
|
|
25
|
+
export declare const collectionCache: CollectionCache;
|
|
26
|
+
export declare class CollectionFetcher {
|
|
27
|
+
readonly mediaStore: MediaStore;
|
|
28
|
+
constructor(mediaStore: MediaStore);
|
|
29
|
+
private createFileStateObserver;
|
|
30
|
+
private populateCache;
|
|
31
|
+
private removeFromCache;
|
|
32
|
+
getItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): MediaSubscribable<MediaCollectionItem[]>;
|
|
33
|
+
removeFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
|
|
34
|
+
loadNextPage(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FileState } from '../models/file-state';
|
|
2
|
+
export declare type EventPayloadMap<P> = {
|
|
3
|
+
readonly [event: string]: P;
|
|
4
|
+
};
|
|
5
|
+
export declare type EventPayloadListener<M extends EventPayloadMap<P>, E extends keyof M, P = any> = (payload: M[E]) => void;
|
|
6
|
+
export interface MediaViewedEventPayload {
|
|
7
|
+
fileId: string;
|
|
8
|
+
viewingLevel: 'minimal' | 'full' | 'download';
|
|
9
|
+
isUserCollection?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare type UploadEventPayloadMap = {
|
|
12
|
+
'file-added': FileState;
|
|
13
|
+
'media-viewed': MediaViewedEventPayload;
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export declare type FileFetcherErrorReason = 'invalidFileId' | 'emptyItems' | 'zeroVersionFile';
|
|
3
|
+
export declare type FileFetcherErrorAttributes = {
|
|
4
|
+
readonly reason: FileFetcherErrorReason;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly metadata?: {
|
|
7
|
+
readonly collectionName?: string;
|
|
8
|
+
readonly occurrenceKey?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare class FileFetcherError extends BaseMediaClientError<FileFetcherErrorAttributes> {
|
|
12
|
+
readonly reason: FileFetcherErrorReason;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly metadata?: {
|
|
15
|
+
readonly collectionName?: string | undefined;
|
|
16
|
+
readonly occurrenceKey?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
constructor(reason: FileFetcherErrorReason, id: string, metadata?: {
|
|
19
|
+
readonly collectionName?: string | undefined;
|
|
20
|
+
readonly occurrenceKey?: string | undefined;
|
|
21
|
+
} | undefined);
|
|
22
|
+
get attributes(): {
|
|
23
|
+
reason: FileFetcherErrorReason;
|
|
24
|
+
id: string;
|
|
25
|
+
collectionName: string | undefined;
|
|
26
|
+
occurrenceKey: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function isFileFetcherError(err: Error): err is FileFetcherError;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import 'setimmediate';
|
|
2
|
+
import { AuthProvider } from '@atlaskit/media-core';
|
|
3
|
+
import { MediaStore, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
|
|
4
|
+
import { FilePreview, FileState, GetFileOptions } from '../../models/file-state';
|
|
5
|
+
import { MediaFile } from '../../models/media';
|
|
6
|
+
import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
|
|
7
|
+
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
8
|
+
import { UploadController } from '../../upload-controller';
|
|
9
|
+
import { MediaSubscribable } from '../../utils/mediaSubscribable';
|
|
10
|
+
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
11
|
+
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
12
|
+
export { isFileFetcherError, FileFetcherError } from './error';
|
|
13
|
+
export interface CopySourceFile {
|
|
14
|
+
id: string;
|
|
15
|
+
collection?: string;
|
|
16
|
+
authProvider: AuthProvider;
|
|
17
|
+
}
|
|
18
|
+
export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
|
|
19
|
+
authProvider: AuthProvider;
|
|
20
|
+
mediaStore?: MediaStore;
|
|
21
|
+
}
|
|
22
|
+
export interface CopyFileOptions {
|
|
23
|
+
preview?: FilePreview | Promise<FilePreview>;
|
|
24
|
+
mimeType?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare type ExternalUploadPayload = {
|
|
27
|
+
uploadableFileUpfrontIds: UploadableFileUpfrontIds;
|
|
28
|
+
dimensions: Dimensions;
|
|
29
|
+
};
|
|
30
|
+
export interface FileFetcher {
|
|
31
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
32
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
33
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
34
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
35
|
+
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
36
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
37
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
38
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions): Promise<MediaFile>;
|
|
39
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
export declare class FileFetcherImpl implements FileFetcher {
|
|
42
|
+
private readonly mediaStore;
|
|
43
|
+
private readonly dataloader;
|
|
44
|
+
constructor(mediaStore: MediaStore);
|
|
45
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
46
|
+
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
47
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
48
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
49
|
+
private createDownloadFileStream;
|
|
50
|
+
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
51
|
+
private generateUploadableFileUpfrontIds;
|
|
52
|
+
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
53
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
54
|
+
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
55
|
+
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions): Promise<MediaFile>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
2
|
+
import { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
|
+
import { MediaStore, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
|
|
4
|
+
import { CollectionFetcher } from './collection-fetcher';
|
|
5
|
+
import { FileFetcher } from './file-fetcher';
|
|
6
|
+
import { UploadEventPayloadMap, EventPayloadListener } from './events';
|
|
7
|
+
import { StargateClient } from './stargate-client';
|
|
8
|
+
import { MobileUpload } from '../models/mobile-upload';
|
|
9
|
+
export declare class MediaClient {
|
|
10
|
+
readonly mediaClientConfig: MediaClientConfig;
|
|
11
|
+
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
12
|
+
readonly mediaStore: MediaStore;
|
|
13
|
+
readonly collection: CollectionFetcher;
|
|
14
|
+
readonly file: FileFetcher;
|
|
15
|
+
readonly stargate: StargateClient;
|
|
16
|
+
private readonly eventEmitter;
|
|
17
|
+
private mobileUpload?;
|
|
18
|
+
readonly config: MediaClientConfig;
|
|
19
|
+
constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
20
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
|
|
21
|
+
getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
22
|
+
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
23
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|
|
24
|
+
mobileUploadPromise(): Promise<MobileUpload>;
|
|
25
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
26
|
+
off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
27
|
+
emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors';
|
|
2
|
+
export declare type MediaStoreErrorReason = 'failedAuthProvider' | 'tokenExpired' | 'missingInitialAuth' | 'emptyAuth' | 'authProviderTimedOut';
|
|
3
|
+
export declare type MediaStoreErrorAttributes = {
|
|
4
|
+
readonly reason: MediaStoreErrorReason;
|
|
5
|
+
readonly innerError?: Error;
|
|
6
|
+
};
|
|
7
|
+
export declare class MediaStoreError extends BaseMediaClientError<MediaStoreErrorAttributes> {
|
|
8
|
+
readonly reason: MediaStoreErrorReason;
|
|
9
|
+
readonly innerError?: Error | undefined;
|
|
10
|
+
constructor(reason: MediaStoreErrorReason, innerError?: Error | undefined);
|
|
11
|
+
get attributes(): {
|
|
12
|
+
reason: MediaStoreErrorReason;
|
|
13
|
+
innerError: Error | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function isMediaStoreError(err: Error): err is MediaStoreError;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
|
|
2
|
+
import { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
|
+
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
4
|
+
import { MediaChunksProbe, MediaCollectionItemFullDetails, MediaCollectionItems, MediaFile, MediaUpload } from '../../models/media';
|
|
5
|
+
import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata } from '../../utils/request/types';
|
|
6
|
+
export type { MediaStoreErrorReason, MediaStoreErrorAttributes } from './error';
|
|
7
|
+
export { MediaStoreError, isMediaStoreError } from './error';
|
|
8
|
+
export declare class MediaStore {
|
|
9
|
+
private readonly config;
|
|
10
|
+
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
11
|
+
constructor(config: MediaApiConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
12
|
+
getCollectionItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<MediaStoreResponse<MediaCollectionItems>>;
|
|
13
|
+
removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
|
|
14
|
+
createUpload(createUpTo?: number, collectionName?: string): Promise<MediaStoreResponse<MediaUpload[]>>;
|
|
15
|
+
uploadChunk(etag: string, blob: Blob, { collectionName, uploadId, partNumber, }?: {
|
|
16
|
+
collectionName?: string;
|
|
17
|
+
uploadId?: string;
|
|
18
|
+
partNumber?: number;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
probeChunks(chunks: string[], { collectionName, uploadId, }?: {
|
|
21
|
+
collectionName?: string;
|
|
22
|
+
uploadId?: string;
|
|
23
|
+
}): Promise<MediaStoreResponse<MediaChunksProbe>>;
|
|
24
|
+
createFileFromUpload(body: MediaStoreCreateFileFromUploadBody, params?: MediaStoreCreateFileFromUploadParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
25
|
+
touchFiles(body: MediaStoreTouchFileBody, params?: MediaStoreTouchFileParams): Promise<MediaStoreResponse<TouchedFiles>>;
|
|
26
|
+
getFile(fileId: string, params?: MediaStoreGetFileParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
27
|
+
getFileImageURL(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
28
|
+
getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
29
|
+
private createFileImageURL;
|
|
30
|
+
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
31
|
+
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
32
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
|
|
33
|
+
getItems(ids: string[], collectionName?: string): Promise<MediaStoreResponse<ItemsPayload>>;
|
|
34
|
+
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<{
|
|
35
|
+
metadata: ImageMetadata;
|
|
36
|
+
}>;
|
|
37
|
+
appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string): Promise<void>;
|
|
38
|
+
copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams): Promise<MediaStoreResponse<MediaFile>>;
|
|
39
|
+
request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
|
|
40
|
+
resolveAuth: (authContext?: AuthContext | undefined) => Promise<Auth>;
|
|
41
|
+
resolveInitialAuth: () => Auth;
|
|
42
|
+
}
|
|
43
|
+
export declare const getMediaEnvironment: () => string | undefined;
|
|
44
|
+
export declare const getMediaRegion: () => string | undefined;
|
|
45
|
+
export interface ResponseFileItem {
|
|
46
|
+
id: string;
|
|
47
|
+
type: 'file';
|
|
48
|
+
details: MediaCollectionItemFullDetails;
|
|
49
|
+
collection?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ItemsPayload {
|
|
52
|
+
items: ResponseFileItem[];
|
|
53
|
+
}
|
|
54
|
+
export declare type ImageMetadataArtifact = {
|
|
55
|
+
url?: string;
|
|
56
|
+
width?: number;
|
|
57
|
+
height?: number;
|
|
58
|
+
size?: number;
|
|
59
|
+
};
|
|
60
|
+
export interface ImageMetadata {
|
|
61
|
+
pending: boolean;
|
|
62
|
+
preview?: ImageMetadataArtifact;
|
|
63
|
+
original?: ImageMetadataArtifact;
|
|
64
|
+
}
|
|
65
|
+
export interface MediaStoreResponse<Data> {
|
|
66
|
+
readonly data: Data;
|
|
67
|
+
}
|
|
68
|
+
export declare type MediaStoreRequestOptions = RequestMetadata & {
|
|
69
|
+
readonly method?: RequestMethod;
|
|
70
|
+
readonly authContext?: AuthContext;
|
|
71
|
+
readonly params?: RequestParams;
|
|
72
|
+
readonly headers?: RequestHeaders;
|
|
73
|
+
readonly body?: any;
|
|
74
|
+
readonly clientOptions?: ClientOptions;
|
|
75
|
+
};
|
|
76
|
+
export declare type MediaStoreCreateFileFromUploadParams = {
|
|
77
|
+
readonly collection?: string;
|
|
78
|
+
readonly occurrenceKey?: string;
|
|
79
|
+
readonly expireAfter?: number;
|
|
80
|
+
readonly replaceFileId?: string;
|
|
81
|
+
readonly skipConversions?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export declare type MediaStoreCreateFileParams = {
|
|
84
|
+
readonly occurrenceKey?: string;
|
|
85
|
+
readonly collection?: string;
|
|
86
|
+
};
|
|
87
|
+
export interface MediaStoreTouchFileParams {
|
|
88
|
+
readonly collection?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface TouchFileDescriptor {
|
|
91
|
+
fileId: string;
|
|
92
|
+
collection?: string;
|
|
93
|
+
occurrenceKey?: string;
|
|
94
|
+
expireAfter?: number;
|
|
95
|
+
deletable?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface MediaStoreTouchFileBody {
|
|
98
|
+
descriptors: TouchFileDescriptor[];
|
|
99
|
+
}
|
|
100
|
+
export declare type MediaStoreCreateFileFromBinaryParams = {
|
|
101
|
+
readonly replaceFileId?: string;
|
|
102
|
+
readonly collection?: string;
|
|
103
|
+
readonly occurrenceKey?: string;
|
|
104
|
+
readonly expireAfter?: number;
|
|
105
|
+
readonly skipConversions?: boolean;
|
|
106
|
+
readonly name?: string;
|
|
107
|
+
};
|
|
108
|
+
export declare type MediaStoreCreateFileFromUploadConditions = {
|
|
109
|
+
readonly hash: string;
|
|
110
|
+
readonly size: number;
|
|
111
|
+
};
|
|
112
|
+
export declare type MediaStoreCreateFileFromUploadBody = {
|
|
113
|
+
readonly uploadId: string;
|
|
114
|
+
readonly name?: string;
|
|
115
|
+
readonly mimeType?: string;
|
|
116
|
+
readonly conditions?: MediaStoreCreateFileFromUploadConditions;
|
|
117
|
+
};
|
|
118
|
+
export declare type MediaStoreGetFileParams = {
|
|
119
|
+
readonly version?: number;
|
|
120
|
+
readonly collection?: string;
|
|
121
|
+
};
|
|
122
|
+
export declare type MediaStoreGetFileImageParams = {
|
|
123
|
+
readonly allowAnimated?: boolean;
|
|
124
|
+
readonly version?: number;
|
|
125
|
+
readonly collection?: string;
|
|
126
|
+
readonly width?: number;
|
|
127
|
+
readonly height?: number;
|
|
128
|
+
readonly mode?: 'fit' | 'full-fit' | 'crop';
|
|
129
|
+
readonly upscale?: boolean;
|
|
130
|
+
readonly 'max-age'?: number;
|
|
131
|
+
};
|
|
132
|
+
export declare type MediaStoreGetCollectionItemsParams = {
|
|
133
|
+
readonly limit?: number;
|
|
134
|
+
readonly inclusiveStartKey?: string;
|
|
135
|
+
readonly sortDirection?: 'asc' | 'desc';
|
|
136
|
+
readonly details?: 'minimal' | 'full';
|
|
137
|
+
};
|
|
138
|
+
export interface SourceFile {
|
|
139
|
+
id: string;
|
|
140
|
+
owner: ClientAltBasedAuth | AsapBasedAuth;
|
|
141
|
+
collection?: string;
|
|
142
|
+
version?: number;
|
|
143
|
+
}
|
|
144
|
+
export declare type MediaStoreCopyFileWithTokenBody = {
|
|
145
|
+
sourceFile: SourceFile;
|
|
146
|
+
};
|
|
147
|
+
export declare type MediaStoreCopyFileWithTokenParams = {
|
|
148
|
+
readonly collection?: string;
|
|
149
|
+
readonly replaceFileId?: string;
|
|
150
|
+
readonly occurrenceKey?: string;
|
|
151
|
+
};
|
|
152
|
+
export declare type AppendChunksToUploadRequestBody = {
|
|
153
|
+
readonly chunks: string[];
|
|
154
|
+
readonly hash?: string;
|
|
155
|
+
readonly offset?: number;
|
|
156
|
+
};
|
|
157
|
+
export interface CreatedTouchedFile {
|
|
158
|
+
fileId: string;
|
|
159
|
+
uploadId: string;
|
|
160
|
+
}
|
|
161
|
+
export declare type TouchedFiles = {
|
|
162
|
+
created: CreatedTouchedFile[];
|
|
163
|
+
};
|
|
164
|
+
export interface EmptyFile {
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly createdAt: number;
|
|
167
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Auth, AuthContext, AuthProvider } from '@atlaskit/media-core';
|
|
2
|
+
export declare const DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
|
|
3
|
+
export declare const resolveAuth: (authProvider: AuthProvider, authContext?: AuthContext | undefined, authProviderTimeout?: number) => Promise<Auth>;
|
|
4
|
+
export declare const resolveInitialAuth: (auth?: Auth | undefined) => Auth;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent } from '../models/mobile-upload';
|
|
2
|
+
import { MediaStore } from './media-store';
|
|
3
|
+
export declare class MobileUploadImpl implements MobileUpload {
|
|
4
|
+
private readonly dataloader;
|
|
5
|
+
private readonly servicesCache;
|
|
6
|
+
constructor(mediaStore: MediaStore);
|
|
7
|
+
notifyUploadStart(event: MobileUploadStartEvent): void;
|
|
8
|
+
notifyUploadProgress(event: MobileUploadProgressEvent): void;
|
|
9
|
+
notifyUploadEnd(event: MobileUploadEndEvent): void;
|
|
10
|
+
notifyUploadError(event: MobileUploadErrorEvent): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface EdgeData {
|
|
2
|
+
data: {
|
|
3
|
+
clientId: string;
|
|
4
|
+
token: string;
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
expiresIn: number;
|
|
7
|
+
iat: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare class StargateClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
constructor(baseUrl: string | undefined);
|
|
13
|
+
fetchToken(clientId: string): Promise<EdgeData>;
|
|
14
|
+
isTokenExpired(token: EdgeData): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const RECENTS_COLLECTION = "recents";
|
|
2
|
+
export declare const FILE_CACHE_MAX_AGE: number;
|
|
3
|
+
export declare const MAX_RESOLUTION = 4096;
|
|
4
|
+
export declare const CHUNK_SIZE: number;
|
|
5
|
+
export declare const PROCESSING_BATCH_SIZE = 1000;
|
|
6
|
+
export declare const MAX_UPLOAD_FILE_SIZE: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-fast';
|
|
2
|
+
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
3
|
+
import { FileState } from './models/file-state';
|
|
4
|
+
export declare class StreamsCache<T> {
|
|
5
|
+
private readonly streams;
|
|
6
|
+
constructor(streams: LRUCache<string, ReplaySubject<T>>);
|
|
7
|
+
has(id: string): boolean;
|
|
8
|
+
set(id: string, stream: ReplaySubject<T>): void;
|
|
9
|
+
get(id: string): ReplaySubject<T> | undefined;
|
|
10
|
+
getOrInsert(id: string, callback: () => ReplaySubject<T>): ReplaySubject<T>;
|
|
11
|
+
removeAll(): void;
|
|
12
|
+
remove(id: string): void;
|
|
13
|
+
get size(): number;
|
|
14
|
+
}
|
|
15
|
+
export declare const getFileStreamsCache: () => StreamsCache<FileState>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UploadEventPayloadMap, EventPayloadListener } from './client/events';
|
|
2
|
+
export declare const globalMediaEventEmitter: {
|
|
3
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E, any>): void;
|
|
4
|
+
off<E_1 extends keyof UploadEventPayloadMap>(event: E_1, listener: EventPayloadListener<UploadEventPayloadMap, E_1, any>): void;
|
|
5
|
+
emit<E_2 extends keyof UploadEventPayloadMap>(event: E_2, payload: UploadEventPayloadMap[E_2]): boolean | undefined;
|
|
6
|
+
};
|