@shopgate/pwa-common 7.29.0-alpha.3 → 7.29.0-alpha.4
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PipelineRequest}from'@shopgate/pwa-core';import{getDeviceTypeForCms}from'@shopgate/engage/core';import{hasNewServices}from'@shopgate/engage/core/helpers';import{SHOPGATE_CMS_GET_PAGE_CONFIG}from"../../constants/Pipelines";import{requestPageConfig,receivePageConfig,errorPageConfig}from"../../action-creators/page";import{shouldFetchData,mutable}from"../../helpers/redux";import{getPageConfigById}from"../../selectors/page";/**
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PipelineRequest}from'@shopgate/pwa-core';import{getDeviceTypeForCms}from'@shopgate/engage/core';import{makeGetPage,getIsCms2Enabled}from'@shopgate/engage/page/selectors';import{requestPageConfigV2,receivePageConfigV2,errorPageConfigV2}from'@shopgate/engage/page/action-creators';import{hasNewServices}from'@shopgate/engage/core/helpers';import{SHOPGATE_CMS_GET_PAGE_CONFIG}from"../../constants/Pipelines";import{requestPageConfig,receivePageConfig,errorPageConfig}from"../../action-creators/page";import{shouldFetchData,mutable}from"../../helpers/redux";import{getPageConfigById}from"../../selectors/page";/**
|
|
2
2
|
* Retrieves the config for a page.
|
|
3
3
|
* @param {string} pageId The ID of the page to request.
|
|
4
4
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/function fetchPageConfig(pageId){return function(dispatch,getState){var state=getState();var pageConfig=getPageConfigById(state,{pageId:pageId});if(!shouldFetchData(pageConfig)){return Promise.resolve(null);}var deviceTypeOfCmsPage=getDeviceTypeForCms();dispatch(requestPageConfig(pageId));var request=new PipelineRequest(SHOPGATE_CMS_GET_PAGE_CONFIG).setInput(_extends({pageId:pageId},hasNewServices()?{deviceType:deviceTypeOfCmsPage}:null)).dispatch();request.then(function(result){dispatch(receivePageConfig(pageId,result));})["catch"](function(error){dispatch(errorPageConfig(pageId,error.code));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchPageConfig);
|
|
5
|
+
*/function fetchPageConfig(pageId){return function(dispatch,getState){var state=getState();var cmsV2Enabled=getIsCms2Enabled(state);var pageConfig;if(cmsV2Enabled){pageConfig=makeGetPage({slug:pageId})(state);}else{pageConfig=getPageConfigById(state,{pageId:pageId});}if(!shouldFetchData(pageConfig)){return Promise.resolve(null);}var deviceTypeOfCmsPage=getDeviceTypeForCms();if(cmsV2Enabled){dispatch(requestPageConfigV2({slug:pageId}));}else{dispatch(requestPageConfig(pageId));}var request=new PipelineRequest(SHOPGATE_CMS_GET_PAGE_CONFIG).setVersion(cmsV2Enabled?2:1).setInput(_extends({pageId:pageId},hasNewServices()&&!cmsV2Enabled?{deviceType:deviceTypeOfCmsPage}:null)).dispatch();request.then(function(result){if(cmsV2Enabled){dispatch(receivePageConfigV2({slug:pageId,data:result.page}));}else{dispatch(receivePageConfig(pageId,result));}})["catch"](function(error){if(cmsV2Enabled){dispatch(errorPageConfigV2({slug:pageId,code:error.code}));}else{dispatch(errorPageConfig(pageId,error.code));}});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchPageConfig);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.29.0-alpha.
|
|
3
|
+
"version": "7.29.0-alpha.4",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@redux-devtools/extension": "^3.3.0",
|
|
19
19
|
"@sentry/browser": "6.0.1",
|
|
20
|
-
"@shopgate/pwa-benchmark": "7.29.0-alpha.
|
|
20
|
+
"@shopgate/pwa-benchmark": "7.29.0-alpha.4",
|
|
21
21
|
"@virtuous/conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/react-conductor": "~2.5.0",
|
|
23
23
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"url-search-params": "^0.10.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@shopgate/pwa-core": "7.29.0-alpha.
|
|
46
|
+
"@shopgate/pwa-core": "7.29.0-alpha.4",
|
|
47
47
|
"@types/react-portal": "^3.0.9",
|
|
48
48
|
"lodash": "^4.17.4",
|
|
49
49
|
"prop-types": "~15.8.1",
|
package/selectors/page.js
CHANGED
|
@@ -5,4 +5,9 @@ import{createSelector}from'reselect';/**
|
|
|
5
5
|
* @param {Object} state The current application state.
|
|
6
6
|
* @param {Object} props The current component props.
|
|
7
7
|
* @return {Array|null}
|
|
8
|
-
*/export var getPageConfigById=createSelector(getPageState,function(state,props){return props.pageId;},function(pageState,pageId){if(!pageState||!pageState[pageId]){return null;}return pageState[pageId];})
|
|
8
|
+
*/export var getPageConfigById=createSelector(getPageState,function(state,props){return props.pageId;},function(pageState,pageId){if(!pageState||!pageState[pageId]){return null;}return pageState[pageId];});/**
|
|
9
|
+
* Creates a selector that retrieves a page configuration by its ID.
|
|
10
|
+
* @param {Object} params The selector parameters.
|
|
11
|
+
* @param {string} params.pageId The ID of the page.
|
|
12
|
+
* @returns {Function} A selector function that retrieves the page configuration.
|
|
13
|
+
*/export var makeGetPageConfigById=function makeGetPageConfigById(_ref){var pageId=_ref.pageId;return createSelector(getPageState,function(pageState){if(!pageState||!pageState[pageId]){return null;}return pageState[pageId];});};
|