@orangelogic/orange-dam-content-browser-sdk 2.1.55 → 2.2.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/.env +1 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +82 -0
  4. package/.releaserc +17 -0
  5. package/.travis.yml +20 -0
  6. package/CBSDKdemo.html +315 -0
  7. package/GitVersion.yml +18 -0
  8. package/azure-pipeline.yaml +94 -0
  9. package/clientlib.config.js +36 -0
  10. package/config/env.js +105 -0
  11. package/config/getHttpsConfig.js +67 -0
  12. package/config/jest/babelTransform.js +30 -0
  13. package/config/jest/cssTransform.js +14 -0
  14. package/config/jest/fileTransform.js +41 -0
  15. package/config/modules.js +135 -0
  16. package/config/paths.js +79 -0
  17. package/config/webpack/persistentCache/createEnvironmentHash.js +10 -0
  18. package/config/webpack.config.js +762 -0
  19. package/config/webpackDevServer.config.js +128 -0
  20. package/config-overrides.js +8 -0
  21. package/gab_extension/GAB.html +85 -0
  22. package/gab_extension/GoogleChrome/manifest.json +28 -0
  23. package/gab_extension/GoogleChrome/src/assets/icon48.png +0 -0
  24. package/gab_extension/GoogleChrome/src/background/index.js +6 -0
  25. package/gab_extension/GoogleChrome/src/scripts/index.js +347 -0
  26. package/gab_extension/MozillaFirefox/manifest.json +20 -0
  27. package/gab_extension/MozillaFirefox/src/assets/icon.png +0 -0
  28. package/gab_extension/MozillaFirefox/src/background/index.js +5 -0
  29. package/gab_extension/MozillaFirefox/src/scripts/index.js +347 -0
  30. package/gab_extension/README.md +11 -0
  31. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.pbxproj +927 -0
  32. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  33. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  34. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/project.xcworkspace/xcuserdata/oldevmac01.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  35. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Orange DAM Asset Browser Extension.xcodeproj/xcuserdata/oldevmac01.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  36. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
  37. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
  38. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/Contents.json +6 -0
  39. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +20 -0
  40. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Base.lproj/Main.html +23 -0
  41. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Icon.png +0 -0
  42. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Script.js +24 -0
  43. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/Resources/Style.css +61 -0
  44. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (App)/ViewController.swift +81 -0
  45. package/gab_extension/Safari/Orange DAM Asset Browser Extension/Shared (Extension)/SafariWebExtensionHandler.swift +26 -0
  46. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/AppDelegate.swift +24 -0
  47. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
  48. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Base.lproj/Main.storyboard +38 -0
  49. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/Info.plist +27 -0
  50. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (App)/SceneDelegate.swift +18 -0
  51. package/gab_extension/Safari/Orange DAM Asset Browser Extension/iOS (Extension)/Info.plist +13 -0
  52. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/AppDelegate.swift +21 -0
  53. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Base.lproj/Main.storyboard +125 -0
  54. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Info.plist +8 -0
  55. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (App)/Orange DAM Asset Browser Extension.entitlements +12 -0
  56. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Info.plist +13 -0
  57. package/gab_extension/Safari/Orange DAM Asset Browser Extension/macOS (Extension)/Orange DAM Asset Browser Extension.entitlements +10 -0
  58. package/package.json +8 -49
  59. package/public/index.html +92 -0
  60. package/scripts/build.js +218 -0
  61. package/scripts/start.js +154 -0
  62. package/scripts/test.js +53 -0
  63. package/src/App.tsx +98 -0
  64. package/src/AppContext.ts +18 -0
  65. package/src/GlobalConfigContext.ts +46 -0
  66. package/src/components/ArrayClamp/ArrayClamp.styled.ts +42 -0
  67. package/src/components/ArrayClamp/ArrayClamp.tsx +167 -0
  68. package/src/components/ArrayClamp/index.ts +1 -0
  69. package/src/components/Browser/Browser.styled.ts +82 -0
  70. package/src/components/Browser/Browser.tsx +284 -0
  71. package/src/components/Browser/BrowserItem.tsx +98 -0
  72. package/src/components/ControlBar/ControlBar.constants.tsx +66 -0
  73. package/src/components/ControlBar/ControlBar.styled.ts +82 -0
  74. package/src/components/ControlBar/ControlBar.tsx +528 -0
  75. package/src/components/ControlBar/Facet/Facet.tsx +113 -0
  76. package/src/components/ControlBar/Facet/index.ts +1 -0
  77. package/src/components/FormatDialog/CropPreviewer/CropPreviewer.tsx +224 -0
  78. package/{build/components/FormatDialog/CropPreviewer/index.d.ts → src/components/FormatDialog/CropPreviewer/index.ts} +1 -1
  79. package/src/components/FormatDialog/CustomRendition/CustomRendition.constants.ts +24 -0
  80. package/src/components/FormatDialog/CustomRendition/CustomRendition.styled.ts +57 -0
  81. package/src/components/FormatDialog/CustomRendition/CustomRendition.tsx +178 -0
  82. package/src/components/FormatDialog/CustomRendition/index.ts +1 -0
  83. package/src/components/FormatDialog/CustomRendition/transformations/Crop.tsx +249 -0
  84. package/src/components/FormatDialog/CustomRendition/transformations/Extension.tsx +54 -0
  85. package/src/components/FormatDialog/CustomRendition/transformations/Format.tsx +86 -0
  86. package/src/components/FormatDialog/CustomRendition/transformations/Resize.tsx +176 -0
  87. package/src/components/FormatDialog/CustomRendition/transformations/Rotate.tsx +101 -0
  88. package/{build/components/FormatDialog/CustomRendition/transformations/index.d.ts → src/components/FormatDialog/CustomRendition/transformations/index.ts} +1 -3
  89. package/src/components/FormatDialog/FormatDialog.styled.ts +137 -0
  90. package/src/components/FormatDialog/FormatDialog.tsx +1533 -0
  91. package/src/components/FormatDialog/Previewer/Previewer.styled.ts +31 -0
  92. package/src/components/FormatDialog/Previewer/Previewer.tsx +143 -0
  93. package/src/components/FormatDialog/Previewer/index.ts +1 -0
  94. package/src/components/FormatDialog/ProxyMenu/ProxyMenu.styled.ts +88 -0
  95. package/src/components/FormatDialog/ProxyMenu/ProxyMenu.tsx +74 -0
  96. package/src/components/FormatDialog/ProxyMenu/index.ts +1 -0
  97. package/src/components/FormatDialog/TrackingParameters/TrackingParameters.tsx +59 -0
  98. package/src/components/FormatDialog/TrackingParameters/index.ts +1 -0
  99. package/src/components/FormatDialog/index.ts +1 -0
  100. package/src/components/Header/Header.styled.ts +51 -0
  101. package/src/components/Header/Header.tsx +118 -0
  102. package/src/components/Loader/Loader.tsx +37 -0
  103. package/src/components/Loader/index.ts +1 -0
  104. package/src/components/NoResult/NoResult.tsx +37 -0
  105. package/src/components/NoResult/index.tsx +1 -0
  106. package/src/components/Result/AssetCard/AssetCard.styled.ts +120 -0
  107. package/src/components/Result/AssetCard/AssetCard.tsx +192 -0
  108. package/src/components/Result/AssetCard/AssetCardWrapper.styled.ts +35 -0
  109. package/src/components/Result/AssetCard/AssetCardWrapper.tsx +165 -0
  110. package/src/components/Result/AssetCard/index.ts +1 -0
  111. package/src/components/Result/AssetPreview/AssetPreview.styled.ts +108 -0
  112. package/src/components/Result/AssetPreview/AssetPreview.tsx +78 -0
  113. package/src/components/Result/AssetPreview/ImagePreview/ImagePreview.tsx +42 -0
  114. package/src/components/Result/AssetPreview/ImagePreview/index.ts +1 -0
  115. package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.ts +23 -0
  116. package/src/components/Result/AssetPreview/OtherPreview/OtherPreview.tsx +28 -0
  117. package/src/components/Result/AssetPreview/OtherPreview/index.ts +1 -0
  118. package/src/components/Result/AssetPreview/VideoPreview/VideoPreview.tsx +132 -0
  119. package/src/components/Result/AssetPreview/VideoPreview/index.ts +1 -0
  120. package/src/components/Result/AssetPreview/index.ts +1 -0
  121. package/src/consts/asset.ts +16 -0
  122. package/src/consts/data.ts +17 -0
  123. package/src/index.tsx +305 -0
  124. package/src/page/Authenticate/Authenticate.tsx +232 -0
  125. package/src/page/Authenticate/ConnectingBackground.tsx +44 -0
  126. package/src/page/Authenticate/index.tsx +94 -0
  127. package/src/page/Home/Home.styled.ts +46 -0
  128. package/src/page/Home/Home.tsx +941 -0
  129. package/src/react-web-component.d.ts +4617 -0
  130. package/src/store/assets/assets.api.ts +167 -0
  131. package/src/store/assets/assets.service.ts +223 -0
  132. package/src/store/assets/assets.slice.ts +104 -0
  133. package/src/store/auth/auth.service.ts +71 -0
  134. package/src/store/auth/auth.slice.ts +295 -0
  135. package/src/store/index.ts +27 -0
  136. package/src/store/search/search.api.ts +319 -0
  137. package/src/store/search/search.slice.ts +28 -0
  138. package/src/store/user/user.api.ts +29 -0
  139. package/src/styles.css +42 -0
  140. package/src/types/assets.ts +71 -0
  141. package/src/types/auth.ts +42 -0
  142. package/src/types/common.ts +11 -0
  143. package/src/types/download.ts +8 -0
  144. package/src/types/navigation.ts +3 -0
  145. package/src/types/search.ts +116 -0
  146. package/{build/types/storage.d.ts → src/types/storage.ts} +1 -1
  147. package/src/types/user.ts +6 -0
  148. package/src/utils/api.ts +186 -0
  149. package/src/utils/array.ts +25 -0
  150. package/src/utils/constants.ts +12 -0
  151. package/src/utils/fetch.ts +116 -0
  152. package/src/utils/getRequestUrl.ts +15 -0
  153. package/src/utils/hooks.ts +36 -0
  154. package/src/utils/icon.ts +22 -0
  155. package/src/utils/image.ts +157 -0
  156. package/src/utils/number.ts +11 -0
  157. package/src/utils/rotate.ts +23 -0
  158. package/src/utils/storage.ts +184 -0
  159. package/src/utils/string.ts +24 -0
  160. package/src/view/AssetsPicker.tsx +24 -0
  161. package/src/web-component.d.ts +8151 -0
  162. package/tsconfig.eslint.json +10 -0
  163. package/tsconfig.json +37 -0
  164. package/build/ApiService.d.ts +0 -15
  165. package/build/App.d.ts +0 -62
  166. package/build/AppContext.d.ts +0 -18
  167. package/build/GlobalConfigContext.d.ts +0 -32
  168. package/build/OrangeDAMContentBrowserSDK.min.css +0 -2
  169. package/build/OrangeDAMContentBrowserSDK.min.css.map +0 -1
  170. package/build/OrangeDAMContentBrowserSDK.min.js +0 -11468
  171. package/build/OrangeDAMContentBrowserSDK.min.js.map +0 -1
  172. package/build/asset-manifest.json +0 -13
  173. package/build/components/ArrayClamp/ArrayClamp.d.ts +0 -10
  174. package/build/components/ArrayClamp/ArrayClamp.styled.d.ts +0 -1
  175. package/build/components/ArrayClamp/index.d.ts +0 -1
  176. package/build/components/Browser/Browser.constants.d.ts +0 -3
  177. package/build/components/Browser/Browser.d.ts +0 -21
  178. package/build/components/Browser/Browser.styled.d.ts +0 -2
  179. package/build/components/Browser/BrowserItem.d.ts +0 -13
  180. package/build/components/Browser/LoadMoreButton.d.ts +0 -9
  181. package/build/components/ControlBar/ControlBar.constants.d.ts +0 -10
  182. package/build/components/ControlBar/ControlBar.d.ts +0 -23
  183. package/build/components/ControlBar/ControlBar.styled.d.ts +0 -1
  184. package/build/components/ControlBar/Facet/Facet.d.ts +0 -14
  185. package/build/components/ControlBar/Facet/index.d.ts +0 -1
  186. package/build/components/FormatDialog/CropPreviewer/CropPreviewer.d.ts +0 -41
  187. package/build/components/FormatDialog/CustomRendition/CustomRendition.constants.d.ts +0 -5
  188. package/build/components/FormatDialog/CustomRendition/CustomRendition.d.ts +0 -56
  189. package/build/components/FormatDialog/CustomRendition/CustomRendition.styled.d.ts +0 -1
  190. package/build/components/FormatDialog/CustomRendition/index.d.ts +0 -1
  191. package/build/components/FormatDialog/CustomRendition/transformations/Crop.d.ts +0 -26
  192. package/build/components/FormatDialog/CustomRendition/transformations/Extension.d.ts +0 -11
  193. package/build/components/FormatDialog/CustomRendition/transformations/Format.d.ts +0 -10
  194. package/build/components/FormatDialog/CustomRendition/transformations/Metadata.d.ts +0 -7
  195. package/build/components/FormatDialog/CustomRendition/transformations/Quality.d.ts +0 -7
  196. package/build/components/FormatDialog/CustomRendition/transformations/Resize.d.ts +0 -18
  197. package/build/components/FormatDialog/CustomRendition/transformations/Rotate.d.ts +0 -8
  198. package/build/components/FormatDialog/FormatDialog.d.ts +0 -49
  199. package/build/components/FormatDialog/FormatDialog.styled.d.ts +0 -3
  200. package/build/components/FormatDialog/Previewer/Previewer.d.ts +0 -17
  201. package/build/components/FormatDialog/Previewer/Previewer.styled.d.ts +0 -1
  202. package/build/components/FormatDialog/Previewer/index.d.ts +0 -1
  203. package/build/components/FormatDialog/ProxyMenu/ProxyMenu.d.ts +0 -20
  204. package/build/components/FormatDialog/ProxyMenu/ProxyMenu.styled.d.ts +0 -2
  205. package/build/components/FormatDialog/ProxyMenu/index.d.ts +0 -1
  206. package/build/components/FormatDialog/TrackingParameters/TrackingParameters.d.ts +0 -13
  207. package/build/components/FormatDialog/TrackingParameters/index.d.ts +0 -1
  208. package/build/components/FormatDialog/VersionHistory/VersionHistory.d.ts +0 -6
  209. package/build/components/FormatDialog/VersionHistory/VersionHistory.styled.d.ts +0 -1
  210. package/build/components/FormatDialog/VersionHistory/index.d.ts +0 -1
  211. package/build/components/FormatDialog/index.d.ts +0 -1
  212. package/build/components/Header/Header.d.ts +0 -15
  213. package/build/components/Header/Header.styled.d.ts +0 -5
  214. package/build/components/Loader/Loader.d.ts +0 -7
  215. package/build/components/Loader/index.d.ts +0 -1
  216. package/build/components/NoResult/NoResult.d.ts +0 -7
  217. package/build/components/NoResult/index.d.ts +0 -1
  218. package/build/components/Result/AssetCard/AssetCard.d.ts +0 -15
  219. package/build/components/Result/AssetCard/AssetCard.styled.d.ts +0 -2
  220. package/build/components/Result/AssetCard/AssetCardWrapper.d.ts +0 -18
  221. package/build/components/Result/AssetCard/AssetCardWrapper.styled.d.ts +0 -1
  222. package/build/components/Result/AssetCard/index.d.ts +0 -1
  223. package/build/components/Result/AssetPreview/AssetPreview.d.ts +0 -11
  224. package/build/components/Result/AssetPreview/AssetPreview.styled.d.ts +0 -1
  225. package/build/components/Result/AssetPreview/ImagePreview/ImagePreview.d.ts +0 -11
  226. package/build/components/Result/AssetPreview/ImagePreview/index.d.ts +0 -1
  227. package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.d.ts +0 -9
  228. package/build/components/Result/AssetPreview/OtherPreview/OtherPreview.styled.d.ts +0 -1
  229. package/build/components/Result/AssetPreview/OtherPreview/index.d.ts +0 -1
  230. package/build/components/Result/AssetPreview/VideoPreview/VideoPreview.d.ts +0 -11
  231. package/build/components/Result/AssetPreview/VideoPreview/index.d.ts +0 -1
  232. package/build/components/Result/AssetPreview/index.d.ts +0 -1
  233. package/build/consts/asset.d.ts +0 -14
  234. package/build/consts/auth.d.ts +0 -4
  235. package/build/consts/data.d.ts +0 -21
  236. package/build/index.d.ts +0 -225
  237. package/build/index.html +0 -1
  238. package/build/page/Authenticate/Authenticate.d.ts +0 -2
  239. package/build/page/Authenticate/ConnectingBackground.d.ts +0 -8
  240. package/build/page/Authenticate/index.d.ts +0 -2
  241. package/build/page/Home/Home.d.ts +0 -6
  242. package/build/page/Home/Home.styled.d.ts +0 -2
  243. package/build/setupTests.d.ts +0 -1
  244. package/build/store/assets/assets.api.d.ts +0 -66
  245. package/build/store/assets/assets.service.d.ts +0 -23
  246. package/build/store/assets/assets.slice.d.ts +0 -65
  247. package/build/store/auth/auth.service.d.ts +0 -10
  248. package/build/store/auth/auth.slice.d.ts +0 -76
  249. package/build/store/index.d.ts +0 -368
  250. package/build/store/search/search.api.d.ts +0 -39
  251. package/build/store/search/search.slice.d.ts +0 -12
  252. package/build/store/user/user.api.d.ts +0 -5
  253. package/build/types/assets.d.ts +0 -68
  254. package/build/types/auth.d.ts +0 -35
  255. package/build/types/common.d.ts +0 -11
  256. package/build/types/download.d.ts +0 -8
  257. package/build/types/navigation.d.ts +0 -3
  258. package/build/types/search.d.ts +0 -148
  259. package/build/types/user.d.ts +0 -7
  260. package/build/utils/api.d.ts +0 -27
  261. package/build/utils/array.d.ts +0 -13
  262. package/build/utils/constants.d.ts +0 -11
  263. package/build/utils/function.d.ts +0 -1
  264. package/build/utils/getRequestUrl.d.ts +0 -1
  265. package/build/utils/hooks.d.ts +0 -1
  266. package/build/utils/icon.d.ts +0 -3
  267. package/build/utils/image.d.ts +0 -24
  268. package/build/utils/number.d.ts +0 -4
  269. package/build/utils/rotate.d.ts +0 -4
  270. package/build/utils/storage.d.ts +0 -23
  271. package/build/utils/string.d.ts +0 -12
  272. package/build/view/AssetsPicker.d.ts +0 -6
  273. /package/{build → public}/favicon.ico +0 -0
  274. /package/{build → public}/logo192.png +0 -0
  275. /package/{build → public}/logo512.png +0 -0
  276. /package/{build → public}/manifest.json +0 -0
  277. /package/{build → public}/robots.txt +0 -0
  278. /package/{build/components/Browser/index.d.ts → src/components/Browser/index.ts} +0 -0
  279. /package/{build/components/ControlBar/index.d.ts → src/components/ControlBar/index.ts} +0 -0
  280. /package/{build/components/Header/index.d.ts → src/components/Header/index.ts} +0 -0
  281. /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,8 @@
1
+ export type GetDownloadLinksResponse = {
2
+ downloadLinks: DownloadLink[];
3
+ };
4
+
5
+ type DownloadLink = {
6
+ downloadLink: string;
7
+ recordID: string;
8
+ };
@@ -0,0 +1,3 @@
1
+ export type NavigationState = {
2
+ currentPage: 'home' | 'settings';
3
+ };
@@ -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' | 'CustomStorage';
1
+ export type StorageType = 'SessionStorage' | 'LocalStorage' | 'Cookies';
@@ -0,0 +1,6 @@
1
+ export type UserInfo = {
2
+ avatar: string;
3
+ email: string;
4
+ fullName: string;
5
+ loginID: string;
6
+ };
@@ -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
+ };