@beinformed/ui 1.52.2 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/hooks/useModelCatalog.js +57 -9
  3. package/esm/hooks/useModelCatalog.js.map +1 -1
  4. package/esm/hooks/useModularUIBasic.js +5 -1
  5. package/esm/hooks/useModularUIBasic.js.map +1 -1
  6. package/esm/redux/_modularui/ModularUIActions.js +1 -0
  7. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  8. package/esm/redux/_modularui/ModularUIMiddleware.js +2 -1
  9. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  10. package/esm/redux/_modularui/types.js.map +1 -1
  11. package/lib/hooks/useModelCatalog.js +60 -9
  12. package/lib/hooks/useModelCatalog.js.flow +69 -1
  13. package/lib/hooks/useModelCatalog.js.map +1 -1
  14. package/lib/hooks/useModularUIBasic.js +5 -1
  15. package/lib/hooks/useModularUIBasic.js.flow +7 -1
  16. package/lib/hooks/useModularUIBasic.js.map +1 -1
  17. package/lib/redux/_modularui/ModularUIActions.js +1 -0
  18. package/lib/redux/_modularui/ModularUIActions.js.flow +1 -0
  19. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  20. package/lib/redux/_modularui/ModularUIMiddleware.js +2 -1
  21. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +2 -0
  22. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  23. package/lib/redux/_modularui/types.js.flow +1 -0
  24. package/lib/redux/_modularui/types.js.map +1 -1
  25. package/package.json +15 -15
  26. package/src/hooks/useModelCatalog.js +69 -1
  27. package/src/hooks/useModularUIBasic.js +7 -1
  28. package/src/redux/_modularui/ModularUIActions.js +1 -0
  29. package/src/redux/_modularui/ModularUIMiddleware.js +2 -0
  30. package/src/redux/_modularui/types.js +1 -0
  31. package/types/models/concepts/ConceptDetailModel.d.ts +9 -1
  32. package/types/models/concepts/ConceptLinkModel.d.ts +8 -0
  33. package/types/models/concepts/ConceptTypeDetailModel.d.ts +19 -0
  34. package/types/models/content/ContentIndexModel.d.ts +3 -0
  35. package/types/models/links/LinkCollection.d.ts +8 -0
  36. package/types/redux/_modularui/types.d.ts +1 -0
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.54.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.53.0...v1.54.0) (2024-09-17)
6
+
7
+
8
+ ### Features
9
+
10
+ * **modularui:** allow caching data service of modularui ([d1c65f7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d1c65f7081853556aa2eb431064f2fb05a94b422))
11
+
12
+ ## [1.53.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.52.2...v1.53.0) (2024-09-17)
13
+
14
+
15
+ ### Features
16
+
17
+ * **modelcatalog:** new hooks for searching concepts or content by filter ([ef8e0a5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/ef8e0a5c6e6c9496756ecabdc3a9ec79469e98ed))
18
+
5
19
  ## [1.52.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.52.1...v1.52.2) (2024-08-23)
6
20
 
7
21
 
@@ -1,3 +1,4 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
1
2
  import { useLocation } from "./useRouter";
2
3
  import { createHref, filterParameters } from "../utils/helpers/createHref";
3
4
  import ModelCatalogModel from "../models/modelcatalog/ModelCatalogModel";
@@ -9,22 +10,24 @@ import ContentTOCModel from "../models/content/ContentTOCModel";
9
10
  import ContentModel from "../models/content/ContentModel";
10
11
  import { useModularUIBasic } from "./useModularUIBasic";
11
12
  import { ContentTypeModel } from "../models";
12
-
13
13
  /**
14
14
  */
15
- export const useModelCatalog = () => useModularUIBasic("modelcatalog", "/modelcatalog", {
15
+ export const useModelCatalog = options => useModularUIBasic("modelcatalog", "/modelcatalog", {
16
16
  expectedModels: ["ModelCatalog"],
17
- targetModel: ModelCatalogModel
17
+ targetModel: ModelCatalogModel,
18
+ ...options
18
19
  });
19
20
 
20
21
  /**
21
22
  */
22
23
  export const useConceptIndex = function (href) {
23
24
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptindex";
25
+ let options = arguments.length > 2 ? arguments[2] : undefined;
24
26
  const url = filterParameters(href, ["entryDate", "index", "label", "type"]);
25
27
  return useModularUIBasic(key, url, {
26
28
  expectedModels: ["ConceptIndex"],
27
- targetModel: ConceptIndexModel
29
+ targetModel: ConceptIndexModel,
30
+ ...options
28
31
  });
29
32
  };
30
33
 
@@ -32,10 +35,12 @@ export const useConceptIndex = function (href) {
32
35
  */
33
36
  export const useConceptDetail = function (concept) {
34
37
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptdetail";
38
+ let options = arguments.length > 2 ? arguments[2] : undefined;
35
39
  const location = useLocation();
36
40
  const href = createHref("concepts", concept, location, ["entryDate"]);
37
41
  return useModularUIBasic(key, href, {
38
- expectedModels: ["ConceptDetail", "BusinessScenario"]
42
+ expectedModels: ["ConceptDetail", "BusinessScenario"],
43
+ ...options
39
44
  });
40
45
  };
41
46
 
@@ -43,10 +48,12 @@ export const useConceptDetail = function (concept) {
43
48
  */
44
49
  export const useContentIndex = function (href) {
45
50
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentindex";
51
+ let options = arguments.length > 2 ? arguments[2] : undefined;
46
52
  const url = filterParameters(href, ["index", "label", "type"]);
47
53
  return useModularUIBasic(key, url, {
48
54
  expectedModels: ["ContentIndex"],
49
- targetModel: ContentIndexModel
55
+ targetModel: ContentIndexModel,
56
+ ...options
50
57
  });
51
58
  };
52
59
 
@@ -54,11 +61,13 @@ export const useContentIndex = function (href) {
54
61
  */
55
62
  export const useContentTOC = function (content) {
56
63
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttoc";
64
+ let options = arguments.length > 2 ? arguments[2] : undefined;
57
65
  const location = useLocation();
58
66
  const href = createHref("content", content, location, ["entryDate"]);
59
67
  return useModularUIBasic(key, href, {
60
68
  expectedModels: ["ContentTOC"],
61
- targetModel: ContentTOCModel
69
+ targetModel: ContentTOCModel,
70
+ ...options
62
71
  });
63
72
  };
64
73
 
@@ -66,10 +75,12 @@ export const useContentTOC = function (content) {
66
75
  */
67
76
  export const useContent = function (contentSection) {
68
77
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
78
+ let options = arguments.length > 2 ? arguments[2] : undefined;
69
79
  const href = createHref("content", contentSection, null, ["entryDate"]);
70
80
  return useModularUIBasic(key, href, {
71
81
  expectedModels: ["Content"],
72
- targetModel: ContentModel
82
+ targetModel: ContentModel,
83
+ ...options
73
84
  });
74
85
  };
75
86
 
@@ -77,10 +88,47 @@ export const useContent = function (contentSection) {
77
88
  */
78
89
  export const useContentType = function (contentType) {
79
90
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
91
+ let options = arguments.length > 2 ? arguments[2] : undefined;
80
92
  const href = createHref("contenttypes", contentType, null, ["entryDate"]);
81
93
  return useModularUIBasic(key, href, {
82
94
  expectedModels: ["ContentType"],
83
- targetModel: ContentTypeModel
95
+ targetModel: ContentTypeModel,
96
+ ...options
84
97
  });
85
98
  };
99
+
100
+ /**
101
+ */
102
+ const getSearchHref = (uri, filters) => {
103
+ const filterString = [];
104
+ for (const key of _Object$keys(filters)) {
105
+ const filterValue = filters[key];
106
+ if (filterValue) {
107
+ let value = Array.isArray(filterValue) ? filterValue.join(",") : filterValue;
108
+ if (key === "type") {
109
+ value = value.replace("#", "%23"); // handles un-encoded #
110
+ }
111
+ filterString.push(`${key}=${value}`);
112
+ }
113
+ }
114
+ return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
115
+ };
116
+
117
+ /**
118
+ */
119
+ export const useConceptSearch = function (filters) {
120
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
121
+ let options = arguments.length > 2 ? arguments[2] : undefined;
122
+ const href = getSearchHref("/concepts", filters);
123
+ return useConceptIndex(href, key, options);
124
+ };
125
+
126
+ /**
127
+ */
128
+ export const useContentSearch = function (filters) {
129
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
130
+ let options = arguments.length > 2 ? arguments[2] : undefined;
131
+ const href = getSearchHref("/content", filters);
132
+ return useContentIndex(href, key, options);
133
+ };
86
134
  //# sourceMappingURL=useModelCatalog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAA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MF,IAAI,GAAGhB,UAAU,CAAC,SAAS,EAAE6B,cAAc,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC;EACvE,OAAOnB,iBAAiB,CAACO,GAAG,EAAED,IAAI,EAAE;IAClCH,cAAc,EAAE,CAAC,SAAS,CAAC;IAC3BC,WAAW,EAAEL;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,OAAO,MAAMqB,cAAc,GAAG,SAAAA,CAC5BC,WAAmB,EAEG;EAAA,IADtBd,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAE7B,MAAMF,IAAI,GAAGhB,UAAU,CAAC,cAAc,EAAE+B,WAAW,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,CAAC;EACzE,OAAOrB,iBAAiB,CAACO,GAAG,EAAED,IAAI,EAAE;IAClCH,cAAc,EAAE,CAAC,aAAa,CAAC;IAC/BC,WAAW,EAAEH;EACf,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content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AAMiC,gBAAgB,GAAG,SAAAA,CAC9BX,OAAqB,EAGE;EAAA,IAFvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGgB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOT,eAAe,CAACT,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -15,12 +15,16 @@ export const useModularUIBasic = function (key, href) {
15
15
  const useModularUIOptions = {
16
16
  targetModel: undefined,
17
17
  forceTargetModel: undefined,
18
- isReload: false
18
+ isReload: false,
19
+ cache: false
19
20
  };
20
21
  if (options.targetModel) {
21
22
  useModularUIOptions.targetModel = options.targetModel;
22
23
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
23
24
  }
25
+ if (options.cache) {
26
+ useModularUIOptions.cache = options.cache;
27
+ }
24
28
 
25
29
  // reload when the modular service starts with the current location
26
30
  if (location.state?.reload && _startsWithInstanceProperty(_context = location.pathname).call(_context, href.toString())) {
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAUrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ,GAAGb,WAAW,CAAC,CAAC;EAE9B,MAAMc,mBAAmB,GAAG;IAC1BH,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BM,QAAQ,EAAE;EACZ,CAAC;EACD,IAAIT,OAAO,CAACK,WAAW,EAAE;IACvBG,mBAAmB,CAACH,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDG,mBAAmB,CAACF,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;;EAEA;EACA,IAAIC,QAAQ,CAACG,KAAK,EAAEC,MAAM,IAAIC,2BAAA,CAAAb,QAAA,GAAAQ,QAAQ,CAACM,QAAQ,EAAAC,IAAA,CAAAf,QAAA,EAAYD,IAAI,CAACiB,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3EP,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMO,SAAS,GAAGvB,YAAY,CAACI,GAAG,EAAEC,IAAI,EAAEU,mBAAmB,CAAC;EAE9D,IAAIQ,SAAS,EAAEC,KAAK,EAAE;IACpB,MAAM;MAAEA;IAAM,CAAC,GAAGD,SAAS;IAC3B,IAAIhB,OAAO,CAACI,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;MACrC,MAAMgB,cAAc,GAAGlB,OAAO,CAACI,cAAc,CAACe,IAAI,CAAEC,aAAa,IAAK;QACpE,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEhB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOsB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAWrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,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AS,EAAE,oBAAoB,EAAEjB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOuB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -85,6 +85,7 @@ export const loadModel = (key, href, options) => ({
85
85
  childmodels: options?.childmodels,
86
86
  targetModel: options?.targetModel,
87
87
  forceTargetModel: options?.forceTargetModel,
88
+ cache: options?.cache,
88
89
  /**
89
90
  */
90
91
  successAction: model => loadModelSuccessAction(key, model, options?.updateHandler),
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","_Promise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,k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AC,CAAC,CACD6C,KAAK,CAAEd,KAAK,IAAKM,QAAQ,CAACnC,WAAW,CAAC6B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMe,WAAW,GAAGA,CACzBzC,KAAqB,EACrBgB,OAAiC,KAEjCe,aAAa,CAAC/B,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC0C,QAAQ,EAAE;EAC9C,GAAG1B,OAAO;EACV2B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","_Promise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC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AAC,CAAC,CACD8C,KAAK,CAAEd,KAAK,IAAKM,QAAQ,CAACpC,WAAW,CAAC8B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMe,WAAW,GAAGA,CACzB1C,KAAqB,EACrBgB,OAAiC,KAEjCgB,aAAa,CAAChC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC2C,QAAQ,EAAE;EAC9C,GAAG3B,OAAO;EACV4B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -12,7 +12,8 @@ const createRequest = modularui => {
12
12
  data: modularui.data || {},
13
13
  locale: modularui.locale,
14
14
  childmodels: modularui.childmodels ?? true,
15
- isReload: modularui.isReload
15
+ isReload: modularui.isReload,
16
+ cache: modularui.cache
16
17
  });
17
18
  if (modularui.targetModel) {
18
19
  request.targetModel = modularui.targetModel;
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAAkB;AAyB9C;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAACM,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIR,YAAY,CAACS,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ;EACtB,CAAC,CAAC;EAEF,IAAIR,SAAS,CAACS,WAAW,EAAE;IACzBR,OAAO,CAACQ,WAAW,GAAGT,SAAS,CAACS,WAAW;IAC3CR,OAAO,CAACS,gBAAgB,GAAGV,SAAS,CAACU,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOT,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMU,eAAe,GAAGA,CACtBC,IAAc,EACdC,QAAkB,EAClBC,aAA4B,EAC5BC,KAAqB,KAClB;EACH,IAAID,aAAa,EAAE;IACjB,MAAME,aAAa,GAAGF,aAAa,CAACC,KAAK,CAAC;IAE1C,IAAIC,aAAa,YAAAC,QAAmB,EA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D,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPd,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMY,mBAIZ,GACEC,GAAqD,IACrDtB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACO,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOR,WAAW;IAChB;IACAC,MAAM,EACNM,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAC/B,MAAM,EAC1B4B,GAAG,CAACrB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAAkB;AA0B9C;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAACM,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIR,YAAY,CAACS,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ,QAAQ;IAC5BC,KAAK,EAAET,SAAS,CAACS;EACnB,CAAC,CAAC;EAEF,IAAIT,SAAS,CAACU,WAAW,EAAE;IACzBT,OAAO,CAACS,WAAW,GAAGV,SAAS,CAACU,WAAW;IAC3CT,OAAO,CAACU,gBAAgB,GAAGX,SAAS,CAACW,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOV,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMW,eAAe,GAAGA,CACtBC,IAAc,EACdC,QAAkB,EAClBC,aAA4B,E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AAC,GAAGD,MAAM,CAACE,OAAO;EACxED,cAAc,CAACxB,MAAM,GAAGA,MAAM;EAE9B,MAAM0B,gBAAgB,GAAGjC,aAAa,CAAC+B,cAAc,CAAC;EAEtD,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPd,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMY,mBAIZ,GACEC,GAAqD,IACrDtB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACO,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOR,WAAW;IAChB;IACAC,MAAM,EACNM,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAChC,MAAM,EAC1B6B,GAAG,CAACrB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
@@ -4,7 +4,8 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useModelCatalog = exports.useContentType = exports.useContentTOC = exports.useContentIndex = exports.useContent = exports.useConceptIndex = exports.useConceptDetail = void 0;
7
+ exports.useModelCatalog = exports.useContentType = exports.useContentTOC = exports.useContentSearch = exports.useContentIndex = exports.useContent = exports.useConceptSearch = exports.useConceptIndex = exports.useConceptDetail = void 0;
8
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
8
9
  var _useRouter = require("./useRouter");
9
10
  var _createHref = require("../utils/helpers/createHref");
10
11
  var _ModelCatalogModel = _interopRequireDefault(require("../models/modelcatalog/ModelCatalogModel"));
@@ -18,9 +19,10 @@ var _useModularUIBasic = require("./useModularUIBasic");
18
19
  var _models = require("../models");
19
20
  /**
20
21
  */
21
- const useModelCatalog = () => (0, _useModularUIBasic.useModularUIBasic)("modelcatalog", "/modelcatalog", {
22
+ const useModelCatalog = options => (0, _useModularUIBasic.useModularUIBasic)("modelcatalog", "/modelcatalog", {
22
23
  expectedModels: ["ModelCatalog"],
23
- targetModel: _ModelCatalogModel.default
24
+ targetModel: _ModelCatalogModel.default,
25
+ ...options
24
26
  });
25
27
 
26
28
  /**
@@ -28,10 +30,12 @@ const useModelCatalog = () => (0, _useModularUIBasic.useModularUIBasic)("modelca
28
30
  exports.useModelCatalog = useModelCatalog;
29
31
  const useConceptIndex = function (href) {
30
32
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptindex";
33
+ let options = arguments.length > 2 ? arguments[2] : undefined;
31
34
  const url = (0, _createHref.filterParameters)(href, ["entryDate", "index", "label", "type"]);
32
35
  return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
33
36
  expectedModels: ["ConceptIndex"],
34
- targetModel: _ConceptIndexModel.default
37
+ targetModel: _ConceptIndexModel.default,
38
+ ...options
35
39
  });
36
40
  };
37
41
 
@@ -40,10 +44,12 @@ const useConceptIndex = function (href) {
40
44
  exports.useConceptIndex = useConceptIndex;
41
45
  const useConceptDetail = function (concept) {
42
46
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptdetail";
47
+ let options = arguments.length > 2 ? arguments[2] : undefined;
43
48
  const location = (0, _useRouter.useLocation)();
44
49
  const href = (0, _createHref.createHref)("concepts", concept, location, ["entryDate"]);
45
50
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
46
- expectedModels: ["ConceptDetail", "BusinessScenario"]
51
+ expectedModels: ["ConceptDetail", "BusinessScenario"],
52
+ ...options
47
53
  });
48
54
  };
49
55
 
@@ -52,10 +58,12 @@ const useConceptDetail = function (concept) {
52
58
  exports.useConceptDetail = useConceptDetail;
53
59
  const useContentIndex = function (href) {
54
60
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentindex";
61
+ let options = arguments.length > 2 ? arguments[2] : undefined;
55
62
  const url = (0, _createHref.filterParameters)(href, ["index", "label", "type"]);
56
63
  return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
57
64
  expectedModels: ["ContentIndex"],
58
- targetModel: _ContentIndexModel.default
65
+ targetModel: _ContentIndexModel.default,
66
+ ...options
59
67
  });
60
68
  };
61
69
 
@@ -64,11 +72,13 @@ const useContentIndex = function (href) {
64
72
  exports.useContentIndex = useContentIndex;
65
73
  const useContentTOC = function (content) {
66
74
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttoc";
75
+ let options = arguments.length > 2 ? arguments[2] : undefined;
67
76
  const location = (0, _useRouter.useLocation)();
68
77
  const href = (0, _createHref.createHref)("content", content, location, ["entryDate"]);
69
78
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
70
79
  expectedModels: ["ContentTOC"],
71
- targetModel: _ContentTOCModel.default
80
+ targetModel: _ContentTOCModel.default,
81
+ ...options
72
82
  });
73
83
  };
74
84
 
@@ -77,10 +87,12 @@ const useContentTOC = function (content) {
77
87
  exports.useContentTOC = useContentTOC;
78
88
  const useContent = function (contentSection) {
79
89
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
90
+ let options = arguments.length > 2 ? arguments[2] : undefined;
80
91
  const href = (0, _createHref.createHref)("content", contentSection, null, ["entryDate"]);
81
92
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
82
93
  expectedModels: ["Content"],
83
- targetModel: _ContentModel.default
94
+ targetModel: _ContentModel.default,
95
+ ...options
84
96
  });
85
97
  };
86
98
 
@@ -89,11 +101,50 @@ const useContent = function (contentSection) {
89
101
  exports.useContent = useContent;
90
102
  const useContentType = function (contentType) {
91
103
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
104
+ let options = arguments.length > 2 ? arguments[2] : undefined;
92
105
  const href = (0, _createHref.createHref)("contenttypes", contentType, null, ["entryDate"]);
93
106
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
94
107
  expectedModels: ["ContentType"],
95
- targetModel: _models.ContentTypeModel
108
+ targetModel: _models.ContentTypeModel,
109
+ ...options
96
110
  });
97
111
  };
112
+
113
+ /**
114
+ */
98
115
  exports.useContentType = useContentType;
116
+ const getSearchHref = (uri, filters) => {
117
+ const filterString = [];
118
+ for (const key of (0, _keys.default)(filters)) {
119
+ const filterValue = filters[key];
120
+ if (filterValue) {
121
+ let value = Array.isArray(filterValue) ? filterValue.join(",") : filterValue;
122
+ if (key === "type") {
123
+ value = value.replace("#", "%23"); // handles un-encoded #
124
+ }
125
+ filterString.push(`${key}=${value}`);
126
+ }
127
+ }
128
+ return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
129
+ };
130
+
131
+ /**
132
+ */
133
+ const useConceptSearch = function (filters) {
134
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
135
+ let options = arguments.length > 2 ? arguments[2] : undefined;
136
+ const href = getSearchHref("/concepts", filters);
137
+ return useConceptIndex(href, key, options);
138
+ };
139
+
140
+ /**
141
+ */
142
+ exports.useConceptSearch = useConceptSearch;
143
+ const useContentSearch = function (filters) {
144
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
145
+ let options = arguments.length > 2 ? arguments[2] : undefined;
146
+ const href = getSearchHref("/content", filters);
147
+ return useContentIndex(href, key, options);
148
+ };
149
+ exports.useContentSearch = useContentSearch;
99
150
  //# sourceMappingURL=useModelCatalog.js.map