@shopgate/pwa-common-commerce 7.12.1 → 7.12.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common-commerce",
3
- "version": "7.12.1",
3
+ "version": "7.12.2",
4
4
  "description": "Commerce library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -19,8 +19,8 @@
19
19
  "reselect": "^3.0.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@shopgate/pwa-common": "7.12.1",
23
- "@shopgate/pwa-core": "7.12.1",
22
+ "@shopgate/pwa-common": "7.12.2",
23
+ "@shopgate/pwa-core": "7.12.2",
24
24
  "lodash": "^4.17.4",
25
25
  "react": "~16.12.0",
26
26
  "react-dom": "~16.12.0"
@@ -1,12 +1,26 @@
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 fetchHighlightProducts from"./fetchHighlightProducts";import fetchProducts from"./fetchProducts";import fetchProductsById from"./fetchProductsById";/**
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);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import fetchHighlightProducts from"./fetchHighlightProducts";import fetchProducts from"./fetchProducts";import fetchProductsById from"./fetchProductsById";/**
2
2
  * Dispatches other actions based on the query type.
3
3
  * @param {number|string} type The query type.
4
4
  * @param {string} value The value to use with the query.
5
5
  * @param {Object} options Any additional options for requesting products.
6
6
  * @param {string} [id=null] A unique id for the component that is using this action.
7
7
  * @return {Function} A Redux Thunk
8
- */var fetchProductsByQuery=function fetchProductsByQuery(type,value){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var id=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return function(dispatch){switch(type){// Product highlights
9
- case 1:{var params=_extends({},options);dispatch(fetchHighlightProducts(_extends({params:params},id&&{id:id})));break;}// Search phrase
10
- case 2:case 3:{var _params=_extends({searchPhrase:value},options);return dispatch(fetchProducts(_extends({params:_params},id&&{id:id},{includeFilters:false})));}// Product ID's
11
- case 4:{dispatch(fetchProductsById(value,id));break;}// Category
12
- case 5:{var _params2=_extends({categoryId:value},options);return dispatch(fetchProducts(_extends({params:_params2},id&&{id:id},{includeFilters:false})));}default:}return null;};};export default fetchProductsByQuery;
8
+ */var fetchProductsByQuery=function fetchProductsByQuery(type,value){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var id=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return function(dispatch){/**
9
+ * Remove all properties from the options which are just intended to be used inside this function
10
+ * and not supposed to be used for the actual products request.
11
+ */var _options$useDefaultRe=options.useDefaultRequestForProductIds,useDefaultRequestForProductIds=_options$useDefaultRe===void 0?false:_options$useDefaultRe,sanitizedOptions=_objectWithoutProperties(options,["useDefaultRequestForProductIds"]);switch(type){// Product highlights
12
+ case 1:{var params=_extends({},sanitizedOptions);dispatch(fetchHighlightProducts(_extends({params:params},id&&{id:id})));break;}// Search phrase
13
+ case 2:case 3:{var _params=_extends({searchPhrase:value},sanitizedOptions);return dispatch(fetchProducts(_extends({params:_params},id&&{id:id},{includeFilters:false})));}// Product ID's
14
+ case 4:{/**
15
+ * By default the productIds query type bypasses the regular product request logic. It will
16
+ * just request the products that are not available in Redux yet.
17
+ * This can cause update issues in the UI, since selectors might not return fresh data when
18
+ * Redux changes.
19
+ * So when the "useDefaultRequestForProductIds" flag is active, the regular request system is
20
+ * used and whenever the fetch params change, new product data fill be fetched.
21
+ *
22
+ * ATTENTION: To make the system work completely, also the "getProductsResult" selector helper
23
+ * needs to be called with this parameter.
24
+ */if(useDefaultRequestForProductIds){var _params2=_extends({productIds:value},sanitizedOptions);// Limit and offset are not fully supported for product requests with productId list
25
+ delete _params2.limit;delete _params2.offset;dispatch(fetchProducts(_extends({params:_params2},id&&{id:id},{includeFilters:false})));}else{dispatch(fetchProductsById(value,id));}break;}// Category
26
+ case 5:{var _params3=_extends({categoryId:value},sanitizedOptions);return dispatch(fetchProducts(_extends({params:_params3},id&&{id:id},{includeFilters:false})));}default:}return null;};};export default fetchProductsByQuery;