@beinformed/ui 1.16.1 → 1.17.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.17.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.16.1...v1.17.0) (2022-03-29)
6
+
7
+ ### Features
8
+
9
+ - **application:** add isLoggedIn method to application ([61a340d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/61a340d12703c2db0c351c3ab23c4bfed12c4f12))
10
+
11
+ ### Bug Fixes
12
+
13
+ - **check-resource:** handle Href as input argument for resourceExists and resourceRedirectsToSecureLogin ([c49e671](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c49e6715addb2703222ecf4a8b120fc9cb814f35))
14
+ - **href:** absolute href no longer prefixes querystring, use absolutehrefPrefixedQuerystring if needed ([2ff2abd](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/2ff2abd8ce6f6f9545dd82c573891f344ed49c09))
15
+
5
16
  ### [1.16.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.16.0...v1.16.1) (2022-03-22)
6
17
 
7
18
  ## [1.16.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.15.1...v1.16.0) (2022-03-22)
@@ -125,13 +125,24 @@ var ApplicationModel = /*#__PURE__*/function (_ResourceModel) {
125
125
  return this._userServices ? this._userServices : null;
126
126
  }
127
127
  /**
128
- * Retrieve link to the user information,
129
- * only available when the user services are available
128
+ * Indicates if the user is logged in
130
129
  */
131
130
  ,
132
131
  set: function set(model) {
133
132
  this._userServices = model instanceof UserServicesModel ? model : null;
134
133
  }
134
+ }, {
135
+ key: "isLoggedIn",
136
+ get: function get() {
137
+ var _this$userServices$is, _this$userServices;
138
+
139
+ return (_this$userServices$is = (_this$userServices = this.userServices) === null || _this$userServices === void 0 ? void 0 : _this$userServices.isLoggedIn) !== null && _this$userServices$is !== void 0 ? _this$userServices$is : false;
140
+ }
141
+ /**
142
+ * Retrieve link to the user information,
143
+ * only available when the user services are available
144
+ */
145
+
135
146
  }, {
136
147
  key: "userHref",
137
148
  get: function get() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","ApplicationModel","userService","links","getLinkByKey","href","path","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","create","_userServices","userLink","data","contributions","resourcetype"],"mappings":";;;;;;;;;;;;;;;AACA,OAAOA,aAAP,MAA0B,uBAA1B;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,OAAOC,iBAAP,MAA8B,2BAA9B;AAEA,SAASC,sBAAT,QAAuC,kBAAvC;;AAOA;AACA;AACA;IACqBC,gB;;;;;;;;;;;;;;;;;;;;;;;;;;AAGnB;AACF;AACA;AACE,mBAAmB;AACjB,aAAO,aAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,UAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;AACA,UAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;AACrD,cAAM,IAAIN,sBAAJ,CACJ,kIADI,CAAN;AAGD;;AAED,aAAOE,WAAW,GAAG,CAACA,WAAD,CAAH,GAAmB,EAArC;AACD;AAED;AACF;;;;WACE,wBAAeK,MAAf,EAA8C;AAC5C,UAAMC,gBAAgB,GAAG,sBAAAD,MAAM,MAAN,CAAAA,MAAM,EAC7B,UAACE,KAAD;AAAA,eAAWA,KAAK,CAACC,IAAN,KAAe,cAA1B;AAAA,OAD6B,CAA/B;;AAIA,UAAIF,gBAAJ,EAAsB;AACpB,aAAKG,YAAL,GAAoBH,gBAApB;AACD;AACF;AAED;AACF;AACA;;;;SACE,eAAoB;AAClB,aAAO,KAAKI,eAAL,CAAqB,OAArB,EAA8B,EAA9B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA2B;AACzB,aAAO,KAAKT,KAAL,CAAWU,eAAX,CAA2B,KAA3B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA8B;AAC5B,aAAOf,SAAS,CAACgB,MAAV,CAAiB,cAAjB,EAAiC,eAAjC,EAAkD,eAAlD,CAAP;AACD;AAED;AACF;AACA;;;;;AAKE;AACF;AACA;AACE,mBAAuC;AACrC,aAAO,KAAKC,aAAL,GAAqB,KAAKA,aAA1B,GAA0C,IAAjD;AACD;AAED;AACF;AACA;AACA;;SAdE,aAAiBN,KAAjB,EAAyC;AACvC,WAAKM,aAAL,GAAqBN,KAAK,YAAYV,iBAAjB,GAAqCU,KAArC,GAA6C,IAAlE;AACD;;;SAaD,eAA4B;AAC1B,UAAI,KAAKE,YAAL,IAAqB,IAArB,IAA6B,KAAKA,YAAL,CAAkBK,QAAlB,IAA8B,IAA/D,EAAqE;AACnE,eAAO,KAAKL,YAAL,CAAkBK,QAAlB,CAA2BX,IAAlC;AACD;;AAED,aAAO,IAAP;AACD;;;WA7ED,2BAAyBY,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACC,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;AAID;;;;EAjB2CtB,a;;SAAzBI,gB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.js"}
1
+ {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","ApplicationModel","userService","links","getLinkByKey","href","path","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","create","_userServices","isLoggedIn","userLink","data","contributions","resourcetype"],"mapp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AA1B,GAA0C,IAAjD;AACD;AAED;AACF;AACA;;SAbE,aAAiBN,KAAjB,EAAyC;AACvC,WAAKM,aAAL,GAAqBN,KAAK,YAAYV,iBAAjB,GAAqCU,KAArC,GAA6C,IAAlE;AACD;;;SAYD,eAA0B;AAAA;;AACxB,4DAAO,KAAKE,YAAZ,uDAAO,mBAAmBK,UAA1B,yEAAwC,KAAxC;AACD;AAED;AACF;AACA;AACA;;;;SACE,eAA4B;AAC1B,UAAI,KAAKL,YAAL,IAAqB,IAArB,IAA6B,KAAKA,YAAL,CAAkBM,QAAlB,IAA8B,IAA/D,EAAqE;AACnE,eAAO,KAAKN,YAAL,CAAkBM,QAAlB,CAA2BZ,IAAlC;AACD;;AAED,aAAO,IAAP;AACD;;;WApFD,2BAAyBa,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACC,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;AAID;;;;EAjB2CvB,a;;SAAzBI,gB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.js"}
@@ -390,11 +390,21 @@ var Href = /*#__PURE__*/function () {
390
390
  return this.querystring.length > 0 ? [this.path, this.querystring].join("?") : this.path;
391
391
  }
392
392
  /**
393
- * Getting the URL including the base path
393
+ * Getting the URL including the base path, querystring is prefixed
394
394
  */
395
395
 
396
396
  }, {
397
397
  key: "absolutehref",
398
+ get: function get() {
399
+ var querystring = this.getQuerystring(false);
400
+ return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
401
+ }
402
+ /**
403
+ * Getting the URL including the base path, the querystring is prefixed
404
+ */
405
+
406
+ }, {
407
+ key: "absolutehrefPrefixedQuerystring",
398
408
  get: function get() {
399
409
  var querystring = this.getQuerystring(true);
400
410
  return querystring.length > 0 ? [this.absolutepath, querystring].join("?") : this.absolutepath;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/href/Href.js"],"names":["BASE","CONTENT_PATH","HTTP_METHODS","Parameter","IllegalArgumentException","Href","href","resourcetype","path","parameters","hash","state","method","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;AACA,SAASA,IAAT,EAAeC,YAAf,EAA6BC,YAA7B,QAAiD,2BAAjD;AAEA,OAAOC,SAAP,MAAsB,wBAAtB;AACA,SAASC,wBAAT,QAAyC,kBAAzC;;AAgBA;AACA;AACA;IACMC,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,GAAcV,YAAY,CAACW,GAA3B;AACA,SAAKN,YAAL,GAAoBA,YAAY,IAAI,EAApC;;AAEA,QAAID,IAAI,YAAYD,IAApB,EAA0B;AACxB,WAAKS,WAAL,CAAiBR,IAAjB;AACD,KAFD,MAEO,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AACnC,WAAKS,aAAL,CAAmBT,IAAnB;AACD,KAFM,MAEA,IAAI,QAAOA,IAAP,MAAgB,QAApB,EAA8B;AACnC,WAAKU,u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,GAAb,IAAoB,CAAhC,CAArB,GAA0D,EAAjE;AACD;;;;;;AA+SH,eAAejE,IAAf","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":["BASE","CONTENT_PATH","HTTP_METHODS","Parameter","IllegalArgumentException","Href","href","resourcetype","path","parameters","hash","state","method","GET","setFromHref","setFromString","setFromLocationOrObject","pathname","_path","search","addParametersFromString","Array","isArray","_parameters","param","addParameter","_name","_value","_prefix","getHashFromString","_hash","_state","getPathFromString","checkAbsoluteUrl","split","forEach","paramFromString","fromString","setParameter","name","value","prefix","removeParameter","push","getParameter","undefined","_method","withPrefix","toQuerystring","join","isModUIParameter","getQuerystring","_resourcetype","isExternal","querystring","length","absolutepath","thisPath","otherPath","equals","thisParams","toString","every","checkAbsolute","RegExp","test","decodedHref","decodeURI","hrefNoHash","substr","indexOf"],"mappings":";;;;;;;;;AACA,SAASA,IAAT,EAAeC,YAAf,EAA6BC,YAA7B,QAAiD,2BAAjD;AAEA,OAAOC,SAAP,MAAsB,wBAAtB;AACA,SAASC,wBAAT,QAAyC,kBAAzC;;AAgBA;AACA;AACA;IACMC,I;AAQJ;AACF;AACA;AACE,gBAAYC,IAAZ,EAA8BC,YAA9B,EAAqD;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACnD,SAAKC,IAAL,GAAY,EAAZ;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AAd,CAAmB3D,IAAnB,CAAP;AACD;;;WAYD,2BAAyBA,IAAzB,EAA+C;AAC7C,UAAM4D,WAAW,GAAGC,SAAS,CAAC7D,IAAD,CAA7B;AAEA,UAAM8D,UAAU,GAAG,0BAAAF,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,0BAAAE,UAAU,MAAV,CAAAA,UAAU,EAAU,GAAV,CAAV,GAA2BA,UAAU,CAAClC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAA3B,GAAsDkC,UAA7D;AACD;AAED;AACF;AACA;;;;WACE,6BAAoD;AAAA,UAA3B9D,IAA2B,uEAAZ,EAAY;AAClD,aAAO,0BAAAA,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GAAqBA,IAAI,CAAC+D,MAAL,CAAY/D,IAAI,CAACgE,OAAL,CAAa,GAAb,IAAoB,CAAhC,CAArB,GAA0D,EAAjE;AACD;;;;;;AA0TH,eAAejE,IAAf","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"}
@@ -1,6 +1,5 @@
1
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
1
  import _endsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/ends-with";
3
- import { BASE } from "../../constants/Constants";
2
+ import Href from "../../models/href/Href";
4
3
  /**
5
4
  * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
6
5
  * When the resource returns a 404, the resource does not exists and the method returns false
@@ -10,9 +9,7 @@ import { BASE } from "../../constants/Constants";
10
9
  */
11
10
 
12
11
  export var resourceExists = function resourceExists(url) {
13
- var _context;
14
-
15
- var fullUrl = _concatInstanceProperty(_context = "".concat(BASE, "/")).call(_context, url).replace(/\/\//g, "/");
12
+ var fullUrl = new Href(url).absolutehref; // const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
16
13
 
17
14
  var xhr = new XMLHttpRequest();
18
15
  xhr.open("HEAD", fullUrl, false);
@@ -28,10 +25,9 @@ export var resourceExists = function resourceExists(url) {
28
25
  */
29
26
 
30
27
  export var resourceRedirectsToSecureLogin = function resourceRedirectsToSecureLogin(url) {
31
- var _context2, _xhr$responseURL;
32
-
33
- var fullUrl = _concatInstanceProperty(_context2 = "".concat(BASE, "/")).call(_context2, url).replace(/\/\//g, "/");
28
+ var _xhr$responseURL;
34
29
 
30
+ var fullUrl = new Href(url).absolutehref;
35
31
  var xhr = new XMLHttpRequest();
36
32
  xhr.open("HEAD", fullUrl, false);
37
33
  xhr.setRequestHeader("Accept", "application/json");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/helpers/checkResource.js"],"names":["BASE","resourceExists","url","fullUrl","replace","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL"],"mappings":";;AACA,SAASA,IAAT,QAAqB,2BAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,GAAD,EAA0B;AAAA;;AACtD,MAAMC,OAAO,GAAG,6CAAGH,IAAH,uBAAWE,GAAX,EAAiBE,OAAjB,CAAyB,OAAzB,EAAkC,GAAlC,CAAhB;;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBJ,OAAjB,EAA0B,KAA1B;AACAE,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;;AACA,OAAO,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACT,GAAD,EAA0B;AAAA;;AACtE,MAAMC,OAAO,GAAG,8CAAGH,IAAH,wBAAWE,GAAX,EAAiBE,OAAjB,CAAyB,OAAzB,EAAkC,GAAlC,CAAhB;;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBJ,OAAjB,EAA0B,KAA1B;AACAE,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,0BAAAE,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":["Href","resourceExists","url","fullUrl","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","resourceRedirectsToSecureLogin","responseURL"],"mappings":";AACA,OAAOA,IAAP,MAAiB,wBAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,GAAD,EAAiC;AAC7D,MAAMC,OAAO,GAAG,IAAIH,IAAJ,CAASE,GAAT,EAAcE,YAA9B,CAD6D,CAG7D;;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBJ,OAAjB,EAA0B,KAA1B;AACAE,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;;AACA,OAAO,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACT,GAAD,EAAiC;AAAA;;AAC7E,MAAMC,OAAO,GAAG,IAAIH,IAAJ,CAASE,GAAT,EAAcE,YAA9B;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBJ,OAAjB,EAA0B,KAA1B;AACAE,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,0BAAAE,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"}
@@ -144,13 +144,24 @@ var ApplicationModel = /*#__PURE__*/function (_ResourceModel) {
144
144
  return this._userServices ? this._userServices : null;
145
145
  }
146
146
  /**
147
- * Retrieve link to the user information,
148
- * only available when the user services are available
147
+ * Indicates if the user is logged in
149
148
  */
150
149
  ,
151
150
  set: function set(model) {
152
151
  this._userServices = model instanceof _UserServicesModel.default ? model : null;
153
152
  }
153
+ }, {
154
+ key: "isLoggedIn",
155
+ get: function get() {
156
+ var _this$userServices$is, _this$userServices;
157
+
158
+ return (_this$userServices$is = (_this$userServices = this.userServices) === null || _this$userServices === void 0 ? void 0 : _this$userServices.isLoggedIn) !== null && _this$userServices$is !== void 0 ? _this$userServices$is : false;
159
+ }
160
+ /**
161
+ * Retrieve link to the user information,
162
+ * only available when the user services are available
163
+ */
164
+
154
165
  }, {
155
166
  key: "userHref",
156
167
  get: function get() {
@@ -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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","userLink","data","contributions","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,gB;;;;;;;;;;;;;;;;;;;;;;;;AAGnB;AACF;AACA;AACE,mBAAmB;AACjB,aAAO,aAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,UAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;AACA,UAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;AACrD,cAAM,IAAIC,kCAAJ,CACJ,kIADI,CAAN;AAGD;;AAED,aAAOL,WAAW,GAAG,CAACA,WAAD,CAAH,GAAmB,EAArC;AACD;AAED;AACF;;;;WACE,wBAAeM,MAAf,EAA8C;AAC5C,UAAMC,gBAAgB,GAAG,mBAAAD,MAAM,MAAN,CAAAA,MAAM,EAC7B,UAACE,KAAD;AAAA,eAAWA,KAAK,CAACC,IAAN,KAAe,cAA1B;AAAA,OAD6B,CAA/B;;AAIA,UAAIF,gBAAJ,EAAsB;AACpB,aAAKG,YAAL,GAAoBH,gBAApB;AACD;AACF;AAED;AACF;AACA;;;;SACE,eAAoB;AAClB,aAAO,KAAKI,eAAL,CAAqB,OAArB,EAA8B,EAA9B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA2B;AACzB,aAAO,KAAKV,KAAL,CAAWW,eAAX,CAA2B,KAA3B,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA8B;AAC5B,aAAOC,mBAAUC,MAAV,CAAiB,cAAjB,EAAiC,eAAjC,EAAkD,eAAlD,CAAP;AACD;AAED;AACF;AACA;;;;;AAKE;AACF;AACA;AACE,mBAAuC;AACrC,aAAO,KAAKC,aAAL,GAAqB,KAAKA,aAA1B,GAA0C,IAAjD;AACD;AAED;AACF;AACA;AACA;;SAdE,aAAiBP,KAAjB,EAAyC;AACvC,WAAKO,aAAL,GAAqBP,KAAK,YAAYQ,0BAAjB,GAAqCR,KAArC,GAA6C,IAAlE;AACD;;;SAaD,eAA4B;AAC1B,UAAI,KAAKE,YAAL,IAAqB,IAArB,IAA6B,KAAKA,YAAL,CAAkBO,QAAlB,IAA8B,IAA/D,EAAqE;AACnE,eAAO,KAAKP,YAAL,CAAkBO,QAAlB,CAA2Bd,IAAlC;AACD;;AAED,aAAO,IAAP;AACD;;;WA7ED,2BAAyBe,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACC,aAAL,CAAmBC,YAAnB,IACAF,IAAI,CAACC,aAAL,CAAmBC,YAAnB,KAAoC,aAFtC;AAID;;;EAjB2CC,uB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.js"}
1
+ {"version":3,"sources":["../../../src/models/application/ApplicationModel.js"],"names":["ApplicationModel","userService","links","getLinkByKey","href","path","NotAllowedUriException","models","userServiceModel","model","type","userServices","getContribution","getLinksByGroup","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userLink","data","contributions","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,gB;;;;;;;;;;;;;;;;;;;;;;;;AAGnB;AACF;AACA;AACE,mBAAmB;AACjB,aAAO,aAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,UAAMC,WAAW,GAAG,KAAKC,KAAL,CAAWC,YAAX,CAAwB,cAAxB,CAApB;;AACA,UAAIF,WAAW,IAAIA,WAAW,CAACG,IAAZ,CAAiBC,IAAjB,KAA0B,QAA7C,EAAuD;AACrD,cAAM,IAAIC,kCAAJ,CACJ,kIADI,CAAN;AAGD;;AAED,aAAOL,WAAW,GAAG,CAACA,WAAD,CAAH,GAAmB,EAArC;AACD;AAED;AACF;;;;WACE,wBAAeM,MAAf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jB2CC,uB","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"file":"ApplicationModel.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,KAA4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AAoC,CAAC,yBAAAA,IAAI,MAAJ,CAAAA,IAAI,EAAY,kBAAZ,CAD3C;AAGD;AAED;AACF;;;;WACE,0BAAwBF,IAAxB,EAA+C;AAC7C,UAAM8D,aAAa,GAAG,IAAIC,MAAJ,CAAW,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;;;;;WAC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A;;;;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;;;;;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"}
@@ -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":";;;;;;;;;;;;;AAC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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.1",
3
+ "version": "1.17.0",
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
@@ -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
@@ -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);