@atlaskit/media-client 17.0.0 → 17.1.2

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 (56) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/client/collection-fetcher.js +4 -4
  3. package/dist/cjs/client/file-fetcher/index.js +5 -7
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/uploader/index.js +112 -37
  6. package/dist/cjs/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +4 -4
  7. package/dist/cjs/utils/mediaSubscribable/index.js +27 -0
  8. package/dist/cjs/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +3 -3
  9. package/dist/cjs/utils/mediaSubscribable/types.js +5 -0
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/client/collection-fetcher.js +2 -2
  12. package/dist/es2019/client/file-fetcher/index.js +5 -6
  13. package/dist/es2019/index.js +1 -1
  14. package/dist/es2019/uploader/index.js +13 -7
  15. package/dist/es2019/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +3 -3
  16. package/dist/es2019/utils/mediaSubscribable/index.js +2 -0
  17. package/dist/es2019/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +1 -1
  18. package/dist/es2019/utils/mediaSubscribable/types.js +1 -0
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/client/collection-fetcher.js +3 -3
  21. package/dist/esm/client/file-fetcher/index.js +6 -7
  22. package/dist/esm/client/media-client.js +1 -1
  23. package/dist/esm/client/media-store/index.js +1 -1
  24. package/dist/esm/client/media-store/resolveAuth.js +1 -1
  25. package/dist/esm/client/stargate-client.js +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/uploader/index.js +113 -38
  28. package/dist/esm/utils/createFileDataLoader.js +1 -1
  29. package/dist/esm/utils/getDimensionsFromBlob.js +1 -1
  30. package/dist/esm/utils/getVideoDimensionsFromBlob.js +1 -1
  31. package/dist/esm/utils/hashing/hasherCreator.js +1 -1
  32. package/dist/esm/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +3 -3
  33. package/dist/esm/utils/mediaSubscribable/index.js +2 -0
  34. package/dist/esm/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +1 -1
  35. package/dist/esm/utils/mediaSubscribable/types.js +1 -0
  36. package/dist/esm/utils/mobileUpload/helpers.js +1 -1
  37. package/dist/esm/utils/mobileUpload/stateMachine/index.js +1 -1
  38. package/dist/esm/utils/polling/index.js +1 -1
  39. package/dist/esm/utils/request/helpers.js +1 -1
  40. package/dist/esm/utils/request/index.js +1 -1
  41. package/dist/esm/utils/shouldFetchRemoteFileStates.js +1 -1
  42. package/dist/esm/version.json +1 -1
  43. package/dist/types/client/collection-fetcher.d.ts +1 -1
  44. package/dist/types/client/file-fetcher/index.d.ts +1 -1
  45. package/dist/types/index.d.ts +3 -3
  46. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +5 -0
  47. package/dist/types/utils/mediaSubscribable/index.d.ts +3 -0
  48. package/dist/types/utils/{mediaSubscribableToPromise.d.ts → mediaSubscribable/toPromise.d.ts} +3 -3
  49. package/dist/types/utils/mediaSubscribable/types.d.ts +16 -0
  50. package/dist/types/utils/safeUnsubscribe.d.ts +1 -1
  51. package/example-helpers/styles.ts +99 -0
  52. package/example-helpers/stylesWrapper.tsx +82 -0
  53. package/package.json +8 -7
  54. package/report.api.md +1389 -0
  55. package/dist/types/utils/toMediaSubscribable.d.ts +0 -20
  56. package/example-helpers/styled.ts +0 -77
package/report.api.md ADDED
@@ -0,0 +1,1389 @@
1
+ ## API Report File for "@atlaskit/media-client"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ import { AsapBasedAuth } from '@atlaskit/media-core';
7
+ import { Auth } from '@atlaskit/media-core';
8
+ import { AuthContext } from '@atlaskit/media-core';
9
+ import { AuthProvider } from '@atlaskit/media-core';
10
+ import { ChunkinatorFile } from '@atlaskit/chunkinator';
11
+ import { ClientAltBasedAuth } from '@atlaskit/media-core';
12
+ import { FileStatus as FileStatus_2 } from '@atlaskit/media-common';
13
+ import { LRUCache } from 'lru-fast';
14
+ import { MediaApiConfig } from '@atlaskit/media-core';
15
+ import { MediaClientConfig } from '@atlaskit/media-core';
16
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
17
+ import { MediaType } from '@atlaskit/media-common';
18
+ import { default as React_2 } from 'react';
19
+ import { ReplaySubject } from 'rxjs/ReplaySubject';
20
+
21
+ export declare type AbortFunction = () => void;
22
+
23
+ export declare const addFileAttrsToUrl: (
24
+ url: string,
25
+ fileAttrs: MediaBlobUrlAttrs,
26
+ ) => string;
27
+
28
+ export declare type AppendChunksToUploadRequestBody = {
29
+ readonly chunks: string[];
30
+ readonly hash?: string;
31
+ readonly offset?: number;
32
+ };
33
+
34
+ export declare type Artifacts = {
35
+ [name: string]: MediaArtifact;
36
+ };
37
+
38
+ /**
39
+ * Base class for media errors
40
+ */
41
+ declare abstract class BaseMediaClientError<
42
+ Attributes extends MediaClientErrorAttributes
43
+ >
44
+ extends Error
45
+ implements MediaClientError<Attributes> {
46
+ readonly message: string;
47
+ constructor(message: string);
48
+ abstract get attributes(): Attributes;
49
+ }
50
+
51
+ export declare const checkWebpSupport: () => Promise<boolean>;
52
+
53
+ export declare type ClientOptions = {
54
+ readonly retryOptions?: Partial<RetryOptions>;
55
+ readonly clientTimeout?: number;
56
+ };
57
+
58
+ export declare class CollectionFetcher {
59
+ readonly mediaStore: MediaStore;
60
+ constructor(mediaStore: MediaStore);
61
+ private createFileStateObserver;
62
+ private populateCache;
63
+ private removeFromCache;
64
+ getItems(
65
+ collectionName: string,
66
+ params?: MediaStoreGetCollectionItemsParams,
67
+ ): MediaSubscribable<MediaCollectionItem[]>;
68
+ removeFile(
69
+ id: string,
70
+ collectionName: string,
71
+ occurrenceKey?: string,
72
+ ): Promise<void>;
73
+ loadNextPage(
74
+ collectionName: string,
75
+ params?: MediaStoreGetCollectionItemsParams,
76
+ ): Promise<void>;
77
+ }
78
+
79
+ declare type CompletionObserver<
80
+ T extends MediaSubscribableItem
81
+ > = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'complete'>>;
82
+
83
+ export declare interface CopyDestination
84
+ extends MediaStoreCopyFileWithTokenParams {
85
+ authProvider: AuthProvider;
86
+ mediaStore?: MediaStore;
87
+ }
88
+
89
+ export declare interface CopyFileOptions {
90
+ preview?: FilePreview | Promise<FilePreview>;
91
+ mimeType?: string;
92
+ }
93
+
94
+ export declare interface CopySourceFile {
95
+ id: string;
96
+ collection?: string;
97
+ authProvider: AuthProvider;
98
+ }
99
+
100
+ export declare interface CreatedTouchedFile {
101
+ fileId: string;
102
+ uploadId: string;
103
+ }
104
+
105
+ export declare function createMediaSubject<T extends MediaSubscribableItem>(
106
+ initialState?: T | Error,
107
+ ): ReplaySubject<T>;
108
+
109
+ export declare function createMediaSubscribable<
110
+ T extends MediaSubscribableItem
111
+ >(mediaSubscribableItem?: T | Error): MediaSubscribable<T>;
112
+
113
+ export declare function createUrl(
114
+ url: string,
115
+ { params, auth }: CreateUrlOptions,
116
+ ): string;
117
+
118
+ export declare type CreateUrlOptions = {
119
+ readonly params?: RequestParams;
120
+ readonly auth?: Auth;
121
+ };
122
+
123
+ export declare type Dimensions = {
124
+ width: number;
125
+ height: number;
126
+ };
127
+
128
+ export declare interface EdgeData {
129
+ data: {
130
+ clientId: string;
131
+ token: string;
132
+ baseUrl: string;
133
+ expiresIn: number;
134
+ iat: number;
135
+ };
136
+ }
137
+
138
+ export declare interface EmptyFile {
139
+ readonly id: string;
140
+ readonly createdAt: number;
141
+ }
142
+
143
+ export declare interface ErrorFileState {
144
+ status: 'error';
145
+ id: string;
146
+ occurrenceKey?: string;
147
+ message?: string;
148
+ }
149
+
150
+ declare type ErrorObserver<T extends MediaSubscribableItem> = PartialObserver<
151
+ T
152
+ > &
153
+ Required<Pick<PartialObserver<T>, 'error'>>;
154
+
155
+ export declare type EventPayloadListener<
156
+ M extends EventPayloadMap<P>,
157
+ E extends keyof M,
158
+ P = any
159
+ > = (payload: M[E]) => void;
160
+
161
+ declare type EventPayloadMap<P> = {
162
+ readonly [event: string]: P;
163
+ };
164
+
165
+ export declare type Executor = () => Promise<void>;
166
+
167
+ export declare interface ExternalImageIdentifier {
168
+ readonly mediaItemType: 'external-image';
169
+ readonly dataURI: string;
170
+ readonly name?: string;
171
+ }
172
+
173
+ declare type ExternalUploadPayload = {
174
+ uploadableFileUpfrontIds: UploadableFileUpfrontIds;
175
+ dimensions: Dimensions;
176
+ };
177
+
178
+ export declare interface FileDetails {
179
+ id: string;
180
+ name?: string;
181
+ size?: number;
182
+ mimeType?: string;
183
+ mediaType?: MediaType;
184
+ creationDate?: number;
185
+ processingStatus?: FileProcessingStatus;
186
+ artifacts?: Artifacts;
187
+ createdAt?: number;
188
+ }
189
+
190
+ export declare interface FileFetcher {
191
+ getFileState(
192
+ id: string,
193
+ options?: GetFileOptions,
194
+ ): MediaSubscribable<FileState>;
195
+ getArtifactURL(
196
+ artifacts: MediaFileArtifacts,
197
+ artifactName: keyof MediaFileArtifacts,
198
+ collectionName?: string,
199
+ ): Promise<string>;
200
+ touchFiles(
201
+ descriptors: TouchFileDescriptor[],
202
+ collection?: string,
203
+ ): Promise<TouchedFiles>;
204
+ upload(
205
+ file: UploadableFile,
206
+ controller?: UploadController,
207
+ uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
208
+ ): MediaSubscribable<FileState>;
209
+ uploadExternal(
210
+ url: string,
211
+ collection?: string,
212
+ ): Promise<ExternalUploadPayload>;
213
+ downloadBinary(
214
+ id: string,
215
+ name?: string,
216
+ collectionName?: string,
217
+ ): Promise<void>;
218
+ getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
219
+ copyFile(
220
+ source: CopySourceFile,
221
+ destination: CopyDestination,
222
+ options?: CopyFileOptions,
223
+ ): Promise<MediaFile>;
224
+ getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
225
+ }
226
+
227
+ export declare class FileFetcherError extends BaseMediaClientError<
228
+ FileFetcherErrorAttributes
229
+ > {
230
+ readonly reason: FileFetcherErrorReason;
231
+ readonly id: string;
232
+ readonly metadata?:
233
+ | {
234
+ readonly collectionName?: string | undefined;
235
+ readonly occurrenceKey?: string | undefined;
236
+ }
237
+ | undefined;
238
+ constructor(
239
+ reason: FileFetcherErrorReason,
240
+ id: string,
241
+ metadata?:
242
+ | {
243
+ readonly collectionName?: string | undefined;
244
+ readonly occurrenceKey?: string | undefined;
245
+ }
246
+ | undefined,
247
+ );
248
+ get attributes(): {
249
+ reason: FileFetcherErrorReason;
250
+ id: string;
251
+ collectionName: string | undefined;
252
+ occurrenceKey: string | undefined;
253
+ };
254
+ }
255
+
256
+ export declare type FileFetcherErrorAttributes = {
257
+ readonly reason: FileFetcherErrorReason;
258
+ readonly id: string;
259
+ readonly metadata?: {
260
+ readonly collectionName?: string;
261
+ readonly occurrenceKey?: string;
262
+ };
263
+ };
264
+
265
+ export declare type FileFetcherErrorReason =
266
+ | 'invalidFileId'
267
+ | 'emptyItems'
268
+ | 'zeroVersionFile';
269
+
270
+ export declare class FileFetcherImpl implements FileFetcher {
271
+ private readonly mediaStore;
272
+ private readonly dataloader;
273
+ constructor(mediaStore: MediaStore);
274
+ getFileState(
275
+ id: string,
276
+ options?: GetFileOptions,
277
+ ): MediaSubscribable<FileState>;
278
+ getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
279
+ getArtifactURL(
280
+ artifacts: MediaFileArtifacts,
281
+ artifactName: keyof MediaFileArtifacts,
282
+ collectionName?: string,
283
+ ): Promise<string>;
284
+ getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
285
+ private createDownloadFileStream;
286
+ touchFiles(
287
+ descriptors: TouchFileDescriptor[],
288
+ collection?: string,
289
+ ): Promise<TouchedFiles>;
290
+ private generateUploadableFileUpfrontIds;
291
+ uploadExternal(
292
+ url: string,
293
+ collection?: string,
294
+ ): Promise<ExternalUploadPayload>;
295
+ upload(
296
+ file: UploadableFile,
297
+ controller?: UploadController,
298
+ uploadableFileUpfrontIds?: UploadableFileUpfrontIds,
299
+ ): MediaSubscribable<FileState>;
300
+ downloadBinary(
301
+ id: string,
302
+ name?: string,
303
+ collectionName?: string,
304
+ ): Promise<void>;
305
+ copyFile(
306
+ source: CopySourceFile,
307
+ destination: CopyDestination,
308
+ options?: CopyFileOptions,
309
+ ): Promise<MediaFile>;
310
+ }
311
+
312
+ export declare interface FileIdentifier {
313
+ readonly mediaItemType: 'file';
314
+ readonly id: string;
315
+ readonly occurrenceKey?: string;
316
+ readonly collectionName?: string;
317
+ }
318
+
319
+ export declare interface FileItem {
320
+ type: 'file';
321
+ details: FileDetails;
322
+ }
323
+
324
+ export declare interface FilePreview {
325
+ value: Blob | string;
326
+ origin?: 'local' | 'remote';
327
+ originalDimensions?: {
328
+ width: number;
329
+ height: number;
330
+ };
331
+ }
332
+
333
+ export declare type FileProcessingStatus =
334
+ | 'pending'
335
+ | 'running'
336
+ | 'succeeded'
337
+ | 'failed';
338
+
339
+ export declare type FileState =
340
+ | UploadingFileState
341
+ | ProcessingFileState
342
+ | ProcessedFileState
343
+ | ErrorFileState
344
+ | ProcessingFailedState;
345
+
346
+ export declare type FileStatus = FileStatus_2;
347
+
348
+ export declare const getArtifactUrl: (
349
+ artifacts: MediaFileArtifacts,
350
+ prop: keyof MediaFileArtifacts,
351
+ ) => string | undefined;
352
+
353
+ export declare const getAttrsFromUrl: (
354
+ blobUrl: string,
355
+ ) => MediaBlobUrlAttrs | undefined;
356
+
357
+ export declare const getDimensionsFromBlob: (
358
+ mediaType: MediaType,
359
+ blob: Blob,
360
+ ) => Promise<Dimensions>;
361
+
362
+ export declare interface GetFileOptions {
363
+ preview?: PreviewOptions;
364
+ collectionName?: string;
365
+ occurrenceKey?: string;
366
+ }
367
+
368
+ export declare const getMediaClient: (
369
+ mediaClientConfig: MediaClientConfig,
370
+ featureFlags?: MediaFeatureFlags | undefined,
371
+ ) => MediaClient;
372
+
373
+ export declare function getMediaClientErrorReason(
374
+ err: Error,
375
+ ): MediaClientErrorReason | 'unknown';
376
+
377
+ export declare const getMediaEnvironment: () => string | undefined;
378
+
379
+ export declare const getMediaRegion: () => string | undefined;
380
+
381
+ /**
382
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
383
+ */
384
+ export declare const getMediaTypeFromMimeType: (mimeType: string) => MediaType;
385
+
386
+ export declare const globalMediaEventEmitter: {
387
+ on<E extends keyof UploadEventPayloadMap>(
388
+ event: E,
389
+ listener: EventPayloadListener<UploadEventPayloadMap, E, any>,
390
+ ): void;
391
+ off<E_1 extends keyof UploadEventPayloadMap>(
392
+ event: E_1,
393
+ listener: EventPayloadListener<UploadEventPayloadMap, E_1, any>,
394
+ ): void;
395
+ emit<E_2 extends keyof UploadEventPayloadMap>(
396
+ event: E_2,
397
+ payload: UploadEventPayloadMap[E_2],
398
+ ): boolean | undefined;
399
+ };
400
+
401
+ export declare type Identifier = FileIdentifier | ExternalImageIdentifier;
402
+
403
+ export declare interface ImageMetadata {
404
+ pending: boolean;
405
+ preview?: ImageMetadataArtifact;
406
+ original?: ImageMetadataArtifact;
407
+ }
408
+
409
+ export declare type ImageMetadataArtifact = {
410
+ url?: string;
411
+ width?: number;
412
+ height?: number;
413
+ size?: number;
414
+ };
415
+
416
+ export declare type ImageResizeMode =
417
+ | 'crop'
418
+ | 'fit'
419
+ | 'full-fit'
420
+ | 'stretchy-fit';
421
+
422
+ export declare const imageResizeModeToFileImageMode: (
423
+ resizeMode?: ImageResizeMode | undefined,
424
+ ) => MediaStoreGetFileImageParams['mode'];
425
+
426
+ export declare function isAbortedRequestError(err: any): boolean;
427
+
428
+ /**
429
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
430
+ */
431
+ export declare const isAudioMimeTypeSupportedByServer: (
432
+ mimeType: string,
433
+ ) => boolean;
434
+
435
+ export declare const isDifferentIdentifier: (
436
+ a: Identifier,
437
+ b: Identifier,
438
+ ) => boolean;
439
+
440
+ /**
441
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
442
+ */
443
+ export declare const isDocumentMimeTypeSupportedByBrowser: (
444
+ mimeType: string,
445
+ ) => boolean;
446
+
447
+ /**
448
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
449
+ */
450
+ export declare const isDocumentMimeTypeSupportedByServer: (
451
+ mimeType: string,
452
+ ) => boolean;
453
+
454
+ export declare const isErrorFileState: (
455
+ fileState: FileState,
456
+ ) => fileState is ErrorFileState;
457
+
458
+ export declare const isExternalImageIdentifier: (
459
+ identifier: Identifier,
460
+ ) => identifier is ExternalImageIdentifier;
461
+
462
+ export declare function isFileFetcherError(err: Error): err is FileFetcherError;
463
+
464
+ export declare const isFileIdentifier: (
465
+ identifier: Identifier,
466
+ ) => identifier is FileIdentifier;
467
+
468
+ export declare const isFinalFileState: (
469
+ fileState: FileState,
470
+ ) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
471
+
472
+ /**
473
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
474
+ */
475
+ export declare const isImageMimeTypeSupportedByBrowser: (
476
+ mimeType: string,
477
+ ) => boolean;
478
+
479
+ /**
480
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
481
+ */
482
+ export declare const isImageMimeTypeSupportedByServer: (
483
+ mimeType: string,
484
+ ) => boolean;
485
+
486
+ export declare const isImageRemote: (
487
+ imageUrl: string,
488
+ windowOrigin?: string,
489
+ ) => boolean;
490
+
491
+ export declare const isImageRepresentationReady: (
492
+ fileState: FileState,
493
+ ) => boolean;
494
+
495
+ export declare const isMediaBlobUrl: (url: string) => boolean;
496
+
497
+ export declare function isMediaClientError(
498
+ error: any,
499
+ ): error is MediaClientError<{
500
+ reason: MediaClientErrorReason;
501
+ }>;
502
+
503
+ export declare const isMediaCollectionItemFullDetails: (
504
+ mediaCollectionItem: MediaCollectionItemDetails,
505
+ ) => mediaCollectionItem is MediaCollectionItemFullDetails;
506
+
507
+ export declare function isMediaStoreError(err: Error): err is MediaStoreError;
508
+
509
+ /**
510
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
511
+ */
512
+ export declare const isMimeTypeSupportedByBrowser: (
513
+ mimeType: string,
514
+ ) => boolean;
515
+
516
+ /**
517
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
518
+ */
519
+ export declare const isMimeTypeSupportedByServer: (mimeType: string) => boolean;
520
+
521
+ export declare function isPollingError(err?: Error): err is PollingError;
522
+
523
+ export declare const isPreviewableFileState: (
524
+ fileState: FileState,
525
+ ) => fileState is (
526
+ | UploadingFileState
527
+ | ProcessingFileState
528
+ | ProcessedFileState
529
+ | ProcessingFailedState
530
+ ) &
531
+ PreviewableFileState;
532
+
533
+ export declare const isPreviewableType: (
534
+ type: MediaType,
535
+ featureFlags?: MediaFeatureFlags | undefined,
536
+ ) => boolean;
537
+
538
+ export declare const isProcessedFileState: (
539
+ fileState: FileState,
540
+ ) => fileState is ProcessedFileState;
541
+
542
+ export declare const isProcessingFileState: (
543
+ fileState: FileState,
544
+ ) => fileState is ProcessingFileState;
545
+
546
+ export declare function isRateLimitedError(error: Error | undefined): boolean;
547
+
548
+ export declare function isRequestError(err: Error): err is RequestError;
549
+
550
+ /**
551
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
552
+ */
553
+ export declare const isUnknownMimeTypeSupportedByServer: (
554
+ mimeType: string,
555
+ ) => boolean;
556
+
557
+ export declare const isUploadingFileState: (
558
+ fileState: FileState,
559
+ ) => fileState is UploadingFileState;
560
+
561
+ /**
562
+ * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
563
+ */
564
+ export declare const isVideoMimeTypeSupportedByServer: (
565
+ mimeType: string,
566
+ ) => boolean;
567
+
568
+ export declare interface ItemsPayload {
569
+ items: ResponseFileItem[];
570
+ }
571
+
572
+ export declare const mapMediaFileToFileState: (
573
+ mediaFile: MediaStoreResponse<MediaFile>,
574
+ ) => FileState;
575
+
576
+ export declare const mapMediaItemToFileState: (
577
+ id: string,
578
+ item: MediaCollectionItemFullDetails,
579
+ ) => FileState;
580
+
581
+ /**
582
+ * @deprecated Helper is deprecated and will be removed in the next major version.
583
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
584
+ */
585
+ export declare function mapResponseToBlob(response: Response): Promise<Blob>;
586
+
587
+ /**
588
+ * @deprecated Helper is deprecated and will be removed in the next major version.
589
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
590
+ */
591
+ export declare function mapResponseToJson(response: Response): Promise<any>;
592
+
593
+ /**
594
+ * @deprecated Helper is deprecated and will be removed in the next major version.
595
+ * TODO: https://product-fabric.atlassian.net/browse/BMPT-1354
596
+ */
597
+ export declare function mapResponseToVoid(): Promise<void>;
598
+
599
+ export declare const MAX_RESOLUTION = 4096;
600
+
601
+ export declare interface MediaArtifact {
602
+ processingStatus?: FileProcessingStatus;
603
+ url?: string;
604
+ }
605
+
606
+ export declare interface MediaBlobUrlAttrs {
607
+ id: string;
608
+ contextId: string;
609
+ collection?: string;
610
+ size?: number;
611
+ name?: string;
612
+ mimeType?: string;
613
+ width?: number;
614
+ height?: number;
615
+ alt?: string;
616
+ }
617
+
618
+ export declare type MediaChunksProbe = {
619
+ readonly results: {
620
+ readonly [etag: string]: {
621
+ readonly exists: boolean;
622
+ };
623
+ };
624
+ };
625
+
626
+ export declare class MediaClient {
627
+ readonly mediaClientConfig: MediaClientConfig;
628
+ readonly featureFlags?: MediaFeatureFlags | undefined;
629
+ readonly mediaStore: MediaStore;
630
+ readonly collection: CollectionFetcher;
631
+ readonly file: FileFetcher;
632
+ readonly stargate: StargateClient;
633
+ private readonly eventEmitter;
634
+ private mobileUpload?;
635
+ readonly config: MediaClientConfig;
636
+ constructor(
637
+ mediaClientConfig: MediaClientConfig,
638
+ featureFlags?: MediaFeatureFlags | undefined,
639
+ );
640
+ getImage(
641
+ id: string,
642
+ params?: MediaStoreGetFileImageParams,
643
+ controller?: AbortController,
644
+ fetchMaxRes?: boolean,
645
+ ): Promise<Blob>;
646
+ getImageUrl(
647
+ id: string,
648
+ params?: MediaStoreGetFileImageParams,
649
+ ): Promise<string>;
650
+ getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
651
+ getImageMetadata(
652
+ id: string,
653
+ params?: MediaStoreGetFileImageParams,
654
+ ): Promise<ImageMetadata>;
655
+ mobileUploadPromise(): Promise<MobileUpload>;
656
+ on<E extends keyof UploadEventPayloadMap>(
657
+ event: E,
658
+ listener: EventPayloadListener<UploadEventPayloadMap, E>,
659
+ ): void;
660
+ off<E extends keyof UploadEventPayloadMap>(
661
+ event: E,
662
+ listener: EventPayloadListener<UploadEventPayloadMap, E>,
663
+ ): void;
664
+ emit<E extends keyof UploadEventPayloadMap>(
665
+ event: E,
666
+ payload: UploadEventPayloadMap[E],
667
+ ): boolean;
668
+ }
669
+
670
+ /**
671
+ * MediaClientError is the main interface which all the errors
672
+ * in Media Client must implement.
673
+ * MediaClientErrorReason is a dictionary that restricts all the possible
674
+ * reasons that the erros can define. Its values are private to this file.
675
+ * Any new error has to define its own Error Reasons locally, and also declare them
676
+ * here to comply with the interface restrictions
677
+ */
678
+ export declare interface MediaClientError<
679
+ Attributes extends MediaClientErrorAttributes
680
+ > extends Error {
681
+ readonly attributes: Attributes;
682
+ }
683
+
684
+ export declare interface MediaClientErrorAttributes {
685
+ reason: MediaClientErrorReason;
686
+ }
687
+
688
+ export declare type MediaClientErrorReason =
689
+ | 'clientOffline'
690
+ | 'clientAbortedRequest'
691
+ | 'clientTimeoutRequest'
692
+ | 'serverInvalidBody'
693
+ | 'serverBadRequest'
694
+ | 'serverUnauthorized'
695
+ | 'serverForbidden'
696
+ | 'serverNotFound'
697
+ | 'serverRateLimited'
698
+ | 'serverInternalError'
699
+ | 'serverBadGateway'
700
+ | 'serverUnexpectedError'
701
+ | 'failedAuthProvider'
702
+ | 'tokenExpired'
703
+ | 'missingInitialAuth'
704
+ | 'emptyAuth'
705
+ | 'authProviderTimedOut'
706
+ | 'invalidFileId'
707
+ | 'emptyItems'
708
+ | 'zeroVersionFile'
709
+ | 'pollingMaxAttemptsExceeded'
710
+ | 'fileSizeExceedsLimit';
711
+
712
+ export declare type MediaCollection = {
713
+ readonly name: string;
714
+ readonly createdAt: number;
715
+ };
716
+
717
+ export declare type MediaCollectionItem = {
718
+ readonly id: string;
719
+ readonly insertedAt: number;
720
+ readonly occurrenceKey: string;
721
+ readonly details: MediaCollectionItemDetails;
722
+ };
723
+
724
+ export declare type MediaCollectionItemDetails =
725
+ | MediaCollectionItemMinimalDetails
726
+ | MediaCollectionItemFullDetails;
727
+
728
+ export declare type MediaCollectionItemFullDetails = {
729
+ readonly mediaType: MediaType;
730
+ readonly mimeType: string;
731
+ readonly name: string;
732
+ readonly processingStatus: MediaFileProcessingStatus;
733
+ readonly size: number;
734
+ readonly artifacts: MediaFileArtifacts;
735
+ readonly representations: MediaRepresentations;
736
+ readonly createdAt?: number;
737
+ };
738
+
739
+ export declare type MediaCollectionItemMinimalDetails = {
740
+ readonly name: string;
741
+ readonly size: number;
742
+ };
743
+
744
+ export declare type MediaCollectionItems = {
745
+ readonly contents: MediaCollectionItem[];
746
+ readonly nextInclusiveStartKey?: string;
747
+ };
748
+
749
+ export declare type MediaFile = {
750
+ readonly id: string;
751
+ readonly mediaType: MediaType;
752
+ readonly mimeType: string;
753
+ readonly name: string;
754
+ readonly processingStatus?: MediaFileProcessingStatus;
755
+ readonly size: number;
756
+ readonly artifacts: MediaFileArtifacts;
757
+ readonly representations: MediaRepresentations;
758
+ readonly createdAt?: number;
759
+ };
760
+
761
+ export declare type MediaFileArtifact = {
762
+ readonly url: string;
763
+ readonly processingStatus: MediaFileProcessingStatus;
764
+ };
765
+
766
+ export declare interface MediaFileArtifacts {
767
+ 'video_1280.mp4'?: MediaFileArtifact;
768
+ 'video_640.mp4'?: MediaFileArtifact;
769
+ 'document.pdf'?: MediaFileArtifact;
770
+ 'audio.mp3'?: MediaFileArtifact;
771
+ }
772
+
773
+ export declare type MediaFileProcessingStatus =
774
+ | 'pending'
775
+ | 'succeeded'
776
+ | 'failed';
777
+
778
+ export declare type MediaItemType = 'file' | 'external-image';
779
+
780
+ export declare type MediaObserver<T extends MediaSubscribableItem> =
781
+ | NextObserver<T>
782
+ | ErrorObserver<T>
783
+ | CompletionObserver<T>
784
+ | ((value: T) => void);
785
+
786
+ export declare type MediaRepresentations = {
787
+ image?: Object;
788
+ };
789
+
790
+ export declare class MediaStore {
791
+ private readonly config;
792
+ readonly featureFlags?: MediaFeatureFlags | undefined;
793
+ constructor(
794
+ config: MediaApiConfig,
795
+ featureFlags?: MediaFeatureFlags | undefined,
796
+ );
797
+ getCollectionItems(
798
+ collectionName: string,
799
+ params?: MediaStoreGetCollectionItemsParams,
800
+ ): Promise<MediaStoreResponse<MediaCollectionItems>>;
801
+ removeCollectionFile(
802
+ id: string,
803
+ collectionName: string,
804
+ occurrenceKey?: string,
805
+ ): Promise<void>;
806
+ createUpload(
807
+ createUpTo?: number,
808
+ collectionName?: string,
809
+ ): Promise<MediaStoreResponse<MediaUpload[]>>;
810
+ uploadChunk(
811
+ etag: string,
812
+ blob: Blob,
813
+ {
814
+ collectionName,
815
+ uploadId,
816
+ partNumber,
817
+ }?: {
818
+ collectionName?: string;
819
+ uploadId?: string;
820
+ partNumber?: number;
821
+ },
822
+ ): Promise<void>;
823
+ probeChunks(
824
+ chunks: string[],
825
+ {
826
+ collectionName,
827
+ uploadId,
828
+ }?: {
829
+ collectionName?: string;
830
+ uploadId?: string;
831
+ },
832
+ ): Promise<MediaStoreResponse<MediaChunksProbe>>;
833
+ createFileFromUpload(
834
+ body: MediaStoreCreateFileFromUploadBody,
835
+ params?: MediaStoreCreateFileFromUploadParams,
836
+ ): Promise<MediaStoreResponse<MediaFile>>;
837
+ touchFiles(
838
+ body: MediaStoreTouchFileBody,
839
+ params?: MediaStoreTouchFileParams,
840
+ ): Promise<MediaStoreResponse<TouchedFiles>>;
841
+ getFile(
842
+ fileId: string,
843
+ params?: MediaStoreGetFileParams,
844
+ ): Promise<MediaStoreResponse<MediaFile>>;
845
+ getFileImageURL(
846
+ id: string,
847
+ params?: MediaStoreGetFileImageParams,
848
+ ): Promise<string>;
849
+ getFileImageURLSync(
850
+ id: string,
851
+ params?: MediaStoreGetFileImageParams,
852
+ ): string;
853
+ private createFileImageURL;
854
+ getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
855
+ getArtifactURL(
856
+ artifacts: MediaFileArtifacts,
857
+ artifactName: keyof MediaFileArtifacts,
858
+ collectionName?: string,
859
+ ): Promise<string>;
860
+ getImage(
861
+ id: string,
862
+ params?: MediaStoreGetFileImageParams,
863
+ controller?: AbortController,
864
+ fetchMaxRes?: boolean,
865
+ ): Promise<Blob>;
866
+ getItems(
867
+ ids: string[],
868
+ collectionName?: string,
869
+ ): Promise<MediaStoreResponse<ItemsPayload>>;
870
+ getImageMetadata(
871
+ id: string,
872
+ params?: MediaStoreGetFileImageParams,
873
+ ): Promise<{
874
+ metadata: ImageMetadata;
875
+ }>;
876
+ appendChunksToUpload(
877
+ uploadId: string,
878
+ body: AppendChunksToUploadRequestBody,
879
+ collectionName?: string,
880
+ ): Promise<void>;
881
+ copyFileWithToken(
882
+ body: MediaStoreCopyFileWithTokenBody,
883
+ params: MediaStoreCopyFileWithTokenParams,
884
+ ): Promise<MediaStoreResponse<MediaFile>>;
885
+ request(
886
+ path: string,
887
+ options?: MediaStoreRequestOptions,
888
+ controller?: AbortController,
889
+ ): Promise<Response>;
890
+ resolveAuth: (authContext?: AuthContext | undefined) => Promise<Auth>;
891
+ resolveInitialAuth: () => Auth;
892
+ }
893
+
894
+ export declare type MediaStoreCopyFileWithTokenBody = {
895
+ sourceFile: SourceFile;
896
+ };
897
+
898
+ export declare type MediaStoreCopyFileWithTokenParams = {
899
+ readonly collection?: string;
900
+ readonly replaceFileId?: string;
901
+ readonly occurrenceKey?: string;
902
+ };
903
+
904
+ export declare type MediaStoreCreateFileFromBinaryParams = {
905
+ readonly replaceFileId?: string;
906
+ readonly collection?: string;
907
+ readonly occurrenceKey?: string;
908
+ readonly expireAfter?: number;
909
+ readonly skipConversions?: boolean;
910
+ readonly name?: string;
911
+ };
912
+
913
+ export declare type MediaStoreCreateFileFromUploadBody = {
914
+ readonly uploadId: string;
915
+ readonly name?: string;
916
+ readonly mimeType?: string;
917
+ readonly conditions?: MediaStoreCreateFileFromUploadConditions;
918
+ };
919
+
920
+ export declare type MediaStoreCreateFileFromUploadConditions = {
921
+ readonly hash: string;
922
+ readonly size: number;
923
+ };
924
+
925
+ export declare type MediaStoreCreateFileFromUploadParams = {
926
+ readonly collection?: string;
927
+ readonly occurrenceKey?: string;
928
+ readonly expireAfter?: number;
929
+ readonly replaceFileId?: string;
930
+ readonly skipConversions?: boolean;
931
+ };
932
+
933
+ export declare type MediaStoreCreateFileParams = {
934
+ readonly occurrenceKey?: string;
935
+ readonly collection?: string;
936
+ };
937
+
938
+ export declare class MediaStoreError extends BaseMediaClientError<
939
+ MediaStoreErrorAttributes
940
+ > {
941
+ readonly reason: MediaStoreErrorReason;
942
+ readonly innerError?: Error | undefined;
943
+ constructor(reason: MediaStoreErrorReason, innerError?: Error | undefined);
944
+ get attributes(): {
945
+ reason: MediaStoreErrorReason;
946
+ innerError: Error | undefined;
947
+ };
948
+ }
949
+
950
+ export declare type MediaStoreErrorAttributes = {
951
+ readonly reason: MediaStoreErrorReason;
952
+ readonly innerError?: Error;
953
+ };
954
+
955
+ export declare type MediaStoreErrorReason =
956
+ | 'failedAuthProvider'
957
+ | 'tokenExpired'
958
+ | 'missingInitialAuth'
959
+ | 'emptyAuth'
960
+ | 'authProviderTimedOut';
961
+
962
+ export declare type MediaStoreGetCollectionItemsParams = {
963
+ readonly limit?: number;
964
+ readonly inclusiveStartKey?: string;
965
+ readonly sortDirection?: 'asc' | 'desc';
966
+ readonly details?: 'minimal' | 'full';
967
+ };
968
+
969
+ export declare type MediaStoreGetFileImageParams = {
970
+ readonly allowAnimated?: boolean;
971
+ readonly version?: number;
972
+ readonly collection?: string;
973
+ readonly width?: number;
974
+ readonly height?: number;
975
+ readonly mode?: 'fit' | 'full-fit' | 'crop';
976
+ readonly upscale?: boolean;
977
+ readonly 'max-age'?: number;
978
+ };
979
+
980
+ export declare type MediaStoreGetFileParams = {
981
+ readonly version?: number;
982
+ readonly collection?: string;
983
+ };
984
+
985
+ export declare type MediaStoreRequestOptions = RequestMetadata & {
986
+ readonly method?: RequestMethod;
987
+ readonly authContext?: AuthContext;
988
+ readonly params?: RequestParams;
989
+ readonly headers?: RequestHeaders;
990
+ readonly body?: any;
991
+ readonly clientOptions?: ClientOptions;
992
+ };
993
+
994
+ export declare interface MediaStoreResponse<Data> {
995
+ readonly data: Data;
996
+ }
997
+
998
+ export declare interface MediaStoreTouchFileBody {
999
+ descriptors: TouchFileDescriptor[];
1000
+ }
1001
+
1002
+ export declare interface MediaStoreTouchFileParams {
1003
+ readonly collection?: string;
1004
+ }
1005
+
1006
+ export declare type MediaSubscribable<T extends MediaSubscribableItem> = {
1007
+ subscribe(observer?: MediaObserver<T>): MediaSubscription;
1008
+ };
1009
+
1010
+ export declare type MediaSubscribableItem = FileState | MediaCollectionItem[];
1011
+
1012
+ export declare type MediaSubscription = {
1013
+ unsubscribe: () => void;
1014
+ };
1015
+
1016
+ export { MediaType };
1017
+
1018
+ export declare type MediaUpload = {
1019
+ readonly id: string;
1020
+ readonly created: number;
1021
+ readonly expires: number;
1022
+ };
1023
+
1024
+ export declare interface MediaViewedEventPayload {
1025
+ fileId: string;
1026
+ viewingLevel: 'minimal' | 'full' | 'download';
1027
+ isUserCollection?: boolean;
1028
+ }
1029
+
1030
+ declare interface MobileUpload {
1031
+ notifyUploadStart(event: MobileUploadStartEvent): void;
1032
+ notifyUploadProgress(event: MobileUploadProgressEvent): void;
1033
+ notifyUploadEnd(event: MobileUploadEndEvent): void;
1034
+ notifyUploadError(event: MobileUploadErrorEvent): void;
1035
+ }
1036
+
1037
+ export declare type MobileUploadEndEvent = {
1038
+ fileId: string;
1039
+ };
1040
+
1041
+ export declare type MobileUploadErrorEvent = {
1042
+ fileId: string;
1043
+ message: string;
1044
+ };
1045
+
1046
+ export declare type MobileUploadProgressEvent = {
1047
+ fileId: string;
1048
+ progress: number;
1049
+ };
1050
+
1051
+ export declare type MobileUploadStartEvent = {
1052
+ fileId: string;
1053
+ collectionName?: string;
1054
+ occurrenceKey?: string;
1055
+ fileName: string;
1056
+ fileSize: number;
1057
+ fileMimetype: string;
1058
+ preview?: FilePreview;
1059
+ createdAt?: number;
1060
+ };
1061
+
1062
+ declare type NextObserver<T extends MediaSubscribableItem> = PartialObserver<
1063
+ T
1064
+ > &
1065
+ Required<Pick<PartialObserver<T>, 'next'>>;
1066
+
1067
+ export declare type NonErrorFileState = Exclude<FileState, ErrorFileState>;
1068
+
1069
+ export declare const objectToQueryString: (json: {
1070
+ [key: string]: string | number | boolean | null | undefined;
1071
+ }) => string;
1072
+
1073
+ declare type PartialObserver<T extends MediaSubscribableItem> = {
1074
+ next?: (value: T) => void;
1075
+ error?: (err: any) => void;
1076
+ complete?: () => void;
1077
+ };
1078
+
1079
+ export declare class PollingError extends BaseMediaClientError<
1080
+ PollingErrorAttributes
1081
+ > {
1082
+ readonly reason: PollingErrorReason;
1083
+ readonly attempts: number;
1084
+ constructor(reason: PollingErrorReason, attempts: number);
1085
+ get attributes(): {
1086
+ reason: 'pollingMaxAttemptsExceeded';
1087
+ attempts: number;
1088
+ };
1089
+ }
1090
+
1091
+ export declare type PollingErrorAttributes = {
1092
+ readonly reason: PollingErrorReason;
1093
+ readonly attempts: number;
1094
+ readonly innerError?: Error;
1095
+ };
1096
+
1097
+ export declare type PollingErrorReason = 'pollingMaxAttemptsExceeded';
1098
+
1099
+ /**
1100
+ * This class encapsulates polling functionality with the following features:
1101
+ *
1102
+ * - async executor function provides each attempt
1103
+ * - executor will only repeat defined max amount of times (options)
1104
+ * - each attempt uses a timeout to the next attempt by an interval (ms)
1105
+ * - each attempt increases the timeout interval by a "poll_backoffFactor"
1106
+ * - if max attempts are exceeded or executor has exception then onError handler is called
1107
+ *
1108
+ * IMPORTANT! the executor function must explicitly call ".next()" for the next iteration to run
1109
+ */
1110
+ export declare class PollingFunction {
1111
+ options: PollingOptions;
1112
+ poll_intervalMs: number;
1113
+ attempt: number;
1114
+ shouldIterate: boolean;
1115
+ onError?: (error: Error) => void;
1116
+ timeoutId: number;
1117
+ constructor(options?: Partial<PollingOptions>);
1118
+ execute(executor: Executor): Promise<void>;
1119
+ private fail;
1120
+ getIntervalMsForIteration(iteration: number): number;
1121
+ next(): void;
1122
+ cancel(): void;
1123
+ }
1124
+
1125
+ declare interface PollingOptions {
1126
+ poll_intervalMs: number;
1127
+ poll_maxAttempts: number;
1128
+ poll_backoffFactor: number;
1129
+ poll_maxIntervalMs: number;
1130
+ }
1131
+
1132
+ export declare interface PreviewableFileState {
1133
+ preview: FilePreview | Promise<FilePreview>;
1134
+ }
1135
+
1136
+ export declare interface PreviewOptions {}
1137
+
1138
+ export declare interface ProcessedFileState {
1139
+ status: 'processed';
1140
+ id: string;
1141
+ occurrenceKey?: string;
1142
+ name: string;
1143
+ size: number;
1144
+ artifacts: MediaFileArtifacts;
1145
+ mediaType: MediaType;
1146
+ mimeType: string;
1147
+ preview?: FilePreview | Promise<FilePreview>;
1148
+ representations?: MediaRepresentations;
1149
+ createdAt?: number;
1150
+ }
1151
+
1152
+ export declare interface ProcessingFailedState {
1153
+ status: 'failed-processing';
1154
+ id: string;
1155
+ occurrenceKey?: string;
1156
+ name: string;
1157
+ size: number;
1158
+ artifacts: Object;
1159
+ mediaType: MediaType;
1160
+ mimeType: string;
1161
+ preview?: FilePreview | Promise<FilePreview>;
1162
+ representations?: MediaRepresentations;
1163
+ createdAt?: number;
1164
+ }
1165
+
1166
+ export declare interface ProcessingFileState {
1167
+ status: 'processing';
1168
+ id: string;
1169
+ occurrenceKey?: string;
1170
+ name: string;
1171
+ size: number;
1172
+ artifacts?: MediaFileArtifacts;
1173
+ mediaType: MediaType;
1174
+ mimeType: string;
1175
+ preview?: FilePreview | Promise<FilePreview>;
1176
+ representations?: MediaRepresentations;
1177
+ createdAt?: number;
1178
+ }
1179
+
1180
+ export declare const RECENTS_COLLECTION = 'recents';
1181
+
1182
+ export declare function request(
1183
+ url: string,
1184
+ options?: RequestOptions,
1185
+ controller?: AbortController,
1186
+ ): Promise<Response>;
1187
+
1188
+ export declare class RequestError extends BaseMediaClientError<
1189
+ RequestErrorAttributes
1190
+ > {
1191
+ readonly reason: RequestErrorReason;
1192
+ readonly metadata?: RequestErrorMetadata | undefined;
1193
+ readonly innerError?: Error | undefined;
1194
+ constructor(
1195
+ reason: RequestErrorReason,
1196
+ metadata?: RequestErrorMetadata | undefined,
1197
+ innerError?: Error | undefined,
1198
+ );
1199
+ get attributes(): {
1200
+ reason: RequestErrorReason;
1201
+ method: RequestMethod | undefined;
1202
+ endpoint: string | undefined;
1203
+ mediaRegion: string | undefined;
1204
+ mediaEnv: string | undefined;
1205
+ attempts: number | undefined;
1206
+ clientExhaustedRetries: boolean | undefined;
1207
+ statusCode: number | undefined;
1208
+ innerError: Error | undefined;
1209
+ };
1210
+ }
1211
+
1212
+ export declare type RequestErrorAttributes = RequestErrorMetadata & {
1213
+ readonly reason: RequestErrorReason;
1214
+ };
1215
+
1216
+ export declare type RequestErrorMetadata = RequestMetadata & {
1217
+ readonly attempts?: number;
1218
+ readonly clientExhaustedRetries?: boolean;
1219
+ readonly statusCode?: number;
1220
+ };
1221
+
1222
+ export declare type RequestErrorReason =
1223
+ | 'clientOffline'
1224
+ | 'clientAbortedRequest'
1225
+ | 'clientTimeoutRequest'
1226
+ | 'serverInvalidBody'
1227
+ | 'serverBadRequest'
1228
+ | 'serverUnauthorized'
1229
+ | 'serverForbidden'
1230
+ | 'serverNotFound'
1231
+ | 'serverRateLimited'
1232
+ | 'serverInternalError'
1233
+ | 'serverBadGateway'
1234
+ | 'serverUnexpectedError';
1235
+
1236
+ export declare type RequestHeaders = {
1237
+ [key: string]: string;
1238
+ };
1239
+
1240
+ export declare type RequestMetadata = {
1241
+ readonly method?: RequestMethod;
1242
+ readonly endpoint?: string;
1243
+ readonly mediaRegion?: string;
1244
+ readonly mediaEnv?: string;
1245
+ };
1246
+
1247
+ export declare type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
1248
+
1249
+ export declare type RequestOptions = RequestMetadata & {
1250
+ readonly auth?: Auth;
1251
+ readonly params?: RequestParams;
1252
+ readonly headers?: RequestHeaders;
1253
+ readonly body?: any;
1254
+ readonly clientOptions?: ClientOptions;
1255
+ };
1256
+
1257
+ export declare type RequestParams = {
1258
+ [key: string]: any;
1259
+ };
1260
+
1261
+ export declare interface ResponseFileItem {
1262
+ id: string;
1263
+ type: 'file';
1264
+ details: MediaCollectionItemFullDetails;
1265
+ collection?: string;
1266
+ }
1267
+
1268
+ export declare type RetryOptions = {
1269
+ readonly startTimeoutInMs: number;
1270
+ readonly maxAttempts: number;
1271
+ readonly factor: number;
1272
+ };
1273
+
1274
+ export declare const safeUnsubscribe: (subscription: MediaSubscription) => void;
1275
+
1276
+ export declare interface SourceFile {
1277
+ id: string;
1278
+ owner: ClientAltBasedAuth | AsapBasedAuth;
1279
+ collection?: string;
1280
+ version?: number;
1281
+ }
1282
+
1283
+ export declare class StargateClient {
1284
+ private baseUrl;
1285
+ constructor(baseUrl: string | undefined);
1286
+ fetchToken(clientId: string): Promise<EdgeData>;
1287
+ isTokenExpired(token: EdgeData): boolean;
1288
+ }
1289
+
1290
+ export declare class StreamsCache<T> {
1291
+ private readonly streams;
1292
+ constructor(streams: LRUCache<string, ReplaySubject<T>>);
1293
+ has(id: string): boolean;
1294
+ set(id: string, stream: ReplaySubject<T>): void;
1295
+ get(id: string): ReplaySubject<T> | undefined;
1296
+ getOrInsert(id: string, callback: () => ReplaySubject<T>): ReplaySubject<T>;
1297
+ removeAll(): void;
1298
+ remove(id: string): void;
1299
+ get size(): number;
1300
+ }
1301
+
1302
+ export declare type TouchedFiles = {
1303
+ created: CreatedTouchedFile[];
1304
+ };
1305
+
1306
+ export declare interface TouchFileDescriptor {
1307
+ fileId: string;
1308
+ collection?: string;
1309
+ occurrenceKey?: string;
1310
+ expireAfter?: number;
1311
+ deletable?: boolean;
1312
+ }
1313
+
1314
+ export declare type UploadableFile = {
1315
+ content: ChunkinatorFile;
1316
+ name?: string;
1317
+ mimeType?: string;
1318
+ collection?: string;
1319
+ };
1320
+
1321
+ export declare type UploadableFileUpfrontIds = {
1322
+ id: string;
1323
+ deferredUploadId: Promise<string>;
1324
+ occurrenceKey?: string;
1325
+ };
1326
+
1327
+ export declare class UploadController {
1328
+ abortFunction?: AbortFunction;
1329
+ constructor();
1330
+ setAbort(abortFunction: AbortFunction): void;
1331
+ abort(): void;
1332
+ }
1333
+
1334
+ export declare type UploadEventPayloadMap = {
1335
+ 'file-added': FileState;
1336
+ 'media-viewed': MediaViewedEventPayload;
1337
+ };
1338
+
1339
+ export declare const uploadFile: (
1340
+ file: UploadableFile,
1341
+ store: MediaStore,
1342
+ uploadableFileUpfrontIds: UploadableFileUpfrontIds,
1343
+ callbacks?: UploadFileCallbacks | undefined,
1344
+ ) => UploadFileResult;
1345
+
1346
+ export declare type UploadFileCallbacks = {
1347
+ onProgress: (progress: number) => void;
1348
+ onUploadFinish: (error?: any) => void;
1349
+ };
1350
+
1351
+ export declare interface UploadFileResult {
1352
+ cancel: () => void;
1353
+ }
1354
+
1355
+ export declare interface UploadingFileState {
1356
+ status: 'uploading';
1357
+ id: string;
1358
+ occurrenceKey?: string;
1359
+ name: string;
1360
+ size: number;
1361
+ progress: number;
1362
+ mediaType: MediaType;
1363
+ mimeType: string;
1364
+ preview?: FilePreview | Promise<FilePreview>;
1365
+ createdAt?: number;
1366
+ }
1367
+
1368
+ export declare interface WithMediaClient {
1369
+ mediaClient: MediaClient;
1370
+ identifier?: Identifier;
1371
+ }
1372
+
1373
+ export declare const withMediaClient: WithMediaClientFunction;
1374
+
1375
+ export declare interface WithMediaClientConfig {
1376
+ mediaClientConfig: MediaClientConfig;
1377
+ }
1378
+
1379
+ export declare type WithMediaClientConfigProps<
1380
+ P extends WithMediaClient
1381
+ > = Omit<P, 'mediaClient'> & WithMediaClientConfig;
1382
+
1383
+ export declare type WithMediaClientFunction = <P extends WithMediaClient>(
1384
+ Component: React_2.ComponentType<P>,
1385
+ featureFlags?: MediaFeatureFlags,
1386
+ ) => React_2.ComponentType<WithMediaClientConfigProps<P>>;
1387
+
1388
+ export {};
1389
+ ```