@atlaskit/media-client 37.2.37 → 37.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/cjs/client/file-fetcher/FileFetcherError.js +54 -0
- package/dist/cjs/client/file-fetcher/error.js +13 -52
- package/dist/cjs/client/file-fetcher/index.js +59 -46
- package/dist/cjs/client/file-fetcher/isFileFetcherError.js +10 -0
- package/dist/cjs/client/media-client.js +4 -4
- package/dist/cjs/client/media-store/MediaStore.js +100 -108
- package/dist/cjs/client/media-store/MediaStoreError.js +36 -0
- package/dist/cjs/client/media-store/cdnFeatureFlag.js +14 -0
- package/dist/cjs/client/media-store/decodeJwtToken.js +9 -0
- package/dist/cjs/client/media-store/error.js +13 -34
- package/dist/cjs/client/media-store/extendImageParams.js +23 -0
- package/dist/cjs/client/media-store/getMediaEnvironment.js +11 -0
- package/dist/cjs/client/media-store/getMediaRegion.js +11 -0
- package/dist/cjs/client/media-store/getValueFromSessionStorage.js +10 -0
- package/dist/cjs/client/media-store/isMediaStoreError.js +10 -0
- package/dist/cjs/client/media-store/jsonHeaders.js +10 -0
- package/dist/cjs/client/media-store/resolveAuth.js +10 -16
- package/dist/cjs/client/media-store/resolveInitialAuth.js +13 -0
- package/dist/cjs/client/media-store/setKeyValueInSessionStorage.js +19 -0
- package/dist/cjs/client/mobile-upload.js +9 -6
- package/dist/cjs/identifier.js +20 -15
- package/dist/cjs/index.js +60 -37
- package/dist/cjs/is-different-identifier.js +16 -0
- package/dist/cjs/is-external-image-identifier.js +9 -0
- package/dist/cjs/is-file-identifier.js +9 -0
- package/dist/cjs/models/artifacts.js +2 -2
- package/dist/cjs/models/errors/BaseMediaClientError.js +43 -0
- package/dist/cjs/models/errors/CommonMediaClientError.js +32 -0
- package/dist/cjs/models/errors/fromCommonMediaClientError.js +28 -0
- package/dist/cjs/models/errors/getMediaClientErrorReason.js +10 -0
- package/dist/cjs/models/errors/helpers.js +14 -8
- package/dist/cjs/models/errors/index.js +37 -96
- package/dist/cjs/models/errors/isCommonMediaClientError.js +17 -0
- package/dist/cjs/models/errors/isMediaClientError.js +9 -0
- package/dist/cjs/models/errors/toCommonMediaClientError.js +13 -0
- package/dist/cjs/models/file-state.js +75 -93
- package/dist/cjs/models/has-artifacts.js +9 -0
- package/dist/cjs/models/is-error-file-state.js +9 -0
- package/dist/cjs/models/is-final-file-state.js +9 -0
- package/dist/cjs/models/is-image-representation-ready.js +16 -0
- package/dist/cjs/models/is-non-error-final-file-state.js +9 -0
- package/dist/cjs/models/is-not-found-media-item-details.js +9 -0
- package/dist/cjs/models/is-previewable-file-state.js +10 -0
- package/dist/cjs/models/is-previewable-type.js +10 -0
- package/dist/cjs/models/is-processed-file-state.js +9 -0
- package/dist/cjs/models/is-processing-file-state.js +9 -0
- package/dist/cjs/models/is-uploading-file-state.js +9 -0
- package/dist/cjs/models/map-media-file-to-file-state.js +59 -0
- package/dist/cjs/models/map-media-item-to-file-state.js +18 -0
- package/dist/cjs/models/media.js +23 -10
- package/dist/cjs/uploader/{error.js → UploaderError.js} +2 -6
- package/dist/cjs/uploader/index.js +4 -4
- package/dist/cjs/uploader/isUploaderError.js +10 -0
- package/dist/cjs/utils/addFileAttrsToUrl.js +24 -0
- package/dist/cjs/utils/createBatchLoadingFunc.js +127 -0
- package/dist/cjs/utils/createFileDataLoader.js +1 -170
- package/dist/cjs/utils/createFileDataloader-2.js +15 -0
- package/dist/cjs/utils/getAttrsFromUrl.js +41 -0
- package/dist/cjs/utils/getItemsFromKeys.js +50 -0
- package/dist/cjs/utils/isCDNEnabled.js +15 -0
- package/dist/cjs/utils/isMediaBlobUrl.js +10 -0
- package/dist/cjs/utils/isPathBasedEnabled.js +14 -0
- package/dist/cjs/utils/mapRetryUrlToPathBasedUrl.js +24 -0
- package/dist/cjs/utils/mapToMediaCdnUrl.js +38 -0
- package/dist/cjs/utils/mapToPathBasedUrl.js +32 -0
- package/dist/cjs/utils/mediaCdn.js +2 -40
- package/dist/cjs/utils/mediaSubscribable/createMediaSubscribable.js +11 -0
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +13 -5
- package/dist/cjs/utils/mobileUpload/{error.js → MobileUploadError.js} +2 -6
- package/dist/cjs/utils/mobileUpload/{helpers.js → createMobileDownloadFileStream.js} +8 -18
- package/dist/cjs/utils/mobileUpload/createMobileFileStateSubject.js +16 -0
- package/dist/cjs/utils/mobileUpload/isMobileUploadError.js +10 -0
- package/dist/cjs/utils/mobileUpload/stateMachine/createMobileUploadService.js +10 -0
- package/dist/cjs/utils/mobileUpload/stateMachine/{index.js → createMobileUploadStateMachine.js} +8 -12
- package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +3 -3
- package/dist/cjs/utils/objectToQueryString.js +17 -0
- package/dist/cjs/utils/overrideMediaTypeIfUnknown.js +2 -2
- package/dist/cjs/utils/pathBasedUrl.js +2 -49
- package/dist/cjs/utils/polling/PollingError.js +36 -0
- package/dist/cjs/utils/polling/errors.js +13 -34
- package/dist/cjs/utils/polling/index.js +11 -6
- package/dist/cjs/utils/polling/isPollingError.js +10 -0
- package/dist/cjs/utils/rejectTimeout.js +11 -0
- package/dist/cjs/utils/request/RequestError.js +56 -0
- package/dist/cjs/utils/request/cloneRequestError.js +17 -0
- package/dist/cjs/utils/request/createMapResponseToBlob.js +43 -0
- package/dist/cjs/utils/request/createMapResponseToJson.js +43 -0
- package/dist/cjs/utils/request/createProcessFetchResponse.js +16 -0
- package/dist/cjs/utils/request/createRequestErrorFromResponse.js +20 -0
- package/dist/cjs/utils/request/createRequestErrorReason.js +30 -0
- package/dist/cjs/utils/request/createUrl.js +31 -0
- package/dist/cjs/utils/request/defaultShouldRetryError.js +12 -0
- package/dist/cjs/utils/request/errors.js +13 -54
- package/dist/cjs/utils/request/extendHeaders.js +21 -0
- package/dist/cjs/utils/request/extendTraceContext.js +16 -0
- package/dist/cjs/utils/request/extractMediaHeaders.js +15 -0
- package/dist/cjs/utils/request/fetchRetry.js +120 -0
- package/dist/cjs/utils/request/getStatusCode.js +11 -0
- package/dist/cjs/utils/request/helpers.js +198 -313
- package/dist/cjs/utils/request/index.js +36 -20
- package/dist/cjs/utils/request/isAbortedRequestError.js +9 -0
- package/dist/cjs/utils/request/isFetchNetworkError.js +10 -0
- package/dist/cjs/utils/request/isRateLimitedError.js +11 -0
- package/dist/cjs/utils/request/isRequestError.js +10 -0
- package/dist/cjs/utils/request/mapAuthToRequestHeaders.js +22 -0
- package/dist/cjs/utils/request/waitPromise.js +11 -0
- package/dist/cjs/utils/{setTimeoutPromise.js → resolveTimeout.js} +1 -6
- package/dist/cjs/utils/url.js +43 -63
- package/dist/es2019/client/file-fetcher/FileFetcherError.js +34 -0
- package/dist/es2019/client/file-fetcher/error.js +9 -37
- package/dist/es2019/client/file-fetcher/index.js +32 -17
- package/dist/es2019/client/file-fetcher/isFileFetcherError.js +4 -0
- package/dist/es2019/client/media-client.js +1 -1
- package/dist/es2019/client/media-store/MediaStore.js +35 -59
- package/dist/es2019/client/media-store/MediaStoreError.js +19 -0
- package/dist/es2019/client/media-store/cdnFeatureFlag.js +8 -0
- package/dist/es2019/client/media-store/decodeJwtToken.js +3 -0
- package/dist/es2019/client/media-store/error.js +9 -22
- package/dist/es2019/client/media-store/extendImageParams.js +14 -0
- package/dist/es2019/client/media-store/getMediaEnvironment.js +5 -0
- package/dist/es2019/client/media-store/getMediaRegion.js +5 -0
- package/dist/es2019/client/media-store/getValueFromSessionStorage.js +4 -0
- package/dist/es2019/client/media-store/isMediaStoreError.js +4 -0
- package/dist/es2019/client/media-store/jsonHeaders.js +4 -0
- package/dist/es2019/client/media-store/resolveAuth.js +2 -8
- package/dist/es2019/client/media-store/resolveInitialAuth.js +7 -0
- package/dist/es2019/client/media-store/setKeyValueInSessionStorage.js +13 -0
- package/dist/es2019/client/mobile-upload.js +5 -2
- package/dist/es2019/identifier.js +14 -14
- package/dist/es2019/index.js +31 -8
- package/dist/es2019/is-different-identifier.js +9 -0
- package/dist/es2019/is-external-image-identifier.js +3 -0
- package/dist/es2019/is-file-identifier.js +3 -0
- package/dist/es2019/models/artifacts.js +1 -1
- package/dist/es2019/models/errors/BaseMediaClientError.js +23 -0
- package/dist/es2019/models/errors/CommonMediaClientError.js +13 -0
- package/dist/es2019/models/errors/fromCommonMediaClientError.js +20 -0
- package/dist/es2019/models/errors/getMediaClientErrorReason.js +4 -0
- package/dist/es2019/models/errors/helpers.js +10 -6
- package/dist/es2019/models/errors/index.js +27 -72
- package/dist/es2019/models/errors/isCommonMediaClientError.js +11 -0
- package/dist/es2019/models/errors/isMediaClientError.js +3 -0
- package/dist/es2019/models/errors/toCommonMediaClientError.js +8 -0
- package/dist/es2019/models/file-state.js +46 -79
- package/dist/es2019/models/has-artifacts.js +1 -0
- package/dist/es2019/models/is-error-file-state.js +1 -0
- package/dist/es2019/models/is-final-file-state.js +1 -0
- package/dist/es2019/models/is-image-representation-ready.js +10 -0
- package/dist/es2019/models/is-non-error-final-file-state.js +1 -0
- package/dist/es2019/models/is-not-found-media-item-details.js +3 -0
- package/dist/es2019/models/is-previewable-file-state.js +2 -0
- package/dist/es2019/models/is-previewable-type.js +4 -0
- package/dist/es2019/models/is-processed-file-state.js +1 -0
- package/dist/es2019/models/is-processing-file-state.js +1 -0
- package/dist/es2019/models/is-uploading-file-state.js +1 -0
- package/dist/es2019/models/map-media-file-to-file-state.js +53 -0
- package/dist/es2019/models/map-media-item-to-file-state.js +9 -0
- package/dist/es2019/models/media.js +12 -8
- package/dist/es2019/uploader/{error.js → UploaderError.js} +1 -4
- package/dist/es2019/uploader/index.js +3 -3
- package/dist/es2019/uploader/isUploaderError.js +4 -0
- package/dist/es2019/utils/addFileAttrsToUrl.js +19 -0
- package/dist/es2019/utils/createBatchLoadingFunc.js +74 -0
- package/dist/es2019/utils/createFileDataLoader.js +1 -122
- package/dist/es2019/utils/createFileDataloader-2.js +8 -0
- package/dist/es2019/utils/getAttrsFromUrl.js +35 -0
- package/dist/es2019/utils/getItemsFromKeys.js +43 -0
- package/dist/es2019/utils/isCDNEnabled.js +9 -0
- package/dist/es2019/utils/isMediaBlobUrl.js +4 -0
- package/dist/es2019/utils/isPathBasedEnabled.js +7 -0
- package/dist/es2019/utils/mapRetryUrlToPathBasedUrl.js +17 -0
- package/dist/es2019/utils/mapToMediaCdnUrl.js +32 -0
- package/dist/es2019/utils/mapToPathBasedUrl.js +25 -0
- package/dist/es2019/utils/mediaCdn.js +1 -37
- package/dist/es2019/utils/mediaSubscribable/createMediaSubscribable.js +5 -0
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +7 -4
- package/dist/es2019/utils/mobileUpload/{error.js → MobileUploadError.js} +1 -4
- package/dist/es2019/utils/mobileUpload/{helpers.js → createMobileDownloadFileStream.js} +3 -11
- package/dist/es2019/utils/mobileUpload/createMobileFileStateSubject.js +8 -0
- package/dist/es2019/utils/mobileUpload/isMobileUploadError.js +4 -0
- package/dist/es2019/utils/mobileUpload/stateMachine/createMobileUploadService.js +4 -0
- package/dist/es2019/utils/mobileUpload/stateMachine/{index.js → createMobileUploadStateMachine.js} +7 -10
- package/dist/es2019/utils/mobileUpload/stateMachine/states/uploading.js +1 -1
- package/dist/es2019/utils/objectToQueryString.js +9 -0
- package/dist/es2019/utils/overrideMediaTypeIfUnknown.js +1 -1
- package/dist/es2019/utils/pathBasedUrl.js +1 -45
- package/dist/es2019/utils/polling/PollingError.js +21 -0
- package/dist/es2019/utils/polling/errors.js +9 -24
- package/dist/es2019/utils/polling/index.js +10 -2
- package/dist/es2019/utils/polling/isPollingError.js +4 -0
- package/dist/es2019/utils/rejectTimeout.js +3 -0
- package/dist/es2019/utils/request/RequestError.js +39 -0
- package/dist/es2019/utils/request/cloneRequestError.js +12 -0
- package/dist/es2019/utils/request/createMapResponseToBlob.js +15 -0
- package/dist/es2019/utils/request/createMapResponseToJson.js +15 -0
- package/dist/es2019/utils/request/createProcessFetchResponse.js +10 -0
- package/dist/es2019/utils/request/createRequestErrorFromResponse.js +14 -0
- package/dist/es2019/utils/request/createRequestErrorReason.js +24 -0
- package/dist/es2019/utils/request/createUrl.js +17 -0
- package/dist/es2019/utils/request/defaultShouldRetryError.js +6 -0
- package/dist/es2019/utils/request/errors.js +9 -42
- package/dist/es2019/utils/request/extendHeaders.js +18 -0
- package/dist/es2019/utils/request/extendTraceContext.js +5 -0
- package/dist/es2019/utils/request/extractMediaHeaders.js +11 -0
- package/dist/es2019/utils/request/fetchRetry.js +54 -0
- package/dist/es2019/utils/request/getStatusCode.js +5 -0
- package/dist/es2019/utils/request/helpers.js +73 -215
- package/dist/es2019/utils/request/index.js +25 -4
- package/dist/es2019/utils/request/isAbortedRequestError.js +3 -0
- package/dist/es2019/utils/request/isFetchNetworkError.js +4 -0
- package/dist/es2019/utils/request/isRateLimitedError.js +5 -0
- package/dist/es2019/utils/request/isRequestError.js +4 -0
- package/dist/es2019/utils/request/mapAuthToRequestHeaders.js +16 -0
- package/dist/es2019/utils/request/waitPromise.js +3 -0
- package/dist/es2019/utils/resolveTimeout.js +3 -0
- package/dist/es2019/utils/url.js +18 -65
- package/dist/esm/client/file-fetcher/FileFetcherError.js +47 -0
- package/dist/esm/client/file-fetcher/error.js +9 -50
- package/dist/esm/client/file-fetcher/index.js +32 -17
- package/dist/esm/client/file-fetcher/isFileFetcherError.js +4 -0
- package/dist/esm/client/media-client.js +1 -1
- package/dist/esm/client/media-store/MediaStore.js +35 -58
- package/dist/esm/client/media-store/MediaStoreError.js +29 -0
- package/dist/esm/client/media-store/cdnFeatureFlag.js +8 -0
- package/dist/esm/client/media-store/decodeJwtToken.js +3 -0
- package/dist/esm/client/media-store/error.js +9 -32
- package/dist/esm/client/media-store/extendImageParams.js +16 -0
- package/dist/esm/client/media-store/getMediaEnvironment.js +5 -0
- package/dist/esm/client/media-store/getMediaRegion.js +5 -0
- package/dist/esm/client/media-store/getValueFromSessionStorage.js +4 -0
- package/dist/esm/client/media-store/isMediaStoreError.js +4 -0
- package/dist/esm/client/media-store/jsonHeaders.js +4 -0
- package/dist/esm/client/media-store/resolveAuth.js +3 -9
- package/dist/esm/client/media-store/resolveInitialAuth.js +7 -0
- package/dist/esm/client/media-store/setKeyValueInSessionStorage.js +13 -0
- package/dist/esm/client/mobile-upload.js +5 -2
- package/dist/esm/identifier.js +14 -14
- package/dist/esm/index.js +31 -8
- package/dist/esm/is-different-identifier.js +9 -0
- package/dist/esm/is-external-image-identifier.js +3 -0
- package/dist/esm/is-file-identifier.js +3 -0
- package/dist/esm/models/artifacts.js +1 -1
- package/dist/esm/models/errors/BaseMediaClientError.js +36 -0
- package/dist/esm/models/errors/CommonMediaClientError.js +25 -0
- package/dist/esm/models/errors/fromCommonMediaClientError.js +21 -0
- package/dist/esm/models/errors/getMediaClientErrorReason.js +4 -0
- package/dist/esm/models/errors/helpers.js +10 -6
- package/dist/esm/models/errors/index.js +27 -91
- package/dist/esm/models/errors/isCommonMediaClientError.js +11 -0
- package/dist/esm/models/errors/isMediaClientError.js +3 -0
- package/dist/esm/models/errors/toCommonMediaClientError.js +8 -0
- package/dist/esm/models/file-state.js +46 -93
- package/dist/esm/models/has-artifacts.js +3 -0
- package/dist/esm/models/is-error-file-state.js +3 -0
- package/dist/esm/models/is-final-file-state.js +3 -0
- package/dist/esm/models/is-image-representation-ready.js +10 -0
- package/dist/esm/models/is-non-error-final-file-state.js +3 -0
- package/dist/esm/models/is-not-found-media-item-details.js +3 -0
- package/dist/esm/models/is-previewable-file-state.js +4 -0
- package/dist/esm/models/is-previewable-type.js +4 -0
- package/dist/esm/models/is-processed-file-state.js +3 -0
- package/dist/esm/models/is-processing-file-state.js +3 -0
- package/dist/esm/models/is-uploading-file-state.js +3 -0
- package/dist/esm/models/map-media-file-to-file-state.js +52 -0
- package/dist/esm/models/map-media-item-to-file-state.js +11 -0
- package/dist/esm/models/media.js +12 -8
- package/dist/esm/uploader/{error.js → UploaderError.js} +2 -5
- package/dist/esm/uploader/index.js +3 -3
- package/dist/esm/uploader/isUploaderError.js +4 -0
- package/dist/esm/utils/addFileAttrsToUrl.js +17 -0
- package/dist/esm/utils/createBatchLoadingFunc.js +121 -0
- package/dist/esm/utils/createFileDataLoader.js +1 -166
- package/dist/esm/utils/createFileDataloader-2.js +8 -0
- package/dist/esm/utils/getAttrsFromUrl.js +35 -0
- package/dist/esm/utils/getItemsFromKeys.js +43 -0
- package/dist/esm/utils/isCDNEnabled.js +9 -0
- package/dist/esm/utils/isMediaBlobUrl.js +4 -0
- package/dist/esm/utils/isPathBasedEnabled.js +7 -0
- package/dist/esm/utils/mapRetryUrlToPathBasedUrl.js +17 -0
- package/dist/esm/utils/mapToMediaCdnUrl.js +32 -0
- package/dist/esm/utils/mapToPathBasedUrl.js +25 -0
- package/dist/esm/utils/mediaCdn.js +1 -37
- package/dist/esm/utils/mediaSubscribable/createMediaSubscribable.js +5 -0
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +7 -4
- package/dist/esm/utils/mobileUpload/{error.js → MobileUploadError.js} +2 -5
- package/dist/esm/utils/mobileUpload/{helpers.js → createMobileDownloadFileStream.js} +3 -13
- package/dist/esm/utils/mobileUpload/createMobileFileStateSubject.js +10 -0
- package/dist/esm/utils/mobileUpload/isMobileUploadError.js +4 -0
- package/dist/esm/utils/mobileUpload/stateMachine/createMobileUploadService.js +4 -0
- package/dist/esm/utils/mobileUpload/stateMachine/{index.js → createMobileUploadStateMachine.js} +7 -10
- package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +1 -1
- package/dist/esm/utils/objectToQueryString.js +11 -0
- package/dist/esm/utils/overrideMediaTypeIfUnknown.js +1 -1
- package/dist/esm/utils/pathBasedUrl.js +1 -45
- package/dist/esm/utils/polling/PollingError.js +29 -0
- package/dist/esm/utils/polling/errors.js +9 -32
- package/dist/esm/utils/polling/index.js +10 -2
- package/dist/esm/utils/polling/isPollingError.js +4 -0
- package/dist/esm/utils/rejectTimeout.js +5 -0
- package/dist/esm/utils/request/RequestError.js +49 -0
- package/dist/esm/utils/request/cloneRequestError.js +10 -0
- package/dist/esm/utils/request/createMapResponseToBlob.js +36 -0
- package/dist/esm/utils/request/createMapResponseToJson.js +36 -0
- package/dist/esm/utils/request/createProcessFetchResponse.js +10 -0
- package/dist/esm/utils/request/createRequestErrorFromResponse.js +13 -0
- package/dist/esm/utils/request/createRequestErrorReason.js +24 -0
- package/dist/esm/utils/request/createUrl.js +24 -0
- package/dist/esm/utils/request/defaultShouldRetryError.js +6 -0
- package/dist/esm/utils/request/errors.js +9 -52
- package/dist/esm/utils/request/extendHeaders.js +14 -0
- package/dist/esm/utils/request/extendTraceContext.js +9 -0
- package/dist/esm/utils/request/extractMediaHeaders.js +9 -0
- package/dist/esm/utils/request/fetchRetry.js +113 -0
- package/dist/esm/utils/request/getStatusCode.js +5 -0
- package/dist/esm/utils/request/helpers.js +73 -295
- package/dist/esm/utils/request/index.js +25 -4
- package/dist/esm/utils/request/isAbortedRequestError.js +3 -0
- package/dist/esm/utils/request/isFetchNetworkError.js +4 -0
- package/dist/esm/utils/request/isRateLimitedError.js +5 -0
- package/dist/esm/utils/request/isRequestError.js +4 -0
- package/dist/esm/utils/request/mapAuthToRequestHeaders.js +16 -0
- package/dist/esm/utils/request/waitPromise.js +5 -0
- package/dist/esm/utils/{setTimeoutPromise.js → resolveTimeout.js} +0 -5
- package/dist/esm/utils/url.js +18 -65
- package/dist/types/client/file-fetcher/FileFetcherError.d.ts +32 -0
- package/dist/types/client/file-fetcher/error.d.ts +9 -33
- package/dist/types/client/file-fetcher/index.d.ts +15 -7
- package/dist/types/client/file-fetcher/isFileFetcherError.d.ts +2 -0
- package/dist/types/client/media-client.d.ts +4 -3
- package/dist/types/client/media-store/MediaStore.d.ts +18 -6
- package/dist/types/client/media-store/MediaStoreError.d.ts +14 -0
- package/dist/types/client/media-store/cdnFeatureFlag.d.ts +1 -0
- package/dist/types/client/media-store/decodeJwtToken.d.ts +3 -0
- package/dist/types/client/media-store/error.d.ts +9 -15
- package/dist/types/client/media-store/extendImageParams.d.ts +2 -0
- package/dist/types/client/media-store/getMediaEnvironment.d.ts +1 -0
- package/dist/types/client/media-store/getMediaRegion.d.ts +1 -0
- package/dist/types/client/media-store/getValueFromSessionStorage.d.ts +1 -0
- package/dist/types/client/media-store/isMediaStoreError.d.ts +2 -0
- package/dist/types/client/media-store/jsonHeaders.d.ts +1 -0
- package/dist/types/client/media-store/resolveAuth.d.ts +0 -1
- package/dist/types/client/media-store/resolveInitialAuth.d.ts +2 -0
- package/dist/types/client/media-store/setKeyValueInSessionStorage.d.ts +1 -0
- package/dist/types/client/mobile-upload.d.ts +1 -1
- package/dist/types/identifier.d.ts +12 -3
- package/dist/types/index.d.ts +34 -10
- package/dist/types/is-different-identifier.d.ts +2 -0
- package/dist/types/is-external-image-identifier.d.ts +2 -0
- package/dist/types/is-file-identifier.d.ts +2 -0
- package/dist/types/models/errors/BaseMediaClientError.d.ts +11 -0
- package/dist/types/models/errors/CommonMediaClientError.d.ts +7 -0
- package/dist/types/models/errors/fromCommonMediaClientError.d.ts +4 -0
- package/dist/types/models/errors/getMediaClientErrorReason.d.ts +2 -0
- package/dist/types/models/errors/helpers.d.ts +8 -5
- package/dist/types/models/errors/index.d.ts +26 -21
- package/dist/types/models/errors/isCommonMediaClientError.d.ts +3 -0
- package/dist/types/models/errors/isMediaClientError.d.ts +4 -0
- package/dist/types/models/errors/toCommonMediaClientError.d.ts +4 -0
- package/dist/types/models/file-state.d.ts +45 -16
- package/dist/types/models/has-artifacts.d.ts +4 -0
- package/dist/types/models/is-error-file-state.d.ts +2 -0
- package/dist/types/models/is-final-file-state.d.ts +2 -0
- package/dist/types/models/is-image-representation-ready.d.ts +2 -0
- package/dist/types/models/is-non-error-final-file-state.d.ts +2 -0
- package/dist/types/models/is-not-found-media-item-details.d.ts +2 -0
- package/dist/types/models/is-previewable-file-state.d.ts +3 -0
- package/dist/types/models/is-previewable-type.d.ts +2 -0
- package/dist/types/models/is-processed-file-state.d.ts +2 -0
- package/dist/types/models/is-processing-file-state.d.ts +2 -0
- package/dist/types/models/is-uploading-file-state.d.ts +2 -0
- package/dist/types/models/map-media-file-to-file-state.d.ts +4 -0
- package/dist/types/models/map-media-item-to-file-state.d.ts +3 -0
- package/dist/types/models/media.d.ts +8 -2
- package/dist/types/uploader/{error.d.ts → UploaderError.d.ts} +12 -13
- package/dist/types/uploader/index.d.ts +1 -1
- package/dist/types/uploader/isUploaderError.d.ts +2 -0
- package/dist/types/utils/addFileAttrsToUrl.d.ts +2 -0
- package/dist/types/utils/createBatchLoadingFunc.d.ts +11 -0
- package/dist/types/utils/createCopyIntentRegisterationBatcher.d.ts +1 -1
- package/dist/types/utils/createFileDataLoader.d.ts +0 -14
- package/dist/types/utils/createFileDataloader-2.d.ts +4 -0
- package/dist/types/utils/getAttrsFromUrl.d.ts +2 -0
- package/dist/types/utils/getItemsFromKeys.d.ts +3 -0
- package/dist/types/utils/imageResizeModeToFileImageMode.d.ts +1 -1
- package/dist/types/utils/isCDNEnabled.d.ts +1 -0
- package/dist/types/utils/isMediaBlobUrl.d.ts +1 -0
- package/dist/types/utils/isPathBasedEnabled.d.ts +1 -0
- package/dist/types/utils/mapRetryUrlToPathBasedUrl.d.ts +1 -0
- package/dist/types/utils/mapToMediaCdnUrl.d.ts +1 -0
- package/dist/types/utils/mapToPathBasedUrl.d.ts +1 -0
- package/dist/types/utils/mediaCdn.d.ts +1 -2
- package/dist/types/utils/mediaSubscribable/createMediaSubscribable.d.ts +3 -0
- package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +4 -1
- package/dist/types/utils/mobileUpload/{error.d.ts → MobileUploadError.d.ts} +15 -16
- package/dist/types/utils/mobileUpload/createMobileDownloadFileStream.d.ts +5 -0
- package/dist/types/utils/mobileUpload/{helpers.d.ts → createMobileFileStateSubject.d.ts} +0 -3
- package/dist/types/utils/mobileUpload/isMobileUploadError.d.ts +2 -0
- package/dist/types/utils/mobileUpload/stateMachine/createMobileUploadService.d.ts +3 -0
- package/dist/types/utils/mobileUpload/stateMachine/{index.d.ts → createMobileUploadStateMachine.d.ts} +2 -3
- package/dist/types/utils/objectToQueryString.d.ts +3 -0
- package/dist/types/utils/pathBasedUrl.d.ts +1 -3
- package/dist/types/utils/polling/PollingError.d.ts +10 -0
- package/dist/types/utils/polling/errors.d.ts +8 -11
- package/dist/types/utils/polling/index.d.ts +8 -1
- package/dist/types/utils/polling/isPollingError.d.ts +2 -0
- package/dist/types/utils/{setTimeoutPromise.d.ts → rejectTimeout.d.ts} +0 -1
- package/dist/types/utils/request/RequestError.d.ts +21 -0
- package/dist/types/utils/request/cloneRequestError.d.ts +3 -0
- package/dist/types/utils/request/createMapResponseToBlob.d.ts +2 -0
- package/dist/types/utils/request/createMapResponseToJson.d.ts +2 -0
- package/dist/types/utils/request/createProcessFetchResponse.d.ts +2 -0
- package/dist/types/utils/request/createRequestErrorFromResponse.d.ts +3 -0
- package/dist/types/utils/request/createRequestErrorReason.d.ts +2 -0
- package/dist/types/utils/request/createUrl.d.ts +2 -0
- package/dist/types/utils/request/defaultShouldRetryError.d.ts +1 -0
- package/dist/types/utils/request/errors.d.ts +8 -22
- package/dist/types/utils/request/extendHeaders.d.ts +4 -0
- package/dist/types/utils/request/extendTraceContext.d.ts +2 -0
- package/dist/types/utils/request/extractMediaHeaders.d.ts +4 -0
- package/dist/types/utils/request/fetchRetry.d.ts +2 -0
- package/dist/types/utils/request/getStatusCode.d.ts +1 -0
- package/dist/types/utils/request/helpers.d.ts +73 -24
- package/dist/types/utils/request/index.d.ts +16 -2
- package/dist/types/utils/request/isAbortedRequestError.d.ts +1 -0
- package/dist/types/utils/request/isFetchNetworkError.d.ts +1 -0
- package/dist/types/utils/request/isRateLimitedError.d.ts +1 -0
- package/dist/types/utils/request/isRequestError.d.ts +2 -0
- package/dist/types/utils/request/mapAuthToRequestHeaders.d.ts +3 -0
- package/dist/types/utils/request/waitPromise.d.ts +1 -0
- package/dist/types/utils/resolveTimeout.d.ts +1 -0
- package/dist/types/utils/url.d.ts +17 -6
- package/example-helpers/CardsWrapper.tsx +15 -0
- package/example-helpers/FileInput.tsx +20 -0
- package/example-helpers/FileStateWrapper.tsx +15 -0
- package/example-helpers/FileWrapper.tsx +22 -0
- package/example-helpers/Header.tsx +15 -0
- package/example-helpers/ImagePreview.tsx +18 -0
- package/example-helpers/MetadataWrapper.tsx +15 -0
- package/example-helpers/PreviewWrapper.tsx +15 -0
- package/example-helpers/Response.tsx +15 -0
- package/example-helpers/Row.tsx +15 -0
- package/example-helpers/UploadTouchWrapper.tsx +15 -0
- package/example-helpers/Wrapper.tsx +15 -0
- package/package.json +2 -2
- package/dist/cjs/client/media-store/index.js +0 -37
- package/dist/cjs/utils/mediaSubscribable/index.js +0 -25
- package/dist/cjs/utils/mobileUpload/index.js +0 -45
- package/dist/es2019/client/media-store/index.js +0 -2
- package/dist/es2019/utils/mediaSubscribable/index.js +0 -2
- package/dist/es2019/utils/mobileUpload/index.js +0 -4
- package/dist/es2019/utils/setTimeoutPromise.js +0 -6
- package/dist/esm/client/media-store/index.js +0 -2
- package/dist/esm/utils/mediaSubscribable/index.js +0 -2
- package/dist/esm/utils/mobileUpload/index.js +0 -4
- package/dist/types/client/media-store/index.d.ts +0 -4
- package/dist/types/utils/mediaSubscribable/index.d.ts +0 -3
- package/dist/types/utils/mobileUpload/index.d.ts +0 -5
- package/example-helpers/stylesWrapper.tsx +0 -98
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
2
|
+
|
|
1
3
|
// Warning! You can't add new media file processing status!
|
|
2
4
|
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
3
5
|
|
|
4
|
-
export const isPreviewableType = type => {
|
|
5
|
-
const defaultPreviewableTypes = ['audio', 'video', 'image', 'doc'];
|
|
6
|
-
return defaultPreviewableTypes.indexOf(type) > -1;
|
|
7
|
-
};
|
|
8
|
-
export const isNotFoundMediaItemDetails = itemDetails => {
|
|
9
|
-
return 'type' in itemDetails && itemDetails.type === 'not-found';
|
|
10
|
-
};
|
|
11
6
|
export let DATA_UNIT = /*#__PURE__*/function (DATA_UNIT) {
|
|
12
7
|
DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
|
|
13
8
|
DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
|
|
14
9
|
DATA_UNIT[DATA_UNIT["TB"] = 1099511627776] = "TB";
|
|
15
10
|
return DATA_UNIT;
|
|
16
|
-
}({});
|
|
11
|
+
}({});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `import { isPreviewableType } from '@atlaskit/media-client'` instead.
|
|
15
|
+
*/
|
|
16
|
+
export { isPreviewableType } from './is-previewable-type';
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `import { isNotFoundMediaItemDetails } from '@atlaskit/media-client/media'` instead.
|
|
19
|
+
*/
|
|
20
|
+
export { isNotFoundMediaItemDetails } from './is-not-found-media-item-details';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../models/errors';
|
|
1
|
+
import { BaseMediaClientError } from '../models/errors/BaseMediaClientError';
|
|
2
2
|
export class UploaderError extends BaseMediaClientError {
|
|
3
3
|
// Legacy Attribute. Should be removed
|
|
4
4
|
|
|
@@ -25,7 +25,4 @@ export class UploaderError extends BaseMediaClientError {
|
|
|
25
25
|
occurrenceKey
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
}
|
|
29
|
-
export function isUploaderError(err) {
|
|
30
|
-
return err instanceof UploaderError;
|
|
31
28
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { chunkinator } from '@atlaskit/chunkinator';
|
|
2
1
|
import { from } from 'rxjs/observable/from';
|
|
3
2
|
import { concatMap } from 'rxjs/operators/concatMap';
|
|
4
|
-
import {
|
|
5
|
-
import { UploaderError } from './error';
|
|
3
|
+
import { chunkinator } from '@atlaskit/chunkinator';
|
|
6
4
|
import { CHUNK_SIZE, PROCESSING_BATCH_SIZE } from '../constants';
|
|
5
|
+
import { createHasher } from '../utils/hashing/hasherCreator';
|
|
6
|
+
import { UploaderError } from './UploaderError';
|
|
7
7
|
import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
|
|
8
8
|
|
|
9
9
|
// TODO: Allow to pass multiple files
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { objectToQueryString } from './objectToQueryString';
|
|
2
|
+
import { mediaBlobUrlIdentifier } from './url';
|
|
3
|
+
export const addFileAttrsToUrl = (url, fileAttrs) => {
|
|
4
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
5
|
+
if (isSafari) {
|
|
6
|
+
return url;
|
|
7
|
+
}
|
|
8
|
+
const mediaIdentifierAttr = {
|
|
9
|
+
[mediaBlobUrlIdentifier]: 'true'
|
|
10
|
+
};
|
|
11
|
+
const mergedAttrs = {
|
|
12
|
+
...mediaIdentifierAttr,
|
|
13
|
+
...fileAttrs
|
|
14
|
+
};
|
|
15
|
+
const queryAttrs = objectToQueryString(mergedAttrs);
|
|
16
|
+
|
|
17
|
+
// we can't use '?' separator for blob url params
|
|
18
|
+
return `${url}#${queryAttrs}`;
|
|
19
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getRandomTelemetryId } from '@atlaskit/media-common';
|
|
2
|
+
import { getItemsFromKeys } from './getItemsFromKeys';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
|
|
6
|
+
* Such contract is formalised by Dataloader 1.0, @see https://github.com/graphql/dataloader
|
|
7
|
+
*
|
|
8
|
+
* If an Error is resolved in the results, it must be at same position then their corresponding key:
|
|
9
|
+
* - Dataloader will re-throw that Error when accessing/loading that particular key
|
|
10
|
+
*
|
|
11
|
+
* @param mediaStore instance of MediaStore
|
|
12
|
+
*/
|
|
13
|
+
export function createBatchLoadingFunc(mediaStore) {
|
|
14
|
+
return async keys => {
|
|
15
|
+
const nonCollectionName = '__media-single-file-collection__';
|
|
16
|
+
const includeHashByCollection = keys.reduce((acc, key) => {
|
|
17
|
+
const collectionName = key.collectionName || nonCollectionName;
|
|
18
|
+
if (key.includeHashForDuplicateFiles) {
|
|
19
|
+
acc[collectionName] = key.includeHashForDuplicateFiles;
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
}, {});
|
|
23
|
+
const fileIdsByCollection = keys.reduce((acc, key) => {
|
|
24
|
+
const collectionName = key.collectionName || nonCollectionName;
|
|
25
|
+
const fileIds = acc[collectionName] || [];
|
|
26
|
+
|
|
27
|
+
// de-duplicate ids in collection
|
|
28
|
+
if (fileIds.indexOf(key.id) === -1) {
|
|
29
|
+
fileIds.push(key.id);
|
|
30
|
+
}
|
|
31
|
+
acc[collectionName] = fileIds;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
const items = [];
|
|
35
|
+
await Promise.all(Object.keys(fileIdsByCollection).map(async collectionNameKey => {
|
|
36
|
+
const metadataTraceContext = {
|
|
37
|
+
traceId: getRandomTelemetryId(),
|
|
38
|
+
spanId: getRandomTelemetryId()
|
|
39
|
+
};
|
|
40
|
+
const fileIds = fileIdsByCollection[collectionNameKey];
|
|
41
|
+
const includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
|
|
42
|
+
const collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
43
|
+
try {
|
|
44
|
+
const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
|
|
45
|
+
const itemsWithMetadataTraceContext = response.data.items.map(item => ({
|
|
46
|
+
...item,
|
|
47
|
+
metadataTraceContext
|
|
48
|
+
}));
|
|
49
|
+
items.push(...itemsWithMetadataTraceContext);
|
|
50
|
+
|
|
51
|
+
// add EmptyResponseFileItem for each file ID not included in /items response
|
|
52
|
+
const itemsIds = itemsWithMetadataTraceContext.map(item => item.id);
|
|
53
|
+
const fileIdsNotFound = fileIds.filter(id => !itemsIds.includes(id));
|
|
54
|
+
fileIdsNotFound.forEach(fileId => {
|
|
55
|
+
items.push({
|
|
56
|
+
id: fileId,
|
|
57
|
+
collection: collectionName,
|
|
58
|
+
type: 'not-found',
|
|
59
|
+
metadataTraceContext
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
fileIds.forEach(fileId => {
|
|
64
|
+
items.push({
|
|
65
|
+
id: fileId,
|
|
66
|
+
collection: collectionName,
|
|
67
|
+
error: error
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
return getItemsFromKeys(keys, items);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -1,122 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getRandomTelemetryId } from '@atlaskit/media-common';
|
|
3
|
-
export const MAX_BATCH_SIZE = 100;
|
|
4
|
-
const isBatchLoadingErrorResult = result => {
|
|
5
|
-
return result.error instanceof Error;
|
|
6
|
-
};
|
|
7
|
-
const isResponseFileItem = fileItem => {
|
|
8
|
-
return 'details' in fileItem;
|
|
9
|
-
};
|
|
10
|
-
const makeCacheKey = (id, collection) => collection ? `${id}-${collection}` : id;
|
|
11
|
-
export const getItemsFromKeys = (dataloaderKeys, fileItems) => {
|
|
12
|
-
const itemsByKey = fileItems.reduce((prev, fileItem) => {
|
|
13
|
-
const {
|
|
14
|
-
id,
|
|
15
|
-
collection
|
|
16
|
-
} = fileItem;
|
|
17
|
-
const key = makeCacheKey(id, collection);
|
|
18
|
-
if (isBatchLoadingErrorResult(fileItem)) {
|
|
19
|
-
prev[key] = fileItem.error;
|
|
20
|
-
} else if (isResponseFileItem(fileItem)) {
|
|
21
|
-
prev[key] = {
|
|
22
|
-
...fileItem.details,
|
|
23
|
-
metadataTraceContext: fileItem.metadataTraceContext
|
|
24
|
-
};
|
|
25
|
-
} else {
|
|
26
|
-
prev[key] = {
|
|
27
|
-
id,
|
|
28
|
-
collection,
|
|
29
|
-
type: 'not-found',
|
|
30
|
-
metadataTraceContext: fileItem.metadataTraceContext
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return prev;
|
|
34
|
-
}, {});
|
|
35
|
-
return dataloaderKeys.map(dataloaderKey => {
|
|
36
|
-
const {
|
|
37
|
-
id,
|
|
38
|
-
collectionName
|
|
39
|
-
} = dataloaderKey;
|
|
40
|
-
const key = makeCacheKey(id, collectionName);
|
|
41
|
-
return itemsByKey[key] || {
|
|
42
|
-
id,
|
|
43
|
-
type: 'not-found'
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Returns a function that, given Array<DataloaderKey>, resolves to an array of same length containing either DataloaderResult or Error.
|
|
49
|
-
* Such contract is formalised by Dataloader 1.0, @see https://github.com/graphql/dataloader
|
|
50
|
-
*
|
|
51
|
-
* If an Error is resolved in the results, it must be at same position then their corresponding key:
|
|
52
|
-
* - Dataloader will re-throw that Error when accessing/loading that particular key
|
|
53
|
-
*
|
|
54
|
-
* @param mediaStore instance of MediaStore
|
|
55
|
-
*/
|
|
56
|
-
export function createBatchLoadingFunc(mediaStore) {
|
|
57
|
-
return async keys => {
|
|
58
|
-
const nonCollectionName = '__media-single-file-collection__';
|
|
59
|
-
const includeHashByCollection = keys.reduce((acc, key) => {
|
|
60
|
-
const collectionName = key.collectionName || nonCollectionName;
|
|
61
|
-
if (key.includeHashForDuplicateFiles) {
|
|
62
|
-
acc[collectionName] = key.includeHashForDuplicateFiles;
|
|
63
|
-
}
|
|
64
|
-
return acc;
|
|
65
|
-
}, {});
|
|
66
|
-
const fileIdsByCollection = keys.reduce((acc, key) => {
|
|
67
|
-
const collectionName = key.collectionName || nonCollectionName;
|
|
68
|
-
const fileIds = acc[collectionName] || [];
|
|
69
|
-
|
|
70
|
-
// de-duplicate ids in collection
|
|
71
|
-
if (fileIds.indexOf(key.id) === -1) {
|
|
72
|
-
fileIds.push(key.id);
|
|
73
|
-
}
|
|
74
|
-
acc[collectionName] = fileIds;
|
|
75
|
-
return acc;
|
|
76
|
-
}, {});
|
|
77
|
-
const items = [];
|
|
78
|
-
await Promise.all(Object.keys(fileIdsByCollection).map(async collectionNameKey => {
|
|
79
|
-
const metadataTraceContext = {
|
|
80
|
-
traceId: getRandomTelemetryId(),
|
|
81
|
-
spanId: getRandomTelemetryId()
|
|
82
|
-
};
|
|
83
|
-
const fileIds = fileIdsByCollection[collectionNameKey];
|
|
84
|
-
const includeHashForDuplicateFiles = includeHashByCollection[collectionNameKey];
|
|
85
|
-
const collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
86
|
-
try {
|
|
87
|
-
const response = await mediaStore.getItems(fileIds, collectionName, metadataTraceContext, includeHashForDuplicateFiles);
|
|
88
|
-
const itemsWithMetadataTraceContext = response.data.items.map(item => ({
|
|
89
|
-
...item,
|
|
90
|
-
metadataTraceContext
|
|
91
|
-
}));
|
|
92
|
-
items.push(...itemsWithMetadataTraceContext);
|
|
93
|
-
|
|
94
|
-
// add EmptyResponseFileItem for each file ID not included in /items response
|
|
95
|
-
const itemsIds = itemsWithMetadataTraceContext.map(item => item.id);
|
|
96
|
-
const fileIdsNotFound = fileIds.filter(id => !itemsIds.includes(id));
|
|
97
|
-
fileIdsNotFound.forEach(fileId => {
|
|
98
|
-
items.push({
|
|
99
|
-
id: fileId,
|
|
100
|
-
collection: collectionName,
|
|
101
|
-
type: 'not-found',
|
|
102
|
-
metadataTraceContext
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
} catch (error) {
|
|
106
|
-
fileIds.forEach(fileId => {
|
|
107
|
-
items.push({
|
|
108
|
-
id: fileId,
|
|
109
|
-
collection: collectionName,
|
|
110
|
-
error: error
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}));
|
|
115
|
-
return getItemsFromKeys(keys, items);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
export function createFileDataloader(mediaStore) {
|
|
119
|
-
return new Dataloader(createBatchLoadingFunc(mediaStore), {
|
|
120
|
-
maxBatchSize: MAX_BATCH_SIZE
|
|
121
|
-
});
|
|
122
|
-
}
|
|
1
|
+
export const MAX_BATCH_SIZE = 100;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Dataloader from 'dataloader';
|
|
2
|
+
import { createBatchLoadingFunc } from './createBatchLoadingFunc';
|
|
3
|
+
import { MAX_BATCH_SIZE } from './createFileDataLoader';
|
|
4
|
+
export function createFileDataloader(mediaStore) {
|
|
5
|
+
return new Dataloader(createBatchLoadingFunc(mediaStore), {
|
|
6
|
+
maxBatchSize: MAX_BATCH_SIZE
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const getNumberFromParams = (params, name) => {
|
|
2
|
+
const value = params.get(name);
|
|
3
|
+
return typeof value === 'string' && !isNaN(parseInt(value)) ? parseInt(value) : undefined;
|
|
4
|
+
};
|
|
5
|
+
const getStringFromParams = (params, name) => {
|
|
6
|
+
const value = params.get(name);
|
|
7
|
+
if (!value) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return decodeURIComponent(value);
|
|
11
|
+
};
|
|
12
|
+
export const getAttrsFromUrl = blobUrl => {
|
|
13
|
+
const url = new URL(blobUrl);
|
|
14
|
+
const hash = url.hash.replace('#', '');
|
|
15
|
+
const params = new URLSearchParams(hash);
|
|
16
|
+
const id = params.get('id');
|
|
17
|
+
const contextId = params.get('contextId');
|
|
18
|
+
const clientId = params.get('clientId');
|
|
19
|
+
// check if we have the required params (clientId is optional for backwards compatibility)
|
|
20
|
+
if (!id || !contextId) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
contextId,
|
|
26
|
+
clientId: clientId || undefined,
|
|
27
|
+
collection: getStringFromParams(params, 'collection'),
|
|
28
|
+
alt: getStringFromParams(params, 'alt'),
|
|
29
|
+
height: getNumberFromParams(params, 'height'),
|
|
30
|
+
width: getNumberFromParams(params, 'width'),
|
|
31
|
+
size: getNumberFromParams(params, 'size'),
|
|
32
|
+
name: getStringFromParams(params, 'name'),
|
|
33
|
+
mimeType: getStringFromParams(params, 'mimeType')
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const isBatchLoadingErrorResult = result => {
|
|
2
|
+
return result.error instanceof Error;
|
|
3
|
+
};
|
|
4
|
+
const isResponseFileItem = fileItem => {
|
|
5
|
+
return 'details' in fileItem;
|
|
6
|
+
};
|
|
7
|
+
const makeCacheKey = (id, collection) => collection ? `${id}-${collection}` : id;
|
|
8
|
+
export const getItemsFromKeys = (dataloaderKeys, fileItems) => {
|
|
9
|
+
const itemsByKey = fileItems.reduce((prev, fileItem) => {
|
|
10
|
+
const {
|
|
11
|
+
id,
|
|
12
|
+
collection
|
|
13
|
+
} = fileItem;
|
|
14
|
+
const key = makeCacheKey(id, collection);
|
|
15
|
+
if (isBatchLoadingErrorResult(fileItem)) {
|
|
16
|
+
prev[key] = fileItem.error;
|
|
17
|
+
} else if (isResponseFileItem(fileItem)) {
|
|
18
|
+
prev[key] = {
|
|
19
|
+
...fileItem.details,
|
|
20
|
+
metadataTraceContext: fileItem.metadataTraceContext
|
|
21
|
+
};
|
|
22
|
+
} else {
|
|
23
|
+
prev[key] = {
|
|
24
|
+
id,
|
|
25
|
+
collection,
|
|
26
|
+
type: 'not-found',
|
|
27
|
+
metadataTraceContext: fileItem.metadataTraceContext
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return prev;
|
|
31
|
+
}, {});
|
|
32
|
+
return dataloaderKeys.map(dataloaderKey => {
|
|
33
|
+
const {
|
|
34
|
+
id,
|
|
35
|
+
collectionName
|
|
36
|
+
} = dataloaderKey;
|
|
37
|
+
const key = makeCacheKey(id, collectionName);
|
|
38
|
+
return itemsByKey[key] || {
|
|
39
|
+
id,
|
|
40
|
+
type: 'not-found'
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isGoogleCloudPlatform } from '@atlaskit/atlassian-context/cloud-provider';
|
|
2
|
+
import { isIsolatedCloud } from '@atlaskit/atlassian-context/is-isolated-cloud';
|
|
3
|
+
import { isGCPtenant as isGCPtenantInStaging } from '@atlaskit/media-common/mediaEnvUtils';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { isCommercial } from './isCommercial';
|
|
6
|
+
import { isPathBasedEnabled } from './isPathBasedEnabled';
|
|
7
|
+
export function isCDNEnabled() {
|
|
8
|
+
return isCommercial() && !isIsolatedCloud() && !(isGoogleCloudPlatform() || isGCPtenantInStaging()) && fg('platform_media_cdn_delivery') && !isPathBasedEnabled();
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import getDocument from './getDocument';
|
|
3
|
+
export function isPathBasedEnabled() {
|
|
4
|
+
var _getDocument, _getDocument$location;
|
|
5
|
+
const isLocalhost = ((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : (_getDocument$location = _getDocument.location) === null || _getDocument$location === void 0 ? void 0 : _getDocument$location.hostname) === 'localhost';
|
|
6
|
+
return fg('platform_media_path_based_route') && !isLocalhost;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import getDocument from './getDocument';
|
|
2
|
+
import { mediaApiPathPrefix } from './pathBasedUrl';
|
|
3
|
+
export function mapRetryUrlToPathBasedUrl(url) {
|
|
4
|
+
var _getDocument$location, _getDocument;
|
|
5
|
+
const parsedUrl = new URL(url);
|
|
6
|
+
parsedUrl.host = (_getDocument$location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
|
|
7
|
+
|
|
8
|
+
// remove CDN from the URL for retry if it exists
|
|
9
|
+
const pathname = parsedUrl.pathname;
|
|
10
|
+
if (pathname.endsWith('/cdn')) {
|
|
11
|
+
parsedUrl.pathname = pathname.replace('/cdn', '');
|
|
12
|
+
}
|
|
13
|
+
if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
|
|
14
|
+
parsedUrl.pathname = `${mediaApiPathPrefix}${parsedUrl.pathname}`;
|
|
15
|
+
}
|
|
16
|
+
return parsedUrl;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isGoogleCloudPlatform } from '@atlaskit/atlassian-context/cloud-provider';
|
|
2
|
+
import { isGCPtenant as isGCPtenantInStaging } from '@atlaskit/media-common/mediaEnvUtils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { isCDNEnabled } from './isCDNEnabled';
|
|
5
|
+
import { MEDIA_CDN_MAP, MEDIA_TOKEN_LENGTH_LIMIT } from './mediaCdn';
|
|
6
|
+
export function mapToMediaCdnUrl(url, token) {
|
|
7
|
+
var _token$length;
|
|
8
|
+
const tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
|
|
9
|
+
if (!isCDNEnabled() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
|
|
10
|
+
return url;
|
|
11
|
+
}
|
|
12
|
+
const isGcpTenant = isGoogleCloudPlatform() || isGCPtenantInStaging();
|
|
13
|
+
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
14
|
+
if (!isGcpTenant && fg('platform_media_cdn_delivery') && fg('platform_media_cdn_single_host')) {
|
|
15
|
+
try {
|
|
16
|
+
const parsedUrl = new URL(url);
|
|
17
|
+
const cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
|
|
18
|
+
|
|
19
|
+
// If no mapping is found, return the original URL
|
|
20
|
+
if (!cdnHost) {
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Replace the host with the CDN host in the original URL
|
|
25
|
+
parsedUrl.host = cdnHost;
|
|
26
|
+
return parsedUrl.toString();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return url;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return url;
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import getDocument from './getDocument';
|
|
2
|
+
import { isPathBasedEnabled } from './isPathBasedEnabled';
|
|
3
|
+
import { mediaApiPathPrefix } from './pathBasedUrl';
|
|
4
|
+
function getRelativeUrl(absoluteUrl) {
|
|
5
|
+
const url = new URL(absoluteUrl);
|
|
6
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
7
|
+
}
|
|
8
|
+
export function mapToPathBasedUrl(url) {
|
|
9
|
+
if (isPathBasedEnabled()) {
|
|
10
|
+
var _getDocument;
|
|
11
|
+
const parsedUrl = new URL(url);
|
|
12
|
+
if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
|
|
13
|
+
parsedUrl.pathname = `${mediaApiPathPrefix}${parsedUrl.pathname}`;
|
|
14
|
+
}
|
|
15
|
+
const location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location;
|
|
16
|
+
|
|
17
|
+
// in this case we are most likely in SSR / a non browser environment so just return a relative URL
|
|
18
|
+
if (!location) {
|
|
19
|
+
return getRelativeUrl(parsedUrl.toString());
|
|
20
|
+
}
|
|
21
|
+
parsedUrl.host = location.host;
|
|
22
|
+
return parsedUrl.toString();
|
|
23
|
+
}
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { isCommercial } from './isCommercial';
|
|
3
|
-
import { isIsolatedCloud } from '@atlaskit/atlassian-context/is-isolated-cloud';
|
|
4
|
-
import { isGoogleCloudPlatform } from '@atlaskit/atlassian-context/cloud-provider';
|
|
5
|
-
import { isGCPtenant as isGCPtenantInStaging } from '@atlaskit/media-common/mediaEnvUtils';
|
|
6
|
-
import { isPathBasedEnabled } from './pathBasedUrl';
|
|
7
1
|
export const MEDIA_CDN_MAP = {
|
|
8
2
|
'api.media.atlassian.com': 'media-cdn.atlassian.com',
|
|
9
3
|
'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
|
|
@@ -12,34 +6,4 @@ export const MEDIA_CDN_MAP = {
|
|
|
12
6
|
// Cloudfront has a hard limit of 8,192 bytes
|
|
13
7
|
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
|
|
14
8
|
// Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
|
|
15
|
-
const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
|
|
16
|
-
export function isCDNEnabled() {
|
|
17
|
-
return isCommercial() && !isIsolatedCloud() && !(isGoogleCloudPlatform() || isGCPtenantInStaging()) && fg('platform_media_cdn_delivery') && !isPathBasedEnabled();
|
|
18
|
-
}
|
|
19
|
-
export function mapToMediaCdnUrl(url, token) {
|
|
20
|
-
var _token$length;
|
|
21
|
-
const tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
|
|
22
|
-
if (!isCDNEnabled() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
|
|
23
|
-
return url;
|
|
24
|
-
}
|
|
25
|
-
const isGcpTenant = isGoogleCloudPlatform() || isGCPtenantInStaging();
|
|
26
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
27
|
-
if (!isGcpTenant && fg('platform_media_cdn_delivery') && fg('platform_media_cdn_single_host')) {
|
|
28
|
-
try {
|
|
29
|
-
const parsedUrl = new URL(url);
|
|
30
|
-
const cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
|
|
31
|
-
|
|
32
|
-
// If no mapping is found, return the original URL
|
|
33
|
-
if (!cdnHost) {
|
|
34
|
-
return url;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Replace the host with the CDN host in the original URL
|
|
38
|
-
parsedUrl.host = cdnHost;
|
|
39
|
-
return parsedUrl.toString();
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return url;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return url;
|
|
45
|
-
}
|
|
9
|
+
export const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
|
|
2
|
+
|
|
2
3
|
export function fromObservable(observable) {
|
|
3
4
|
return {
|
|
4
5
|
subscribe: observer => {
|
|
@@ -14,6 +15,8 @@ export function fromObservable(observable) {
|
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `import { createMediaSubscribable } from '@atlaskit/media-client'` instead.
|
|
21
|
+
*/
|
|
22
|
+
export { createMediaSubscribable } from './createMediaSubscribable';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseMediaClientError } from '../../models/errors';
|
|
1
|
+
import { BaseMediaClientError } from '../../models/errors/BaseMediaClientError';
|
|
2
2
|
export class MobileUploadError extends BaseMediaClientError {
|
|
3
3
|
// Legacy Attribute. Should be removed
|
|
4
4
|
|
|
@@ -29,7 +29,4 @@ export class MobileUploadError extends BaseMediaClientError {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
}
|
|
33
|
-
export function isMobileUploadError(err) {
|
|
34
|
-
return err instanceof MobileUploadError;
|
|
35
32
|
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { map } from 'rxjs/operators/map';
|
|
4
|
-
import { mapMediaItemToFileState } from '../../models/file-state';
|
|
1
|
+
import { isNotFoundMediaItemDetails } from '../../models/is-not-found-media-item-details';
|
|
2
|
+
import { mapMediaItemToFileState } from '../../models/map-media-item-to-file-state';
|
|
5
3
|
import { createMediaSubject } from '../createMediaSubject';
|
|
6
4
|
import { isEmptyFile } from '../detectEmptyFile';
|
|
7
5
|
import { PollingFunction } from '../polling';
|
|
8
|
-
import { MobileUploadError } from './
|
|
9
|
-
import { isNotFoundMediaItemDetails } from '../../models/media';
|
|
10
|
-
export const createMobileFileStateSubject = service => {
|
|
11
|
-
const subject = new ReplaySubject(1);
|
|
12
|
-
from(service.start()).pipe(map(state => state.context.currentFileState)).subscribe(subject);
|
|
13
|
-
return subject;
|
|
14
|
-
};
|
|
6
|
+
import { MobileUploadError } from './MobileUploadError';
|
|
15
7
|
export const createMobileDownloadFileStream = (dataloader, id, collectionName, occurrenceKey) => {
|
|
16
8
|
const subject = createMediaSubject();
|
|
17
9
|
const poll = new PollingFunction();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { from } from 'rxjs/observable/from';
|
|
2
|
+
import { map } from 'rxjs/operators/map';
|
|
3
|
+
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
4
|
+
export const createMobileFileStateSubject = service => {
|
|
5
|
+
const subject = new ReplaySubject(1);
|
|
6
|
+
from(service.start()).pipe(map(state => state.context.currentFileState)).subscribe(subject);
|
|
7
|
+
return subject;
|
|
8
|
+
};
|
package/dist/es2019/utils/mobileUpload/stateMachine/{index.js → createMobileUploadStateMachine.js}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { map } from 'rxjs/operators/map';
|
|
2
|
-
import { createMachine
|
|
3
|
-
import { isProcessingFileState } from '../../../models/file-state';
|
|
2
|
+
import { createMachine } from 'xstate';
|
|
3
|
+
import { isProcessingFileState } from '../../../models/is-processing-file-state';
|
|
4
4
|
import { shouldFetchRemoteFileStates } from '../../shouldFetchRemoteFileStates';
|
|
5
|
-
import { createMobileDownloadFileStream } from '../
|
|
6
|
-
import {
|
|
7
|
-
import { machineProcessingState } from './states/processing';
|
|
5
|
+
import { createMobileDownloadFileStream } from '../createMobileDownloadFileStream';
|
|
6
|
+
import { machineErrorState } from './states/error';
|
|
8
7
|
import { machineProcessedState } from './states/processed';
|
|
8
|
+
import { machineProcessingState } from './states/processing';
|
|
9
9
|
import { machineProcessingFailedState } from './states/processingFailed';
|
|
10
|
-
import {
|
|
10
|
+
import { machineUploadingState } from './states/uploading';
|
|
11
11
|
export const createMobileUploadStateMachine = (dataloader, initialState, collectionName) => createMachine({
|
|
12
12
|
// Initial state
|
|
13
13
|
initial: initialState.status,
|
|
@@ -44,7 +44,4 @@ export const createMobileUploadStateMachine = (dataloader, initialState, collect
|
|
|
44
44
|
fileState
|
|
45
45
|
})))
|
|
46
46
|
}
|
|
47
|
-
});
|
|
48
|
-
export function createMobileUploadService(machine) {
|
|
49
|
-
return interpret(machine);
|
|
50
|
-
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const objectToQueryString = json => {
|
|
2
|
+
return Object.keys(json).filter(attrName => typeof json[attrName] !== 'undefined' && json[attrName] !== null).map(key => {
|
|
3
|
+
const value = json[key];
|
|
4
|
+
if (typeof value === 'undefined' || value === null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`;
|
|
8
|
+
}).join('&');
|
|
9
|
+
};
|