@beinformed/ui 1.16.0 → 1.17.1

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 (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/models/application/ApplicationModel.js +13 -2
  3. package/esm/models/application/ApplicationModel.js.map +1 -1
  4. package/esm/models/attributes/AttributeContent.js +3 -6
  5. package/esm/models/attributes/AttributeContent.js.map +1 -1
  6. package/esm/models/href/Href.js +11 -1
  7. package/esm/models/href/Href.js.map +1 -1
  8. package/esm/models/index.js +1 -0
  9. package/esm/models/index.js.map +1 -1
  10. package/esm/utils/helpers/checkResource.js +4 -8
  11. package/esm/utils/helpers/checkResource.js.map +1 -1
  12. package/lib/models/application/ApplicationModel.js +13 -2
  13. package/lib/models/application/ApplicationModel.js.flow +7 -0
  14. package/lib/models/application/ApplicationModel.js.map +1 -1
  15. package/lib/models/attributes/AttributeContent.js +3 -6
  16. package/lib/models/attributes/AttributeContent.js.flow +3 -6
  17. package/lib/models/attributes/AttributeContent.js.map +1 -1
  18. package/lib/models/href/Href.js +11 -1
  19. package/lib/models/href/Href.js.flow +12 -1
  20. package/lib/models/href/Href.js.map +1 -1
  21. package/lib/models/index.js +8 -0
  22. package/lib/models/index.js.flow +1 -0
  23. package/lib/models/index.js.map +1 -1
  24. package/lib/utils/helpers/__tests__/checkResource.spec.js.flow +11 -7
  25. package/lib/utils/helpers/checkResource.js +4 -7
  26. package/lib/utils/helpers/checkResource.js.flow +7 -5
  27. package/lib/utils/helpers/checkResource.js.map +1 -1
  28. package/package.json +6 -6
  29. package/src/models/application/ApplicationModel.js +7 -0
  30. package/src/models/attributes/AttributeContent.js +3 -6
  31. package/src/models/href/Href.js +12 -1
  32. package/src/models/index.js +1 -0
  33. package/src/utils/helpers/__tests__/checkResource.spec.js +11 -7
  34. package/src/utils/helpers/checkResource.js +7 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAaMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,UAAIA,WAAJ,EAAiB;AACf,YAAI,0BAAcA,WAAd,KAA8B,aAAaA,WAA/C,EAA4D;AAC1DH,UAAAA,iBAAiB,GAAGG,WAAW,CAACC,OAAhC;AACD,SAFD,MAEO,IAAI,OAAOD,WAAP,KAAuB,QAA3B,EAAqC;AAC1CH,UAAAA,iBAAiB,GAAGG,WAApB;AACD;AACF;;AAED,aAAO;AAAEF,QAAAA,KAAK,EAAEF,WAAT;AAAsBI,QAAAA,WAAW,EAAEH;AAAnC,OAAP;AACD;AAED;AACF;;;;SACE,eAA2B;AAAA;;AACzB,6BAAI,KAAKF,QAAT,4CAAI,gBAAeO,QAAnB,EAA6B;AAAA;;AAC3B,wCAAO,KAAKP,QAAL,CAAcO,QAAr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7B,EAAyE;AACvE,aAAO,KAAKE,mCAAL,CAGL,iBAHK,EAGc,YAHd,EAG4BF,MAH5B,CAAP;AAID;AAED;AACF;;;;SACE,eAA6C;AAC3C,aAAO,KAAKC,4BAAL,CACL,qBADK,EAEL,eAFK,CAAP;AAID;AAED;AACF;AACA;;;;WACE,kCAAyBD,MAAzB,EAAyE;AACvE,aAAO,KAAKE,mCAAL,CAGL,qBAHK,EAGkB,eAHlB,EAGmCF,MAHnC,CAAP;AAID;AAED;AACF;;;;SACE,eAAoC;AAClC,aAAO,KAAKC,4BAAL,CACL,gBADK,EAEL,UAFK,CAAP;AAID;AAED;AACF;;;;WACE,2BAAkBE,KAAlB,EAA6D;AAAA;;AAC3D,aAAO,sCAAKT,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,uBAAAQ,KAAK,MAAL,CAAAA,KAAK,EAAUR,OAAO,CAACS,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;AACA;;;;WACE,6BAAoBJ,MAApB,EAAgE;AAC9D,aAAO,KAAKE,mCAAL,CAGL,gBAHK,EAGa,UAHb,EAGyBF,MAHzB,CAAP;AAID;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMK,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue[incompatible-use]\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n // $FlowIssue[incompatible-use]\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue[incompatible-use]\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","labels","getContentElementCollections","getContentElementCollectionByLabels","types","type","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAaMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,UAAIA,WAAJ,EAAiB;AACf,YAAI,0BAAcA,WAAd,KAA8B,aAAaA,WAA/C,EAA4D;AAC1DH,UAAAA,iBAAiB,GAAGG,WAAW,CAACC,OAAhC;AACD,SAFD,MAEO,IAAI,OAAOD,WAAP,KAAuB,QAA3B,EAAqC;AAC1CH,UAAAA,iBAAiB,GAAGG,WAApB;AACD;AACF;;AAED,aAAO;AAAEF,QAAAA,KAAK,EAAEF,WAAT;AAAsBI,QAAAA,WAAW,EAAEH;AAAnC,OAAP;AACD;AAED;AACF;;;;SACE,eAA2B;AAAA;;AACzB,6BAAI,KAAKF,QAAT,4CAAI,gBAAe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ADK,EAEL,YAFK,CAAP;AAID;AAED;AACF;AACA;;;;WACE,sCAA6BD,MAA7B,EAAyE;AACvE,aAAO,KAAKE,mCAAL,CAGL,iBAHK,EAGc,YAHd,EAG4BF,MAH5B,CAAP;AAID;AAED;AACF;;;;SACE,eAA6C;AAC3C,aAAO,KAAKC,4BAAL,CACL,qBADK,EAEL,eAFK,CAAP;AAID;AAED;AACF;AACA;;;;WACE,kCAAyBD,MAAzB,EAAyE;AACvE,aAAO,KAAKE,mCAAL,CAGL,qBAHK,EAGkB,eAHlB,EAGmCF,MAHnC,CAAP;AAID;AAED;AACF;;;;SACE,eAAoC;AAClC,aAAO,KAAKC,4BAAL,CACL,gBADK,EAEL,UAFK,CAAP;AAID;AAED;AACF;;;;WACE,2BAAkBE,KAAlB,EAA6D;AAAA;;AAC3D,aAAO,sCAAKT,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,uBAAAQ,KAAK,MAAL,CAAAA,KAAK,EAAUR,OAAO,CAACS,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;AACA;;;;WACE,6BAAoBJ,MAApB,EAAgE;AAC9D,aAAO,KAAKE,mCAAL,CAGL,gBAHK,EAGa,UAHb,EAGyBF,MAHzB,CAAP;AAID;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMK,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\"\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
@@ -403,11 +403,21 @@ var Href = /*#__PURE__*/function () {
403
403
  return this.querystring.length > 0 ? [this.path, this.querystring].join("?") : this.path;
404
404
  }
405
405
  /**
406
- * Getting the URL including the base path
406
+ * Getting the URL including the base path, querystring is prefixed
407
407
  */
408
408
 
409
409
  }, {
410
410
  key: "absolutehref",
411
+ get: function get() {
412
+ var querystring = this.getQuerystring(false);
413
+ return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
414
+ }
415
+ /**
416
+ * Getting the URL including the base path, the querystring is prefixed
417
+ */
418
+
419
+ }, {
420
+ key: "absolutehrefPrefixedQuerystring",
411
421
  get: function get() {
412
422
  var querystring = this.getQuerystring(true);
413
423
  return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
@@ -366,9 +366,20 @@ class Href {
366
366
  }
367
367
 
368
368
  /**
369
- * Getting the URL including the base path
369
+ * Getting the URL including the base path, querystring is prefixed
370
370
  */
371
371
  get absolutehref(): string {
372
+ const querystring = this.getQuerystring(false);
373
+
374
+ return querystring.length > 0
375
+ ? [this.absolutepath, querystring].join("?")
376
+ : this.absolutepath;
377
+ }
378
+
379
+ /**
380
+ * Getting the URL including the base path, the querystring is prefixed
381
+ */
382
+ get absolutehrefPrefixedQuerystring(): string {
372
383
  const querystring = this.getQuerystring(true);
373
384
 
374
385
  return querystring.length > 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/href/Href.js"],"names":["Href","href","resourcetype","path","parameters","hash","state","method","HTTP_METHODS","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","Parameter","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","BASE","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","IllegalArgumentException","CONTENT_PATH","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAgBA;AACA;AACA;IACMA,I;AAQJ;AACF;AACA;AACE,gBAAYC,IAAZ,EAA8BC,YAA9B,EAAqD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACnD,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,KAAL,GAAa,IAAb;AACA,SAAKC,MAAL,GAAcC,wBAAaC,GAA3B;AACA,SAAKP,YAAL,GAAoBA,YAAY,IAAI,EAApC;;AAEA,QAAID,IAAI,YAAYD,IAApB,EAA0B;AACxB,WAAKU,WAAL,CAAiBT,IAAjB;AACD,KAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AACnC,WAAKU,aAAL,CAAmBV,IAAnB;AACD,KAFM,MAEA,IAAI,sBAAOA,IAAP,MAAgB,QAApB,EAA8B;AACnC,WAAKW,uBAAL,CAA6BX,IAA7B;AACD;AACF;AAED;AACF;AACA;;;;;WACE,qBAAYA,IAAZ,EAAwB;AACtB,WAAKE,IAAL,GAAYF,IAAI,CAACE,IAAjB;AACA,WAAKC,UAAL,GAAkBH,IAAI,CAACG,UAAvB;AACA,WAAKC,IAAL,GAAYJ,IAAI,CAACI,IAAjB;AACA,WAAKC,KAAL,GAAaL,IAAI,CAACK,KAAlB;AACD;AAED;AACF;;;;WACE,iCAAwBL,IAAxB,EAA0D;AAAA;;AACxD,UAAI,OAAOA,IAAI,CAAC,UAAD,CAAX,KAA4B,QAAhC,EAA0C;AACxC,aAAKE,IAAL,GAAYF,IAAI,CAACY,QAAjB;AACD,OAFD,MAEO,IAAI,OAAOZ,IAAI,CAACa,KAAZ,KAAsB,QAA1B,EAAoC;AACzC,aAAKX,IAAL,GAAYF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AAW,iBAAX,EAA8B,GAA9B,CAAtB;AACA,aAAOD,aAAa,CAACE,IAAd,CAAmBhE,IAAnB,CAAP;AACD;;;WAYD,2BAAyBA,IAAzB,EAA+C;AAC7C,UAAMiE,WAAW,GAAGC,SAAS,CAAClE,IAAD,CAA7B;AAEA,UAAMmE,UAAU,GAAG,uBAAAF,WAAW,MAAX,CAAAA,WAAW,EAAU,GAAV,CAAX,GACfA,WAAW,CAACG,MAAZ,CAAmB,CAAnB,EAAsBH,WAAW,CAACI,OAAZ,CAAoB,GAApB,CAAtB,CADe,GAEfJ,WAFJ;AAIA,aAAO,uBAAAE,UAAU,MAAV,CAAAA,UAAU,EAAU,GAAV,CAAV,GAA2BA,UAAU,CAACtC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAA3B,GAAsDsC,UAA7D;AACD;AAED;AACF;AACA;;;;WACE,6BAAoD;AAAA,UAA3BnE,IAA2B,uEAAZ,EAAY;AAClD,aAAO,uBAAAA,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GAAqBA,IAAI,CAACoE,MAAL,CAAYpE,IAAI,CAACqE,OAAL,CAAa,GAAb,IAAoB,CAAhC,CAArB,GAA0D,EAAjE;AACD;;;;;eA+SYtE,I","sourcesContent":["// @flow\nimport { BASE, CONTENT_PATH, HTTP_METHODS } from \"../../constants/Constants\";\n\nimport Parameter from \"../parameter/Parameter\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { LocationShape } from \"react-router\";\n\ntype HrefObject = {\n _path: string,\n _hash: string,\n _parameters: Array<Parameter>,\n _resourcetype: string,\n _method: $Keys<typeof HTTP_METHODS>,\n _state: ?{ [key: string]: any },\n pathname: ?string,\n};\n\nexport type HrefInput = Href | HrefObject | LocationShape | string;\n\n/**\n * Defines a Href with the parameters\n */\nclass Href {\n _path: string;\n _hash: string;\n _parameters: Array<Parameter>;\n _resourcetype: string;\n _method: $Keys<typeof HTTP_METHODS>;\n _state: ?{ +[key: string]: any };\n\n /**\n * Create a Href\n */\n constructor(href?: HrefInput, resourcetype?: string) {\n this.path = \"\";\n this.parameters = [];\n this.hash = \"\";\n this.state = null;\n this.method = HTTP_METHODS.GET;\n this.resourcetype = resourcetype || \"\";\n\n if (href instanceof Href) {\n this.setFromHref(href);\n } else if (typeof href === \"string\") {\n this.setFromString(href);\n } else if (typeof href === \"object\") {\n this.setFromLocationOrObject(href);\n }\n }\n\n /**\n * Set parameters from Href model input\n */\n setFromHref(href: Href) {\n this.path = href.path;\n this.parameters = href.parameters;\n this.hash = href.hash;\n this.state = href.state;\n }\n\n /**\n */\n setFromLocationOrObject(href: LocationShape | HrefObject) {\n if (typeof href[\"pathname\"] === \"string\") {\n this.path = href.pathname;\n } else if (typeof href._path === \"string\") {\n this.path = href._path;\n }\n\n if (href.search) {\n this.addParametersFromString(href.search);\n } else if (Array.isArray(href._parameters)) {\n // $FlowExpectedError[incompatible-call]\n href._parameters.map((param: Parameter) =>\n this.addParameter(param._name, param._value, param._prefix)\n );\n }\n\n if (href.hash) {\n this.hash = Href.getHashFromString(href.hash);\n } else if (typeof href._hash === \"string\") {\n this.hash = href._hash;\n }\n\n if (href.state) {\n this.state = href.state || null;\n } else if (typeof href._state === \"object\") {\n this.state = href._state;\n }\n }\n\n /**\n * Set parameters from string input\n */\n setFromString(href: string) {\n this.path = Href.getPathFromString(href);\n this.addParametersFromString(href);\n this.hash = Href.getHashFromString(href);\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this._path.includes(\"/change-password\");\n }\n\n /**\n * check if the path is referencing a camel route\n */\n static isCamelRoute(path: string): boolean {\n return (\n path.startsWith(\"/restServices\") && !path.startsWith(\"/restServices/ui\")\n );\n }\n\n /**\n */\n static checkAbsoluteUrl(href: string): boolean {\n const checkAbsolute = new RegExp(\"^(?:[a-z]+:)?//\", \"i\");\n return checkAbsolute.test(href);\n }\n\n // Check if url is relative (not checking for absolute urls with same domain)\n /**\n */\n get isExternal(): boolean {\n return Href.checkAbsoluteUrl(this.path);\n }\n\n /**\n * Retrieve the relative path part of a href string, e.g. https://www.beinformed.com/BeInformed/tab/view?q=url => /tab/view\n */\n static getPathFromString(href: string): string {\n const decodedHref = decodeURI(href);\n\n const hrefNoHash = decodedHref.includes(\"#\")\n ? decodedHref.substr(0, decodedHref.indexOf(\"#\"))\n : decodedHref;\n\n return hrefNoHash.includes(\"?\") ? hrefNoHash.split(\"?\")[0] : hrefNoHash;\n }\n\n /**\n * Retrieve hash of href string\n */\n static getHashFromString(href: string = \"\"): string {\n return href.includes(\"#\") ? href.substr(href.indexOf(\"#\") + 1) : \"\";\n }\n\n /**\n * Add a parameter for each parameter found in the querystring of an URL string, e.g. https://www.beinformed.com?q=url => q=url\n */\n addParametersFromString(href: string): Href {\n if (href.includes(\"?\")) {\n href\n .split(\"?\")[1]\n .split(\"&\")\n .forEach((param) => {\n const paramFromString = Parameter.fromString(param);\n if (paramFromString) {\n this.setParameter(\n paramFromString.name,\n paramFromString.value,\n paramFromString.prefix\n );\n }\n });\n }\n\n return this;\n }\n\n /**\n * Add a querystring parameter to the parameter collection of this Href, skips parameters that have a value of null\n */\n addParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value !== null) {\n this.removeParameter(name, prefix);\n this._parameters.push(new Parameter(prefix, name, value));\n }\n\n return this;\n }\n\n /**\n * Adds or overwrites a parameter when it exists and value is not null.\n * Removes the parameter when the value is null\n */\n setParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value === null) {\n this.removeParameter(name, prefix);\n } else {\n this.addParameter(name, value, prefix);\n }\n\n return this;\n }\n\n /**\n * Retrieve a parameter by it's name and (optionally) prefix\n */\n getParameter(name: string, prefix: ?string): ?Parameter {\n return this._parameters.find(\n (param) => param.prefix === prefix && param.name === name\n );\n }\n\n /**\n */\n hasParameter(name: string, prefix: ?string): boolean {\n return this.getParameter(name, prefix) !== undefined;\n }\n\n /**\n * Get request method\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n * Set request method\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method || HTTP_METHODS.GET;\n }\n\n /**\n * Retrieve all paremters\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n * Replace parameters of Href\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n * Remove a parameter from the parameter collection\n */\n removeParameter(name: string, prefix: ?string): Href {\n this._parameters = this._parameters.filter(\n (param) => param.prefix !== prefix || param.name !== name\n );\n\n return this;\n }\n\n /**\n * Get the parameters as a querystring, e.g. param1=value1&param2=value2, optionally with prefix\n */\n getQuerystring(withPrefix: boolean = false): string {\n return this.parameters\n .filter((param) => param.value != null)\n .map((param) => param.toQuerystring(withPrefix))\n .join(\"&\");\n }\n\n /**\n * Retrieve a querystring that only contains parameter that can be send to the modular ui, parameters are filtered by prefix\n */\n getQuerystringForModularUI(prefix: string = \"\"): string {\n return this.parameters\n .filter(\n (param) =>\n param.isModUIParameter &&\n (!prefix || !param.prefix || param.prefix === prefix) &&\n param.value != null\n )\n .map((param) => param.toQuerystring(false))\n .join(\"&\");\n }\n\n /**\n * Retrieve all parameters from the parameter collection in a querystring style name1=value1&name2=value2, without the prefix\n */\n get querystring(): string {\n return this.getQuerystring(false);\n }\n\n /**\n * Set the path of the Href, the part before the querystring question mark\n */\n set path(path: string) {\n this._path = path;\n }\n\n /**\n * Retrieve the path\n */\n get path(): string {\n return this._path || \"\";\n }\n\n /**\n * Set hash\n */\n set hash(hash: string) {\n this._hash = hash;\n }\n\n /**\n * Retrieve hash\n */\n get hash(): string {\n return this._hash;\n }\n\n /**\n */\n set state(state: ?{ +[key: string]: any }) {\n this._state = state;\n }\n\n /**\n */\n get state(): ?{ +[key: string]: any } {\n return this._state;\n }\n\n /**\n */\n setState(state: { [key: string]: any }): Href {\n this.state = state;\n\n return this;\n }\n\n /**\n * Set resourctype\n */\n set resourcetype(resourcetype: string) {\n this._resourcetype = resourcetype;\n }\n\n /**\n * Retrieve resourceType\n */\n get resourcetype(): string {\n return this._resourcetype;\n }\n\n /**\n * Retrieve the path combined with the BASE of the application, e.g. /BeInformed\n */\n get absolutepath(): string {\n if (this.isExternal) {\n return this.path;\n }\n\n return BASE + this.path;\n }\n\n /**\n * Retrieves the combination of the path and the querystring\n */\n get href(): string {\n return this.querystring.length > 0\n ? [this.path, this.querystring].join(\"?\")\n : this.path;\n }\n\n /**\n * Getting the URL including the base path\n */\n get absolutehref(): string {\n const querystring = this.getQuerystring(true);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Checks if the URL starts within the given href\n */\n startsWith(href: Href | string): boolean {\n const thisPath = `${this.path}/`;\n const otherPath = href instanceof Href ? `${href.path}/` : href;\n\n return thisPath.startsWith(otherPath);\n }\n\n /**\n * Checks if the given Href equals this Href\n */\n equals(href: Href | string): boolean {\n if (href instanceof Href) {\n return this.path === href.path;\n }\n\n return this.path === href;\n }\n\n /**\n */\n equalsWithParameters(href: Href): boolean {\n if (!this.equals(href)) {\n return false;\n }\n\n if (href instanceof Href) {\n if (this.parameters.length !== href.parameters.length) {\n return false;\n }\n\n if (this.parameters.length === 0 && href.parameters.length === 0) {\n return true;\n }\n\n const thisParams = this.parameters.map((param) => param.toString());\n\n return href.parameters.every((param) =>\n thisParams.includes(param.toString())\n );\n }\n\n throw new IllegalArgumentException(`${href} is not an instance of Href`);\n }\n\n /**\n * Indicates if the link is a content link\n */\n get isContent(): boolean {\n return this.absolutepath.startsWith(CONTENT_PATH);\n }\n\n /**\n * Returns a complete url from the Href\n */\n toString(): string {\n return this.href;\n }\n\n /**\n */\n toLocation(): LocationShape {\n return {\n pathname: this.path,\n search: this.querystring.length > 0 ? `?${this.querystring}` : \"\",\n hash: this.hash.length > 0 ? `#${this.hash}` : \"\",\n state: this.state,\n };\n }\n}\n\nexport default Href;\n"],"file":"Href.js"}
1
+ {"version":3,"sources":["../../../src/models/href/Href.js"],"names":["Href","href","resourcetype","path","parameters","hash","state","method","HTTP_METHODS","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","Parameter","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","BASE","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","IllegalArgumentException","CONTENT_PATH","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAgBA;AACA;AACA;IACMA,I;AAQJ;AACF;AACA;AACE,gBAAYC,IAAZ,EAA8BC,YAA9B,EAAqD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACnD,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,KAAL,GAAa,IAAb;AACA,SAAKC,MAAL,GAAcC,wBAAaC,GAA3B;AACA,SAAKP,YAAL,GAAoBA,YAAY,IAAI,EAApC;;AAEA,QAAID,IAAI,YAAYD,IAApB,EAA0B;AACxB,WAAKU,WAAL,CAAiBT,IAAjB;AACD,KAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AACnC,WAAKU,aAAL,CAAmBV,IAAnB;AACD,KAFM,MAEA,IAAI,sBAAOA,IAAP,MAAgB,QAApB,EAA8B;AACnC,WAAKW,uBAAL,CAA6BX,IAA7B;AACD;AACF;AAED;AACF;AACA;;;;;WACE,qBAAYA,IAAZ,EAAwB;AACtB,WAAKE,IAAL,GAAYF,IAAI,CAACE,IAAjB;AACA,WAAKC,UAAL,GAAkBH,IAAI,CAACG,UAAvB;AACA,WAAKC,IAAL,GAAYJ,IAAI,CAACI,IAAj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AAI,CAACqE,OAAL,CAAa,GAAb,IAAoB,CAAhC,CAArB,GAA0D,EAAjE;AACD;;;;;eA0TYtE,I","sourcesContent":["// @flow\nimport { BASE, CONTENT_PATH, HTTP_METHODS } from \"../../constants/Constants\";\n\nimport Parameter from \"../parameter/Parameter\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { LocationShape } from \"react-router\";\n\ntype HrefObject = {\n _path: string,\n _hash: string,\n _parameters: Array<Parameter>,\n _resourcetype: string,\n _method: $Keys<typeof HTTP_METHODS>,\n _state: ?{ [key: string]: any },\n pathname: ?string,\n};\n\nexport type HrefInput = Href | HrefObject | LocationShape | string;\n\n/**\n * Defines a Href with the parameters\n */\nclass Href {\n _path: string;\n _hash: string;\n _parameters: Array<Parameter>;\n _resourcetype: string;\n _method: $Keys<typeof HTTP_METHODS>;\n _state: ?{ +[key: string]: any };\n\n /**\n * Create a Href\n */\n constructor(href?: HrefInput, resourcetype?: string) {\n this.path = \"\";\n this.parameters = [];\n this.hash = \"\";\n this.state = null;\n this.method = HTTP_METHODS.GET;\n this.resourcetype = resourcetype || \"\";\n\n if (href instanceof Href) {\n this.setFromHref(href);\n } else if (typeof href === \"string\") {\n this.setFromString(href);\n } else if (typeof href === \"object\") {\n this.setFromLocationOrObject(href);\n }\n }\n\n /**\n * Set parameters from Href model input\n */\n setFromHref(href: Href) {\n this.path = href.path;\n this.parameters = href.parameters;\n this.hash = href.hash;\n this.state = href.state;\n }\n\n /**\n */\n setFromLocationOrObject(href: LocationShape | HrefObject) {\n if (typeof href[\"pathname\"] === \"string\") {\n this.path = href.pathname;\n } else if (typeof href._path === \"string\") {\n this.path = href._path;\n }\n\n if (href.search) {\n this.addParametersFromString(href.search);\n } else if (Array.isArray(href._parameters)) {\n // $FlowExpectedError[incompatible-call]\n href._parameters.map((param: Parameter) =>\n this.addParameter(param._name, param._value, param._prefix)\n );\n }\n\n if (href.hash) {\n this.hash = Href.getHashFromString(href.hash);\n } else if (typeof href._hash === \"string\") {\n this.hash = href._hash;\n }\n\n if (href.state) {\n this.state = href.state || null;\n } else if (typeof href._state === \"object\") {\n this.state = href._state;\n }\n }\n\n /**\n * Set parameters from string input\n */\n setFromString(href: string) {\n this.path = Href.getPathFromString(href);\n this.addParametersFromString(href);\n this.hash = Href.getHashFromString(href);\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this._path.includes(\"/change-password\");\n }\n\n /**\n * check if the path is referencing a camel route\n */\n static isCamelRoute(path: string): boolean {\n return (\n path.startsWith(\"/restServices\") && !path.startsWith(\"/restServices/ui\")\n );\n }\n\n /**\n */\n static checkAbsoluteUrl(href: string): boolean {\n const checkAbsolute = new RegExp(\"^(?:[a-z]+:)?//\", \"i\");\n return checkAbsolute.test(href);\n }\n\n // Check if url is relative (not checking for absolute urls with same domain)\n /**\n */\n get isExternal(): boolean {\n return Href.checkAbsoluteUrl(this.path);\n }\n\n /**\n * Retrieve the relative path part of a href string, e.g. https://www.beinformed.com/BeInformed/tab/view?q=url => /tab/view\n */\n static getPathFromString(href: string): string {\n const decodedHref = decodeURI(href);\n\n const hrefNoHash = decodedHref.includes(\"#\")\n ? decodedHref.substr(0, decodedHref.indexOf(\"#\"))\n : decodedHref;\n\n return hrefNoHash.includes(\"?\") ? hrefNoHash.split(\"?\")[0] : hrefNoHash;\n }\n\n /**\n * Retrieve hash of href string\n */\n static getHashFromString(href: string = \"\"): string {\n return href.includes(\"#\") ? href.substr(href.indexOf(\"#\") + 1) : \"\";\n }\n\n /**\n * Add a parameter for each parameter found in the querystring of an URL string, e.g. https://www.beinformed.com?q=url => q=url\n */\n addParametersFromString(href: string): Href {\n if (href.includes(\"?\")) {\n href\n .split(\"?\")[1]\n .split(\"&\")\n .forEach((param) => {\n const paramFromString = Parameter.fromString(param);\n if (paramFromString) {\n this.setParameter(\n paramFromString.name,\n paramFromString.value,\n paramFromString.prefix\n );\n }\n });\n }\n\n return this;\n }\n\n /**\n * Add a querystring parameter to the parameter collection of this Href, skips parameters that have a value of null\n */\n addParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value !== null) {\n this.removeParameter(name, prefix);\n this._parameters.push(new Parameter(prefix, name, value));\n }\n\n return this;\n }\n\n /**\n * Adds or overwrites a parameter when it exists and value is not null.\n * Removes the parameter when the value is null\n */\n setParameter(name: string, value: ?string, prefix: ?string): Href {\n if (value === null) {\n this.removeParameter(name, prefix);\n } else {\n this.addParameter(name, value, prefix);\n }\n\n return this;\n }\n\n /**\n * Retrieve a parameter by it's name and (optionally) prefix\n */\n getParameter(name: string, prefix: ?string): ?Parameter {\n return this._parameters.find(\n (param) => param.prefix === prefix && param.name === name\n );\n }\n\n /**\n */\n hasParameter(name: string, prefix: ?string): boolean {\n return this.getParameter(name, prefix) !== undefined;\n }\n\n /**\n * Get request method\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n * Set request method\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method || HTTP_METHODS.GET;\n }\n\n /**\n * Retrieve all paremters\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n * Replace parameters of Href\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n * Remove a parameter from the parameter collection\n */\n removeParameter(name: string, prefix: ?string): Href {\n this._parameters = this._parameters.filter(\n (param) => param.prefix !== prefix || param.name !== name\n );\n\n return this;\n }\n\n /**\n * Get the parameters as a querystring, e.g. param1=value1&param2=value2, optionally with prefix\n */\n getQuerystring(withPrefix: boolean = false): string {\n return this.parameters\n .filter((param) => param.value != null)\n .map((param) => param.toQuerystring(withPrefix))\n .join(\"&\");\n }\n\n /**\n * Retrieve a querystring that only contains parameter that can be send to the modular ui, parameters are filtered by prefix\n */\n getQuerystringForModularUI(prefix: string = \"\"): string {\n return this.parameters\n .filter(\n (param) =>\n param.isModUIParameter &&\n (!prefix || !param.prefix || param.prefix === prefix) &&\n param.value != null\n )\n .map((param) => param.toQuerystring(false))\n .join(\"&\");\n }\n\n /**\n * Retrieve all parameters from the parameter collection in a querystring style name1=value1&name2=value2, without the prefix\n */\n get querystring(): string {\n return this.getQuerystring(false);\n }\n\n /**\n * Set the path of the Href, the part before the querystring question mark\n */\n set path(path: string) {\n this._path = path;\n }\n\n /**\n * Retrieve the path\n */\n get path(): string {\n return this._path || \"\";\n }\n\n /**\n * Set hash\n */\n set hash(hash: string) {\n this._hash = hash;\n }\n\n /**\n * Retrieve hash\n */\n get hash(): string {\n return this._hash;\n }\n\n /**\n */\n set state(state: ?{ +[key: string]: any }) {\n this._state = state;\n }\n\n /**\n */\n get state(): ?{ +[key: string]: any } {\n return this._state;\n }\n\n /**\n */\n setState(state: { [key: string]: any }): Href {\n this.state = state;\n\n return this;\n }\n\n /**\n * Set resourctype\n */\n set resourcetype(resourcetype: string) {\n this._resourcetype = resourcetype;\n }\n\n /**\n * Retrieve resourceType\n */\n get resourcetype(): string {\n return this._resourcetype;\n }\n\n /**\n * Retrieve the path combined with the BASE of the application, e.g. /BeInformed\n */\n get absolutepath(): string {\n if (this.isExternal) {\n return this.path;\n }\n\n return BASE + this.path;\n }\n\n /**\n * Retrieves the combination of the path and the querystring\n */\n get href(): string {\n return this.querystring.length > 0\n ? [this.path, this.querystring].join(\"?\")\n : this.path;\n }\n\n /**\n * Getting the URL including the base path, querystring is prefixed\n */\n get absolutehref(): string {\n const querystring = this.getQuerystring(false);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Getting the URL including the base path, the querystring is prefixed\n */\n get absolutehrefPrefixedQuerystring(): string {\n const querystring = this.getQuerystring(true);\n\n return querystring.length > 0\n ? [this.absolutepath, querystring].join(\"?\")\n : this.absolutepath;\n }\n\n /**\n * Checks if the URL starts within the given href\n */\n startsWith(href: Href | string): boolean {\n const thisPath = `${this.path}/`;\n const otherPath = href instanceof Href ? `${href.path}/` : href;\n\n return thisPath.startsWith(otherPath);\n }\n\n /**\n * Checks if the given Href equals this Href\n */\n equals(href: Href | string): boolean {\n if (href instanceof Href) {\n return this.path === href.path;\n }\n\n return this.path === href;\n }\n\n /**\n */\n equalsWithParameters(href: Href): boolean {\n if (!this.equals(href)) {\n return false;\n }\n\n if (href instanceof Href) {\n if (this.parameters.length !== href.parameters.length) {\n return false;\n }\n\n if (this.parameters.length === 0 && href.parameters.length === 0) {\n return true;\n }\n\n const thisParams = this.parameters.map((param) => param.toString());\n\n return href.parameters.every((param) =>\n thisParams.includes(param.toString())\n );\n }\n\n throw new IllegalArgumentException(`${href} is not an instance of Href`);\n }\n\n /**\n * Indicates if the link is a content link\n */\n get isContent(): boolean {\n return this.absolutepath.startsWith(CONTENT_PATH);\n }\n\n /**\n * Returns a complete url from the Href\n */\n toString(): string {\n return this.href;\n }\n\n /**\n */\n toLocation(): LocationShape {\n return {\n pathname: this.path,\n search: this.querystring.length > 0 ? `?${this.querystring}` : \"\",\n hash: this.hash.length > 0 ? `#${this.hash}` : \"\",\n state: this.state,\n };\n }\n}\n\nexport default Href;\n"],"file":"Href.js"}
@@ -107,6 +107,12 @@ Object.defineProperty(exports, "ChoiceAttributeModel", {
107
107
  return _ChoiceAttributeModel.default;
108
108
  }
109
109
  });
110
+ Object.defineProperty(exports, "ChoiceAttributeOptionCollection", {
111
+ enumerable: true,
112
+ get: function get() {
113
+ return _ChoiceAttributeOptionCollection.default;
114
+ }
115
+ });
110
116
  Object.defineProperty(exports, "ChoiceAttributeOptionModel", {
111
117
  enumerable: true,
112
118
  get: function get() {
@@ -598,6 +604,8 @@ var _CaptchaAttributeModel = _interopRequireDefault(require("./attributes/Captch
598
604
 
599
605
  var _ChoiceAttributeModel = _interopRequireDefault(require("./attributes/ChoiceAttributeModel"));
600
606
 
607
+ var _ChoiceAttributeOptionCollection = _interopRequireDefault(require("./attributes/ChoiceAttributeOptionCollection"));
608
+
601
609
  var _ChoiceAttributeOptionModel = _interopRequireDefault(require("./attributes/ChoiceAttributeOptionModel"));
602
610
 
603
611
  var _CompositeAttributeModel = _interopRequireDefault(require("./attributes/CompositeAttributeModel"));
@@ -15,6 +15,7 @@ export { default as AttributeModel } from "./attributes/AttributeModel";
15
15
  import { default as BooleanAttributeModel } from "./attributes/BooleanAttributeModel";
16
16
  import { default as CaptchaAttributeModel } from "./attributes/CaptchaAttributeModel";
17
17
  import { default as ChoiceAttributeModel } from "./attributes/ChoiceAttributeModel";
18
+ export { default as ChoiceAttributeOptionCollection } from "./attributes/ChoiceAttributeOptionCollection";
18
19
  export { default as ChoiceAttributeOptionModel } from "./attributes/ChoiceAttributeOptionModel";
19
20
  import { default as CompositeAttributeModel } from "./attributes/CompositeAttributeModel";
20
21
  export { default as CompositeAttributeChildCollection } from "./attributes/CompositeAttributeChildCollection";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAKA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\nexport { default as resolveModel } from \"./resolveModel\";\n\nexport { default as BaseCollection } from \"./base/BaseCollection\";\n\nexport { default as ActionCollection } from \"./actions/ActionCollection\";\nexport { default as ActionModel } from \"./actions/ActionModel\";\n\nimport { default as ApplicationModel } from \"./application/ApplicationModel\";\n\nexport { default as AttributeCollection } from \"./attributes/AttributeCollection\";\nexport { default as AttributeSetModel } from \"./attributes/AttributeSetModel\";\n\nexport { default as AttributeModel } from \"./attributes/AttributeModel\";\nimport { default as BooleanAttributeModel } from \"./attributes/BooleanAttributeModel\";\nimport { default as CaptchaAttributeModel } from \"./attributes/CaptchaAttributeModel\";\nimport { default as ChoiceAttributeModel } from \"./attributes/ChoiceAttributeModel\";\nexport { default as ChoiceAttributeOptionModel } from \"./attributes/ChoiceAttributeOptionModel\";\nimport { default as CompositeAttributeModel } from \"./attributes/CompositeAttributeModel\";\nexport { default as CompositeAttributeChildCollection } from \"./attributes/CompositeAttributeChildCollection\";\nimport { default as DatetimeAttributeModel } from \"./attributes/DatetimeAttributeModel\";\nimport { default as HelptextAttributeModel } from \"./attributes/HelptextAttributeModel\";\nimport { default as LabelAttributeModel } from \"./attributes/LabelAttributeModel\";\nimport { default as MemoAttributeModel } from \"./attributes/MemoAttributeModel\";\nimport { default as MoneyAttributeModel } from \"./attributes/MoneyAttributeModel\";\nimport { default as NumberAttributeModel } from \"./attributes/NumberAttributeModel\";\nimport { default as PasswordAttributeModel } from \"./attributes/PasswordAttributeModel\";\nimport { default as StringAttributeModel } from \"./attributes/StringAttributeModel\";\nimport { default as UploadAttributeModel } from \"./attributes/UploadAttributeModel\";\nimport { default as XMLAttributeModel } from \"./attributes/XMLAttributeModel\";\n\nexport { default as AttributeContent } from \"./attributes/AttributeContent\";\n\nexport {\n default as LayoutHintRuleCollection,\n addLayoutHintRule,\n updateLayoutHintRules,\n} from \"./attributes/layouthint-rules/LayoutHintRuleCollection\";\nexport { default as BaseLayoutHintRule } from \"./attributes/layouthint-rules/BaseLayoutHintRule\";\nexport { default as DependentAttribute } from \"./attributes/layouthint-rules/DependentAttribute\";\nexport { default as RemainingTotalUploadSize } from \"./attributes/layouthint-rules/RemainingTotalUploadSize\";\n\nimport { default as CaseViewModel } from \"./caseview/CaseViewModel\";\n\nimport { default as BusinessScenarioModel } from \"./concepts/BusinessScenarioModel\";\nimport { default as ConceptDetailModel } from \"./concepts/ConceptDetailModel\";\nimport { default as ConceptIndexModel } from \"./concepts/ConceptIndexModel\";\nexport { default as ConceptLinkModel } from \"./concepts/ConceptLinkModel\";\nexport { default as ConceptRelationCollection } from \"./concepts/ConceptRelationCollection\";\nexport { default as ConceptRelationModel } from \"./concepts/ConceptRelationModel\";\nimport { default as ConceptTypeDetailModel } from \"./concepts/ConceptTypeDetailModel\";\nexport { default as SourceReferenceCollection } from \"./concepts/SourceReferenceCollection\";\nexport { default as SourceReferenceModel } from \"./concepts/SourceReferenceModel\";\n\nexport { default as ConstraintCollection } from \"./attributes/input-constraints/ConstraintCollection\";\nexport { default as ConstraintModel } from \"./attributes/input-constraints/ConstraintModel\";\n\nimport { default as ContentIndexModel } from \"./content/ContentIndexModel\";\nexport { default as ContentLinkModel } from \"./content/ContentLinkModel\";\nimport { default as ContentModel } from \"./content/ContentModel\";\nimport { default as ContentTOCModel } from \"./content/ContentTOCModel\";\nimport { default as ContentTypeModel } from \"./content/ContentTypeModel\";\nexport { default as SectionModel } from \"./content/SectionModel\";\nexport { default as SubSectionModel } from \"./content/SubSectionModel\";\n\nexport { default as ContentConfiguration } from \"./contentconfiguration/ContentConfiguration\";\nexport { default as ContentConfigurationElements } from \"./contentconfiguration/ContentConfigurationElements\";\nexport { default as ContentConfigurationEndResults } from \"./contentconfiguration/ContentConfigurationEndResults\";\nexport { default as ContentConfigurationQuestions } from \"./contentconfiguration/ContentConfigurationQuestions\";\nexport { default as ContentConfigurationResults } from \"./contentconfiguration/ContentConfigurationResults\";\n\nimport { default as DetailModel } from \"./detail/DetailModel\";\n\nexport { default as ErrorCollection } from \"./error/ErrorCollection\";\nexport { default as ErrorModel } from \"./error/ErrorModel\";\nexport { default as ErrorResponse } from \"./error/ErrorResponse\";\n\nimport { default as AssignmentFilterModel } from \"./filters/AssignmentFilterModel\";\nimport { default as FilterModel } from \"./filters/FilterModel\";\nimport { default as RangeFilterModel } from \"./filters/RangeFilterModel\";\nimport { default as ConceptIndexFilterModel } from \"./filters/ConceptIndexFilterModel\";\nexport { default as FilterCollection } from \"./filters/FilterCollection\";\n\nimport { default as FormModel } from \"./form/FormModel\";\nexport { default as FormObjectModel } from \"./form/FormObjectModel\";\n\nexport { default as GroupingModel, GroupModel } from \"./grouping/GroupingModel\";\n\nexport { default as Href } from \"./href/Href\";\nexport { default as ListHref } from \"./href/ListHref\";\n\nexport { default as LinkCollection } from \"./links/LinkCollection\";\nexport { default as LinkModel } from \"./links/LinkModel\";\n\nimport { default as ListDetailModel } from \"./list/ListDetailModel\";\nexport { default as ListHeaderModel } from \"./list/ListHeaderModel\";\nexport { default as ListItemCollection } from \"./list/ListItemCollection\";\nexport { default as ListItemModel } from \"./list/ListItemModel\";\nimport { default as ListModel } from \"./list/ListModel\";\n\nexport { default as LookupOptionsModel } from \"./lookup/LookupOptionsModel\";\nexport { default as LookupOptionCollection } from \"./lookup/LookupOptionCollection\";\n\nimport { default as ModelCatalogModel } from \"./modelcatalog/ModelCatalogModel\";\n\nexport { default as ProcessStatusSettingsModel } from \"./process/ProcessStatusSettingsModel\";\n\nexport { default as PagesizeModel } from \"./paging/PagesizeModel\";\nexport { default as PagingModel } from \"./paging/PagingModel\";\n\nexport { default as Parameter } from \"./parameter/Parameter\";\n\nimport { default as GroupingPanelModel } from \"./panels/GroupingPanelModel\";\n\nimport { default as CaseSearchModel } from \"./search/CaseSearchModel\";\n\nexport { default as SortingModel } from \"./sorting/SortingModel\";\nexport { default as SortOptionModel } from \"./sorting/SortOptionModel\";\n\nimport { default as TabModel } from \"./tab/TabModel\";\n\nexport { default as TaskGroupCollection } from \"./taskgroup/TaskGroupCollection\";\nimport { default as TaskGroupModel } from \"./taskgroup/TaskGroupModel\";\n\nimport { default as UserModel } from \"./user/UserModel\";\nimport { default as UserProfileModel } from \"./user/UserProfileModel\";\nimport { default as UserServicesModel } from \"./user/UserServicesModel\";\n\nexport {\n ApplicationModel,\n CaseSearchModel,\n CaseViewModel,\n ListDetailModel,\n DetailModel,\n FormModel,\n GroupingPanelModel,\n ListModel,\n TabModel,\n TaskGroupModel,\n UserModel,\n UserProfileModel,\n UserServicesModel,\n ModelCatalogModel,\n ConceptIndexModel,\n ConceptDetailModel,\n BusinessScenarioModel,\n ConceptTypeDetailModel,\n ContentIndexModel,\n ContentTOCModel,\n ContentModel,\n ContentTypeModel,\n BooleanAttributeModel,\n CaptchaAttributeModel,\n ChoiceAttributeModel,\n DatetimeAttributeModel,\n HelptextAttributeModel,\n LabelAttributeModel,\n MemoAttributeModel,\n MoneyAttributeModel,\n NumberAttributeModel,\n PasswordAttributeModel,\n CompositeAttributeModel,\n StringAttributeModel,\n UploadAttributeModel,\n XMLAttributeModel,\n AssignmentFilterModel,\n FilterModel,\n RangeFilterModel,\n ConceptIndexFilterModel,\n};\n\nexport type * from \"./types\";\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/models/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAKA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AACA","sourcesContent":["// @flow\nexport { default as resolveModel } from \"./resolveModel\";\n\nexport { default as BaseCollection } from \"./base/BaseCollection\";\n\nexport { default as ActionCollection } from \"./actions/ActionCollection\";\nexport { default as ActionModel } from \"./actions/ActionModel\";\n\nimport { default as ApplicationModel } from \"./application/ApplicationModel\";\n\nexport { default as AttributeCollection } from \"./attributes/AttributeCollection\";\nexport { default as AttributeSetModel } from \"./attributes/AttributeSetModel\";\n\nexport { default as AttributeModel } from \"./attributes/AttributeModel\";\nimport { default as BooleanAttributeModel } from \"./attributes/BooleanAttributeModel\";\nimport { default as CaptchaAttributeModel } from \"./attributes/CaptchaAttributeModel\";\nimport { default as ChoiceAttributeModel } from \"./attributes/ChoiceAttributeModel\";\nexport { default as ChoiceAttributeOptionCollection } from \"./attributes/ChoiceAttributeOptionCollection\";\nexport { default as ChoiceAttributeOptionModel } from \"./attributes/ChoiceAttributeOptionModel\";\nimport { default as CompositeAttributeModel } from \"./attributes/CompositeAttributeModel\";\nexport { default as CompositeAttributeChildCollection } from \"./attributes/CompositeAttributeChildCollection\";\nimport { default as DatetimeAttributeModel } from \"./attributes/DatetimeAttributeModel\";\nimport { default as HelptextAttributeModel } from \"./attributes/HelptextAttributeModel\";\nimport { default as LabelAttributeModel } from \"./attributes/LabelAttributeModel\";\nimport { default as MemoAttributeModel } from \"./attributes/MemoAttributeModel\";\nimport { default as MoneyAttributeModel } from \"./attributes/MoneyAttributeModel\";\nimport { default as NumberAttributeModel } from \"./attributes/NumberAttributeModel\";\nimport { default as PasswordAttributeModel } from \"./attributes/PasswordAttributeModel\";\nimport { default as StringAttributeModel } from \"./attributes/StringAttributeModel\";\nimport { default as UploadAttributeModel } from \"./attributes/UploadAttributeModel\";\nimport { default as XMLAttributeModel } from \"./attributes/XMLAttributeModel\";\n\nexport { default as AttributeContent } from \"./attributes/AttributeContent\";\n\nexport {\n default as LayoutHintRuleCollection,\n addLayoutHintRule,\n updateLayoutHintRules,\n} from \"./attributes/layouthint-rules/LayoutHintRuleCollection\";\nexport { default as BaseLayoutHintRule } from \"./attributes/layouthint-rules/BaseLayoutHintRule\";\nexport { default as DependentAttribute } from \"./attributes/layouthint-rules/DependentAttribute\";\nexport { default as RemainingTotalUploadSize } from \"./attributes/layouthint-rules/RemainingTotalUploadSize\";\n\nimport { default as CaseViewModel } from \"./caseview/CaseViewModel\";\n\nimport { default as BusinessScenarioModel } from \"./concepts/BusinessScenarioModel\";\nimport { default as ConceptDetailModel } from \"./concepts/ConceptDetailModel\";\nimport { default as ConceptIndexModel } from \"./concepts/ConceptIndexModel\";\nexport { default as ConceptLinkModel } from \"./concepts/ConceptLinkModel\";\nexport { default as ConceptRelationCollection } from \"./concepts/ConceptRelationCollection\";\nexport { default as ConceptRelationModel } from \"./concepts/ConceptRelationModel\";\nimport { default as ConceptTypeDetailModel } from \"./concepts/ConceptTypeDetailModel\";\nexport { default as SourceReferenceCollection } from \"./concepts/SourceReferenceCollection\";\nexport { default as SourceReferenceModel } from \"./concepts/SourceReferenceModel\";\n\nexport { default as ConstraintCollection } from \"./attributes/input-constraints/ConstraintCollection\";\nexport { default as ConstraintModel } from \"./attributes/input-constraints/ConstraintModel\";\n\nimport { default as ContentIndexModel } from \"./content/ContentIndexModel\";\nexport { default as ContentLinkModel } from \"./content/ContentLinkModel\";\nimport { default as ContentModel } from \"./content/ContentModel\";\nimport { default as ContentTOCModel } from \"./content/ContentTOCModel\";\nimport { default as ContentTypeModel } from \"./content/ContentTypeModel\";\nexport { default as SectionModel } from \"./content/SectionModel\";\nexport { default as SubSectionModel } from \"./content/SubSectionModel\";\n\nexport { default as ContentConfiguration } from \"./contentconfiguration/ContentConfiguration\";\nexport { default as ContentConfigurationElements } from \"./contentconfiguration/ContentConfigurationElements\";\nexport { default as ContentConfigurationEndResults } from \"./contentconfiguration/ContentConfigurationEndResults\";\nexport { default as ContentConfigurationQuestions } from \"./contentconfiguration/ContentConfigurationQuestions\";\nexport { default as ContentConfigurationResults } from \"./contentconfiguration/ContentConfigurationResults\";\n\nimport { default as DetailModel } from \"./detail/DetailModel\";\n\nexport { default as ErrorCollection } from \"./error/ErrorCollection\";\nexport { default as ErrorModel } from \"./error/ErrorModel\";\nexport { default as ErrorResponse } from \"./error/ErrorResponse\";\n\nimport { default as AssignmentFilterModel } from \"./filters/AssignmentFilterModel\";\nimport { default as FilterModel } from \"./filters/FilterModel\";\nimport { default as RangeFilterModel } from \"./filters/RangeFilterModel\";\nimport { default as ConceptIndexFilterModel } from \"./filters/ConceptIndexFilterModel\";\nexport { default as FilterCollection } from \"./filters/FilterCollection\";\n\nimport { default as FormModel } from \"./form/FormModel\";\nexport { default as FormObjectModel } from \"./form/FormObjectModel\";\n\nexport { default as GroupingModel, GroupModel } from \"./grouping/GroupingModel\";\n\nexport { default as Href } from \"./href/Href\";\nexport { default as ListHref } from \"./href/ListHref\";\n\nexport { default as LinkCollection } from \"./links/LinkCollection\";\nexport { default as LinkModel } from \"./links/LinkModel\";\n\nimport { default as ListDetailModel } from \"./list/ListDetailModel\";\nexport { default as ListHeaderModel } from \"./list/ListHeaderModel\";\nexport { default as ListItemCollection } from \"./list/ListItemCollection\";\nexport { default as ListItemModel } from \"./list/ListItemModel\";\nimport { default as ListModel } from \"./list/ListModel\";\n\nexport { default as LookupOptionsModel } from \"./lookup/LookupOptionsModel\";\nexport { default as LookupOptionCollection } from \"./lookup/LookupOptionCollection\";\n\nimport { default as ModelCatalogModel } from \"./modelcatalog/ModelCatalogModel\";\n\nexport { default as ProcessStatusSettingsModel } from \"./process/ProcessStatusSettingsModel\";\n\nexport { default as PagesizeModel } from \"./paging/PagesizeModel\";\nexport { default as PagingModel } from \"./paging/PagingModel\";\n\nexport { default as Parameter } from \"./parameter/Parameter\";\n\nimport { default as GroupingPanelModel } from \"./panels/GroupingPanelModel\";\n\nimport { default as CaseSearchModel } from \"./search/CaseSearchModel\";\n\nexport { default as SortingModel } from \"./sorting/SortingModel\";\nexport { default as SortOptionModel } from \"./sorting/SortOptionModel\";\n\nimport { default as TabModel } from \"./tab/TabModel\";\n\nexport { default as TaskGroupCollection } from \"./taskgroup/TaskGroupCollection\";\nimport { default as TaskGroupModel } from \"./taskgroup/TaskGroupModel\";\n\nimport { default as UserModel } from \"./user/UserModel\";\nimport { default as UserProfileModel } from \"./user/UserProfileModel\";\nimport { default as UserServicesModel } from \"./user/UserServicesModel\";\n\nexport {\n ApplicationModel,\n CaseSearchModel,\n CaseViewModel,\n ListDetailModel,\n DetailModel,\n FormModel,\n GroupingPanelModel,\n ListModel,\n TabModel,\n TaskGroupModel,\n UserModel,\n UserProfileModel,\n UserServicesModel,\n ModelCatalogModel,\n ConceptIndexModel,\n ConceptDetailModel,\n BusinessScenarioModel,\n ConceptTypeDetailModel,\n ContentIndexModel,\n ContentTOCModel,\n ContentModel,\n ContentTypeModel,\n BooleanAttributeModel,\n CaptchaAttributeModel,\n ChoiceAttributeModel,\n DatetimeAttributeModel,\n HelptextAttributeModel,\n LabelAttributeModel,\n MemoAttributeModel,\n MoneyAttributeModel,\n NumberAttributeModel,\n PasswordAttributeModel,\n CompositeAttributeModel,\n StringAttributeModel,\n UploadAttributeModel,\n XMLAttributeModel,\n AssignmentFilterModel,\n FilterModel,\n RangeFilterModel,\n ConceptIndexFilterModel,\n};\n\nexport type * from \"./types\";\n"],"file":"index.js"}
@@ -3,6 +3,8 @@ import {
3
3
  resourceRedirectsToSecureLogin,
4
4
  } from "../checkResource";
5
5
 
6
+ import Href from "../../../models/href/Href";
7
+
6
8
  const mockXMLHttpRequest = () => {
7
9
  const mock = {
8
10
  open: jest.fn(),
@@ -26,22 +28,22 @@ describe("checkResource", () => {
26
28
  const mock = mockXMLHttpRequest();
27
29
  mock.status = 200;
28
30
 
29
- expect.assertions(1);
30
-
31
31
  const exists = resourceExists("/");
32
-
33
32
  expect(exists).toBe(true);
33
+
34
+ const hrefExists = resourceExists(new Href("/caseview"));
35
+ expect(hrefExists).toBe(true);
34
36
  });
35
37
 
36
38
  it("indicates a resource does not exists if it has a status code of 404", () => {
37
39
  const mock = mockXMLHttpRequest();
38
40
  mock.status = 404;
39
41
 
40
- expect.assertions(1);
41
-
42
42
  const exists = resourceExists("/");
43
-
44
43
  expect(exists).toBe(false);
44
+
45
+ const hrefExists = resourceExists(new Href("/caseview"));
46
+ expect(hrefExists).toBe(false);
45
47
  });
46
48
 
47
49
  it("indicates resource request redirects to secureLogin", () => {
@@ -50,7 +52,9 @@ describe("checkResource", () => {
50
52
  mock.status = 400;
51
53
 
52
54
  const toLogin = resourceRedirectsToSecureLogin("/");
53
-
54
55
  expect(toLogin).toBe(true);
56
+
57
+ const hrefToLogin = resourceExists(new Href("/caseview"));
58
+ expect(hrefToLogin).toBe(true);
55
59
  });
56
60
  });
@@ -7,11 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.resourceRedirectsToSecureLogin = exports.resourceExists = void 0;
9
9
 
10
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
-
12
10
  var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/ends-with"));
13
11
 
14
- var _Constants = require("../../constants/Constants");
12
+ var _Href = _interopRequireDefault(require("../../models/href/Href"));
15
13
 
16
14
  /**
17
15
  * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
@@ -21,9 +19,8 @@ var _Constants = require("../../constants/Constants");
21
19
  * @returns {boolean}
22
20
  */
23
21
  var resourceExists = function resourceExists(url) {
24
- var _context;
22
+ var fullUrl = new _Href.default(url).absolutehref; // const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
25
23
 
26
- var fullUrl = (0, _concat.default)(_context = "".concat(_Constants.BASE, "/")).call(_context, url).replace(/\/\//g, "/");
27
24
  var xhr = new XMLHttpRequest();
28
25
  xhr.open("HEAD", fullUrl, false);
29
26
  xhr.setRequestHeader("Accept", "application/json");
@@ -41,9 +38,9 @@ var resourceExists = function resourceExists(url) {
41
38
  exports.resourceExists = resourceExists;
42
39
 
43
40
  var resourceRedirectsToSecureLogin = function resourceRedirectsToSecureLogin(url) {
44
- var _context2, _xhr$responseURL;
41
+ var _xhr$responseURL;
45
42
 
46
- var fullUrl = (0, _concat.default)(_context2 = "".concat(_Constants.BASE, "/")).call(_context2, url).replace(/\/\//g, "/");
43
+ var fullUrl = new _Href.default(url).absolutehref;
47
44
  var xhr = new XMLHttpRequest();
48
45
  xhr.open("HEAD", fullUrl, false);
49
46
  xhr.setRequestHeader("Accept", "application/json");
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import { BASE } from "../../constants/Constants";
2
+ import Href from "../../models/href/Href";
3
3
 
4
4
  /**
5
5
  * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
@@ -8,8 +8,10 @@ import { BASE } from "../../constants/Constants";
8
8
  * @param url
9
9
  * @returns {boolean}
10
10
  */
11
- export const resourceExists = (url: string): boolean => {
12
- const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
11
+ export const resourceExists = (url: string | Href): boolean => {
12
+ const fullUrl = new Href(url).absolutehref;
13
+
14
+ // const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
13
15
 
14
16
  const xhr = new XMLHttpRequest();
15
17
  xhr.open("HEAD", fullUrl, false);
@@ -25,8 +27,8 @@ export const resourceExists = (url: string): boolean => {
25
27
  * @param url
26
28
  * @returns {boolean}
27
29
  */
28
- export const resourceRedirectsToSecureLogin = (url: string): boolean => {
29
- const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
30
+ export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
31
+ const fullUrl = new Href(url).absolutehref;
30
32
 
31
33
  const xhr = new XMLHttpRequest();
32
34
  xhr.open("HEAD", fullUrl, false);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/helpers/checkResource.js"],"names":["resourceExists","url","fullUrl","BASE","replace","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL"],"mappings":";;;;;;;;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,GAAD,EAA0B;AAAA;;AACtD,MAAMC,OAAO,GAAG,0CAAGC,eAAH,uBAAWF,GAAX,EAAiBG,OAAjB,CAAyB,OAAzB,EAAkC,GAAlC,CAAhB;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBL,OAAjB,EAA0B,KAA1B;AACAG,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,QAArB,EAA+B,kBAA/B;AACAH,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,cAArB,EAAqC,kBAArC;AACAH,EAAAA,GAAG,CAACI,IAAJ;AAEA,SAAOJ,GAAG,CAACK,MAAJ,KAAe,GAAtB;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACV,GAAD,EAA0B;AAAA;;AACtE,MAAMC,OAAO,GAAG,2CAAGC,eAAH,wBAAWF,GAAX,EAAiBG,OAAjB,CAAyB,OAAzB,EAAkC,GAAlC,CAAhB;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBL,OAAjB,EAA0B,KAA1B;AACAG,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,QAArB,EAA+B,kBAA/B;AACAH,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,cAArB,EAAqC,kBAArC;AACAH,EAAAA,GAAG,CAACI,IAAJ;AAEA,MAAMG,WAAW,uBAAGP,GAAG,CAACO,WAAP,+DAAsB,EAAvC;AAEA,SAAOP,GAAG,CAACK,MAAJ,KAAe,GAAf,IAAsB,uBAAAE,WAAW,MAAX,CAAAA,WAAW,EAAU,cAAV,CAAxC;AACD,CAZM","sourcesContent":["// @flow\nimport { BASE } from \"../../constants/Constants\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string): boolean => {\n const fullUrl = `${BASE}/${url}`.replace(/\\/\\//g, \"/\");\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.send();\n\n return xhr.status !== 404;\n};\n\n/**\n * Indicates if a request to the given url resuls in a redirect to /secureRedirect\n * @param url\n * @returns {boolean}\n */\nexport const resourceRedirectsToSecureLogin = (url: string): boolean => {\n const fullUrl = `${BASE}/${url}`.replace(/\\/\\//g, \"/\");\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.send();\n\n const responseURL = xhr.responseURL ?? \"\";\n\n return xhr.status === 400 && responseURL.endsWith(\"/secureLogin\");\n};\n"],"file":"checkResource.js"}
1
+ {"version":3,"sources":["../../../src/utils/helpers/checkResource.js"],"names":["resourceExists","url","fullUrl","Href","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL"],"mappings":";;;;;;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,GAAD,EAAiC;AAC7D,MAAMC,OAAO,GAAG,IAAIC,aAAJ,CAASF,GAAT,EAAcG,YAA9B,CAD6D,CAG7D;;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBL,OAAjB,EAA0B,KAA1B;AACAG,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,QAArB,EAA+B,kBAA/B;AACAH,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,cAArB,EAAqC,kBAArC;AACAH,EAAAA,GAAG,CAACI,IAAJ;AAEA,SAAOJ,GAAG,CAACK,MAAJ,KAAe,GAAtB;AACD,CAZM;AAcP;AACA;AACA;AACA;AACA;;;;;AACO,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACV,GAAD,EAAiC;AAAA;;AAC7E,MAAMC,OAAO,GAAG,IAAIC,aAAJ,CAASF,GAAT,EAAcG,YAA9B;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBL,OAAjB,EAA0B,KAA1B;AACAG,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,QAArB,EAA+B,kBAA/B;AACAH,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,cAArB,EAAqC,kBAArC;AACAH,EAAAA,GAAG,CAACI,IAAJ;AAEA,MAAMG,WAAW,uBAAGP,GAAG,CAACO,WAAP,+DAAsB,EAAvC;AAEA,SAAOP,GAAG,CAACK,MAAJ,KAAe,GAAf,IAAsB,uBAAAE,WAAW,MAAX,CAAAA,WAAW,EAAU,cAAV,CAAxC;AACD,CAZM","sourcesContent":["// @flow\nimport Href from \"../../models/href/Href\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n // const fullUrl = `${BASE}/${url}`.replace(/\\/\\//g, \"/\");\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.send();\n\n return xhr.status !== 404;\n};\n\n/**\n * Indicates if a request to the given url resuls in a redirect to /secureRedirect\n * @param url\n * @returns {boolean}\n */\nexport const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.send();\n\n const responseURL = xhr.responseURL ?? \"\";\n\n return xhr.status === 400 && responseURL.endsWith(\"/secureLogin\");\n};\n"],"file":"checkResource.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -113,13 +113,13 @@
113
113
  "cherry-pick": "^0.5.0",
114
114
  "cross-env": "^7.0.3",
115
115
  "documentation": "^13.2.5",
116
- "eslint": "^8.9.0",
116
+ "eslint": "^8.12.0",
117
117
  "eslint-config-prettier": "^8.3.0",
118
118
  "eslint-plugin-babel": "^5.3.1",
119
119
  "eslint-plugin-ft-flow": "^2.0.1",
120
120
  "eslint-plugin-import": "^2.25.4",
121
- "eslint-plugin-jest": "^26.1.2",
122
- "eslint-plugin-jsdoc": "^38.0.6",
121
+ "eslint-plugin-jest": "^26.1.3",
122
+ "eslint-plugin-jsdoc": "^38.1.3",
123
123
  "eslint-plugin-react": "^7.28.0",
124
124
  "eslint-plugin-react-hooks": "^4.3.0",
125
125
  "flow-bin": "^0.174.1",
@@ -134,7 +134,7 @@
134
134
  "jscodeshift": "^0.13.1",
135
135
  "lint-staged": "^12.3.7",
136
136
  "polished": "^4.1.4",
137
- "prettier": "^2.6.0",
137
+ "prettier": "^2.6.1",
138
138
  "react": "^17.0.2",
139
139
  "react-dom": "^17.0.2",
140
140
  "react-helmet-async": "^1.2.3",
@@ -146,7 +146,7 @@
146
146
  "redux-thunk": "^2.4.1",
147
147
  "rimraf": "^3.0.2",
148
148
  "standard-version": "^9.3.2",
149
- "styled-components": "^5.3.3",
149
+ "styled-components": "^5.3.5",
150
150
  "xhr-mock": "^2.5.1"
151
151
  },
152
152
  "scarfSettings": {
@@ -92,6 +92,13 @@ export default class ApplicationModel extends ResourceModel {
92
92
  return this._userServices ? this._userServices : null;
93
93
  }
94
94
 
95
+ /**
96
+ * Indicates if the user is logged in
97
+ */
98
+ get isLoggedIn(): boolean {
99
+ return this.userServices?.isLoggedIn ?? false;
100
+ }
101
+
95
102
  /**
96
103
  * Retrieve link to the user information,
97
104
  * only available when the user services are available
@@ -61,8 +61,7 @@ class AttributeContent {
61
61
  get elements(): ContentAll {
62
62
  if (this._content?.elements) {
63
63
  return this._content.elements?.map((element) => {
64
- if ("propertyElement" in element) {
65
- // $FlowIssue[incompatible-use]
64
+ if (element.propertyElement) {
66
65
  const { label, layouthint, properties } = element.propertyElement;
67
66
 
68
67
  return {
@@ -74,8 +73,7 @@ class AttributeContent {
74
73
  };
75
74
  }
76
75
 
77
- if ("textFragmentElement" in element) {
78
- // $FlowIssue[incompatible-use]
76
+ if (element.textFragmentElement) {
79
77
  const { label, layouthint, textfragments } =
80
78
  element.textFragmentElement;
81
79
  return {
@@ -90,8 +88,7 @@ class AttributeContent {
90
88
  };
91
89
  }
92
90
 
93
- if ("contentElement" in element) {
94
- // $FlowIssue[incompatible-use]
91
+ if (element.contentElement) {
95
92
  const { label, layouthint, sections } = element.contentElement;
96
93
  return {
97
94
  contentElement: {
@@ -366,9 +366,20 @@ class Href {
366
366
  }
367
367
 
368
368
  /**
369
- * Getting the URL including the base path
369
+ * Getting the URL including the base path, querystring is prefixed
370
370
  */
371
371
  get absolutehref(): string {
372
+ const querystring = this.getQuerystring(false);
373
+
374
+ return querystring.length > 0
375
+ ? [this.absolutepath, querystring].join("?")
376
+ : this.absolutepath;
377
+ }
378
+
379
+ /**
380
+ * Getting the URL including the base path, the querystring is prefixed
381
+ */
382
+ get absolutehrefPrefixedQuerystring(): string {
372
383
  const querystring = this.getQuerystring(true);
373
384
 
374
385
  return querystring.length > 0
@@ -15,6 +15,7 @@ export { default as AttributeModel } from "./attributes/AttributeModel";
15
15
  import { default as BooleanAttributeModel } from "./attributes/BooleanAttributeModel";
16
16
  import { default as CaptchaAttributeModel } from "./attributes/CaptchaAttributeModel";
17
17
  import { default as ChoiceAttributeModel } from "./attributes/ChoiceAttributeModel";
18
+ export { default as ChoiceAttributeOptionCollection } from "./attributes/ChoiceAttributeOptionCollection";
18
19
  export { default as ChoiceAttributeOptionModel } from "./attributes/ChoiceAttributeOptionModel";
19
20
  import { default as CompositeAttributeModel } from "./attributes/CompositeAttributeModel";
20
21
  export { default as CompositeAttributeChildCollection } from "./attributes/CompositeAttributeChildCollection";
@@ -3,6 +3,8 @@ import {
3
3
  resourceRedirectsToSecureLogin,
4
4
  } from "../checkResource";
5
5
 
6
+ import Href from "../../../models/href/Href";
7
+
6
8
  const mockXMLHttpRequest = () => {
7
9
  const mock = {
8
10
  open: jest.fn(),
@@ -26,22 +28,22 @@ describe("checkResource", () => {
26
28
  const mock = mockXMLHttpRequest();
27
29
  mock.status = 200;
28
30
 
29
- expect.assertions(1);
30
-
31
31
  const exists = resourceExists("/");
32
-
33
32
  expect(exists).toBe(true);
33
+
34
+ const hrefExists = resourceExists(new Href("/caseview"));
35
+ expect(hrefExists).toBe(true);
34
36
  });
35
37
 
36
38
  it("indicates a resource does not exists if it has a status code of 404", () => {
37
39
  const mock = mockXMLHttpRequest();
38
40
  mock.status = 404;
39
41
 
40
- expect.assertions(1);
41
-
42
42
  const exists = resourceExists("/");
43
-
44
43
  expect(exists).toBe(false);
44
+
45
+ const hrefExists = resourceExists(new Href("/caseview"));
46
+ expect(hrefExists).toBe(false);
45
47
  });
46
48
 
47
49
  it("indicates resource request redirects to secureLogin", () => {
@@ -50,7 +52,9 @@ describe("checkResource", () => {
50
52
  mock.status = 400;
51
53
 
52
54
  const toLogin = resourceRedirectsToSecureLogin("/");
53
-
54
55
  expect(toLogin).toBe(true);
56
+
57
+ const hrefToLogin = resourceExists(new Href("/caseview"));
58
+ expect(hrefToLogin).toBe(true);
55
59
  });
56
60
  });
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import { BASE } from "../../constants/Constants";
2
+ import Href from "../../models/href/Href";
3
3
 
4
4
  /**
5
5
  * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
@@ -8,8 +8,10 @@ import { BASE } from "../../constants/Constants";
8
8
  * @param url
9
9
  * @returns {boolean}
10
10
  */
11
- export const resourceExists = (url: string): boolean => {
12
- const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
11
+ export const resourceExists = (url: string | Href): boolean => {
12
+ const fullUrl = new Href(url).absolutehref;
13
+
14
+ // const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
13
15
 
14
16
  const xhr = new XMLHttpRequest();
15
17
  xhr.open("HEAD", fullUrl, false);
@@ -25,8 +27,8 @@ export const resourceExists = (url: string): boolean => {
25
27
  * @param url
26
28
  * @returns {boolean}
27
29
  */
28
- export const resourceRedirectsToSecureLogin = (url: string): boolean => {
29
- const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
30
+ export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
31
+ const fullUrl = new Href(url).absolutehref;
30
32
 
31
33
  const xhr = new XMLHttpRequest();
32
34
  xhr.open("HEAD", fullUrl, false);