@beinformed/ui 1.13.6 → 1.14.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 +6 -0
- package/esm/redux/actions/Authorization.js +2 -1
- package/esm/redux/actions/Authorization.js.map +1 -1
- package/esm/utils/helpers/checkResourceExists.js +23 -0
- package/esm/utils/helpers/checkResourceExists.js.map +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/index.js.map +1 -1
- package/lib/redux/actions/Authorization.js +2 -1
- package/lib/redux/actions/Authorization.js.flow +1 -0
- package/lib/redux/actions/Authorization.js.map +1 -1
- package/lib/utils/helpers/checkResourceExists.js +34 -0
- package/lib/utils/helpers/checkResourceExists.js.flow +21 -0
- package/lib/utils/helpers/checkResourceExists.js.map +1 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +12 -12
- package/src/redux/actions/Authorization.js +1 -0
- package/src/utils/helpers/checkResourceExists.js +21 -0
- package/src/utils/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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.14.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.13.6...v1.14.0) (2022-02-18)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **helper:** add helper method resourceExists ([14f4fc9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/14f4fc92799da99ec14a8899639e40d5250617b0))
|
|
10
|
+
|
|
5
11
|
### [1.13.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.13.5...v1.13.6) (2022-02-10)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
|
@@ -38,7 +38,8 @@ export var handleUnauthorized = function handleUnauthorized(errorResponse) {
|
|
|
38
38
|
id: errorResponse.id,
|
|
39
39
|
defaultMessage: errorResponse.message
|
|
40
40
|
}, null, WARNING_TIMEOUT));
|
|
41
|
-
}
|
|
41
|
+
} // add current location as from location before redirect
|
|
42
|
+
|
|
42
43
|
|
|
43
44
|
var location = getState().router.location;
|
|
44
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/redux/actions/Authorization.js"],"names":["LOGIN_PATH","NOTIFICATION_TYPES","ErrorResponse","replace","logoutSuccess","showNotification","Cache","removeModelByKey","reloadApplication","getSetting","handleUnauthorized","errorResponse","dispatch","getState","connectKey","response","error","window","location","reload","getItem","removeItem","isInvalidUsername","WARNING_TIMEOUT","WARNING","id","defaultMessage","message","router","pathname","locationFrom","state","from","modal","type"],"mappings":"AACA,SAASA,UAAT,EAAqBC,kBAArB,QAA+C,2BAA/C;AAEA,OAAOC,aAAP,MAA0B,kCAA1B;AAEA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,aAAT,QAA8B,WAA9B;AACA,SAASC,gBAAT,QAAiC,gBAAjC;AAEA,OAAOC,KAAP,MAAkB,2BAAlB;AAEA,SAASC,gBAAT,QAAiC,uBAAjC;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA,SAASC,UAAT,QAA2B,iBAA3B;;AAIA;AACA;AACA,OAAO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAACC,aAAD;AAAA,SACA,UAACC,QAAD,EAAWC,QAAX,EAAwB;AAAA;;AACtB,QAAIF,aAAa,CAACG,UAAlB,EAA8B;AAC5BF,MAAAA,QAAQ,CAACL,gBAAgB,CAACI,aAAa,CAACG,UAAf,CAAjB,CAAR;AACD;;AAED,QACEL,UAAU,CAAC,mCAAD,EAAsC,KAAtC,CAAV,6BACAE,aAAa,CAACI,QADd,kDACA,sBAAwBC,KAF1B,EAGE;AACAC,MAAAA,MAAM,CAACC,QAAP,CAAgBC,MAAhB;AACA;AACD,KAXqB,CAatB;;;AACA,QAAIb,KAAK,CAACc,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzBR,MAAAA,QAAQ,CAACJ,iBAAiB,EAAlB,CAAR;AACD,KAhBqB,CAkBtB;;;AACAI,IAAAA,QAAQ,CAACR,aAAa,EAAd,CAAR;AAEAE,IAAAA,KAAK,CAACe,UAAN,CAAiB,MAAjB;;AAEA,QAAIV,aAAa,CAACW,iBAAlB,EAAqC;AACnC,UAAMC,eAAe,GAAG,IAAxB;AACAX,MAAAA,QAAQ,CACNP,gBAAgB,CACdJ,kBAAkB,CAACuB,OADL,EAEd;AACEC,QAAAA,EAAE,EAAEd,aAAa,CAACc,EADpB;AAEEC,QAAAA,cAAc,EAAEf,aAAa,CAACgB;AAFhC,OAFc,EAMd,IANc,EAOdJ,eAPc,CADV,CAAR;AAWD
|
|
1
|
+
{"version":3,"sources":["../../../src/redux/actions/Authorization.js"],"names":["LOGIN_PATH","NOTIFICATION_TYPES","ErrorResponse","replace","logoutSuccess","showNotification","Cache","removeModelByKey","reloadApplication","getSetting","handleUnauthorized","errorResponse","dispatch","getState","connectKey","response","error","window","location","reload","getItem","removeItem","isInvalidUsername","WARNING_TIMEOUT","WARNING","id","defaultMessage","message","router","pathname","locationFrom","state","from","modal","type"],"mappings":"AACA,SAASA,UAAT,EAAqBC,kBAArB,QAA+C,2BAA/C;AAEA,OAAOC,aAAP,MAA0B,kCAA1B;AAEA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,aAAT,QAA8B,WAA9B;AACA,SAASC,gBAAT,QAAiC,gBAAjC;AAEA,OAAOC,KAAP,MAAkB,2BAAlB;AAEA,SAASC,gBAAT,QAAiC,uBAAjC;AACA,SAASC,iBAAT,QAAkC,eAAlC;AAEA,SAASC,UAAT,QAA2B,iBAA3B;;AAIA;AACA;AACA,OAAO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAACC,aAAD;AAAA,SACA,UAACC,QAAD,EAAWC,QAA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e,MAAX,CAAkBV,QADpC;AAElB;AACAe,QAAAA,KAAK,EAAE;AAHW,OAAb,CADM,CAAf;AAOD;;AAED,WAAO;AAAEC,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { LOGIN_PATH, NOTIFICATION_TYPES } from \"../../constants/Constants\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { replace } from \"../_router/actions\";\nimport { logoutSuccess } from \"./SignOut\";\nimport { showNotification } from \"./Notification\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport { removeModelByKey } from \"../_modularui/actions\";\nimport { reloadApplication } from \"./Application\";\n\nimport { getSetting } from \"../../constants\";\n\nimport type { ThunkAction } from \"../types\";\n\n/**\n */\nexport const handleUnauthorized =\n (errorResponse: ErrorResponse): ThunkAction =>\n (dispatch, getState) => {\n if (errorResponse.connectKey) {\n dispatch(removeModelByKey(errorResponse.connectKey));\n }\n\n if (\n getSetting(\"PAGE_RELOAD_ON_UNAUTHORIZED_ERROR\", false) &&\n errorResponse.response?.error\n ) {\n window.location.reload();\n return;\n }\n\n // reload application when flag auth is set\n if (Cache.getItem(\"auth\")) {\n dispatch(reloadApplication());\n }\n\n // set logged auth\n dispatch(logoutSuccess());\n\n Cache.removeItem(\"auth\");\n\n if (errorResponse.isInvalidUsername) {\n const WARNING_TIMEOUT = 4000;\n dispatch(\n showNotification(\n NOTIFICATION_TYPES.WARNING,\n {\n id: errorResponse.id,\n defaultMessage: errorResponse.message,\n },\n null,\n WARNING_TIMEOUT\n )\n );\n }\n\n // add current location as from location before redirect\n const location = getState().router.location;\n if (location?.pathname !== LOGIN_PATH) {\n const locationFrom = location?.state?.from;\n return dispatch(\n replace(LOGIN_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n // cannot open login in a modal, because of previous locations that might be secure\n modal: false,\n })\n );\n }\n\n return { type: \"NO_ACTION\" };\n };\n"],"file":"Authorization.js"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
2
|
+
import { BASE } from "../../constants/Constants";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
|
|
5
|
+
* When the resource returns a 404, the resource does not exists and the method returns false
|
|
6
|
+
*
|
|
7
|
+
* @param url
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export var resourceExists = function resourceExists(url) {
|
|
12
|
+
var _context;
|
|
13
|
+
|
|
14
|
+
var fullUrl = _concatInstanceProperty(_context = "".concat(BASE, "/")).call(_context, url).replace(/\/\//g, "/");
|
|
15
|
+
|
|
16
|
+
var xhr = new XMLHttpRequest();
|
|
17
|
+
xhr.open("HEAD", fullUrl, false);
|
|
18
|
+
xhr.setRequestHeader("Accept", "application/json");
|
|
19
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
20
|
+
xhr.send();
|
|
21
|
+
return xhr.status !== 404;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=checkResourceExists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/helpers/checkResourceExists.js"],"names":["BASE","resourceExists","url","fullUrl","replace","xhr","XMLHttpRequest","open","setRequestHeader","send","status"],"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","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"],"file":"checkResourceExists.js"}
|
package/esm/utils/index.js
CHANGED
|
@@ -12,7 +12,8 @@ export * from "./helpers/createHash";
|
|
|
12
12
|
export { default as createUUID } from "./helpers/createUUID";
|
|
13
13
|
export * from "./helpers/sanitizeHtml";
|
|
14
14
|
export * from "./helpers/objects";
|
|
15
|
-
export * from "./helpers/text";
|
|
15
|
+
export * from "./helpers/text";
|
|
16
|
+
export * from "./helpers/checkResourceExists"; // number
|
|
16
17
|
|
|
17
18
|
export { default as DecimalFormat } from "./number/DecimalFormat";
|
|
18
19
|
export { default as formatValue } from "./number/formatValue";
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.js"],"names":["default","Cache","serverFetch","universalFetch","xhr","createUUID","DecimalFormat","formatValue"],"mappings":"AAEA;AACA,SAASA,OAAO,IAAIC,KAApB,QAAiC,iBAAjC;AACA,cAAc,mBAAd,C,CAEA;;AACA,cAAc,yBAAd,C,CAEA;;AACA,SAASD,OAAO,IAAIE,WAApB,QAAuC,qBAAvC;AACA,SAASF,OAAO,IAAIG,cAApB,QAA0C,wBAA1C;AACA,SAASH,OAAO,IAAII,GAApB,QAA+B,aAA/B;AAGA;AACA,cAAc,sBAAd;AACA,SAASJ,OAAO,IAAIK,UAApB,QAAsC,sBAAtC;AACA,cAAc,wBAAd;AACA,cAAc,mBAAd;AACA,cAAc,gBAAd,C,CAEA;;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,wBAAzC;AACA,SAASN,OAAO,IAAIO,WAApB,QAAuC,sBAAvC;AACA,cAAc,uBAAd","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.js"],"names":["default","Cache","serverFetch","universalFetch","xhr","createUUID","DecimalFormat","formatValue"],"mappings":"AAEA;AACA,SAASA,OAAO,IAAIC,KAApB,QAAiC,iBAAjC;AACA,cAAc,mBAAd,C,CAEA;;AACA,cAAc,yBAAd,C,CAEA;;AACA,SAASD,OAAO,IAAIE,WAApB,QAAuC,qBAAvC;AACA,SAASF,OAAO,IAAIG,cAApB,QAA0C,wBAA1C;AACA,SAASH,OAAO,IAAII,GAApB,QAA+B,aAA/B;AAGA;AACA,cAAc,sBAAd;AACA,SAASJ,OAAO,IAAIK,UAApB,QAAsC,sBAAtC;AACA,cAAc,wBAAd;AACA,cAAc,mBAAd;AACA,cAAc,gBAAd;AACA,cAAc,+BAAd,C,CAEA;;AACA,SAASL,OAAO,IAAIM,aAApB,QAAyC,wBAAzC;AACA,SAASN,OAAO,IAAIO,WAApB,QAAuC,sBAAvC;AACA,cAAc,uBAAd","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\nexport * from \"./helpers/checkResourceExists\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
|
@@ -56,7 +56,8 @@ var handleUnauthorized = function handleUnauthorized(errorResponse) {
|
|
|
56
56
|
id: errorResponse.id,
|
|
57
57
|
defaultMessage: errorResponse.message
|
|
58
58
|
}, null, WARNING_TIMEOUT));
|
|
59
|
-
}
|
|
59
|
+
} // add current location as from location before redirect
|
|
60
|
+
|
|
60
61
|
|
|
61
62
|
var location = getState().router.location;
|
|
62
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/redux/actions/Authorization.js"],"names":["handleUnauthorized","errorResponse","dispatch","getState","connectKey","response","error","window","location","reload","Cache","getItem","removeItem","isInvalidUsername","WARNING_TIMEOUT","NOTIFICATION_TYPES","WARNING","id","defaultMessage","message","router","pathname","LOGIN_PATH","locationFrom","state","from","modal","type"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AAIA;AACA;AACO,IAAMA,kBAAkB,GAC7B,SADWA,kBACX,CAACC,aAAD;AAAA,SACA,UAACC,QAAD,EAAWC,QAAX,EAAwB;AAAA;;AACtB,QAAIF,aAAa,CAACG,UAAlB,EAA8B;AAC5BF,MAAAA,QAAQ,CAAC,gCAAiBD,aAAa,CAACG,UAA/B,CAAD,CAAR;AACD;;AAED,QACE,2BAAW,mCAAX,EAAgD,KAAhD,8BACAH,aAAa,CAACI,QADd,kDACA,sBAAwBC,KAF1B,EAGE;AACAC,MAAAA,MAAM,CAACC,QAAP,CAAgBC,MAAhB;AACA;AACD,KAXqB,CAatB;;;AACA,QAAIC,eAAMC,OAAN,CAAc,MAAd,CAAJ,EAA2B;AACzBT,MAAAA,QAAQ,CAAC,qCAAD,CAAR;AACD,KAhBqB,CAkBtB;;;AACAA,IAAAA,QAAQ,CAAC,6BAAD,CAAR;;AAEAQ,mBAAME,UAAN,CAAiB,MAAjB;;AAEA,QAAIX,aAAa,CAACY,iBAAlB,EAAqC;AACnC,UAAMC,eAAe,GAAG,IAAxB;AACAZ,MAAAA,QAAQ,CACN,oCACEa,8BAAmBC,OADrB,EAEE;AACEC,QAAAA,EAAE,EAAEhB,aAAa,CAACgB,EADpB;AAEEC,QAAAA,cAAc,EAAEjB,aAAa,CAACkB;AAFhC,OAFF,EAME,IANF,EAOEL,eAPF,CADM,CAAR;AAWD
|
|
1
|
+
{"version":3,"sources":["../../../src/redux/actions/Authorization.js"],"names":["handleUnauthorized","errorResponse","dispatch","getState","connectKey","response","error","window","location","reload","Cache","getItem","removeItem","isInvalidUsername","WARNING_TIMEOUT","NOTIFICATION_TYPES","WARNING","id","defaultMessage","message","router","pathname","LOGIN_PATH","locationFrom","state","from","modal","type"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AAIA;AACA;AACO,IAAMA,kBAAkB,G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,GAAGiB,MAAX,CAAkBZ,QADpC;AAElB;AACAkB,QAAAA,KAAK,EAAE;AAHW,OAApB,CADa,CAAf;AAOD;;AAED,WAAO;AAAEC,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { LOGIN_PATH, NOTIFICATION_TYPES } from \"../../constants/Constants\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { replace } from \"../_router/actions\";\nimport { logoutSuccess } from \"./SignOut\";\nimport { showNotification } from \"./Notification\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport { removeModelByKey } from \"../_modularui/actions\";\nimport { reloadApplication } from \"./Application\";\n\nimport { getSetting } from \"../../constants\";\n\nimport type { ThunkAction } from \"../types\";\n\n/**\n */\nexport const handleUnauthorized =\n (errorResponse: ErrorResponse): ThunkAction =>\n (dispatch, getState) => {\n if (errorResponse.connectKey) {\n dispatch(removeModelByKey(errorResponse.connectKey));\n }\n\n if (\n getSetting(\"PAGE_RELOAD_ON_UNAUTHORIZED_ERROR\", false) &&\n errorResponse.response?.error\n ) {\n window.location.reload();\n return;\n }\n\n // reload application when flag auth is set\n if (Cache.getItem(\"auth\")) {\n dispatch(reloadApplication());\n }\n\n // set logged auth\n dispatch(logoutSuccess());\n\n Cache.removeItem(\"auth\");\n\n if (errorResponse.isInvalidUsername) {\n const WARNING_TIMEOUT = 4000;\n dispatch(\n showNotification(\n NOTIFICATION_TYPES.WARNING,\n {\n id: errorResponse.id,\n defaultMessage: errorResponse.message,\n },\n null,\n WARNING_TIMEOUT\n )\n );\n }\n\n // add current location as from location before redirect\n const location = getState().router.location;\n if (location?.pathname !== LOGIN_PATH) {\n const locationFrom = location?.state?.from;\n return dispatch(\n replace(LOGIN_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n // cannot open login in a modal, because of previous locations that might be secure\n modal: false,\n })\n );\n }\n\n return { type: \"NO_ACTION\" };\n };\n"],"file":"Authorization.js"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.resourceExists = void 0;
|
|
9
|
+
|
|
10
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
11
|
+
|
|
12
|
+
var _Constants = require("../../constants/Constants");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
|
|
16
|
+
* When the resource returns a 404, the resource does not exists and the method returns false
|
|
17
|
+
*
|
|
18
|
+
* @param url
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
var resourceExists = function resourceExists(url) {
|
|
22
|
+
var _context;
|
|
23
|
+
|
|
24
|
+
var fullUrl = (0, _concat.default)(_context = "".concat(_Constants.BASE, "/")).call(_context, url).replace(/\/\//g, "/");
|
|
25
|
+
var xhr = new XMLHttpRequest();
|
|
26
|
+
xhr.open("HEAD", fullUrl, false);
|
|
27
|
+
xhr.setRequestHeader("Accept", "application/json");
|
|
28
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
29
|
+
xhr.send();
|
|
30
|
+
return xhr.status !== 404;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.resourceExists = resourceExists;
|
|
34
|
+
//# sourceMappingURL=checkResourceExists.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { BASE } from "../../constants/Constants";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
|
|
6
|
+
* When the resource returns a 404, the resource does not exists and the method returns false
|
|
7
|
+
*
|
|
8
|
+
* @param url
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export const resourceExists = (url: string): boolean => {
|
|
12
|
+
const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
|
|
13
|
+
|
|
14
|
+
const xhr = new XMLHttpRequest();
|
|
15
|
+
xhr.open("HEAD", fullUrl, false);
|
|
16
|
+
xhr.setRequestHeader("Accept", "application/json");
|
|
17
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
18
|
+
xhr.send();
|
|
19
|
+
|
|
20
|
+
return xhr.status !== 404;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/helpers/checkResourceExists.js"],"names":["resourceExists","url","fullUrl","BASE","replace","xhr","XMLHttpRequest","open","setRequestHeader","send","status"],"mappings":";;;;;;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,GAAD,EAA0B;AAAA;;AACtD,MAAMC,OAAO,GAAG,0CAAGC,eAAH,uBAAWF,GAAX,EAAiBG,OAAjB,CAAyB,OAAzB,EAAkC,GAAlC,CAAhB;AAEA,MAAMC,GAAG,GAAG,IAAIC,cAAJ,EAAZ;AACAD,EAAAA,GAAG,CAACE,IAAJ,CAAS,MAAT,EAAiBL,OAAjB,EAA0B,KAA1B;AACAG,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,QAArB,EAA+B,kBAA/B;AACAH,EAAAA,GAAG,CAACG,gBAAJ,CAAqB,cAArB,EAAqC,kBAArC;AACAH,EAAAA,GAAG,CAACI,IAAJ;AAEA,SAAOJ,GAAG,CAACK,MAAJ,KAAe,GAAtB;AACD,CAVM","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"],"file":"checkResourceExists.js"}
|
package/lib/utils/index.js
CHANGED
|
@@ -153,6 +153,20 @@ _Object$keys(_text).forEach(function (key) {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
var _checkResourceExists = require("./helpers/checkResourceExists");
|
|
157
|
+
|
|
158
|
+
_Object$keys(_checkResourceExists).forEach(function (key) {
|
|
159
|
+
if (key === "default" || key === "__esModule") return;
|
|
160
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
161
|
+
if (key in exports && exports[key] === _checkResourceExists[key]) return;
|
|
162
|
+
Object.defineProperty(exports, key, {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function get() {
|
|
165
|
+
return _checkResourceExists[key];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
156
170
|
var _DecimalFormat = _interopRequireDefault(require("./number/DecimalFormat"));
|
|
157
171
|
|
|
158
172
|
var _formatValue = _interopRequireDefault(require("./number/formatValue"));
|
package/lib/utils/index.js.flow
CHANGED
|
@@ -19,6 +19,7 @@ export { default as createUUID } from "./helpers/createUUID";
|
|
|
19
19
|
export * from "./helpers/sanitizeHtml";
|
|
20
20
|
export * from "./helpers/objects";
|
|
21
21
|
export * from "./helpers/text";
|
|
22
|
+
export * from "./helpers/checkResourceExists";
|
|
22
23
|
|
|
23
24
|
// number
|
|
24
25
|
export { default as DecimalFormat } from "./number/DecimalFormat";
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\nexport * from \"./helpers/checkResourceExists\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"element-closest": "^3.0.2",
|
|
87
87
|
"file-size": "^1.0.0",
|
|
88
88
|
"focus-visible": "^5.2.0",
|
|
89
|
-
"format-message": "^6.2.
|
|
89
|
+
"format-message": "^6.2.4",
|
|
90
90
|
"he": "^1.2.0",
|
|
91
91
|
"iban": "^0.0.14",
|
|
92
92
|
"js-cookie": "^3.0.1",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"setimmediate": "^1.0.5"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@babel/cli": "^7.17.
|
|
99
|
-
"@babel/core": "^7.17.
|
|
98
|
+
"@babel/cli": "^7.17.3",
|
|
99
|
+
"@babel/core": "^7.17.5",
|
|
100
100
|
"@babel/eslint-parser": "^7.17.0",
|
|
101
101
|
"@babel/eslint-plugin": "^7.16.5",
|
|
102
102
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"@babel/preset-env": "^7.16.11",
|
|
105
105
|
"@babel/preset-flow": "^7.16.7",
|
|
106
106
|
"@babel/preset-react": "^7.16.7",
|
|
107
|
-
"@commitlint/cli": "^16.1
|
|
108
|
-
"@commitlint/config-conventional": "^16.
|
|
107
|
+
"@commitlint/cli": "^16.2.1",
|
|
108
|
+
"@commitlint/config-conventional": "^16.2.1",
|
|
109
109
|
"@testing-library/react-hooks": "^7.0.2",
|
|
110
110
|
"auditjs": "^4.0.36",
|
|
111
111
|
"babel-jest": "^27.5.1",
|
|
@@ -113,16 +113,16 @@
|
|
|
113
113
|
"cherry-pick": "^0.5.0",
|
|
114
114
|
"cross-env": "^7.0.3",
|
|
115
115
|
"documentation": "^13.2.5",
|
|
116
|
-
"eslint": "^8.
|
|
116
|
+
"eslint": "^8.9.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.
|
|
122
|
-
"eslint-plugin-jsdoc": "^37.
|
|
121
|
+
"eslint-plugin-jest": "^26.1.1",
|
|
122
|
+
"eslint-plugin-jsdoc": "^37.9.4",
|
|
123
123
|
"eslint-plugin-react": "^7.28.0",
|
|
124
124
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
125
|
-
"flow-bin": "^0.
|
|
125
|
+
"flow-bin": "^0.172.0",
|
|
126
126
|
"flow-copy-source": "^2.0.9",
|
|
127
127
|
"flow-typed": "^3.6.1",
|
|
128
128
|
"glob": "^7.2.0",
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
"jest-junit": "^13.0.0",
|
|
133
133
|
"jest-sonar-reporter": "^2.0.0",
|
|
134
134
|
"jscodeshift": "^0.13.1",
|
|
135
|
-
"lint-staged": "^12.3.
|
|
135
|
+
"lint-staged": "^12.3.4",
|
|
136
136
|
"polished": "^4.1.4",
|
|
137
137
|
"prettier": "^2.5.1",
|
|
138
138
|
"react": "^17.0.2",
|
|
139
139
|
"react-dom": "^17.0.2",
|
|
140
|
-
"react-helmet-async": "^1.2.
|
|
140
|
+
"react-helmet-async": "^1.2.3",
|
|
141
141
|
"react-redux": "^7.2.6",
|
|
142
142
|
"react-router-dom": "^5.3.0",
|
|
143
143
|
"react-test-renderer": "^17.0.2",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { BASE } from "../../constants/Constants";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)
|
|
6
|
+
* When the resource returns a 404, the resource does not exists and the method returns false
|
|
7
|
+
*
|
|
8
|
+
* @param url
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*/
|
|
11
|
+
export const resourceExists = (url: string): boolean => {
|
|
12
|
+
const fullUrl = `${BASE}/${url}`.replace(/\/\//g, "/");
|
|
13
|
+
|
|
14
|
+
const xhr = new XMLHttpRequest();
|
|
15
|
+
xhr.open("HEAD", fullUrl, false);
|
|
16
|
+
xhr.setRequestHeader("Accept", "application/json");
|
|
17
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
18
|
+
xhr.send();
|
|
19
|
+
|
|
20
|
+
return xhr.status !== 404;
|
|
21
|
+
};
|
package/src/utils/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export { default as createUUID } from "./helpers/createUUID";
|
|
|
19
19
|
export * from "./helpers/sanitizeHtml";
|
|
20
20
|
export * from "./helpers/objects";
|
|
21
21
|
export * from "./helpers/text";
|
|
22
|
+
export * from "./helpers/checkResourceExists";
|
|
22
23
|
|
|
23
24
|
// number
|
|
24
25
|
export { default as DecimalFormat } from "./number/DecimalFormat";
|