@orangelogic/orange-dam-content-browser-sdk 2.1.55 → 2.2.0-beta
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 +94 -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
package/src/styles.css
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import url('https://design-system.orangelogic.com/css/ol-light.css');
|
|
2
|
+
|
|
3
|
+
#cortex-asset-picker-root {
|
|
4
|
+
--cx-button-text-transform: none;
|
|
5
|
+
--default-representative-background-color: #6cdaf3;
|
|
6
|
+
--default-representative-color: #377a86;
|
|
7
|
+
|
|
8
|
+
color: var(--cx-color-neutral);
|
|
9
|
+
font-family: var(--cx-font-sans);
|
|
10
|
+
font-synthesis-weight: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#cortex-asset-picker-root *:not(:defined) {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#cortex-asset-picker-root * {
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#cortex-asset-picker-root ::-webkit-scrollbar {
|
|
22
|
+
width: 17px;
|
|
23
|
+
height: 17px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#cortex-asset-picker-root ::-webkit-scrollbar-corner {
|
|
27
|
+
background-color: transparent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#cortex-asset-picker-root ::-webkit-scrollbar-thumb {
|
|
31
|
+
border-radius: 13px;
|
|
32
|
+
background: #8e8e93;
|
|
33
|
+
background-clip: padding-box;
|
|
34
|
+
border: 7px solid rgba(0, 0, 0, 0);
|
|
35
|
+
min-height: 50px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#cortex-asset-picker-root ::-webkit-scrollbar-thumb:hover {
|
|
39
|
+
background: #5b5b6f;
|
|
40
|
+
background-clip: padding-box;
|
|
41
|
+
border: 4px solid rgba(0, 0, 0, 0);
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Asset } from './search';
|
|
2
|
+
|
|
3
|
+
export type GetLargestDownloadLinkRes = {
|
|
4
|
+
downloadLink: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type AssetsState = {
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export enum ImageImportStatus {
|
|
12
|
+
Importing,
|
|
13
|
+
Success,
|
|
14
|
+
Failed,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ImageImport = {
|
|
18
|
+
image: Asset;
|
|
19
|
+
message?: string;
|
|
20
|
+
status: ImageImportStatus;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export enum TransformationAction {
|
|
24
|
+
Resize,
|
|
25
|
+
Crop,
|
|
26
|
+
Rotate,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type Transformation = {
|
|
30
|
+
key: TransformationAction;
|
|
31
|
+
value: {
|
|
32
|
+
width?: number;
|
|
33
|
+
height?: number;
|
|
34
|
+
x?: number;
|
|
35
|
+
y?: number;
|
|
36
|
+
rotation?: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type TrackingParameter = { key: string; value: string };
|
|
41
|
+
|
|
42
|
+
export enum Unit {
|
|
43
|
+
Pixel = 'pixels',
|
|
44
|
+
AspectRatio = 'aspect-ratio',
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type SortOrder = {
|
|
48
|
+
description: string;
|
|
49
|
+
id: string;
|
|
50
|
+
isDefault?: boolean;
|
|
51
|
+
legacyValue: string;
|
|
52
|
+
name: string;
|
|
53
|
+
sortDirection: string;
|
|
54
|
+
sortDirectionDisplayName: string;
|
|
55
|
+
sortDirectionGroupKey: string;
|
|
56
|
+
sortType: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* ShowDialog: no loader, the format dialog is ready to open
|
|
62
|
+
*
|
|
63
|
+
* ShowLoader : show loader, hide the format dialog
|
|
64
|
+
*
|
|
65
|
+
* Hide: hide loader, hide the format dialog
|
|
66
|
+
*/
|
|
67
|
+
export enum FormatLoaderState {
|
|
68
|
+
Hide = 'hide',
|
|
69
|
+
ShowLoader = 'show-loader',
|
|
70
|
+
ShowDialog = 'show-dialog',
|
|
71
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type AuthorizationResult = {
|
|
2
|
+
requestID: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export enum GetAccessKeyResponseCode {
|
|
6
|
+
Authorized = 'Authorized',
|
|
7
|
+
RepeatRequest = 'RepeatRequest',
|
|
8
|
+
NotAuthorized = 'NotAuthorized',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type GetAccessKeyResponse = {
|
|
12
|
+
accessKey?: string;
|
|
13
|
+
code: GetAccessKeyResponseCode;
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type GetAccessTokenResponse = {
|
|
18
|
+
accessToken?: string;
|
|
19
|
+
success: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type RequestAuthorizeRes = {
|
|
23
|
+
nonce: string;
|
|
24
|
+
requestID: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type GetAccessKeyRes = {
|
|
28
|
+
accessKey?: string;
|
|
29
|
+
code: GetAccessKeyResponseCode;
|
|
30
|
+
message?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type GetAccessTokenRes = {
|
|
34
|
+
accessToken?: string;
|
|
35
|
+
success: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type OAuthRes = {
|
|
39
|
+
accessKey?: string;
|
|
40
|
+
accessToken?: string;
|
|
41
|
+
siteUrl: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error response from Cortex API.
|
|
3
|
+
* The body will always contain a message and an error code. Other field usually the placeholder for error message.
|
|
4
|
+
*/
|
|
5
|
+
export type CortexErrorResponse = {
|
|
6
|
+
Message: string;
|
|
7
|
+
ErrorCode: 'OL_ERR_001_NOTFOUND' | 'OL_ERR_002_NOTALLOWED' | 'OL_ERR_003_REMOVED' | 'OL_ASSETLINKSERVICE_ERROR_001_LINKS_TO_NON_REQUIRED_FORMATS_NOT_ALLOWED' | 'OL_ERR_006_BADREQUEST';
|
|
8
|
+
'Asset ID'?: string;
|
|
9
|
+
'Asset Identifier'?: string;
|
|
10
|
+
'Format'?: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export type Folder = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
docType: string;
|
|
5
|
+
path: string[];
|
|
6
|
+
parents: Folder[];
|
|
7
|
+
fullPath: string;
|
|
8
|
+
hasChildren: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Asset = {
|
|
12
|
+
docType: MediaType;
|
|
13
|
+
docSubType: string;
|
|
14
|
+
extension: string;
|
|
15
|
+
height?: string;
|
|
16
|
+
id: string;
|
|
17
|
+
identifier: string;
|
|
18
|
+
imageUrl: string;
|
|
19
|
+
originalUrl: string;
|
|
20
|
+
name: string;
|
|
21
|
+
scrubUrl: string;
|
|
22
|
+
size: string;
|
|
23
|
+
tags: string;
|
|
24
|
+
width?: string;
|
|
25
|
+
allowATSLink?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ContentItem = {
|
|
29
|
+
fields: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
recordID: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type GetContentResponse = {
|
|
36
|
+
contentItems?: ContentItem[];
|
|
37
|
+
facets: Record<string, Record<string, number>>;
|
|
38
|
+
totalCount: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type GetContentRequest = {
|
|
42
|
+
extensions: string[];
|
|
43
|
+
folderID: string;
|
|
44
|
+
isSeeThrough: boolean;
|
|
45
|
+
mediaTypes: string[];
|
|
46
|
+
start: number;
|
|
47
|
+
pageSize: number;
|
|
48
|
+
searchText: string;
|
|
49
|
+
sortOrder?: string;
|
|
50
|
+
statuses: string[];
|
|
51
|
+
visibilityClasses: string[];
|
|
52
|
+
useSession?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type GetAssetLinkResponse = {
|
|
56
|
+
extraFields?: {
|
|
57
|
+
[key: string]: string;
|
|
58
|
+
};
|
|
59
|
+
imageUrl: string;
|
|
60
|
+
metadata?: {
|
|
61
|
+
[key: string]: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type GetTransformedAssetLinkResponse = {
|
|
66
|
+
expirationDate: string | null,
|
|
67
|
+
fileExtension: string | null,
|
|
68
|
+
format: string,
|
|
69
|
+
identifier: string,
|
|
70
|
+
imageResizingMethod: string | null
|
|
71
|
+
link: string,
|
|
72
|
+
maxHeight: number,
|
|
73
|
+
maxWidth: number,
|
|
74
|
+
recordID: string,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export enum MediaType {
|
|
78
|
+
Album = 'Album',
|
|
79
|
+
Audio = 'Audio',
|
|
80
|
+
Image = 'Image',
|
|
81
|
+
Multimedia = 'Multimedia',
|
|
82
|
+
Story = 'Story',
|
|
83
|
+
Video = 'Video',
|
|
84
|
+
Widget = 'Widget',
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export enum GridView {
|
|
88
|
+
Small = 'small',
|
|
89
|
+
Medium = 'medium',
|
|
90
|
+
Large = 'large',
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export enum SortDirection {
|
|
94
|
+
Ascending = 'ascending',
|
|
95
|
+
Descending = 'descending',
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type Filter = {
|
|
99
|
+
mediaTypes: string[],
|
|
100
|
+
visibilityClasses: string[],
|
|
101
|
+
statuses: string[],
|
|
102
|
+
extensions: string[],
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type Proxy = {
|
|
106
|
+
cdnName: string | null;
|
|
107
|
+
extension: string | null;
|
|
108
|
+
id: string;
|
|
109
|
+
formatHeight: number;
|
|
110
|
+
formatWidth: number;
|
|
111
|
+
height: number;
|
|
112
|
+
permanentLink: string | null;
|
|
113
|
+
proxyLabel: string;
|
|
114
|
+
proxyName: string;
|
|
115
|
+
width: number;
|
|
116
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type StorageType = 'SessionStorage' | 'LocalStorage' | 'Cookies'
|
|
1
|
+
export type StorageType = 'SessionStorage' | 'LocalStorage' | 'Cookies';
|
package/src/utils/api.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Mutex } from 'async-mutex';
|
|
2
|
+
|
|
3
|
+
import { RootState, store } from '@/store';
|
|
4
|
+
import { getAccessTokenService } from '@/store/auth/auth.service';
|
|
5
|
+
import {
|
|
6
|
+
accessTokenSelector, AUTH_FEATURE_KEY, logout, setAccessToken,
|
|
7
|
+
} from '@/store/auth/auth.slice';
|
|
8
|
+
import {
|
|
9
|
+
BaseQueryFn, FetchArgs, fetchBaseQuery, FetchBaseQueryError,
|
|
10
|
+
} from '@reduxjs/toolkit/dist/query';
|
|
11
|
+
|
|
12
|
+
import { getRequestUrl } from './getRequestUrl';
|
|
13
|
+
|
|
14
|
+
type CortexFetchOptions = RequestInit & {
|
|
15
|
+
/**
|
|
16
|
+
* Time out in milliseconds
|
|
17
|
+
*/
|
|
18
|
+
timeout?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Extended with timeout option and retry option. This value is true by default.
|
|
21
|
+
* Fetch the data from the given url with retry when the response is not ok or have status code 401
|
|
22
|
+
* This function will try to fetch the data again with a new token if the previous token is expired
|
|
23
|
+
* The token will be refreshed similar to the logic in AppBaseQuery
|
|
24
|
+
*/
|
|
25
|
+
retryWhenUnauthorize?: boolean
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const mutex = new Mutex();
|
|
29
|
+
|
|
30
|
+
function appendQueryStringParam(
|
|
31
|
+
args: string | FetchArgs,
|
|
32
|
+
key: string,
|
|
33
|
+
value: string,
|
|
34
|
+
): string | FetchArgs {
|
|
35
|
+
let urlEnd = typeof args === 'string' ? args : args.url;
|
|
36
|
+
|
|
37
|
+
if (urlEnd.indexOf('?') < 0) urlEnd += '?';
|
|
38
|
+
else urlEnd += '&';
|
|
39
|
+
|
|
40
|
+
urlEnd += `${key}=${value}`;
|
|
41
|
+
|
|
42
|
+
return typeof args === 'string' ? urlEnd : { ...args, url: urlEnd };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const AppBaseQuery: BaseQueryFn<
|
|
46
|
+
string | FetchArgs,
|
|
47
|
+
unknown,
|
|
48
|
+
FetchBaseQueryError
|
|
49
|
+
> = async (args, api, extraOptions) => {
|
|
50
|
+
const rootState = api.getState() as RootState;
|
|
51
|
+
const token = accessTokenSelector(rootState);
|
|
52
|
+
if (token)
|
|
53
|
+
args = appendQueryStringParam(args, 'Token', token);
|
|
54
|
+
const authState = rootState[AUTH_FEATURE_KEY];
|
|
55
|
+
const rawBaseQuery = fetchBaseQuery({
|
|
56
|
+
baseUrl: authState.siteUrl,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await mutex.waitForUnlock();
|
|
60
|
+
const result = await rawBaseQuery(args, api, extraOptions);
|
|
61
|
+
|
|
62
|
+
if (result.error && result.error.status === 401) {
|
|
63
|
+
if (!mutex.isLocked()) {
|
|
64
|
+
const release = await mutex.acquire();
|
|
65
|
+
try {
|
|
66
|
+
if (authState.accessKey) {
|
|
67
|
+
const accessToken = (
|
|
68
|
+
await getAccessTokenService(authState.accessKey)
|
|
69
|
+
).accessToken;
|
|
70
|
+
api.dispatch(setAccessToken(accessToken));
|
|
71
|
+
}
|
|
72
|
+
} finally {
|
|
73
|
+
release();
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
await mutex.waitForUnlock();
|
|
77
|
+
return rawBaseQuery(args, api, extraOptions);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export function GetValueByKeyCaseInsensitive(
|
|
85
|
+
obj: { [key: string]: string },
|
|
86
|
+
key: string,
|
|
87
|
+
) {
|
|
88
|
+
const lowerCaseKey = key.toLowerCase();
|
|
89
|
+
const foundKey = Object.keys(obj).find(
|
|
90
|
+
(k) => k.toLowerCase() === lowerCaseKey,
|
|
91
|
+
);
|
|
92
|
+
return foundKey ? obj[foundKey] : undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* Check if the available status of the site url
|
|
97
|
+
* If site is not available then we will return an error message, else null
|
|
98
|
+
*/
|
|
99
|
+
export const checkCorrectSiteUrl = (url: string): Promise<string | null> => {
|
|
100
|
+
return new Promise((resolve, rejected) => {
|
|
101
|
+
const img = new Image();
|
|
102
|
+
img.onload = () => resolve(null);
|
|
103
|
+
img.onerror = () => rejected();
|
|
104
|
+
img.src = `${url}${url.endsWith('/') ? '' : '/'}Include/ImageUsedToCheckSiteAvailabilityFromBrowser.gif`;
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Wrapper of fetch API with timeout option
|
|
111
|
+
* @param resource
|
|
112
|
+
* @param options
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
const fetchWithTimeout = async (resource: RequestInfo | URL, options?: RequestInit & { timeout?: number }) => {
|
|
116
|
+
const { timeout } = options ?? {};
|
|
117
|
+
|
|
118
|
+
if (timeout) {
|
|
119
|
+
const controller = new AbortController();
|
|
120
|
+
const id = setTimeout(() => controller.abort(), timeout);
|
|
121
|
+
|
|
122
|
+
const response = await fetch(resource, {
|
|
123
|
+
...options,
|
|
124
|
+
signal: options?.signal ?? controller.signal,
|
|
125
|
+
});
|
|
126
|
+
clearTimeout(id);
|
|
127
|
+
return response;
|
|
128
|
+
} else {
|
|
129
|
+
return await fetch(resource, options);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Wrapper of fetch API with timeout option
|
|
135
|
+
* @param resource
|
|
136
|
+
* @param options
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
139
|
+
export const cortexFetch = async (resource: string, options?: CortexFetchOptions) => {
|
|
140
|
+
const { retryWhenUnauthorize = true } = options || {};
|
|
141
|
+
const authState = store.getState()[AUTH_FEATURE_KEY];
|
|
142
|
+
resource = getRequestUrl(authState.siteUrl, resource, authState.accessToken);
|
|
143
|
+
const response = await fetchWithTimeout(resource, options);
|
|
144
|
+
|
|
145
|
+
if (retryWhenUnauthorize && !response.ok && response.status === 401) {
|
|
146
|
+
await mutex.waitForUnlock();
|
|
147
|
+
|
|
148
|
+
if (!mutex.isLocked()) {
|
|
149
|
+
const release = await mutex.acquire();
|
|
150
|
+
try {
|
|
151
|
+
if (!authState.accessKey || !authState.siteUrl) {
|
|
152
|
+
store.dispatch(logout());
|
|
153
|
+
return response;
|
|
154
|
+
} else {
|
|
155
|
+
let needsLoggingOut = false;
|
|
156
|
+
try {
|
|
157
|
+
const tokenResp = await getAccessTokenService(authState.accessKey);
|
|
158
|
+
|
|
159
|
+
if (tokenResp.accessToken) {
|
|
160
|
+
store.dispatch(setAccessToken(tokenResp.accessToken));
|
|
161
|
+
resource = getRequestUrl(authState.siteUrl, resource, authState.accessToken);
|
|
162
|
+
return await fetchWithTimeout(resource, options);
|
|
163
|
+
} else {
|
|
164
|
+
needsLoggingOut = true;
|
|
165
|
+
return response;
|
|
166
|
+
}
|
|
167
|
+
} catch (e) {
|
|
168
|
+
needsLoggingOut = true;
|
|
169
|
+
return response;
|
|
170
|
+
} finally {
|
|
171
|
+
if (needsLoggingOut) {
|
|
172
|
+
store.dispatch(logout());
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} finally {
|
|
177
|
+
release();
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
await mutex.waitForUnlock();
|
|
181
|
+
return await fetchWithTimeout(resource, options);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return response;
|
|
186
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if an array has elements
|
|
3
|
+
* @param arr array to check
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export const hasElements = (arr: object | undefined | null): boolean => {
|
|
7
|
+
return !!arr && Object.keys(arr).length > 0;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Removes duplicate elements from an array based on a key generated by the provided callback function.
|
|
12
|
+
* @param arr - The array from which to remove duplicates.
|
|
13
|
+
* @param keyGenerator - A callback function that generates a unique key for each element.
|
|
14
|
+
* @returns A new array with unique elements.
|
|
15
|
+
*/
|
|
16
|
+
export const uniqueArray = <T>(arr: T[], keyGenerator: (element: T) => string = (element) => element as string): T[] => {
|
|
17
|
+
const uniqueElements: { [key: string]: T } = {};
|
|
18
|
+
|
|
19
|
+
arr.forEach((element) => {
|
|
20
|
+
const key = keyGenerator(element);
|
|
21
|
+
uniqueElements[key] = element;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return Object.keys(uniqueElements).map((key) => uniqueElements[key]);
|
|
25
|
+
};
|