@atlaskit/media-client 14.1.0 → 14.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/cjs/client/file-fetcher/index.js +1 -10
  3. package/dist/cjs/client/media-client.js +50 -1
  4. package/dist/cjs/client/media-store/resolveAuth.js +22 -19
  5. package/dist/cjs/client/mobile-upload.js +98 -0
  6. package/dist/cjs/index.js +8 -0
  7. package/dist/cjs/models/mobile-upload.js +5 -0
  8. package/dist/cjs/utils/imageResizeModeToFileImageMode.js +12 -0
  9. package/dist/cjs/utils/mobileUpload/error.js +67 -0
  10. package/dist/cjs/utils/mobileUpload/helpers.js +110 -0
  11. package/dist/cjs/utils/mobileUpload/index.js +49 -0
  12. package/dist/cjs/utils/mobileUpload/servicesCache.js +12 -0
  13. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +103 -0
  14. package/dist/cjs/utils/mobileUpload/stateMachine/states/error.js +10 -0
  15. package/dist/cjs/utils/mobileUpload/stateMachine/states/processed.js +10 -0
  16. package/dist/cjs/utils/mobileUpload/stateMachine/states/processing.js +77 -0
  17. package/dist/cjs/utils/mobileUpload/stateMachine/states/processingFailed.js +10 -0
  18. package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +70 -0
  19. package/dist/cjs/utils/mobileUpload/stateMachine/types.js +5 -0
  20. package/dist/cjs/utils/polling/index.js +5 -6
  21. package/dist/cjs/version.json +1 -1
  22. package/dist/es2019/client/file-fetcher/index.js +1 -11
  23. package/dist/es2019/client/media-client.js +15 -1
  24. package/dist/es2019/client/media-store/resolveAuth.js +3 -3
  25. package/dist/es2019/client/mobile-upload.js +80 -0
  26. package/dist/es2019/index.js +1 -0
  27. package/dist/es2019/models/mobile-upload.js +1 -0
  28. package/dist/es2019/utils/imageResizeModeToFileImageMode.js +1 -0
  29. package/dist/es2019/utils/mobileUpload/error.js +30 -0
  30. package/dist/es2019/utils/mobileUpload/helpers.js +55 -0
  31. package/dist/es2019/utils/mobileUpload/index.js +4 -0
  32. package/dist/es2019/utils/mobileUpload/servicesCache.js +4 -0
  33. package/dist/es2019/utils/mobileUpload/stateMachine/index.js +52 -0
  34. package/dist/es2019/utils/mobileUpload/stateMachine/states/error.js +3 -0
  35. package/dist/es2019/utils/mobileUpload/stateMachine/states/processed.js +3 -0
  36. package/dist/es2019/utils/mobileUpload/stateMachine/states/processing.js +60 -0
  37. package/dist/es2019/utils/mobileUpload/stateMachine/states/processingFailed.js +3 -0
  38. package/dist/es2019/utils/mobileUpload/stateMachine/states/uploading.js +44 -0
  39. package/dist/es2019/utils/mobileUpload/stateMachine/types.js +1 -0
  40. package/dist/es2019/utils/polling/index.js +5 -5
  41. package/dist/es2019/version.json +1 -1
  42. package/dist/esm/client/file-fetcher/index.js +1 -9
  43. package/dist/esm/client/media-client.js +44 -1
  44. package/dist/esm/client/media-store/resolveAuth.js +20 -17
  45. package/dist/esm/client/mobile-upload.js +83 -0
  46. package/dist/esm/index.js +1 -0
  47. package/dist/esm/models/mobile-upload.js +1 -0
  48. package/dist/esm/utils/imageResizeModeToFileImageMode.js +3 -0
  49. package/dist/esm/utils/mobileUpload/error.js +51 -0
  50. package/dist/esm/utils/mobileUpload/helpers.js +86 -0
  51. package/dist/esm/utils/mobileUpload/index.js +4 -0
  52. package/dist/esm/utils/mobileUpload/servicesCache.js +4 -0
  53. package/dist/esm/utils/mobileUpload/stateMachine/index.js +78 -0
  54. package/dist/esm/utils/mobileUpload/stateMachine/states/error.js +3 -0
  55. package/dist/esm/utils/mobileUpload/stateMachine/states/processed.js +3 -0
  56. package/dist/esm/utils/mobileUpload/stateMachine/states/processing.js +68 -0
  57. package/dist/esm/utils/mobileUpload/stateMachine/states/processingFailed.js +3 -0
  58. package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +58 -0
  59. package/dist/esm/utils/mobileUpload/stateMachine/types.js +1 -0
  60. package/dist/esm/utils/polling/index.js +5 -5
  61. package/dist/esm/version.json +1 -1
  62. package/dist/types/client/media-client.d.ts +3 -0
  63. package/dist/types/client/media-store/resolveAuth.d.ts +2 -2
  64. package/dist/types/client/mobile-upload.d.ts +11 -0
  65. package/dist/types/index.d.ts +4 -2
  66. package/dist/types/models/mobile-upload.d.ts +28 -0
  67. package/dist/types/utils/imageResizeModeToFileImageMode.d.ts +3 -0
  68. package/dist/types/utils/mobileUpload/error.d.ts +29 -0
  69. package/dist/types/utils/mobileUpload/helpers.d.ts +8 -0
  70. package/dist/types/utils/mobileUpload/index.d.ts +5 -0
  71. package/dist/types/utils/mobileUpload/servicesCache.d.ts +4 -0
  72. package/dist/types/utils/mobileUpload/stateMachine/index.d.ts +7 -0
  73. package/dist/types/utils/mobileUpload/stateMachine/states/error.d.ts +3 -0
  74. package/dist/types/utils/mobileUpload/stateMachine/states/processed.d.ts +3 -0
  75. package/dist/types/utils/mobileUpload/stateMachine/states/processing.d.ts +3 -0
  76. package/dist/types/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +3 -0
  77. package/dist/types/utils/mobileUpload/stateMachine/states/uploading.d.ts +3 -0
  78. package/dist/types/utils/mobileUpload/stateMachine/types.d.ts +69 -0
  79. package/dist/types/utils/polling/errors.d.ts +1 -1
  80. package/dist/types/utils/polling/index.d.ts +8 -3
  81. package/package.json +6 -5
@@ -0,0 +1,68 @@
1
+ import { assign, send } from 'xstate';
2
+ export var machineProcessingState = {
3
+ // Events
4
+ on: {
5
+ REMOTE_FILESTATE_PROCESSED: 'processed',
6
+ REMOTE_FILESTATE_PROCESSING_FAILED: 'processingFailed',
7
+ REMOTE_FILESTATE_ERROR: 'error'
8
+ },
9
+ // Initial sub state
10
+ initial: 'loading',
11
+ // Sub states definitions
12
+ states: {
13
+ loading: {
14
+ invoke: {
15
+ src: 'shouldFetchRemoteFileStates',
16
+ onDone: {
17
+ actions: send(function (_, event) {
18
+ return {
19
+ // shouldFetchRemoteFileStates resolves a boolean
20
+ type: event.data ? 'REMOTE_FILESTATE_FETCH' : 'REMOTE_FILESTATE_BYPASS'
21
+ };
22
+ })
23
+ },
24
+ onError: 'idle'
25
+ },
26
+ on: {
27
+ REMOTE_FILESTATE_FETCH: 'fetchingRemoteFileStates',
28
+ REMOTE_FILESTATE_BYPASS: 'idle'
29
+ }
30
+ },
31
+ fetchingRemoteFileStates: {
32
+ invoke: {
33
+ src: 'fetchRemoteFileStates',
34
+ onDone: {
35
+ actions: send(function (ctx) {
36
+ return {
37
+ type: ctx.currentFileState.status === 'processed' ? 'REMOTE_FILESTATE_PROCESSED' : 'REMOTE_FILESTATE_PROCESSING_FAILED'
38
+ };
39
+ })
40
+ },
41
+ onError: {
42
+ actions: [assign({
43
+ currentFileState: function currentFileState(ctx, event) {
44
+ return {
45
+ status: 'error',
46
+ id: ctx.currentFileState.id,
47
+ occurrenceKey: ctx.currentFileState.occurrenceKey,
48
+ message: event.data.message
49
+ };
50
+ }
51
+ }), send({
52
+ type: 'REMOTE_FILESTATE_ERROR'
53
+ })]
54
+ }
55
+ },
56
+ on: {
57
+ REMOTE_FILESTATE_RESULT: {
58
+ actions: assign({
59
+ currentFileState: function currentFileState(_, event) {
60
+ return event.fileState;
61
+ }
62
+ })
63
+ }
64
+ }
65
+ },
66
+ idle: {}
67
+ }
68
+ };
@@ -0,0 +1,3 @@
1
+ export var machineProcessingFailedState = {
2
+ type: 'final'
3
+ };
@@ -0,0 +1,58 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ import { assign } from 'xstate';
8
+ import { isUploadingFileState } from '../../../../models/file-state';
9
+ export var machineUploadingState = {
10
+ // Events
11
+ on: {
12
+ UPLOAD_PROGRESS: [{
13
+ target: 'uploading',
14
+ cond: function cond(ctx, event) {
15
+ return isUploadingFileState(ctx.currentFileState) && event.progress > ctx.currentFileState.progress;
16
+ },
17
+ actions: assign({
18
+ currentFileState: function currentFileState(ctx, event) {
19
+ return _objectSpread(_objectSpread({}, ctx.currentFileState), {}, {
20
+ progress: event.progress
21
+ });
22
+ }
23
+ })
24
+ }, {
25
+ target: 'error'
26
+ }],
27
+ UPLOAD_END: {
28
+ target: 'processing',
29
+ actions: assign({
30
+ currentFileState: function currentFileState(ctx) {
31
+ return isUploadingFileState(ctx.currentFileState) && {
32
+ status: 'processing',
33
+ id: ctx.currentFileState.id,
34
+ occurrenceKey: ctx.currentFileState.occurrenceKey,
35
+ name: ctx.currentFileState.name,
36
+ size: ctx.currentFileState.size,
37
+ mediaType: ctx.currentFileState.mediaType,
38
+ mimeType: ctx.currentFileState.mimeType,
39
+ preview: ctx.currentFileState.preview,
40
+ createdAt: ctx.currentFileState.createdAt
41
+ } || ctx.currentFileState;
42
+ }
43
+ })
44
+ },
45
+ UPLOAD_ERROR: {
46
+ target: 'error',
47
+ actions: assign({
48
+ currentFileState: function currentFileState(ctx, event) {
49
+ return {
50
+ status: 'error',
51
+ id: ctx.currentFileState.id,
52
+ message: event.message
53
+ };
54
+ }
55
+ })
56
+ }
57
+ }
58
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -8,13 +8,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
8
 
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10
10
 
11
- import { getMediaFeatureFlag } from '@atlaskit/media-common/mediaFeatureFlags';
12
11
  import { PollingError } from './errors';
12
+ // default polling options without using feature flags
13
13
  export var defaultPollingOptions = {
14
- poll_intervalMs: getMediaFeatureFlag('poll_intervalMs'),
15
- poll_maxAttempts: getMediaFeatureFlag('poll_maxAttempts'),
16
- poll_backoffFactor: getMediaFeatureFlag('poll_backoffFactor'),
17
- poll_maxIntervalMs: getMediaFeatureFlag('poll_maxIntervalMs')
14
+ poll_intervalMs: 3000,
15
+ poll_maxAttempts: 30,
16
+ poll_backoffFactor: 1.25,
17
+ poll_maxIntervalMs: 200000
18
18
  };
19
19
  /**
20
20
  * This class encapsulates polling functionality with the following features:
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "14.1.0",
3
+ "version": "14.3.1",
4
4
  "sideEffects": false
5
5
  }
@@ -5,6 +5,7 @@ import { CollectionFetcher } from './collection-fetcher';
5
5
  import { FileFetcher } from './file-fetcher';
6
6
  import { UploadEventPayloadMap, EventPayloadListener } from './events';
7
7
  import { StargateClient } from './stargate-client';
8
+ import { MobileUpload } from '../models/mobile-upload';
8
9
  export declare class MediaClient {
9
10
  readonly mediaClientConfig: MediaClientConfig;
10
11
  readonly featureFlags?: MediaFeatureFlags | undefined;
@@ -13,12 +14,14 @@ export declare class MediaClient {
13
14
  readonly file: FileFetcher;
14
15
  readonly stargate: StargateClient;
15
16
  private readonly eventEmitter;
17
+ private mobileUpload?;
16
18
  readonly config: MediaClientConfig;
17
19
  constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
18
20
  getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
19
21
  getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
20
22
  getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
21
23
  getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
24
+ mobileUploadPromise(): Promise<MobileUpload>;
22
25
  on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
23
26
  off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
24
27
  emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;
@@ -1,4 +1,4 @@
1
1
  import { Auth, AuthContext, AuthProvider } from '@atlaskit/media-core';
2
- export declare const AUTH_PROVIDER_TIMEOUT = 10000;
3
- export declare const resolveAuth: (authProvider: AuthProvider, authContext?: AuthContext | undefined) => Promise<Auth>;
2
+ export declare const DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
3
+ export declare const resolveAuth: (authProvider: AuthProvider, authContext?: AuthContext | undefined, authProviderTimeout?: number) => Promise<Auth>;
4
4
  export declare const resolveInitialAuth: (auth?: import("@atlaskit/media-core").ClientBasedAuth | import("@atlaskit/media-core").AsapBasedAuth | 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
+ }
@@ -11,6 +11,7 @@ export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
11
11
  export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
12
12
  export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
13
13
  export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
14
+ export type { MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
14
15
  export { getFileStreamsCache, StreamsCache } from './file-streams-cache';
15
16
  export { uploadFile } from './uploader';
16
17
  export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
@@ -21,7 +22,8 @@ export { PollingFunction } from './utils/polling';
21
22
  export { isPollingError, PollingError } from './utils/polling/errors';
22
23
  export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
23
24
  export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
24
- export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
25
+ export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
26
+ export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
25
27
  export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
26
28
  export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
27
29
  export { CollectionFetcher } from './client/collection-fetcher';
@@ -39,7 +41,7 @@ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } f
39
41
  export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
40
42
  export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
41
43
  export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
42
- export type { WithMediaClientConfig, WithMediaClientConfigProps, } from './utils/with-media-client-hoc';
44
+ export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, } from './utils/with-media-client-hoc';
43
45
  export { globalMediaEventEmitter } from './globalMediaEventEmitter';
44
46
  export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
45
47
  export type { MediaBlobUrlAttrs } from './utils/url';
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ import { MediaStoreGetFileImageParams } from '../client/media-store';
2
+ export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
3
+ export declare const imageResizeModeToFileImageMode: (resizeMode?: "crop" | "fit" | "full-fit" | "stretchy-fit" | undefined) => MediaStoreGetFileImageParams['mode'];
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,5 @@
1
+ export { isMobileUploadError, MobileUploadError } from './error';
2
+ export { createServicesCache } from './servicesCache';
3
+ export { createMobileUploadService, createMobileUploadStateMachine, } from './stateMachine';
4
+ export { createMobileFileStateSubject } from './helpers';
5
+ export type { StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate, } from './stateMachine/types';
@@ -0,0 +1,4 @@
1
+ import { LRUCache } from 'lru-fast';
2
+ import { Interpreter } from 'xstate';
3
+ import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
4
+ export declare function createServicesCache(): LRUCache<string, Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>>;
@@ -0,0 +1,7 @@
1
+ import DataLoader from 'dataloader';
2
+ import { Interpreter, StateMachine } from 'xstate';
3
+ import { UploadingFileState } from '../../../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>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineErrorState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineProcessedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { ProcessingStateMachineSchema, StateMachineContext, StateMachineEvent } from '../types';
3
+ export declare const machineProcessingState: StateNodeConfig<StateMachineContext, ProcessingStateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineProcessingFailedState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,3 @@
1
+ import { StateNodeConfig } from 'xstate';
2
+ import { StateMachineContext, StateMachineSchema, StateMachineEvent } from '../types';
3
+ export declare const machineUploadingState: StateNodeConfig<StateMachineContext, StateMachineSchema, StateMachineEvent>;
@@ -0,0 +1,69 @@
1
+ import { StateSchema } from 'xstate';
2
+ import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '../../../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
+ };
@@ -9,4 +9,4 @@ export declare class PollingError extends BaseMediaClientError<PollingErrorAttri
9
9
  attempts: number;
10
10
  };
11
11
  }
12
- export declare function isPollingError(err: Error): err is PollingError;
12
+ export declare function isPollingError(err?: Error): err is PollingError;
@@ -1,6 +1,11 @@
1
- import { PollingOptions } from '@atlaskit/media-common/mediaFeatureFlags';
2
1
  import { Executor } from './types';
3
- export declare const defaultPollingOptions: Required<PollingOptions>;
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;
4
9
  /**
5
10
  * This class encapsulates polling functionality with the following features:
6
11
  *
@@ -13,7 +18,7 @@ export declare const defaultPollingOptions: Required<PollingOptions>;
13
18
  * IMPORTANT! the executor function must explicitly call ".next()" for the next iteration to run
14
19
  */
15
20
  export declare class PollingFunction {
16
- options: Required<PollingOptions>;
21
+ options: PollingOptions;
17
22
  poll_intervalMs: number;
18
23
  attempt: number;
19
24
  shouldIterate: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "14.1.0",
3
+ "version": "14.3.1",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/chunkinator": "^3.0.0",
31
- "@atlaskit/media-common": "^2.8.0",
31
+ "@atlaskit/media-common": "^2.10.0",
32
32
  "@babel/runtime": "^7.0.0",
33
33
  "dataloader": "^2.0.0",
34
34
  "deep-equal": "^1.0.1",
@@ -39,7 +39,8 @@
39
39
  "setimmediate": "^1.0.5",
40
40
  "uuid": "^3.1.0",
41
41
  "uuid-validate": "^0.0.3",
42
- "video-snapshot": "^1.0.11"
42
+ "video-snapshot": "^1.0.11",
43
+ "xstate": "^4.20.0"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "@atlaskit/media-core": "^32.2.0",
@@ -50,9 +51,9 @@
50
51
  "@atlaskit/build-utils": "*",
51
52
  "@atlaskit/button": "^16.1.0",
52
53
  "@atlaskit/docs": "*",
53
- "@atlaskit/media-card": "^70.10.0",
54
+ "@atlaskit/media-card": "^72.1.0",
54
55
  "@atlaskit/media-core": "^32.2.0",
55
- "@atlaskit/media-test-helpers": "^28.7.0",
56
+ "@atlaskit/media-test-helpers": "^28.9.0",
56
57
  "@atlaskit/ssr": "*",
57
58
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
58
59
  "@types/deep-equal": "^1.0.1",