@shopgate/pwa-common-commerce 7.29.1 → 7.29.2-beta.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.29.
|
|
3
|
+
"version": "7.29.2-beta.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": "^4.1.8"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@shopgate/pwa-common": "7.29.
|
|
23
|
-
"@shopgate/pwa-core": "7.29.
|
|
22
|
+
"@shopgate/pwa-common": "7.29.2-beta.2",
|
|
23
|
+
"@shopgate/pwa-core": "7.29.2-beta.2",
|
|
24
24
|
"lodash": "^4.17.4",
|
|
25
25
|
"react": "~16.14.0",
|
|
26
26
|
"react-dom": "~16.14.0"
|
|
@@ -33,7 +33,7 @@ var _excluded=["offset","limit"];function _objectWithoutProperties(source,exclud
|
|
|
33
33
|
* @param {boolean} [options.resolveCachedProducts=false] Whether to resolve with products even
|
|
34
34
|
* when no actual request was done due to cached data.
|
|
35
35
|
* @return {Function} A Redux Thunk
|
|
36
|
-
*/function fetchProducts(options){var _options$params=options.params,params=_options$params===void 0?{}:_options$params,_options$filters=options.filters,filters=_options$filters===void 0?null:_options$filters,_options$pipeline=options.pipeline,pipeline=_options$pipeline===void 0?SHOPGATE_CATALOG_GET_PRODUCTS:_options$pipeline,_options$cached=options.cached,cached=_options$cached===void 0?true:_options$cached,_options$cachedTime=options.cachedTime,cachedTime=_options$cachedTime===void 0?null:_options$cachedTime,_options$id=options.id,id=_options$id===void 0?null:_options$id,_options$includeSort=options.includeSort,includeSort=_options$includeSort===void 0?true:_options$includeSort,_options$includeFilte=options.includeFilters,includeFilters=_options$includeFilte===void 0?true:_options$includeFilte,_options$includeFulfi=options.includeFulfillment,includeFulfillment=_options$includeFulfi===void 0?true:_options$includeFulfi,_options$onBeforeDisp=options.onBeforeDispatch,onBeforeDispatch=_options$onBeforeDisp===void 0?function(){}:_options$onBeforeDisp,_options$resolveCache=options.resolveCachedProducts,resolveCachedProducts=_options$resolveCache===void 0?false:_options$resolveCache;return function(dispatch,getState){var state=getState();var offset=params.offset,limit=params.limit,hashParams=_objectWithoutProperties(params,_excluded);var defaultSort=getDefaultSortOrder(state,{scope:SORT_SCOPE_CATEGORY});var _hashParams$sort=hashParams.sort,sort=_hashParams$sort===void 0?defaultSort:_hashParams$sort;var getProductsRequestParams;if(pipeline===SHOPGATE_CATALOG_GET_PRODUCTS){getProductsRequestParams=configuration.get(DEFAULT_PRODUCTS_FETCH_PARAMS);}// Append additional global fulfillment parameters.
|
|
36
|
+
*/function fetchProducts(options){var _options$params=options.params,params=_options$params===void 0?{}:_options$params,_options$filters=options.filters,filters=_options$filters===void 0?null:_options$filters,_options$pipeline=options.pipeline,pipeline=_options$pipeline===void 0?SHOPGATE_CATALOG_GET_PRODUCTS:_options$pipeline,_options$cached=options.cached,cached=_options$cached===void 0?true:_options$cached,_options$cachedTime=options.cachedTime,cachedTime=_options$cachedTime===void 0?null:_options$cachedTime,_options$id=options.id,id=_options$id===void 0?null:_options$id,_options$includeSort=options.includeSort,includeSort=_options$includeSort===void 0?true:_options$includeSort,_options$includeFilte=options.includeFilters,includeFilters=_options$includeFilte===void 0?true:_options$includeFilte,_options$includeFulfi=options.includeFulfillment,includeFulfillment=_options$includeFulfi===void 0?true:_options$includeFulfi,_options$onBeforeDisp=options.onBeforeDispatch,onBeforeDispatch=_options$onBeforeDisp===void 0?function(){}:_options$onBeforeDisp,_options$resolveCache=options.resolveCachedProducts,resolveCachedProducts=_options$resolveCache===void 0?false:_options$resolveCache,_options$calledByFetc=options.calledByFetchProductsById,calledByFetchProductsById=_options$calledByFetc===void 0?false:_options$calledByFetc;return function(dispatch,getState){var state=getState();var offset=params.offset,limit=params.limit,hashParams=_objectWithoutProperties(params,_excluded);var defaultSort=getDefaultSortOrder(state,{scope:SORT_SCOPE_CATEGORY});var _hashParams$sort=hashParams.sort,sort=_hashParams$sort===void 0?defaultSort:_hashParams$sort;var getProductsRequestParams;if(pipeline===SHOPGATE_CATALOG_GET_PRODUCTS){getProductsRequestParams=configuration.get(DEFAULT_PRODUCTS_FETCH_PARAMS);}// Append additional global fulfillment parameters.
|
|
37
37
|
var fulfillmentParams={};if(includeFulfillment&&pipeline===SHOPGATE_CATALOG_GET_PRODUCTS){fulfillmentParams=getFulfillmentParams(state);}// We need to process the params to handle edge cases in the pipeline params.
|
|
38
38
|
var requestParams=_extends({},fulfillmentParams,{},getProductsRequestParams,{},processParams(params,filters,includeSort,includeFilters));var hash=generateResultHash(_extends({pipeline:pipeline,sort:sort},fulfillmentParams,{},hashParams,{},filters&&Object.keys(filters).length&&{filters:filters},{},id&&{id:id}),includeSort,includeFilters);var result=state.product.resultsByHash[hash];var requiredProductCount=null;// Only set a required number of products if both offset and limit are valid.
|
|
39
39
|
if(isNumber(offset)&&isNumber(limit)){requiredProductCount=offset+limit;}// Stop if we don't need to get any data.
|
|
@@ -47,4 +47,4 @@ onBeforeDispatch();dispatch(requestProducts({hash:hash,cached:cached,cachedTime:
|
|
|
47
47
|
* available products.
|
|
48
48
|
* So we set the products count of the response as totalProductCount to decrease the
|
|
49
49
|
* amount of logic, which is necessary to deal with product related pipeline.
|
|
50
|
-
*/if(typeof totalResultCount==='undefined'&&(pipeline===SHOPGATE_CATALOG_GET_HIGHLIGHT_PRODUCTS||pipeline===SHOPGATE_CATALOG_GET_LIVESHOPPING_PRODUCTS)){totalResultCount=response.products.length;}dispatch(receiveProducts({hash:hash,requestParams:requestParams,products:response.products,totalResultCount:totalResultCount,cached:cached,cachedTime:cachedTime}));if(!isProductIdentifiersProductIdType(params===null||params===void 0?void 0:params.productIdType)&&Array.isArray(params===null||params===void 0?void 0:params.productIds)){var requestIds=params===null||params===void 0?void 0:params.productIds;var responseIds=response.products.map(function(product){return product.id;});var missingResponseIds=difference(requestIds,responseIds);if(missingResponseIds.length>0){dispatch(deleteProductsByIds(missingResponseIds));}}})["catch"](function(error){dispatch(errorProducts({errorCode:error.code,hash:hash,requestParams:requestParams}));});return request;};}export default fetchProducts;
|
|
50
|
+
*/if(typeof totalResultCount==='undefined'&&(pipeline===SHOPGATE_CATALOG_GET_HIGHLIGHT_PRODUCTS||pipeline===SHOPGATE_CATALOG_GET_LIVESHOPPING_PRODUCTS)){totalResultCount=response.products.length;}dispatch(receiveProducts({hash:hash,requestParams:requestParams,products:response.products,totalResultCount:totalResultCount,cached:cached,cachedTime:cachedTime}));if(!isProductIdentifiersProductIdType(params===null||params===void 0?void 0:params.productIdType)&&calledByFetchProductsById&&Array.isArray(params===null||params===void 0?void 0:params.productIds)){var requestIds=params===null||params===void 0?void 0:params.productIds;var responseIds=response.products.map(function(product){return product.id;});var missingResponseIds=difference(requestIds,responseIds);if(missingResponseIds.length>0){dispatch(deleteProductsByIds(missingResponseIds));}}})["catch"](function(error){dispatch(errorProducts({errorCode:error.code,hash:hash,requestParams:requestParams}));});return request;};}export default fetchProducts;
|
|
@@ -20,4 +20,4 @@ localProductIds=optionsOrProductIds.productIds;var _optionsOrProductIds$=options
|
|
|
20
20
|
// and only request the missing ones. That certainly doesn't work for SKUs, EANs or UPCs,
|
|
21
21
|
if(!isProductIdentifiersProductIdType(productIdType)){var state=getState();var products=state.product.productsById;// Filter out only the products that are not yet available in the store.
|
|
22
22
|
requestProductIds=localProductIds.filter(function(id){return shouldFetchData(products[id]);});// Then only perform a pipeline request if there are products missing.
|
|
23
|
-
if(!requestProductIds.length){var productsById=localProductIds.map(function(id){return getProductDataById(state,{productId:id});});var totalProductCount=productsById.length;return{products:productsById,totalProductCount:totalProductCount};}}return dispatch(fetchProducts(_extends({},localComponentId&&{id:localComponentId},{cached:localCached,params:_extends({productIds:requestProductIds},productIdType&&{productIdType:productIdType}),includeFulfillment:localIncludeFulfillment,includeFilters:false,includeSort:false})));};};export default fetchProductsById;
|
|
23
|
+
if(!requestProductIds.length){var productsById=localProductIds.map(function(id){return getProductDataById(state,{productId:id});});var totalProductCount=productsById.length;return{products:productsById,totalProductCount:totalProductCount};}}return dispatch(fetchProducts(_extends({},localComponentId&&{id:localComponentId},{cached:localCached,params:_extends({productIds:requestProductIds},productIdType&&{productIdType:productIdType}),includeFulfillment:localIncludeFulfillment,includeFilters:false,includeSort:false,calledByFetchProductsById:true})));};};export default fetchProductsById;
|
|
@@ -21,6 +21,5 @@ case 4:{/**
|
|
|
21
21
|
*
|
|
22
22
|
* ATTENTION: To make the system work completely, also the "getProductsResult" selector helper
|
|
23
23
|
* needs to be called with this parameter.
|
|
24
|
-
*/if(useDefaultRequestForProductIds){var _params2=_extends({productIds:value,productIdType:productIdType},sanitizedOptions)
|
|
25
|
-
delete _params2.limit;delete _params2.offset;return dispatch(fetchProducts(_extends({params:_params2},id&&{id:id},{includeFilters:false,includeSort:false})));}return dispatch(fetchProductsById(value,id));}// Category
|
|
24
|
+
*/if(useDefaultRequestForProductIds){var _params2=_extends({productIds:value,productIdType:productIdType},sanitizedOptions);return dispatch(fetchProducts(_extends({params:_params2},id&&{id:id},{includeFilters:false})));}return dispatch(fetchProductsById(value,id));}// Category
|
|
26
25
|
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;
|