@beinformed/ui 1.65.26 → 1.65.28

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 (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/hooks/useModularUI.js +1 -1
  3. package/esm/hooks/useModularUI.js.flow +1 -1
  4. package/esm/hooks/useModularUI.js.map +1 -1
  5. package/esm/hooks/useModularUIModel.js +1 -0
  6. package/esm/hooks/useModularUIModel.js.flow +1 -0
  7. package/esm/hooks/useModularUIModel.js.map +1 -1
  8. package/esm/modularui/ModularUIRequest.js +10 -8
  9. package/esm/modularui/ModularUIRequest.js.flow +8 -10
  10. package/esm/modularui/ModularUIRequest.js.map +1 -1
  11. package/esm/react-server/__tests__/serverUtil.spec.js.flow +1 -1
  12. package/esm/react-server/contextPath.js +0 -1
  13. package/esm/react-server/contextPath.js.flow +0 -2
  14. package/esm/react-server/contextPath.js.map +1 -1
  15. package/esm/react-server/serverUtil.js +11 -5
  16. package/esm/react-server/serverUtil.js.flow +13 -9
  17. package/esm/react-server/serverUtil.js.map +1 -1
  18. package/esm/redux/_i18n/I18nReducer.js +3 -1
  19. package/esm/redux/_i18n/I18nReducer.js.flow +2 -1
  20. package/esm/redux/_i18n/I18nReducer.js.map +1 -1
  21. package/esm/redux/_modularui/ModularUIActions.js +4 -1
  22. package/esm/redux/_modularui/ModularUIActions.js.flow +2 -1
  23. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  24. package/esm/redux/actions/Preferences.js +16 -8
  25. package/esm/redux/actions/Preferences.js.flow +16 -8
  26. package/esm/redux/actions/Preferences.js.map +1 -1
  27. package/esm/utils/fetch/xhr.js +3 -1
  28. package/esm/utils/fetch/xhr.js.flow +2 -1
  29. package/esm/utils/fetch/xhr.js.map +1 -1
  30. package/lib/hooks/useModularUI.js +1 -1
  31. package/lib/hooks/useModularUI.js.map +1 -1
  32. package/lib/hooks/useModularUIModel.js +1 -0
  33. package/lib/hooks/useModularUIModel.js.map +1 -1
  34. package/lib/modularui/ModularUIRequest.js +10 -8
  35. package/lib/modularui/ModularUIRequest.js.map +1 -1
  36. package/lib/react-server/contextPath.js +0 -3
  37. package/lib/react-server/contextPath.js.map +1 -1
  38. package/lib/react-server/serverUtil.js +10 -3
  39. package/lib/react-server/serverUtil.js.map +1 -1
  40. package/lib/redux/_i18n/I18nReducer.js +3 -1
  41. package/lib/redux/_i18n/I18nReducer.js.map +1 -1
  42. package/lib/redux/_modularui/ModularUIActions.js +4 -1
  43. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  44. package/lib/redux/actions/Preferences.js +16 -8
  45. package/lib/redux/actions/Preferences.js.map +1 -1
  46. package/lib/utils/fetch/xhr.js +3 -1
  47. package/lib/utils/fetch/xhr.js.map +1 -1
  48. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.65.28](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.27...v1.65.28) (2026-02-02)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **hooks:** ensure `removeOnUnmount` is respected in `useModularUIModel` ([3f28a63](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/3f28a63d5f0d8898a9a59a98d66869ed6cba2fa6))
11
+
12
+ ## [1.65.27](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.26...v1.65.27) (2026-01-31)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **graal:** replace `global` with `globalThis` and check global api's on globalThis ([149e027](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/149e027866df81e2e209246d8f35874b767ce6fd))
18
+
5
19
  ## [1.65.26](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.25...v1.65.26) (2026-01-30)
6
20
 
7
21
 
@@ -40,7 +40,7 @@ export const useModularUI = (modelKey, url, options = {}) => {
40
40
  const requestOptions = useMemo(() => {
41
41
  const merged = {
42
42
  method: HTTP_METHODS.GET,
43
- removeOnUnmount: false,
43
+ removeOnUnmount: true,
44
44
  ...options
45
45
  };
46
46
  if (url instanceof Href) {
@@ -55,7 +55,7 @@ export const useModularUI = (
55
55
  const requestOptions = useMemo(() => {
56
56
  const merged = {
57
57
  method: HTTP_METHODS.GET,
58
- removeOnUnmount: false,
58
+ removeOnUnmount: true,
59
59
  ...options,
60
60
  };
61
61
 
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useEffect","useMemo","useRef","useDispatch","useSelector","useLocation","HTTP_METHODS","MODULARUI_STATUS","loadModularUI","removeModelByKey","useDeepCompareEffect","useModularUIKey","Href","useModularUI","modelKey","url","options","dispatch","hrefInstance","requestUrl","toString","currentQueryString","querystring","prevQueryRef","key","model","state","modularui","requestOptions","merged","method","GET","removeOnUnmount","origin","contextPath","location","redirectLocation","shouldLoad","status","ERROR","current","equals","isReload"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\nimport { useModularUIKey } from \"./useModularUIKey\";\n\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\nimport type { ModelEntry } from \"../redux\";\n\n/**\n * A custom hook to fetch and manage Be Informed modular UI resources.\n * It handles automatic data fetching based on URL/query changes, manages Redux state\n * synchronization, and provides cleanup logic when components unmount.\n *\n * @param {string} modelKey - A unique identifier for the type of model being fetched.\n * @param {string | Href} url - The endpoint URL or Href instance to fetch data from.\n * @param {RequestModularUIOptions} options - Configuration for the request (method, headers, etc.).\n * @returns {ModelEntry} The model data retrieved from the Redux store.\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = (({}: any): RequestModularUIOptions),\n): any => {\n const dispatch = useDispatch();\n\n // Normalize the URL input into a Href instance to safely access query params and paths\n const hrefInstance = useMemo(() => new Href(url), [url]);\n const requestUrl = useMemo(() => hrefInstance.toString(), [hrefInstance]);\n const currentQueryString = hrefInstance.querystring;\n\n // Persistence ref to detect if query parameters have changed between renders\n const prevQueryRef = useRef(currentQueryString);\n\n // Generate a unique key for the Redux store based on the model type and the full URL\n const key = useModularUIKey(modelKey, requestUrl);\n\n // Select the specific piece of state corresponding to this modular UI component\n const model = useSelector((state) => state.modularui[key]);\n\n /**\n * Memoize request options to prevent unnecessary re-renders.\n * Merges default settings (GET method, auto-cleanup) with user-provided options.\n */\n const requestOptions = useMemo(() => {\n const merged = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n ...options,\n };\n\n if (url instanceof Href) {\n merged.origin = merged.origin ?? url.origin;\n merged.contextPath = merged.contextPath ?? url.contextPath;\n }\n return merged;\n }, [options, url]);\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n\n /**\n * Determines if a network request should be initiated.\n * Logic includes:\n * - Model doesn't exist yet (Initial load)\n * - Previous request resulted in an error (Retry)\n * - The query parameters changed (Filtering/Paging)\n * - A redirect was triggered specifically for this URL\n * - Manual 'isReload' flag is passed in options\n */\n const shouldLoad =\n model == null ||\n model.status === MODULARUI_STATUS.ERROR ||\n prevQueryRef.current !== currentQueryString ||\n (redirectLocation instanceof Href\n ? redirectLocation.equals(requestUrl)\n : false) ||\n requestOptions.isReload === true;\n\n // Synchronize the ref after the render cycle determines if we should load\n useEffect(() => {\n prevQueryRef.current = currentQueryString;\n }, [currentQueryString]);\n\n // Execute the load action. Deep compare is used on options to prevent\n // infinite loops caused by passing inline object literals.\n useDeepCompareEffect(() => {\n if (requestUrl !== \"\" && shouldLoad) {\n dispatch(loadModularUI(key, requestUrl, requestOptions));\n }\n }, [key, requestUrl, requestOptions, shouldLoad]);\n\n // Cleanup Effect:\n // If 'removeOnUnmount' is true, this removes the model data from the Redux store\n // when the component using this hook is destroyed.\n useEffect(() => {\n if (requestOptions.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, requestOptions.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,cAAc;AAE1C,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAC7D,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,OAAOC,IAAI,MAAM,qBAAqB;AAKtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,QAAgB,EAChBC,GAAkB,EAClBC,OAAgC,GAAK,CAAC,CAAiC,KAC/D;EACR,MAAMC,QAAQ,GAAGd,WAAW,CAAC,CAAC;;EAE9B;EACA,MAAMe,YAAY,GAAGjB,OAAO,CAAC,MAAM,IAAIW,IAAI,CAACG,GAAG,CAAC,EAAE,CAACA,GAAG,CAAC,CAAC;EACxD,MAAMI,UAAU,GAAGlB,OAAO,CAAC,MAAMiB,YAAY,CAACE,QAAQ,CAAC,CAAC,EAAE,CAACF,YAAY,CAAC,CAAC;EACzE,MAAMG,kBAAkB,GAAGH,YAAY,CAACI,WAAW;;EAEnD;EACA,MAAMC,YAAY,GAAGrB,MAAM,CAACmB,kBAAkB,CAAC;;EAE/C;EACA,MAAMG,GAAG,GAAGb,eAAe,CAACG,QAAQ,EAAEK,UAAU,CAAC;;EAEjD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CAACgB,GAAG,EAAEL,UAAU,EAAES,cAAc,CAAC,CAAC;IAC1D;EACF,CAAC,EAAE,CAACJ,GAAG,EAAEL,UAAU,EAAES,cAAc,EAAES,UAAU,CAAC,CAAC;;EAEjD;EACA;EACA;EACArC,SAAS,CAAC,MAAM;IACd,IAAI4B,cAAc,CAACI,eAAe,EAAE;MAClC,OAAO,MAAM;QACXf,QAAQ,CAACR,gBAAgB,CAACe,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACP,QAAQ,EAAEO,GAAG,EAAEI,cAAc,CAACI,eAAe,CAAC,CAAC;EAEnD,OAAOP,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUI.js","names":["useEffect","useMemo","useRef","useDispatch","useSelector","useLocation","HTTP_METHODS","MODULARUI_STATUS","loadModularUI","removeModelByKey","useDeepCompareEffect","useModularUIKey","Href","useModularUI","modelKey","url","options","dispatch","hrefInstance","requestUrl","toString","currentQueryString","querystring","prevQueryRef","key","model","state","modularui","requestOptions","merged","method","GET","removeOnUnmount","origin","contextPath","location","redirectLocation","shouldLoad","status","ERROR","current","equals","isReload"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\nimport { useModularUIKey } from \"./useModularUIKey\";\n\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\nimport type { ModelEntry } from \"../redux\";\n\n/**\n * A custom hook to fetch and manage Be Informed modular UI resources.\n * It handles automatic data fetching based on URL/query changes, manages Redux state\n * synchronization, and provides cleanup logic when components unmount.\n *\n * @param {string} modelKey - A unique identifier for the type of model being fetched.\n * @param {string | Href} url - The endpoint URL or Href instance to fetch data from.\n * @param {RequestModularUIOptions} options - Configuration for the request (method, headers, etc.).\n * @returns {ModelEntry} The model data retrieved from the Redux store.\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = (({}: any): RequestModularUIOptions),\n): any => {\n const dispatch = useDispatch();\n\n // Normalize the URL input into a Href instance to safely access query params and paths\n const hrefInstance = useMemo(() => new Href(url), [url]);\n const requestUrl = useMemo(() => hrefInstance.toString(), [hrefInstance]);\n const currentQueryString = hrefInstance.querystring;\n\n // Persistence ref to detect if query parameters have changed between renders\n const prevQueryRef = useRef(currentQueryString);\n\n // Generate a unique key for the Redux store based on the model type and the full URL\n const key = useModularUIKey(modelKey, requestUrl);\n\n // Select the specific piece of state corresponding to this modular UI component\n const model = useSelector((state) => state.modularui[key]);\n\n /**\n * Memoize request options to prevent unnecessary re-renders.\n * Merges default settings (GET method, auto-cleanup) with user-provided options.\n */\n const requestOptions = useMemo(() => {\n const merged = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: true,\n ...options,\n };\n\n if (url instanceof Href) {\n merged.origin = merged.origin ?? url.origin;\n merged.contextPath = merged.contextPath ?? url.contextPath;\n }\n return merged;\n }, [options, url]);\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n\n /**\n * Determines if a network request should be initiated.\n * Logic includes:\n * - Model doesn't exist yet (Initial load)\n * - Previous request resulted in an error (Retry)\n * - The query parameters changed (Filtering/Paging)\n * - A redirect was triggered specifically for this URL\n * - Manual 'isReload' flag is passed in options\n */\n const shouldLoad =\n model == null ||\n model.status === MODULARUI_STATUS.ERROR ||\n prevQueryRef.current !== currentQueryString ||\n (redirectLocation instanceof Href\n ? redirectLocation.equals(requestUrl)\n : false) ||\n requestOptions.isReload === true;\n\n // Synchronize the ref after the render cycle determines if we should load\n useEffect(() => {\n prevQueryRef.current = currentQueryString;\n }, [currentQueryString]);\n\n // Execute the load action. Deep compare is used on options to prevent\n // infinite loops caused by passing inline object literals.\n useDeepCompareEffect(() => {\n if (requestUrl !== \"\" && shouldLoad) {\n dispatch(loadModularUI(key, requestUrl, requestOptions));\n }\n }, [key, requestUrl, requestOptions, shouldLoad]);\n\n // Cleanup Effect:\n // If 'removeOnUnmount' is true, this removes the model data from the Redux store\n // when the component using this hook is destroyed.\n useEffect(() => {\n if (requestOptions.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, requestOptions.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,cAAc;AAE1C,SAASC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAC7D,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,OAAOC,IAAI,MAAM,qBAAqB;AAKtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,QAAgB,EAChBC,GAAkB,EAClBC,OAAgC,GAAK,CAAC,CAAiC,KAC/D;EACR,MAAMC,QAAQ,GAAGd,WAAW,CAAC,CAAC;;EAE9B;EACA,MAAMe,YAAY,GAAGjB,OAAO,CAAC,MAAM,IAAIW,IAAI,CAACG,GAAG,CAAC,EAAE,CAACA,GAAG,CAAC,CAAC;EACxD,MAAMI,UAAU,GAAGlB,OAAO,CAAC,MAAMiB,YAAY,CAACE,QAAQ,CAAC,CAAC,EAAE,CAACF,YAAY,CAAC,CAAC;EACzE,MAAMG,kBAAkB,GAAGH,YAAY,CAACI,WAAW;;EAEnD;EACA,MAAMC,YAAY,GAAGrB,MAAM,CAACmB,kBAAkB,CAAC;;EAE/C;EACA,MAAMG,GAA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,EAAE,IAAIkB,UAAU,EAAE;MACnCpB,QAAQ,CAACT,aAAa,CAACgB,GAAG,EAAEL,UAAU,EAAES,cAAc,CAAC,CAAC;IAC1D;EACF,CAAC,EAAE,CAACJ,GAAG,EAAEL,UAAU,EAAES,cAAc,EAAES,UAAU,CAAC,CAAC;;EAEjD;EACA;EACA;EACArC,SAAS,CAAC,MAAM;IACd,IAAI4B,cAAc,CAACI,eAAe,EAAE;MAClC,OAAO,MAAM;QACXf,QAAQ,CAACR,gBAAgB,CAACe,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACP,QAAQ,EAAEO,GAAG,EAAEI,cAAc,CAACI,eAAe,CAAC,CAAC;EAEnD,OAAOP,KAAK;AACd,CAAC","ignoreList":[]}
@@ -11,6 +11,7 @@ import { useModularUIBasic } from "./useModularUIBasic";
11
11
  export const useApplication = options => useModularUIBasic("application", "/", {
12
12
  expectedModels: ["Application"],
13
13
  targetModel: ApplicationModel,
14
+ removeOnUnmount: options?.removeOnUnmount ?? false,
14
15
  ...options
15
16
  });
16
17
 
@@ -20,6 +20,7 @@ export const useApplication = (
20
20
  useModularUIBasic("application", "/", {
21
21
  expectedModels: ["Application"],
22
22
  targetModel: ApplicationModel,
23
+ removeOnUnmount: options?.removeOnUnmount ?? false,
23
24
  ...options,
24
25
  });
25
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIModel.js","names":["ApplicationModel","CaseViewModel","TabModel","GroupingPanelModel","DetailModel","UserProfileModel","useModularUIBasic","useApplication","options","expectedModels","targetModel","useTab","href","useCaseView","useGroupingPanel","useDetailPanel","useUserProfile"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type Href from \"../models/href/Href\";\nimport type { HookOptions } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (\n options?: HookOptions,\n): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n ...options,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (\n href: string | Href,\n options?: HookOptions,\n): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n ...options,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (\n href: string | Href,\n options?: HookOptions,\n): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n ...options,\n });\n\n/**\n */\nexport const useGroupingPanel = (\n href: string | Href,\n options?: HookOptions,\n): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n ...options,\n });\n\n/**\n */\nexport const useDetailPanel = (\n href: string | Href,\n options?: HookOptions,\n): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n ...options,\n });\n\n/**\n */\nexport const useUserProfile = (\n href: string | Href,\n options?: HookOptions,\n): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n ...options,\n });\n"],"mappings":"AACA,OAAOA,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,gBAAgB,MAAM,iCAAiC;AAE9D,SAASC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AE;EACrCH,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEL,gBAAgB;EAC7B,GAAGG;AACL,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIModel.js","names":["ApplicationModel","CaseViewModel","TabModel","GroupingPanelModel","DetailModel","UserProfileModel","useModularUIBasic","useApplication","options","expectedModels","targetModel","removeOnUnmount","useTab","href","useCaseView","useGroupingPanel","useDetailPanel","useUserProfile"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type Href from \"../models/href/Href\";\nimport type { HookOptions } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (\n options?: HookOptions,\n): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n removeOnUnmount: options?.removeOnUnmount ?? false,\n ...options,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (\n href: string | Href,\n options?: HookOptions,\n): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n ...options,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (\n href: string | Href,\n options?: HookOptions,\n): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n ...options,\n });\n\n/**\n */\nexport const useGroupingPanel = (\n href: string | Href,\n options?: HookOptions,\n): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n ...options,\n });\n\n/**\n */\nexport const useDetailPanel = (\n href: string | Href,\n options?: HookOptions,\n): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n ...options,\n });\n\n/**\n */\nexport const useUserProfile = (\n href: string | Href,\n options?: HookOptions,\n): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n ...options,\n });\n"],"mappings":"AACA,OAAOA,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,gBAAgB,MAAM,iCAAiC;AAE9D,SAASC,iBAAiB,QAAQ,qBAAqB;AAKvD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GACzBC,OAAqB,IAErBF,iBAAiB,CAAC,aAAa,EAAE,GAAG,EAAE;EACpCG,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEV,gBAAgB;EAC7BW,eAAe,EAAEH,OAAO,EAAEG,eAAe,IAAI,KAAK;EAClD,GAAGH;AACL,CAAC,CAAC;;AAEJ;AACA;AACA;AACA,OAAO,MAAMI,MAAM,GAAGA,CACpBC,IAAmB,EACnBL,OAAqB,KAErBF,iBAAiB,CAAC,KAAK,EAAEO,IAAI,EAAE;EAC7BJ,cAAc,EAAE,CAAC,KAAK,CAAC;EACvBC,WAAW,EAAER,QAAQ;EACrB,GAAGM;AACL,CAAC,CAAC;;AAEJ;AACA;AACA;AACA,OAAO,MAAMM,WAAW,GAAGA,CACzBD,IAAmB,EACnBL,OAAqB,KAErBF,iBAAiB,CAAC,UAAU,EAAEO,IAAI,EAAE;EAClCJ,cAAc,EAAE,CAAC,UAAU,CAAC;EAC5BC,WAAW,EAAET,aAAa;EAC1B,GAAGO;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMO,gBAAgB,GAAGA,CAC9BF,IAAmB,EACnBL,OAAqB,KAErBF,iBAAiB,CAAC,eAAe,EAAEO,IAAI,EAAE;EACvCJ,cAAc,EAAE,CAAC,eAAe,CAAC;EACjCC,WAAW,EAAEP,kBAAkB;EAC/B,GAAGK;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMQ,cAAc,GAAGA,CAC5BH,IAAmB,EACnBL,OAAqB,KAErBF,iBAAiB,CAAC,aAAa,EAAEO,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,QAAQ,CAAC;EAC1BC,WAAW,EAAEN,WAAW;EACxB,GAAGI;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMS,cAAc,GAAGA,CAC5BJ,IAAmB,EACnBL,OAAqB,KAErBF,iBAAiB,CAAC,aAAa,EAAEO,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEL,gBAAgB;EAC7B,GAAGG;AACL,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
2
+ import _globalThis from "@babel/runtime-corejs3/core-js/global-this";
2
3
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
4
  import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
4
5
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
@@ -77,7 +78,9 @@ class ModularUIRequest {
77
78
  if (optionLocale) {
78
79
  return optionLocale;
79
80
  }
80
- return navigator?.language?.split("-")[0] || "en";
81
+
82
+ // $FlowIssue
83
+ return _globalThis.navigator?.language?.split("-")[0] || "en";
81
84
  }
82
85
 
83
86
  /**
@@ -235,7 +238,7 @@ class ModularUIRequest {
235
238
  }
236
239
  }
237
240
  const Model = resolveModel(this.response, availableModels);
238
- if (Model && Model.isApplicableModel) {
241
+ if (Model?.isApplicableModel) {
239
242
  return Model;
240
243
  }
241
244
  if (availableModels) {
@@ -292,7 +295,7 @@ class ModularUIRequest {
292
295
  this.response.key = key;
293
296
  this.response.data = data;
294
297
  const links = data._links;
295
- if (links && links.contributions) {
298
+ if (links?.contributions) {
296
299
  this.contributionsHref = links.contributions.href;
297
300
  } else if (Array.isArray(links) && links[0].contributions) {
298
301
  this.contributionsHref = links[0].contributions.href;
@@ -350,7 +353,6 @@ class ModularUIRequest {
350
353
  await this.processTabLinks();
351
354
  }
352
355
  await this.processPanelLinks();
353
- return _Promise.resolve();
354
356
  }
355
357
 
356
358
  /**
@@ -523,7 +525,7 @@ class ModularUIRequest {
523
525
  * First load of dynamic values when a form is loaded
524
526
  */
525
527
  loadDynamicValidations(model) {
526
- if (!this.options.isValidationRequest && getSetting("USE_INSTANT_SERVER_VALIDATION") && model instanceof FormModel && model.currentFormObject && model.currentFormObject.hasDynamicValidations) {
528
+ if (!this.options.isValidationRequest && getSetting("USE_INSTANT_SERVER_VALIDATION") && model instanceof FormModel && model.currentFormObject?.hasDynamicValidations) {
527
529
  const validationHref = this.href.setParameter("commit", "false");
528
530
  return universalFetch({
529
531
  ...this.requestOptions,
@@ -556,11 +558,11 @@ class ModularUIRequest {
556
558
  }
557
559
  this.processContributionsService(contributionsData);
558
560
  return this.processAsyncLayoutHints();
559
- }).then(() => _Promise.resolve(this.createModel())).then(model => this.loadDynamicValidations(model)).then(model => {
561
+ }).then(() => this.createModel()).then(model => this.loadDynamicValidations(model)).then(model => {
560
562
  if (this.withChildModels) {
561
563
  return this.fetchChildModels(model);
562
564
  }
563
- return _Promise.resolve(model);
565
+ return model;
564
566
  });
565
567
  }
566
568
 
@@ -622,7 +624,7 @@ class ModularUIRequest {
622
624
  if (withChildSections && model instanceof ContentModel && model.childSectionLinks.length > 0) {
623
625
  return this.fetchContentChildSections(model);
624
626
  }
625
- return _Promise.resolve(model);
627
+ return model;
626
628
  });
627
629
  }
628
630
 
@@ -103,7 +103,8 @@ class ModularUIRequest {
103
103
  return optionLocale;
104
104
  }
105
105
 
106
- return navigator?.language?.split("-")[0] || "en";
106
+ // $FlowIssue
107
+ return globalThis.navigator?.language?.split("-")[0] || "en";
107
108
  }
108
109
 
109
110
  /**
@@ -271,7 +272,7 @@ class ModularUIRequest {
271
272
  availableModels,
272
273
  );
273
274
 
274
- if (Model && Model.isApplicableModel) {
275
+ if (Model?.isApplicableModel) {
275
276
  return Model;
276
277
  }
277
278
 
@@ -350,7 +351,7 @@ class ModularUIRequest {
350
351
 
351
352
  const links = data._links;
352
353
 
353
- if (links && links.contributions) {
354
+ if (links?.contributions) {
354
355
  this.contributionsHref = links.contributions.href;
355
356
  } else if (Array.isArray(links) && links[0].contributions) {
356
357
  this.contributionsHref = links[0].contributions.href;
@@ -412,8 +413,6 @@ class ModularUIRequest {
412
413
  await this.processTabLinks();
413
414
  }
414
415
  await this.processPanelLinks();
415
-
416
- return Promise.resolve();
417
416
  }
418
417
 
419
418
  /**
@@ -634,8 +633,7 @@ class ModularUIRequest {
634
633
  !this.options.isValidationRequest &&
635
634
  getSetting("USE_INSTANT_SERVER_VALIDATION") &&
636
635
  model instanceof FormModel &&
637
- model.currentFormObject &&
638
- model.currentFormObject.hasDynamicValidations
636
+ model.currentFormObject?.hasDynamicValidations
639
637
  ) {
640
638
  const validationHref = this.href.setParameter("commit", "false");
641
639
  return universalFetch({
@@ -678,14 +676,14 @@ class ModularUIRequest {
678
676
  this.processContributionsService(contributionsData);
679
677
  return this.processAsyncLayoutHints();
680
678
  })
681
- .then(() => Promise.resolve(this.createModel()))
679
+ .then(() => this.createModel())
682
680
  .then((model) => this.loadDynamicValidations(model))
683
681
  .then((model) => {
684
682
  if (this.withChildModels) {
685
683
  return this.fetchChildModels(model);
686
684
  }
687
685
 
688
- return Promise.resolve(model);
686
+ return model;
689
687
  });
690
688
  }
691
689
 
@@ -764,7 +762,7 @@ class ModularUIRequest {
764
762
  return this.fetchContentChildSections(model);
765
763
  }
766
764
 
767
- return Promise.resolve(model);
765
+ return model;
768
766
  });
769
767
  }
770
768
 
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIRequest.js","names":["deepmerge","HTTP_METHODS","TIMEVERSION_FILTER_NAME","HIDE_WHEN_EMPTY","getBasePathModularUI","getSetting","Href","universalFetch","resolveModel","FormModel","ContentModel","ErrorResponse","ModularUIResponse","ModularUIError","IllegalArgumentException","IllegalStateException","isPlainObject","ModularUIRequest","constructor","href","options","_defineProperty","GET","_response","locale","getRequestLocale","parameters","contextPath","origin","targetModel","method","optionLocale","navigator","language","split","_origin","_contextPath","contributionsHref","_contributionsHref","_locale","response","_href","_method","_options","requestOptions","forceTargetModel","updateHandler","childmodels","isValidationRequest","removeOnUnmount","withChildModels","_targetModel","_forceTargetModel","availableModels","Array","isArray","Model","isApplicableModel","toString","_mapInstanceProperty","call","m","modelName","join","_JSON$stringify","createModel","processContributionsService","contributionsData","contributionsKey","_Object$keys","error","handleContributionsError","key","contributions","errorMessage","properties","message","handleDataError","absolutepath","handleData","data","links","_links","processDataService","fetchContributionsService","url","cache","fetchDataService","path","params","getQuerystringForModularUI","onProgress","processAsyncLayoutHints","processApplicationLinks","processTabLinks","processPanelLinks","_Promise","resolve","contributionLinks","dataLinks","contributionTabLink","tab","_context","dataTabLinks","_findInstanceProperty","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","_context2","tabLink","component","panel","dataLinksPerName","linksPerName","hideWhenEmptyLinks","_filterInstanceProperty","contributionLink","_context3","layouthint","Function","bind","_includesInstanceProperty","isHiddenListChecks","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","HIDE_WHEN_EMPTY_IGNORE_TASKS","_embedded","actions","noListItems","noActions","isHidden","catch","progressEvent","_progressEvent","getDynamicValidationData","model","prevData","JSON","parse","newData","validationData","loadDynamicValidations","currentFormObject","hasDynamicValidations","validationHref","setParameter","updateValidations","fetch","Error","fetchChildModels","fetchFromCache","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","allSettled","childModels","resolvedChildModels","errorChildModels","forEach","childModel","status","reason","console","debug","value","addChildModels","fetchContent","withChildSections","childSectionLinks","length","fetchContentChildSections","contentModel","_context4","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","entryDate","sectionModels","childSections","post","POST","postForm","form","formdata","update","fetchSync","headers","dataString","dataFetcher","contributionsString"],"sources":["../../src/modularui/ModularUIRequest.js"],"sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport { HTTP_METHODS, TIMEVERSION_FILTER_NAME } from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getBasePathModularUI, getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\nimport ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { TargetModel } from \"./types\";\nimport type {\n RequestBaseOptions,\n RequestModularUIOptions,\n} from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestModularUIOptions;\n _targetModel: ?TargetModel;\n _forceTargetModel: boolean = false;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n /**\n */\n constructor(\n href: Href | string,\n options: $Shape<RequestModularUIOptions> = {},\n ) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\",\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = this.getRequestLocale(options.locale);\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.contextPath) {\n this.contextPath = options.contextPath;\n } else if (this.href.contextPath) {\n this.contextPath = this.href.contextPath;\n }\n\n if (options.origin) {\n this.origin = options.origin;\n } else if (this.href.origin) {\n this.origin = this.href.origin;\n }\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n * Retrieve the preferred language for this request, falls back to the browser language or english\n */\n getRequestLocale(optionLocale: ?string): string {\n if (optionLocale) {\n return optionLocale;\n }\n\n return navigator?.language?.split(\"-\")[0] || \"en\";\n }\n\n /**\n */\n get origin(): string {\n return this._origin;\n }\n\n /**\n */\n set origin(origin: ?string) {\n this._origin = origin ?? \"\";\n this._response.origin = origin ?? \"\";\n }\n\n /**\n */\n get contextPath(): string {\n return this._contextPath;\n }\n\n /**\n */\n set contextPath(contextPath: ?string) {\n this._contextPath = contextPath ?? getBasePathModularUI();\n this._response.contextPath = contextPath ?? getBasePathModularUI();\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestModularUIOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n get requestOptions(): RequestBaseOptions {\n /* eslint-disable no-unused-vars */\n const {\n targetModel,\n forceTargetModel,\n updateHandler,\n childmodels,\n isValidationRequest,\n removeOnUnmount,\n ...requestOptions\n } = this.options;\n /* eslint-enable no-unused-vars */\n return requestOptions;\n }\n\n /**\n */\n set options(options: RequestModularUIOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: TargetModel) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?TargetModel {\n return this._targetModel;\n }\n\n /**\n */\n set forceTargetModel(forceTargetModel: boolean) {\n this._forceTargetModel = forceTargetModel ?? false;\n }\n\n /**\n */\n get forceTargetModel(): boolean {\n return this._forceTargetModel;\n }\n\n /**\n */\n resolveModel(): Class<ModularUIModel> {\n let availableModels;\n if (this.targetModel) {\n availableModels = Array.isArray(this.targetModel)\n ? [...this.targetModel]\n : [this.targetModel];\n\n if (this.forceTargetModel) {\n return availableModels[0];\n }\n }\n\n const Model: Class<ModularUIModel> | null = resolveModel(\n this.response,\n availableModels,\n );\n\n if (Model && Model.isApplicableModel) {\n return Model;\n }\n\n if (availableModels) {\n throw new IllegalStateException(\n `data for ${this.href.toString()} is not applicable for model(s): ${availableModels\n .map((m) => m.modelName)\n .join(\", \")}, received response: ${JSON.stringify(this.response)}`,\n );\n }\n\n throw new IllegalStateException(\n `no javascript model is applicable for received request of ${this.href.toString()}, with response: ${JSON.stringify(\n this.response,\n )}`,\n );\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.resolveModel();\n return new Model(this.response);\n }\n\n /**\n */\n processContributionsService(contributionsData: Object): void {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\",\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object): void {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object): void {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(\n errorMessage,\n error,\n this.href.absolutepath.toString(),\n );\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object): void {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links && links.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`,\n );\n }\n }\n\n /**\n */\n processDataService(data: Object): void {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${this.origin}${this.contextPath}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n\n return Promise.resolve();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name,\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components,\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks),\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n },\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component,\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel,\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Retrieve an object of key: link\n */\n dataLinksPerName(dataLinks: any): { [linkName: string]: any } {\n if (Array.isArray(dataLinks)) {\n const links = {};\n for (const dataLink of dataLinks) {\n links[dataLink.name] = dataLink;\n }\n return links;\n }\n return dataLinks;\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any,\n ): Promise<Object | Array<Object>> {\n const linksPerName = this.dataLinksPerName(dataLinks);\n const hideWhenEmptyLinks = contributionLinks.filter((contributionLink) =>\n contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY),\n );\n\n const isHiddenListChecks = [];\n\n for (const contributionLink of hideWhenEmptyLinks) {\n const dataLink = linksPerName[contributionLink.name];\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href),\n );\n }\n }\n\n return Promise.all(isHiddenListChecks).then(\n (hiddenLinks: Array<string>) => {\n if (Array.isArray(dataLinks)) {\n return dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name),\n );\n }\n\n const newDataLinks: { [string]: any } = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n return newDataLinks;\n },\n );\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<string> {\n const HIDE_WHEN_EMPTY_IGNORE_TASKS = getSetting(\n \"HIDE_WHEN_EMPTY_IGNORE_TASKS\",\n false,\n );\n\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const noListItems = _embedded === null;\n const noActions = actions == null || HIDE_WHEN_EMPTY_IGNORE_TASKS;\n\n const isHidden = noListItems && noActions;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n // $FlowFixMe incompatible-call\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject &&\n model.currentFormObject.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\" || Array.isArray(data)) {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`,\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => Promise.resolve(this.createModel()))\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n const errorChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n // eslint-disable-next-line no-console\n console.debug(\n \"Unexpected error when retrieving child model:\",\n reason,\n );\n }\n errorChildModels.push(\n new ErrorResponse(reason, \"\", {\n origin: this.origin,\n contextPath: this.contextPath,\n }),\n );\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels, errorChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate,\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n }),\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n\n /**\n * Make a post request with optionally data to send\n * @param data\n */\n post(data?: string | { [key: string]: string }): Promise<ModularUIModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data,\n };\n\n return this.fetch();\n }\n\n /**\n * Make a POST request using the form, an updated form is returned (merge of old and new form)\n * @param form\n * @returns {Promise<FormModel>}\n */\n postForm(form: FormModel): Promise<FormModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data: form.formdata,\n };\n\n return this.fetch().then((response) => {\n return form.update(response);\n });\n }\n\n /**\n * Simplified synchronous version of fetch (returns the model, not a Promise)\n * This can be used on the server to retrieve a model. It only loads the request url and it's child models\n */\n fetchSync(): ModularUIModel {\n const options = { headers: { \"Accept-Language\": this.locale } };\n\n const dataString = dataFetcher.fetch(this.href.toString(), options);\n if (dataString == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(JSON.parse(dataString));\n\n const contributionsString = dataFetcher.fetch(\n this.contributionsHref.toString(),\n options,\n );\n if (contributionsString == null) {\n throw new Error(\n `No constributions received for ${this.contributionsHref.toString()}`,\n );\n }\n this.processContributionsService(JSON.parse(contributionsString));\n\n const model = this.createModel();\n\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModels = childModelLinks.map((childModelLink) => {\n return new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n }).fetchSync();\n });\n model.addChildModels(childModels, []);\n\n return model;\n }\n}\n\nexport default ModularUIRequest;\n"],"mappings":";;;;;;;;AACA,OAAOA,SAAS,MAAM,WAAW;AAEjC,SAASC,YAAY,EAAEC,uBAAuB,QAAQ,wBAAwB;AAE9E,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,SAASC,oBAAoB,EAAEC,UAAU,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ACiB,yBAAyB,CAAC,CAAC;IAEzD,MAAMM,WAAW,GAAG5G,oBAAA,CAAAqG,eAAe,EAAApG,IAAA,CAAfoG,eAAe,EAAMG,cAAc,IAAK;MAC1D,OAAO,IAAIlJ,gBAAgB,CAACkJ,cAAc,CAAChJ,IAAI,EAAE;QAC/CK,MAAM,EAAE,IAAI,CAACA;MACf,CAAC,CAAC,CAACgL,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC;IACFxD,KAAK,CAACiC,cAAc,CAACV,WAAW,EAAE,EAAE,CAAC;IAErC,OAAOvB,KAAK;EACd;AACF;AAEA,eAAe/H,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIRequest.js","names":["deepmerge","HTTP_METHODS","TIMEVERSION_FILTER_NAME","HIDE_WHEN_EMPTY","getBasePathModularUI","getSetting","Href","universalFetch","resolveModel","FormModel","ContentModel","ErrorResponse","ModularUIResponse","ModularUIError","IllegalArgumentException","IllegalStateException","isPlainObject","ModularUIRequest","constructor","href","options","_defineProperty","GET","_response","locale","getRequestLocale","parameters","contextPath","origin","targetModel","method","optionLocale","_globalThis","navigator","language","split","_origin","_contextPath","contributionsHref","_contributionsHref","_locale","response","_href","_method","_options","requestOptions","forceTargetModel","updateHandler","childmodels","isValidationRequest","removeOnUnmount","withChildModels","_targetModel","_forceTargetModel","availableModels","Array","isArray","Model","isApplicableModel","toString","_mapInstanceProperty","call","m","modelName","join","_JSON$stringify","createModel","processContributionsService","contributionsData","contributionsKey","_Object$keys","error","handleContributionsError","key","contributions","errorMessage","properties","message","handleDataError","absolutepath","handleData","data","links","_links","processDataService","fetchContributionsService","url","cache","fetchDataService","path","params","getQuerystringForModularUI","onProgress","processAsyncLayoutHints","processApplicationLinks","processTabLinks","processPanelLinks","contributionLinks","dataLinks","_Promise","resolve","contributionTabLink","tab","_context","dataTabLinks","_findInstanceProperty","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","_context2","tabLink","component","panel","dataLinksPerName","linksPerName","hideWhenEmptyLinks","_filterInstanceProperty","contributionLink","_context3","layouthint","Function","bind","_includesInstanceProperty","isHiddenListChecks","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","HIDE_WHEN_EMPTY_IGNORE_TASKS","_embedded","actions","noListItems","noActions","isHidden","catch","progressEvent","_progressEvent","getDynamicValidationData","model","prevData","JSON","parse","newData","validationData","loadDynamicValidations","currentFormObject","hasDynamicValidations","validationHref","setParameter","updateValidations","fetch","Error","fetchChildModels","fetchFromCache","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","allSettled","childModels","resolvedChildModels","errorChildModels","forEach","childModel","status","reason","console","debug","value","addChildModels","fetchContent","withChildSections","childSectionLinks","length","fetchContentChildSections","contentModel","_context4","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","entryDate","sectionModels","childSections","post","POST","postForm","form","formdata","update","fetchSync","headers","dataString","dataFetcher","contributionsString"],"sources":["../../src/modularui/ModularUIRequest.js"],"sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport { HTTP_METHODS, TIMEVERSION_FILTER_NAME } from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getBasePathModularUI, getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\nimport ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { TargetModel } from \"./types\";\nimport type {\n RequestBaseOptions,\n RequestModularUIOptions,\n} from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestModularUIOptions;\n _targetModel: ?TargetModel;\n _forceTargetModel: boolean = false;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n _origin: string = \"\";\n _contextPath: string = getBasePathModularUI();\n\n /**\n */\n constructor(\n href: Href | string,\n options: $Shape<RequestModularUIOptions> = {},\n ) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\",\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = this.getRequestLocale(options.locale);\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.contextPath) {\n this.contextPath = options.contextPath;\n } else if (this.href.contextPath) {\n this.contextPath = this.href.contextPath;\n }\n\n if (options.origin) {\n this.origin = options.origin;\n } else if (this.href.origin) {\n this.origin = this.href.origin;\n }\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n * Retrieve the preferred language for this request, falls back to the browser language or english\n */\n getRequestLocale(optionLocale: ?string): string {\n if (optionLocale) {\n return optionLocale;\n }\n\n // $FlowIssue\n return globalThis.navigator?.language?.split(\"-\")[0] || \"en\";\n }\n\n /**\n */\n get origin(): string {\n return this._origin;\n }\n\n /**\n */\n set origin(origin: ?string) {\n this._origin = origin ?? \"\";\n this._response.origin = origin ?? \"\";\n }\n\n /**\n */\n get contextPath(): string {\n return this._contextPath;\n }\n\n /**\n */\n set contextPath(contextPath: ?string) {\n this._contextPath = contextPath ?? getBasePathModularUI();\n this._response.contextPath = contextPath ?? getBasePathModularUI();\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestModularUIOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n get requestOptions(): RequestBaseOptions {\n /* eslint-disable no-unused-vars */\n const {\n targetModel,\n forceTargetModel,\n updateHandler,\n childmodels,\n isValidationRequest,\n removeOnUnmount,\n ...requestOptions\n } = this.options;\n /* eslint-enable no-unused-vars */\n return requestOptions;\n }\n\n /**\n */\n set options(options: RequestModularUIOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: TargetModel) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?TargetModel {\n return this._targetModel;\n }\n\n /**\n */\n set forceTargetModel(forceTargetModel: boolean) {\n this._forceTargetModel = forceTargetModel ?? false;\n }\n\n /**\n */\n get forceTargetModel(): boolean {\n return this._forceTargetModel;\n }\n\n /**\n */\n resolveModel(): Class<ModularUIModel> {\n let availableModels;\n if (this.targetModel) {\n availableModels = Array.isArray(this.targetModel)\n ? [...this.targetModel]\n : [this.targetModel];\n\n if (this.forceTargetModel) {\n return availableModels[0];\n }\n }\n\n const Model: Class<ModularUIModel> | null = resolveModel(\n this.response,\n availableModels,\n );\n\n if (Model?.isApplicableModel) {\n return Model;\n }\n\n if (availableModels) {\n throw new IllegalStateException(\n `data for ${this.href.toString()} is not applicable for model(s): ${availableModels\n .map((m) => m.modelName)\n .join(\", \")}, received response: ${JSON.stringify(this.response)}`,\n );\n }\n\n throw new IllegalStateException(\n `no javascript model is applicable for received request of ${this.href.toString()}, with response: ${JSON.stringify(\n this.response,\n )}`,\n );\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.resolveModel();\n return new Model(this.response);\n }\n\n /**\n */\n processContributionsService(contributionsData: Object): void {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\",\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object): void {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object): void {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(\n errorMessage,\n error,\n this.href.absolutepath.toString(),\n );\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object): void {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links?.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`,\n );\n }\n }\n\n /**\n */\n processDataService(data: Object): void {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${this.origin}${this.contextPath}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name,\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components,\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks),\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n },\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component,\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel,\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Retrieve an object of key: link\n */\n dataLinksPerName(dataLinks: any): { [linkName: string]: any } {\n if (Array.isArray(dataLinks)) {\n const links = {};\n for (const dataLink of dataLinks) {\n links[dataLink.name] = dataLink;\n }\n return links;\n }\n return dataLinks;\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any,\n ): Promise<Object | Array<Object>> {\n const linksPerName = this.dataLinksPerName(dataLinks);\n const hideWhenEmptyLinks = contributionLinks.filter((contributionLink) =>\n contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY),\n );\n\n const isHiddenListChecks = [];\n\n for (const contributionLink of hideWhenEmptyLinks) {\n const dataLink = linksPerName[contributionLink.name];\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href),\n );\n }\n }\n\n return Promise.all(isHiddenListChecks).then(\n (hiddenLinks: Array<string>) => {\n if (Array.isArray(dataLinks)) {\n return dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name),\n );\n }\n\n const newDataLinks: { [string]: any } = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n return newDataLinks;\n },\n );\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<string> {\n const HIDE_WHEN_EMPTY_IGNORE_TASKS = getSetting(\n \"HIDE_WHEN_EMPTY_IGNORE_TASKS\",\n false,\n );\n\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const noListItems = _embedded === null;\n const noActions = actions == null || HIDE_WHEN_EMPTY_IGNORE_TASKS;\n\n const isHidden = noListItems && noActions;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n // $FlowFixMe incompatible-call\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject?.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.requestOptions,\n url: `${this.origin}${this.contextPath}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\" || Array.isArray(data)) {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`,\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => this.createModel())\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return model;\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n const errorChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n // eslint-disable-next-line no-console\n console.debug(\n \"Unexpected error when retrieving child model:\",\n reason,\n );\n }\n errorChildModels.push(\n new ErrorResponse(reason, \"\", {\n origin: this.origin,\n contextPath: this.contextPath,\n }),\n );\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels, errorChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return model;\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate,\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n }),\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n\n /**\n * Make a post request with optionally data to send\n * @param data\n */\n post(data?: string | { [key: string]: string }): Promise<ModularUIModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data,\n };\n\n return this.fetch();\n }\n\n /**\n * Make a POST request using the form, an updated form is returned (merge of old and new form)\n * @param form\n * @returns {Promise<FormModel>}\n */\n postForm(form: FormModel): Promise<FormModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data: form.formdata,\n };\n\n return this.fetch().then((response) => {\n return form.update(response);\n });\n }\n\n /**\n * Simplified synchronous version of fetch (returns the model, not a Promise)\n * This can be used on the server to retrieve a model. It only loads the request url and it's child models\n */\n fetchSync(): ModularUIModel {\n const options = { headers: { \"Accept-Language\": this.locale } };\n\n const dataString = dataFetcher.fetch(this.href.toString(), options);\n if (dataString == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(JSON.parse(dataString));\n\n const contributionsString = dataFetcher.fetch(\n this.contributionsHref.toString(),\n options,\n );\n if (contributionsString == null) {\n throw new Error(\n `No constributions received for ${this.contributionsHref.toString()}`,\n );\n }\n this.processContributionsService(JSON.parse(contributionsString));\n\n const model = this.createModel();\n\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModels = childModelLinks.map((childModelLink) => {\n return new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n }).fetchSync();\n });\n model.addChildModels(childModels, []);\n\n return model;\n }\n}\n\nexport default ModularUIRequest;\n"],"mappings":";;;;;;;;;AACA,OAAOA,SAAS,MAAM,WAAW;AAEjC,SAASC,YAAY,EAAEC,uBAAuB,QAAQ,wBAAwB;AAE9E,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,SAASC,oBAAoB,EAAEC,UAAU,QAAQ,uBAAuB;AAExE,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,OAAOC,cAAc,MAAM,+BAA+B;AAC1D,OAAOC,YAAY,MAAM,wBAAwB;AACjD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,YAAY,MAAM,gCAAgC;AACzD,OAAOC,aAAa,MAAM,+BAA+B;AAEzD,OAAOC,iBAAiB,MAAM,qBAAqB;AAEnD,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,SAASC,wBAAwB,EAAEC,qBAAqB,QAAQ,eAAe;AAE/E,SAASC,aAAa,QAAQ,0BAA0B;AASxD;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,CAAC;EAgBrB;AACF;EACEC,WAAWA,CACTC,IAAmB,EACnBC,OAAwC,GAAG,CAAC,CAAC,EAC7C;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,4BAf2B,KAAK;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,kBAGIpB,YAAY,CAACqB,GAAG;IAAAD,eAAA;IAAAA,eAAA,kBAIpC,EAAE;IAAAA,eAAA,uBACGjB,oBAAoB,CAAC,CAAC;IAQ3C,IAAI,CAACe,IAAI,EAAE;MACT,MAAM,IAAIL,wBAAwB,CAChC,wDACF,CAAC;IACH;IAEA,IAAI,CAACM,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACG,SAAS,GAAG,IAAIX,iBAAiB,CAAC,CAAC;IAExC,IAAI,CAACO,IAAI,GAAG,OAAOA,IAAI,KA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M5D,KAAK,GAAG,IAAI,CAAC/E,WAAW,CAAC,CAAC;IAEhC,MAAM+F,eAAe,GAAGhB,KAAK,CAACiB,yBAAyB,CAAC,CAAC;IAEzD,MAAMM,WAAW,GAAG5G,oBAAA,CAAAqG,eAAe,EAAApG,IAAA,CAAfoG,eAAe,EAAMG,cAAc,IAAK;MAC1D,OAAO,IAAInJ,gBAAgB,CAACmJ,cAAc,CAACjJ,IAAI,EAAE;QAC/CK,MAAM,EAAE,IAAI,CAACA;MACf,CAAC,CAAC,CAACiL,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC;IACFxD,KAAK,CAACiC,cAAc,CAACV,WAAW,EAAE,EAAE,CAAC;IAErC,OAAOvB,KAAK;EACd;AACF;AAEA,eAAehI,gBAAgB","ignoreList":[]}
@@ -9,7 +9,7 @@ import { IllegalArgumentException } from "../../exceptions";
9
9
 
10
10
  import { availableLocales, Locales } from "../../i18n";
11
11
 
12
- global.preferencesProvider = {
12
+ globalThis.preferencesProvider = {
13
13
  getPreferenceByName: jest.fn(),
14
14
  getLayoutConfigFileLocation: () => "/theme",
15
15
  };
@@ -2,5 +2,4 @@ import { getBasePath } from "../constants/Settings";
2
2
  (function x() {
3
3
  __webpack_public_path__ = `${getBasePath()}/`; // NOSONAR
4
4
  })();
5
- export {};
6
5
  //# sourceMappingURL=contextPath.js.map
@@ -4,5 +4,3 @@ import { getBasePath } from "../constants/Settings";
4
4
  (function x() {
5
5
  __webpack_public_path__ = `${getBasePath()}/`; // NOSONAR
6
6
  })();
7
-
8
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"contextPath.js","names":["getBasePath","x","__webpack_public_path__"],"sources":["../../src/react-server/contextPath.js"],"sourcesContent":["// @flow\nimport { getBasePath } from \"../constants/Settings\";\n\n(function x() {\n __webpack_public_path__ = `${getBasePath()}/`; // NOSONAR\n})();\n\nexport {};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,CAAC,SAASC,CAACA,CAAA,EAAG;EACZC,uBAAuB,GAAG,GAAGF,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC,EAAE,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"contextPath.js","names":["getBasePath","x","__webpack_public_path__"],"sources":["../../src/react-server/contextPath.js"],"sourcesContent":["// @flow\nimport { getBasePath } from \"../constants/Settings\";\n\n(function x() {\n __webpack_public_path__ = `${getBasePath()}/`; // NOSONAR\n})();\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,uBAAuB;AAEnD,CAAC,SAASC,CAACA,CAAA,EAAG;EACZC,uBAAuB,GAAG,GAAGF,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC,EAAE,CAAC","ignoreList":[]}
@@ -2,14 +2,14 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
2
2
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
3
3
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
4
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
5
+ import _globalThis from "@babel/runtime-corejs3/core-js/global-this";
5
6
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
6
7
  import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
7
8
  import { createMemoryHistory } from "history";
8
9
  import { has } from "../utils/helpers/objects";
9
10
  import deepmerge from "deepmerge";
10
11
  import configureStore from "../redux/store/configureStore";
11
- import { availableLocales } from "../i18n/Locales";
12
- import Locales from "../i18n/Locales";
12
+ import Locales, { availableLocales } from "../i18n/Locales";
13
13
  import { getPreferredLocale } from "./requestInformation";
14
14
  import { setLocales } from "../redux/_i18n/I18nActions";
15
15
  import { setServerPreference, setThemePreference, setPreference, setAllContentInDataSetting, setLoginPreferences, setDateTimeSettings } from "../redux/actions/Preferences";
@@ -97,8 +97,12 @@ const setServerPreferences = (store, serverPreferences) => {
97
97
  store.dispatch(setAllContentInDataSetting());
98
98
  store.dispatch(setLoginPreferences());
99
99
  store.dispatch(setDateTimeSettings());
100
- if (preferencesProvider && preferencesProvider.isStudioContext && preferencesProvider.isStudioContext()) {
101
- store.dispatch(setPreference("isStudioContext", true));
100
+
101
+ // $FlowIssue
102
+ if (typeof _globalThis.preferencesProvider?.isStudioContext === "function") {
103
+ store.dispatch(setPreference("isStudioContext",
104
+ // $FlowIssue
105
+ _globalThis.preferencesProvider?.isStudioContext()));
102
106
  }
103
107
  };
104
108
 
@@ -106,7 +110,9 @@ const setServerPreferences = (store, serverPreferences) => {
106
110
  */
107
111
  const setConfigurationTheme = store => {
108
112
  let configTheme = null;
109
- const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();
113
+ const configFileLocation =
114
+ // $FlowIssue
115
+ _globalThis.preferencesProvider?.getLayoutConfigFileLocation();
110
116
  if (typeof configFileLocation === "string") {
111
117
  const configFilePath = _startsWithInstanceProperty(configFileLocation).call(configFileLocation, "/") ? `/resource${configFileLocation}` : `/resource/${configFileLocation}`;
112
118
  configTheme = dataFetcher.fetch(configFilePath);
@@ -5,8 +5,7 @@ import deepmerge from "deepmerge";
5
5
 
6
6
  import configureStore from "../redux/store/configureStore";
7
7
 
8
- import { availableLocales } from "../i18n/Locales";
9
- import Locales from "../i18n/Locales";
8
+ import Locales, { availableLocales } from "../i18n/Locales";
10
9
 
11
10
  import { getPreferredLocale } from "./requestInformation";
12
11
  import { setLocales } from "../redux/_i18n/I18nActions";
@@ -137,12 +136,15 @@ const setServerPreferences = (
137
136
  store.dispatch(setLoginPreferences());
138
137
  store.dispatch(setDateTimeSettings());
139
138
 
140
- if (
141
- preferencesProvider &&
142
- preferencesProvider.isStudioContext &&
143
- preferencesProvider.isStudioContext()
144
- ) {
145
- store.dispatch(setPreference("isStudioContext", true));
139
+ // $FlowIssue
140
+ if (typeof globalThis.preferencesProvider?.isStudioContext === "function") {
141
+ store.dispatch(
142
+ setPreference(
143
+ "isStudioContext",
144
+ // $FlowIssue
145
+ globalThis.preferencesProvider?.isStudioContext(),
146
+ ),
147
+ );
146
148
  }
147
149
  };
148
150
 
@@ -151,7 +153,9 @@ const setServerPreferences = (
151
153
  const setConfigurationTheme = (store: ReduxStore) => {
152
154
  let configTheme = null;
153
155
 
154
- const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();
156
+ const configFileLocation =
157
+ // $FlowIssue
158
+ globalThis.preferencesProvider?.getLayoutConfigFileLocation();
155
159
  if (typeof configFileLocation === "string") {
156
160
  const configFilePath = configFileLocation.startsWith("/")
157
161
  ? `/resource${configFileLocation}`