@orangelogic/orange-dam-content-browser-sdk 2.1.53 → 2.1.54
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/.env +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +82 -0
- package/.releaserc +17 -0
- package/.travis.yml +20 -0
- package/CBSDKdemo.html +315 -0
- package/GitVersion.yml +18 -0
- package/azure-pipeline.yaml +93 -0
- package/clientlib.config.js +36 -0
- package/config/env.js +105 -0
- package/config/getHttpsConfig.js +67 -0
- package/config/jest/babelTransform.js +30 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +41 -0
- package/config/modules.js +135 -0
- package/config/paths.js +79 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +10 -0
- package/config/webpack.config.js +762 -0
- package/config/webpackDevServer.config.js +128 -0
- package/config-overrides.js +8 -0
- package/gab_extension/GAB.html +85 -0
- package/gab_extension/GoogleChrome/manifest.json +28 -0
- package/gab_extension/GoogleChrome/src/assets/icon48.png +0 -0
- package/gab_extension/GoogleChrome/src/background/index.js +6 -0
- package/gab_extension/GoogleChrome/src/scripts/index.js +347 -0
- package/gab_extension/MozillaFirefox/manifest.json +20 -0
- package/gab_extension/MozillaFirefox/src/assets/icon.png +0 -0
- package/gab_extension/MozillaFirefox/src/background/index.js +5 -0
- package/gab_extension/MozillaFirefox/src/scripts/index.js +347 -0
- package/gab_extension/README.md +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.pbxproj +927 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcuserdata/oldevmac01.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/xcuserdata/oldevmac01.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +20 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Base.lproj/Main.html +23 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Icon.png +0 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Script.js +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Style.css +61 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/ViewController.swift +81 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (Extension)/SafariWebExtensionHandler.swift +26 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/AppDelegate.swift +24 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Info.plist +27 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/SceneDelegate.swift +18 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/AppDelegate.swift +21 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Base.lproj/Main.storyboard +125 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Info.plist +8 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Orange DAM Asset Browser Extension.entitlements +12 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Info.plist +13 -0
- package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Orange DAM Asset Browser Extension.entitlements +10 -0
- package/package.json +8 -49
- package/public/index.html +92 -0
- package/scripts/build.js +218 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +53 -0
- package/src/App.tsx +98 -0
- package/src/AppContext.ts +18 -0
- package/src/GlobalConfigContext.ts +46 -0
- package/src/components/ArrayClamp/ArrayClamp.styled.ts +42 -0
- package/src/components/ArrayClamp/ArrayClamp.tsx +167 -0
- package/src/components/ArrayClamp/index.ts +1 -0
- package/src/components/Browser/Browser.styled.ts +82 -0
- package/src/components/Browser/Browser.tsx +284 -0
- package/src/components/Browser/BrowserItem.tsx +98 -0
- package/src/components/ControlBar/ControlBar.constants.tsx +66 -0
- package/src/components/ControlBar/ControlBar.styled.ts +82 -0
- package/src/components/ControlBar/ControlBar.tsx +528 -0
- package/src/components/ControlBar/Facet/Facet.tsx +113 -0
- package/src/components/ControlBar/Facet/index.ts +1 -0
- package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
- package/{build/components/FormatDialog/CropPreviewer/index.d.ts → src/components/FormatDialog/CropPreviewer/index.ts} +1 -1
- package/src/components/FormatDialog/CustomRendition/CustomRendition.constants.ts +24 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.styled.ts +57 -0
- package/src/components/FormatDialog/CustomRendition/CustomRendition.tsx +178 -0
- package/src/components/FormatDialog/CustomRendition/index.ts +1 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Crop.tsx +249 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Extension.tsx +54 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Format.tsx +86 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Resize.tsx +176 -0
- package/src/components/FormatDialog/CustomRendition/transformations/Rotate.tsx +101 -0
- package/{build/components/FormatDialog/CustomRendition/transformations/index.d.ts → src/components/FormatDialog/CustomRendition/transformations/index.ts} +1 -3
- package/src/components/FormatDialog/FormatDialog.styled.ts +137 -0
- package/src/components/FormatDialog/FormatDialog.tsx +1533 -0
- package/src/components/FormatDialog/Previewer/Previewer.styled.ts +31 -0
- package/src/components/FormatDialog/Previewer/Previewer.tsx +143 -0
- package/src/components/FormatDialog/Previewer/index.ts +1 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.styled.ts +88 -0
- package/src/components/FormatDialog/ProxyMenu/ProxyMenu.tsx +74 -0
- package/src/components/FormatDialog/ProxyMenu/index.ts +1 -0
- package/src/components/FormatDialog/TrackingParameters/TrackingParameters.tsx +59 -0
- package/src/components/FormatDialog/TrackingParameters/index.ts +1 -0
- package/src/components/FormatDialog/index.ts +1 -0
- package/src/components/Header/Header.styled.ts +51 -0
- package/src/components/Header/Header.tsx +118 -0
- package/src/components/Loader/Loader.tsx +37 -0
- package/src/components/Loader/index.ts +1 -0
- package/src/components/NoResult/NoResult.tsx +37 -0
- package/src/components/NoResult/index.tsx +1 -0
- package/src/components/Result/AssetCard/AssetCard.styled.ts +120 -0
- package/src/components/Result/AssetCard/AssetCard.tsx +192 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.styled.ts +35 -0
- package/src/components/Result/AssetCard/AssetCardWrapper.tsx +165 -0
- package/src/components/Result/AssetCard/index.ts +1 -0
- package/src/components/Result/AssetPreview/AssetPreview.styled.ts +108 -0
- package/src/components/Result/AssetPreview/AssetPreview.tsx +78 -0
- package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.tsx +42 -0
- package/src/components/Result/AssetPreview/ImagePreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.ts +23 -0
- package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.tsx +28 -0
- package/src/components/Result/AssetPreview/OtherPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +132 -0
- package/src/components/Result/AssetPreview/VideoPreview/index.ts +1 -0
- package/src/components/Result/AssetPreview/index.ts +1 -0
- package/src/consts/asset.ts +16 -0
- package/src/consts/data.ts +17 -0
- package/src/index.tsx +305 -0
- package/src/page/Authenticate/Authenticate.tsx +232 -0
- package/src/page/Authenticate/ConnectingBackground.tsx +44 -0
- package/src/page/Authenticate/index.tsx +94 -0
- package/src/page/Home/Home.styled.ts +46 -0
- package/src/page/Home/Home.tsx +941 -0
- package/src/react-web-component.d.ts +4617 -0
- package/src/store/assets/assets.api.ts +167 -0
- package/src/store/assets/assets.service.ts +223 -0
- package/src/store/assets/assets.slice.ts +104 -0
- package/src/store/auth/auth.service.ts +71 -0
- package/src/store/auth/auth.slice.ts +295 -0
- package/src/store/index.ts +27 -0
- package/src/store/search/search.api.ts +319 -0
- package/src/store/search/search.slice.ts +28 -0
- package/src/store/user/user.api.ts +29 -0
- package/src/styles.css +42 -0
- package/src/types/assets.ts +71 -0
- package/src/types/auth.ts +42 -0
- package/src/types/common.ts +11 -0
- package/src/types/download.ts +8 -0
- package/src/types/navigation.ts +3 -0
- package/src/types/search.ts +116 -0
- package/{build/types/storage.d.ts → src/types/storage.ts} +1 -1
- package/src/types/user.ts +6 -0
- package/src/utils/api.ts +186 -0
- package/src/utils/array.ts +25 -0
- package/src/utils/constants.ts +12 -0
- package/src/utils/fetch.ts +116 -0
- package/src/utils/getRequestUrl.ts +15 -0
- package/src/utils/hooks.ts +36 -0
- package/src/utils/icon.ts +22 -0
- package/src/utils/image.ts +157 -0
- package/src/utils/number.ts +11 -0
- package/src/utils/rotate.ts +23 -0
- package/src/utils/storage.ts +184 -0
- package/src/utils/string.ts +24 -0
- package/src/view/AssetsPicker.tsx +24 -0
- package/src/web-component.d.ts +8151 -0
- package/tsconfig.eslint.json +10 -0
- package/tsconfig.json +37 -0
- package/build/ApiService.d.ts +0 -15
- package/build/App.d.ts +0 -62
- package/build/AppContext.d.ts +0 -18
- package/build/GlobalConfigContext.d.ts +0 -32
- package/build/OrangeDAMContentBrowserSDK.min.css +0 -2
- package/build/OrangeDAMContentBrowserSDK.min.css.map +0 -1
- package/build/OrangeDAMContentBrowserSDK.min.js +0 -11468
- package/build/OrangeDAMContentBrowserSDK.min.js.map +0 -1
- package/build/asset-manifest.json +0 -13
- package/build/components/ArrayClamp/ArrayClamp.d.ts +0 -10
- package/build/components/ArrayClamp/ArrayClamp.styled.d.ts +0 -1
- package/build/components/ArrayClamp/index.d.ts +0 -1
- package/build/components/Browser/Browser.constants.d.ts +0 -3
- package/build/components/Browser/Browser.d.ts +0 -21
- package/build/components/Browser/Browser.styled.d.ts +0 -2
- package/build/components/Browser/BrowserItem.d.ts +0 -13
- package/build/components/Browser/LoadMoreButton.d.ts +0 -9
- package/build/components/ControlBar/ControlBar.constants.d.ts +0 -10
- package/build/components/ControlBar/ControlBar.d.ts +0 -23
- package/build/components/ControlBar/ControlBar.styled.d.ts +0 -1
- package/build/components/ControlBar/Facet/Facet.d.ts +0 -14
- package/build/components/ControlBar/Facet/index.d.ts +0 -1
- package/build/components/FormatDialog/CropPreviewer/CropPreviewer.d.ts +0 -41
- package/build/components/FormatDialog/CustomRendition/CustomRendition.constants.d.ts +0 -5
- package/build/components/FormatDialog/CustomRendition/CustomRendition.d.ts +0 -56
- package/build/components/FormatDialog/CustomRendition/CustomRendition.styled.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/index.d.ts +0 -1
- package/build/components/FormatDialog/CustomRendition/transformations/Crop.d.ts +0 -26
- package/build/components/FormatDialog/CustomRendition/transformations/Extension.d.ts +0 -11
- package/build/components/FormatDialog/CustomRendition/transformations/Format.d.ts +0 -10
- package/build/components/FormatDialog/CustomRendition/transformations/Metadata.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Quality.d.ts +0 -7
- package/build/components/FormatDialog/CustomRendition/transformations/Resize.d.ts +0 -18
- package/build/components/FormatDialog/CustomRendition/transformations/Rotate.d.ts +0 -8
- package/build/components/FormatDialog/FormatDialog.d.ts +0 -49
- package/build/components/FormatDialog/FormatDialog.styled.d.ts +0 -3
- package/build/components/FormatDialog/Previewer/Previewer.d.ts +0 -17
- package/build/components/FormatDialog/Previewer/Previewer.styled.d.ts +0 -1
- package/build/components/FormatDialog/Previewer/index.d.ts +0 -1
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.d.ts +0 -20
- package/build/components/FormatDialog/ProxyMenu/ProxyMenu.styled.d.ts +0 -2
- package/build/components/FormatDialog/ProxyMenu/index.d.ts +0 -1
- package/build/components/FormatDialog/TrackingParameters/TrackingParameters.d.ts +0 -13
- package/build/components/FormatDialog/TrackingParameters/index.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/VersionHistory.d.ts +0 -6
- package/build/components/FormatDialog/VersionHistory/VersionHistory.styled.d.ts +0 -1
- package/build/components/FormatDialog/VersionHistory/index.d.ts +0 -1
- package/build/components/FormatDialog/index.d.ts +0 -1
- package/build/components/Header/Header.d.ts +0 -15
- package/build/components/Header/Header.styled.d.ts +0 -5
- package/build/components/Loader/Loader.d.ts +0 -7
- package/build/components/Loader/index.d.ts +0 -1
- package/build/components/NoResult/NoResult.d.ts +0 -7
- package/build/components/NoResult/index.d.ts +0 -1
- package/build/components/Result/AssetCard/AssetCard.d.ts +0 -15
- package/build/components/Result/AssetCard/AssetCard.styled.d.ts +0 -2
- package/build/components/Result/AssetCard/AssetCardWrapper.d.ts +0 -18
- package/build/components/Result/AssetCard/AssetCardWrapper.styled.d.ts +0 -1
- package/build/components/Result/AssetCard/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/AssetPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/AssetPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/ImagePreview/ImagePreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/ImagePreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.d.ts +0 -9
- package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.d.ts +0 -1
- package/build/components/Result/AssetPreview/OtherPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/VideoPreview/VideoPreview.d.ts +0 -11
- package/build/components/Result/AssetPreview/VideoPreview/index.d.ts +0 -1
- package/build/components/Result/AssetPreview/index.d.ts +0 -1
- package/build/consts/asset.d.ts +0 -14
- package/build/consts/auth.d.ts +0 -4
- package/build/consts/data.d.ts +0 -21
- package/build/index.d.ts +0 -225
- package/build/index.html +0 -1
- package/build/page/Authenticate/Authenticate.d.ts +0 -2
- package/build/page/Authenticate/ConnectingBackground.d.ts +0 -8
- package/build/page/Authenticate/index.d.ts +0 -2
- package/build/page/Home/Home.d.ts +0 -6
- package/build/page/Home/Home.styled.d.ts +0 -2
- package/build/setupTests.d.ts +0 -1
- package/build/store/assets/assets.api.d.ts +0 -66
- package/build/store/assets/assets.service.d.ts +0 -23
- package/build/store/assets/assets.slice.d.ts +0 -65
- package/build/store/auth/auth.service.d.ts +0 -10
- package/build/store/auth/auth.slice.d.ts +0 -76
- package/build/store/index.d.ts +0 -368
- package/build/store/search/search.api.d.ts +0 -39
- package/build/store/search/search.slice.d.ts +0 -12
- package/build/store/user/user.api.d.ts +0 -5
- package/build/types/assets.d.ts +0 -68
- package/build/types/auth.d.ts +0 -35
- package/build/types/common.d.ts +0 -11
- package/build/types/download.d.ts +0 -8
- package/build/types/navigation.d.ts +0 -3
- package/build/types/search.d.ts +0 -148
- package/build/types/user.d.ts +0 -7
- package/build/utils/api.d.ts +0 -27
- package/build/utils/array.d.ts +0 -13
- package/build/utils/constants.d.ts +0 -11
- package/build/utils/function.d.ts +0 -1
- package/build/utils/getRequestUrl.d.ts +0 -1
- package/build/utils/hooks.d.ts +0 -1
- package/build/utils/icon.d.ts +0 -3
- package/build/utils/image.d.ts +0 -24
- package/build/utils/number.d.ts +0 -4
- package/build/utils/rotate.d.ts +0 -4
- package/build/utils/storage.d.ts +0 -23
- package/build/utils/string.d.ts +0 -12
- package/build/view/AssetsPicker.d.ts +0 -6
- /package/{build → public}/favicon.ico +0 -0
- /package/{build → public}/logo192.png +0 -0
- /package/{build → public}/logo512.png +0 -0
- /package/{build → public}/manifest.json +0 -0
- /package/{build → public}/robots.txt +0 -0
- /package/{build/components/Browser/index.d.ts → src/components/Browser/index.ts} +0 -0
- /package/{build/components/ControlBar/index.d.ts → src/components/ControlBar/index.ts} +0 -0
- /package/{build/components/Header/index.d.ts → src/components/Header/index.ts} +0 -0
- /package/{build/page/Home/index.d.ts → src/page/Home/index.ts} +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
|
|
3
|
+
import { SortOrder } from '@/types/assets';
|
|
4
|
+
import { Asset, MediaType, Proxy } from '@/types/search';
|
|
5
|
+
import { AppBaseQuery } from '@/utils/api';
|
|
6
|
+
import { hasElements, uniqueArray } from '@/utils/array';
|
|
7
|
+
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
8
|
+
|
|
9
|
+
const Parameters = {
|
|
10
|
+
ExtensionsThatSupportTransformationUsingATS: 'ExtensionsThatSupportTransformationUsingATS',
|
|
11
|
+
EnableATSInGetLink: 'EnableATSInGetLink',
|
|
12
|
+
CollectionSubtypeCriteria: 'CollectionSubtypeCriteria',
|
|
13
|
+
SupportDocTypes: 'SupportDocTypes',
|
|
14
|
+
RepresentativeSupportedDocSubType: 'RepresentativeSupportedDocSubType',
|
|
15
|
+
ExtensionAuto: 'ExtensionAuto',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type GetAvailableProxiesRequest = {
|
|
19
|
+
assetImages?: Asset[];
|
|
20
|
+
docTypes?: string[];
|
|
21
|
+
useSession?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type GetAvailableProxiesResponse = {
|
|
25
|
+
previewUrl: string;
|
|
26
|
+
proxies: Proxy[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type GetAvailableExtensionsResponse = Record<MediaType, { displayName: string; value: string }[]>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* get query parameter for AvailableProxies_4ea_v2 API
|
|
33
|
+
* @param {GetAvailableProxiesRequest}
|
|
34
|
+
* @returns {string[][]}
|
|
35
|
+
*/
|
|
36
|
+
const getAvailableProxiesAPIParams = ({ assetImages, docTypes, useSession }: GetAvailableProxiesRequest): string[][] => {
|
|
37
|
+
let result = [];
|
|
38
|
+
if (!hasElements(assetImages)) {
|
|
39
|
+
docTypes = hasElements(docTypes) ? docTypes : Object.values(MediaType);
|
|
40
|
+
|
|
41
|
+
result = uniqueArray(docTypes as string[]).map(docType => ['DocTypes', docType]);
|
|
42
|
+
} else {
|
|
43
|
+
const assetDocTypes = uniqueArray(assetImages as Asset[], (asset) => asset.docType)
|
|
44
|
+
.map(asset => ['DocTypes', asset.docType]);
|
|
45
|
+
|
|
46
|
+
result = (assetImages as Asset[]).map(asset => ['RecordID', asset.id]).concat(assetDocTypes);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (useSession) {
|
|
50
|
+
result.push(['UseSession', useSession]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Define a service using a base URL and expected endpoints
|
|
57
|
+
export const assetsApi = createApi({
|
|
58
|
+
reducerPath: 'assetsApi',
|
|
59
|
+
baseQuery: AppBaseQuery,
|
|
60
|
+
tagTypes: ['AvailableExtensions', 'AvailableProxies', 'Parameters', 'SortOrders'],
|
|
61
|
+
endpoints: (builder) => ({
|
|
62
|
+
getAvailableExtensions: builder.query<GetAvailableExtensionsResponse, void>({
|
|
63
|
+
query: () => ({
|
|
64
|
+
url: '/webapi/extensibility/integrations/gab/assetbrowser/getavailableextensionsfortransformation_419v_v1',
|
|
65
|
+
}),
|
|
66
|
+
transformResponse: (response: { extensions: GetAvailableExtensionsResponse }) => {
|
|
67
|
+
return response.extensions;
|
|
68
|
+
},
|
|
69
|
+
providesTags: ['AvailableExtensions'],
|
|
70
|
+
serializeQueryArgs: () => {
|
|
71
|
+
return 'getAvailableExtensions';
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
getAvailableProxies: builder.query<GetAvailableProxiesResponse, GetAvailableProxiesRequest>({
|
|
75
|
+
query: (request) => ({
|
|
76
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/AvailableProxies_4ea_v3?',
|
|
77
|
+
params: getAvailableProxiesAPIParams(request),
|
|
78
|
+
}),
|
|
79
|
+
transformResponse: (response: { proxies: Proxy[]; previewUrl: string }) => {
|
|
80
|
+
const { previewUrl, proxies } = response;
|
|
81
|
+
return {
|
|
82
|
+
previewUrl,
|
|
83
|
+
proxies: proxies.map((proxy) => {
|
|
84
|
+
return {
|
|
85
|
+
...proxy,
|
|
86
|
+
id: uuidv4(),
|
|
87
|
+
};
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
serializeQueryArgs: ({ queryArgs }) => getAvailableProxiesAPIParams(queryArgs),
|
|
92
|
+
providesTags: (_result, _error, _args) => ['AvailableProxies'],
|
|
93
|
+
}),
|
|
94
|
+
getParameters: builder.query<{
|
|
95
|
+
ATSEnabled: boolean;
|
|
96
|
+
autoExtension: string;
|
|
97
|
+
collectionPath: string;
|
|
98
|
+
supportedExtensions: string[];
|
|
99
|
+
supportedRepresentativeSubtypes: string[];
|
|
100
|
+
supportedDocTypes: string[];
|
|
101
|
+
}, {
|
|
102
|
+
useSession?: string;
|
|
103
|
+
}>({
|
|
104
|
+
query: ({ useSession }) => {
|
|
105
|
+
const params = [];
|
|
106
|
+
|
|
107
|
+
if (useSession) {
|
|
108
|
+
params.push(['UseSession', useSession]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
url: '/webapi/configuration/parameters/getparameters_412Z_v1',
|
|
113
|
+
params,
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
transformResponse: (response: Record<string, string>) => {
|
|
117
|
+
return {
|
|
118
|
+
ATSEnabled: response[Parameters.EnableATSInGetLink].toLowerCase() === 'true',
|
|
119
|
+
collectionPath: response[Parameters.CollectionSubtypeCriteria]?.toLowerCase() ?? '',
|
|
120
|
+
supportedDocTypes: response[Parameters.SupportDocTypes]?.split(/\r?\n/) ?? [],
|
|
121
|
+
supportedExtensions: response[Parameters.ExtensionsThatSupportTransformationUsingATS]?.split('\n') ?? [],
|
|
122
|
+
supportedRepresentativeSubtypes: response[Parameters.RepresentativeSupportedDocSubType]?.split('\r\n') ?? [],
|
|
123
|
+
autoExtension: response[Parameters.ExtensionAuto]?.toLowerCase() ?? '.auto',
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
providesTags: ['Parameters'],
|
|
127
|
+
}),
|
|
128
|
+
getSortOrders: builder.query<Record<string, SortOrder[]>, {
|
|
129
|
+
useSession?: string;
|
|
130
|
+
}>({
|
|
131
|
+
query: ({ useSession }) => ({
|
|
132
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/sortorders_4147',
|
|
133
|
+
params: useSession ? [['UseSession', useSession]] : [],
|
|
134
|
+
}),
|
|
135
|
+
providesTags: ['SortOrders'],
|
|
136
|
+
transformResponse: (response: { sortOrders: SortOrder[] }) => {
|
|
137
|
+
const value = response.sortOrders.reduce((acc, item) => {
|
|
138
|
+
const id = (item.sortDirectionGroupKey || item.name).trim().toLowerCase();
|
|
139
|
+
|
|
140
|
+
acc[id] = [...(acc[id] ?? []), item];
|
|
141
|
+
|
|
142
|
+
return acc;
|
|
143
|
+
}, {} as Record<string, SortOrder[]>);
|
|
144
|
+
|
|
145
|
+
Object.keys(value).forEach((key) => {
|
|
146
|
+
const sortOrder = value[key];
|
|
147
|
+
if (sortOrder.length === 1) {
|
|
148
|
+
sortOrder[0].sortDirection = 'Mono';
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return value;
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// < { proxies: { [key: string]: string } }, void>
|
|
159
|
+
|
|
160
|
+
// Export hooks for usage in functional components, which are
|
|
161
|
+
// auto-generated based on the defined endpoints
|
|
162
|
+
export const {
|
|
163
|
+
useGetAvailableExtensionsQuery,
|
|
164
|
+
useGetAvailableProxiesQuery,
|
|
165
|
+
useGetParametersQuery,
|
|
166
|
+
useGetSortOrdersQuery,
|
|
167
|
+
} = assetsApi;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { store } from '@/store';
|
|
2
|
+
import { CortexErrorResponse } from '@/types/common';
|
|
3
|
+
import { Asset, GetAssetLinkResponse } from '@/types/search';
|
|
4
|
+
import { cortexFetch } from '@/utils/api';
|
|
5
|
+
|
|
6
|
+
import { assetsApi } from './assets.api';
|
|
7
|
+
import { TrackingParameter, Transformation, TransformationAction } from '@/types/assets';
|
|
8
|
+
|
|
9
|
+
export const getAssetLinks = async (
|
|
10
|
+
{
|
|
11
|
+
assets,
|
|
12
|
+
extraFields,
|
|
13
|
+
permanentLink,
|
|
14
|
+
proxyPreference,
|
|
15
|
+
transformations,
|
|
16
|
+
parameters,
|
|
17
|
+
extension,
|
|
18
|
+
useSession,
|
|
19
|
+
}: {
|
|
20
|
+
assets: Asset[];
|
|
21
|
+
extraFields?: string;
|
|
22
|
+
permanentLink?: string;
|
|
23
|
+
proxyPreference?: string;
|
|
24
|
+
transformations?: Transformation[];
|
|
25
|
+
parameters?: TrackingParameter[];
|
|
26
|
+
maxWidth?: number;
|
|
27
|
+
maxHeight?: number;
|
|
28
|
+
extension?: string;
|
|
29
|
+
useSession?: string;
|
|
30
|
+
},
|
|
31
|
+
): Promise<GetAssetLinkResponse[]> => {
|
|
32
|
+
let baseUrl = '/webapi/extensibility/integrations/contentBrowserSDK/GetAssetLink_4by?';
|
|
33
|
+
if (useSession) {
|
|
34
|
+
baseUrl += `UseSession=${useSession}&`;
|
|
35
|
+
}
|
|
36
|
+
if (extraFields) {
|
|
37
|
+
baseUrl += `ExtraFields=${extraFields}&`;
|
|
38
|
+
}
|
|
39
|
+
if (permanentLink) {
|
|
40
|
+
baseUrl += `GenerateAssetUrl=${false}&`;
|
|
41
|
+
}
|
|
42
|
+
baseUrl += 'RecordId=';
|
|
43
|
+
|
|
44
|
+
const getAssetLinkErrors: { [key: string]: Asset[] } = {};
|
|
45
|
+
const failToImportAssets: string[] = [];
|
|
46
|
+
const isOnlyOneAssetSelected = assets.length === 1;
|
|
47
|
+
// Loop through all selected assets to replace Image url by IIIF urls
|
|
48
|
+
const result = (await Promise.all(assets.map(async (asset) => {
|
|
49
|
+
let url = baseUrl + asset.id;
|
|
50
|
+
if (proxyPreference) {
|
|
51
|
+
url += `&Proxy=${proxyPreference}`;
|
|
52
|
+
}
|
|
53
|
+
const response = await cortexFetch(url, { method: 'GET' });
|
|
54
|
+
let responseData: GetAssetLinkResponse | CortexErrorResponse | null = null;
|
|
55
|
+
responseData = await response.json();
|
|
56
|
+
|
|
57
|
+
if (!response.ok || !responseData) {
|
|
58
|
+
// We will give more details error message if only one asset was imported
|
|
59
|
+
if (isOnlyOneAssetSelected && responseData) {
|
|
60
|
+
const errorResponseData = responseData as CortexErrorResponse;
|
|
61
|
+
if (!getAssetLinkErrors[errorResponseData.ErrorCode]) {
|
|
62
|
+
getAssetLinkErrors[errorResponseData.ErrorCode] = [asset];
|
|
63
|
+
} else {
|
|
64
|
+
getAssetLinkErrors[errorResponseData.ErrorCode].push(asset);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
failToImportAssets.push(asset.name);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
imageUrl: asset.imageUrl,
|
|
71
|
+
} as GetAssetLinkResponse;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let imageUrl = permanentLink || (responseData as GetAssetLinkResponse).imageUrl;
|
|
75
|
+
|
|
76
|
+
if (transformations && transformations.length > 0) {
|
|
77
|
+
imageUrl += '/t/';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
transformations?.forEach(({ key, value }) => {
|
|
81
|
+
if (key === TransformationAction.Resize) {
|
|
82
|
+
const validTransformations = [
|
|
83
|
+
...[
|
|
84
|
+
{
|
|
85
|
+
key: 're_w_',
|
|
86
|
+
value: value.width,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 're_h_',
|
|
90
|
+
value: value.height,
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
.filter((item) => item.value !== undefined)
|
|
94
|
+
.map((item) => ({
|
|
95
|
+
key: item.key,
|
|
96
|
+
value: Math.round(Number(item.value)),
|
|
97
|
+
})),
|
|
98
|
+
{
|
|
99
|
+
key: 're_rm_',
|
|
100
|
+
value: 'stretch',
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
validTransformations.forEach(({ key: vKey, value: vValue }, index) => {
|
|
105
|
+
imageUrl += `${vKey}${vValue}${index < validTransformations.length - 1 ? ',' : ''}`;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
imageUrl += '/';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (key === TransformationAction.Crop) {
|
|
112
|
+
const validTransformations = [
|
|
113
|
+
...[
|
|
114
|
+
{
|
|
115
|
+
key: 'c_w_',
|
|
116
|
+
value: value.width,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: 'c_h_',
|
|
120
|
+
value: value.height,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
key: 'c_x_',
|
|
124
|
+
value: value.x,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
key: 'c_y_',
|
|
128
|
+
value: value.y,
|
|
129
|
+
},
|
|
130
|
+
]
|
|
131
|
+
.filter((item) => item.value !== undefined)
|
|
132
|
+
.map((item) => ({
|
|
133
|
+
key: item.key,
|
|
134
|
+
value: Math.round(Number(item.value)),
|
|
135
|
+
})),
|
|
136
|
+
{
|
|
137
|
+
key: 'c_whu_',
|
|
138
|
+
value: 'pixel',
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
validTransformations.forEach(({ key: vKey, value: vValue }, index) => {
|
|
143
|
+
imageUrl += `${vKey}${vValue}${index < validTransformations.length - 1 ? ',' : ''}`;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
imageUrl += '/';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (key === TransformationAction.Rotate) {
|
|
150
|
+
const validTransformations = [{
|
|
151
|
+
key: 'r_a_',
|
|
152
|
+
value: value.rotation,
|
|
153
|
+
}].filter(item => item.value !== undefined).map(item => ({ key: item.key, value: Math.round(Number(item.value)) }));
|
|
154
|
+
|
|
155
|
+
validTransformations.forEach(({ key: vKey, value: vValue }, index) => {
|
|
156
|
+
imageUrl += `${vKey}${vValue}${index < validTransformations.length - 1 ? ',' : ''}`;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
imageUrl += '/';
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (transformations && transformations.length > 0) {
|
|
164
|
+
imageUrl += `${asset.identifier}`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!permanentLink) {
|
|
168
|
+
imageUrl += `${extension ?? asset.extension}`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const queryParams: string[] = [];
|
|
172
|
+
|
|
173
|
+
if (parameters && parameters.length > 0) {
|
|
174
|
+
parameters.forEach(({ key, value }) => {
|
|
175
|
+
queryParams.push(`${encodeURIComponent(key.trim())}=${encodeURIComponent(value.trim())}`);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (useSession) {
|
|
180
|
+
queryParams.push(`UseSession=${useSession}`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (queryParams.length > 0) {
|
|
184
|
+
imageUrl += `?${queryParams.join('&')}`;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
(responseData as GetAssetLinkResponse).imageUrl = imageUrl;
|
|
188
|
+
return responseData as GetAssetLinkResponse;
|
|
189
|
+
})));
|
|
190
|
+
|
|
191
|
+
if (failToImportAssets.length > 0) {
|
|
192
|
+
Object.entries(getAssetLinkErrors).reduce((acc, [errorCode, assetsWithError]) => {
|
|
193
|
+
const namesOfAssetWithError = assetsWithError.map(asset => asset.name).join(', ');
|
|
194
|
+
|
|
195
|
+
switch (errorCode) {
|
|
196
|
+
case 'OL_ERR_001_NOTFOUND':
|
|
197
|
+
acc.push(`${namesOfAssetWithError} not found`);
|
|
198
|
+
break;
|
|
199
|
+
case 'OL_ASSETLINKSERVICE_ERROR_001_LINKS_TO_NON_REQUIRED_FORMATS_NOT_ALLOWED':
|
|
200
|
+
const proxies = assetsApi.endpoints.getAvailableProxies.select({})(store.getState()).data?.proxies;
|
|
201
|
+
if (!proxies) {
|
|
202
|
+
acc.push(`Failed to import ${namesOfAssetWithError}. Change the import proxy in Settings or re-check your permission`);
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case 'OL_ERR_002_NOTALLOWED':
|
|
206
|
+
acc.push(`You don't have permission to import ${namesOfAssetWithError}`);
|
|
207
|
+
break;
|
|
208
|
+
case 'OL_ERR_003_REMOVED':
|
|
209
|
+
acc.push(`${namesOfAssetWithError} was removed`);
|
|
210
|
+
break;
|
|
211
|
+
case 'OL_ERR_006_BADREQUEST':
|
|
212
|
+
default:
|
|
213
|
+
acc.push(`Failed to import asset ${namesOfAssetWithError}`);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
return acc;
|
|
217
|
+
}, [] as string[]);
|
|
218
|
+
|
|
219
|
+
throw new Error('Failed to import the following assets: ' + failToImportAssets.join('\n '));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return result;
|
|
223
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AssetsState, TrackingParameter, Transformation } from '@/types/assets';
|
|
2
|
+
import { Asset, GetAssetLinkResponse } from '@/types/search';
|
|
3
|
+
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
|
|
5
|
+
import { getAssetLinks } from './assets.service';
|
|
6
|
+
|
|
7
|
+
export const SETTINGS_DEFAULT_PROXY = 'Always show asset format selector';
|
|
8
|
+
|
|
9
|
+
export const ASSETS_FEATURE_KEY = 'assets';
|
|
10
|
+
export const ASSETS_FEATURE_STORAGE_KEY = ASSETS_FEATURE_KEY + '_storage';
|
|
11
|
+
export const ASSETS_FEATURE_STORAGE_KEY_IMPORT_PROXY = ASSETS_FEATURE_STORAGE_KEY + '_importProxy';
|
|
12
|
+
export const ASSETS_FEATURE_STORAGE_TTL = 1000 * 60 * 60;
|
|
13
|
+
|
|
14
|
+
const initialState: AssetsState = {
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// #region Slice
|
|
18
|
+
export const assetsSlice = createSlice({
|
|
19
|
+
name: ASSETS_FEATURE_KEY,
|
|
20
|
+
initialState,
|
|
21
|
+
reducers: {
|
|
22
|
+
resetImportStatus: (state) => {
|
|
23
|
+
state.errorMessage = undefined;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
extraReducers(builder) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
28
|
+
builder.addCase(importAssets.pending, (state) => {
|
|
29
|
+
state.errorMessage = undefined;
|
|
30
|
+
});
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
32
|
+
builder.addCase(importAssets.rejected, (state, action) => {
|
|
33
|
+
state.errorMessage = action.error.message;
|
|
34
|
+
});
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
36
|
+
builder.addCase(importAssets.fulfilled, (state) => {
|
|
37
|
+
state.errorMessage = undefined;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
// #endregion
|
|
42
|
+
|
|
43
|
+
export const { resetImportStatus } = assetsSlice.actions;
|
|
44
|
+
|
|
45
|
+
// #region Action
|
|
46
|
+
export const importAssets = createAsyncThunk<
|
|
47
|
+
GetAssetLinkResponse[],
|
|
48
|
+
{
|
|
49
|
+
extension?: string;
|
|
50
|
+
extraFields?: string[];
|
|
51
|
+
maxHeight?: number;
|
|
52
|
+
maxWidth?: number;
|
|
53
|
+
parameters?: TrackingParameter[];
|
|
54
|
+
permanentLink?: string;
|
|
55
|
+
proxiesPreference?: string;
|
|
56
|
+
selectedAsset: Asset;
|
|
57
|
+
transformations?: Transformation[];
|
|
58
|
+
useRepresentative?: boolean;
|
|
59
|
+
useSession?: string;
|
|
60
|
+
}
|
|
61
|
+
>(
|
|
62
|
+
`${ASSETS_FEATURE_KEY}/importAssets`,
|
|
63
|
+
async (
|
|
64
|
+
{
|
|
65
|
+
extension,
|
|
66
|
+
extraFields,
|
|
67
|
+
maxHeight,
|
|
68
|
+
maxWidth,
|
|
69
|
+
parameters,
|
|
70
|
+
permanentLink,
|
|
71
|
+
proxiesPreference,
|
|
72
|
+
selectedAsset,
|
|
73
|
+
transformations,
|
|
74
|
+
useRepresentative,
|
|
75
|
+
useSession,
|
|
76
|
+
},
|
|
77
|
+
) => {
|
|
78
|
+
|
|
79
|
+
const images = await getAssetLinks({
|
|
80
|
+
assets: [selectedAsset],
|
|
81
|
+
extraFields: extraFields?.join('&ExtraFields='),
|
|
82
|
+
permanentLink,
|
|
83
|
+
proxyPreference: proxiesPreference,
|
|
84
|
+
transformations,
|
|
85
|
+
parameters,
|
|
86
|
+
maxWidth,
|
|
87
|
+
maxHeight,
|
|
88
|
+
extension,
|
|
89
|
+
useSession,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (useRepresentative) {
|
|
93
|
+
return [{
|
|
94
|
+
...images[0],
|
|
95
|
+
imageUrl: selectedAsset.imageUrl,
|
|
96
|
+
}];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return images;
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
// #endregion
|
|
103
|
+
|
|
104
|
+
export default assetsSlice.reducer;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GetAccessKeyRes, GetAccessTokenRes, RequestAuthorizeRes } from '@/types/auth';
|
|
2
|
+
import { cortexFetch } from '@/utils/api';
|
|
3
|
+
|
|
4
|
+
export const AUTH_MAX_RETRIES = 10;
|
|
5
|
+
export const CANCEL_AUTH_MESSAGE = 'Authentication cancelled';
|
|
6
|
+
|
|
7
|
+
export let authAbortController = new AbortController();
|
|
8
|
+
|
|
9
|
+
export const abortAuthService = () => {
|
|
10
|
+
authAbortController.abort(CANCEL_AUTH_MESSAGE);
|
|
11
|
+
authAbortController = new AbortController();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const requestAuthorizeService = async (
|
|
15
|
+
nonce: string,
|
|
16
|
+
): Promise<RequestAuthorizeRes> => {
|
|
17
|
+
const response = await cortexFetch(
|
|
18
|
+
'webapi/extensibility/integrations/gab/authorization/requestauthorize_4bu_v1',
|
|
19
|
+
{
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: JSON.stringify({ Nonce: nonce }),
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
return { ...(await response.json()), nonce };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getAccessKeyService = async (
|
|
31
|
+
requestID: string,
|
|
32
|
+
): Promise<GetAccessKeyRes> => {
|
|
33
|
+
authAbortController = new AbortController();
|
|
34
|
+
let count = 0;
|
|
35
|
+
let data: GetAccessKeyRes;
|
|
36
|
+
while (count < AUTH_MAX_RETRIES) {
|
|
37
|
+
const response = await cortexFetch(
|
|
38
|
+
'webapi/extensibility/integrations/gab/authorization/getaccesskey_4bv_v1',
|
|
39
|
+
{
|
|
40
|
+
signal: authAbortController.signal,
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: JSON.stringify({ RequestID: requestID }),
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
data = await response.json();
|
|
49
|
+
if (!!data.code && data.code !== 'RepeatRequest') {
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
count++;
|
|
53
|
+
}
|
|
54
|
+
throw new Error('Unable to get Access Key: Max retries exceeded.');
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const getAccessTokenService = async (
|
|
58
|
+
accessKey: string,
|
|
59
|
+
): Promise<GetAccessTokenRes> => {
|
|
60
|
+
const response = await cortexFetch(
|
|
61
|
+
'webapi/extensibility/integrations/gab/authorization/getaccesstoken_4bt_v1',
|
|
62
|
+
{
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body: JSON.stringify({ AccessKey: accessKey }),
|
|
65
|
+
headers: {
|
|
66
|
+
'Content-Type': 'application/json',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
return response.json();
|
|
71
|
+
};
|