@ikas/storefront-providers 6.1.0-beta.23 → 6.1.0-beta.25
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 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as s}from"@ikas/storefront-model-functions";import{searchProducts as u,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as s}from"@ikas/storefront-model-functions";import{searchProducts as u,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as v,SortByTypeEnum as I}from"@ikas/storefront-api";import{IkasStorefrontConfig as E}from"@ikas/storefront-config";import"../blog-category-list/index.js";import"../blog-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";function p(i,o){var u,l,c,f;return e(this,void 0,void 0,(function(){var e,v,I,E,p,g,y;return t(this,(function(t){switch(t.label){case 0:!function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&[a.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=d.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=d.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=d.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=d.INCREASING_PRICE;break;case n.NEWEST:e.sort=d.LAST_ADDED;break;case n.OLDEST:e.sort=d.FIRST_ADDED;break;case n.MANUALLY:e.sort=d.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),v=o?i.page:1,I=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,T(i)];case 2:t.sent(),t.label=3;case 3:if(S(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,C(i))v=void 0,I=200;else if(function(e){return e.type===a.DISCOUNTED}(i))v=1,I=10;else if(function(e){return e.type===a.RECOMMENDED}(i))v=1,I=10;else if(D(i))return[2];return[4,A(i,v||1,I||10,undefined)];case 4:return(E=t.sent())&&i.fetchRequestTime===e?(p=[],D(i)?[2]:(C(i)?(g=i.productListPropValue.productIds||[],p=(null==g?void 0:g.map((function(e){var t,i,n=null===(i=null===(t=E.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),a=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==a?void 0:a.isActive)||(a=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&a)return r(r({},n),{selectedVariantValues:a.variantValues})})).filter((function(e){return!!e})))||[]):p=(null===(l=null===(u=E.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.map((function(e){var t=e.variants.find((function(e){return e.isActive}));return r(r({},e),{selectedVariantValues:(t||e.variants[0]).variantValues})})))||[],function(e,t){var r,i,n=s.isCustomValueFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,a,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=o.values.find((function(e){return e.id===t.id}));r?t.resultCount=r.count:n(e)?t.resultCount=null:t.resultCount=0})):n(e)?null===(i=e.values)||void 0===i||i.forEach((function(e){return e.resultCount=null})):null===(a=e.values)||void 0===a||a.forEach((function(e){return e.resultCount=0}))}));var a=null==t?void 0:t.find((function(e){return"category"===e.id}));a&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=a.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})));e.filters&&e.filters.forEach((function(e){e.values=s.getDisplayedValues(e)}))}(i,null===(c=E.data)||void 0===c?void 0:c.facets),i.data=p,i.count=(null===(f=E.data)||void 0===f?void 0:f.count)||0,i.initialized=!0,i.page=v||1,i.minPage=i.page,[2,!0])):[2];case 5:return y=t.sent(),console.error(y),[3,6];case 6:return[2]}}))}))}function C(e){return e.type===a.STATIC}function D(e){return e.type===a.LAST_VIEWED}function S(e){return e.type===a.SEARCH}function A(r,n,f,p){var D,A,T;return e(this,void 0,void 0,(function(){var e,g,y,R,h,m;return t(this,(function(t){switch(t.label){case 0:return e=[],g=[],y=s.getValueList,null===(D=r.filters)||void 0===D||D.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&g.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),h=function(e){var t,r;switch(e.sort){case d.INCREASING_PRICE:t=v.ASC,r=I.PRICE;break;case d.DECREASING_PRICE:t=v.DESC,r=I.PRICE;break;case d.FIRST_ADDED:t=v.ASC,r=I.CREATED_AT;break;case d.LAST_ADDED:t=v.DESC,r=I.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=v.ASC,r=I.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=v.DESC,r=I.DISCOUNT_RATIO;break;case d.FEATURED:if(S(e))return;t=v.ASC,r=I.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0;break;case d.AVERAGE_RATING:t=v.DESC,r=I.AVERAGE_RATING;break;case d.REVIEW_COUNT:t=v.DESC,r=I.REVIEW_COUNT;break;case d.SALE_COUNT:t=v.DESC,r=I.SALE_COUNT;break;case d.A_Z:t=v.ASC,r=I.NAME;break;case d.Z_A:t=v.DESC,r=I.NAME}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===a.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:case 7:return[2,t.sent()];case 2:return function(e){return e.type===a.RECOMMENDED_PRODUCTS}(r)&&r.recommendedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),brandIds:r.recommendedProductData.brandIds,categoryIds:r.recommendedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,4];case 4:return function(e){return e.type===a.VIEWED_TOGETHER}(r)&&r.viewedTogetherProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),method:c.VIEWED_TOGETHER,productIds:r.viewedTogetherProductData.productIds,locale:E.getCurrentLocale()})]:[3,6];case 6:return m={input:{page:n,perPage:f,productIdList:C(r)?null===(T=r.productListPropValue.productIds)||void 0===T?void 0:T.map((function(e){return e.productId})):p,filterList:e,facetList:g,brandId:r.pageType===i.BRAND&&r.type!==a.SEARCH?r.filterBrandId:void 0,categoryIdList:R&&R.length?R:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),query:r.searchKeyword,order:r.type===a.SEARCH?[]:h?[h]:[],showStockOption:E.getStockPreference()||o.SHOW_ALL}},[4,u(m,r.excludedFields)]}}))}))}function T(r){var n,a,o,d,s;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,f({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:E.getCurrentLocale()})];case 1:return e=t.sent(),r.filters=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||void 0===o?void 0:o.map((function(e){return new g(e)})))||null,r.disabledSortTypes=null===(d=e.data)||void 0===d?void 0:d.disabledSortTypes,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(s=r.filterCategories)||void 0===s?void 0:s.find((function(e){return e.id===r.filterCategoryId})))&&(u.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}var g=function(e){this.id=e.id,this.name=e.name,this.metaData=e.metaData,this.isAutomated=e.isAutomated,this.resultCount=e.resultCount,this.isSelected=e.isSelected,this.imageId=e.imageId};export{p as getInitial};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-providers",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.25",
|
|
4
4
|
"description": "Data providers for ikas storefront theme components.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
20
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
21
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
22
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
23
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
20
|
+
"@ikas/storefront-api": "^6.1.0-beta.25",
|
|
21
|
+
"@ikas/storefront-config": "^6.1.0-beta.25",
|
|
22
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.25",
|
|
23
|
+
"@ikas/storefront-models": "^6.1.0-beta.25",
|
|
24
24
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
25
25
|
"rollup-plugin-rename-node-modules": "^1.2.0",
|
|
26
26
|
"@types/lodash": "^4.14.168",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"mobx": "^6.1.3",
|
|
41
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
42
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
43
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
44
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
41
|
+
"@ikas/storefront-api": "^6.1.0-beta.25",
|
|
42
|
+
"@ikas/storefront-config": "^6.1.0-beta.25",
|
|
43
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.25",
|
|
44
|
+
"@ikas/storefront-models": "^6.1.0-beta.25",
|
|
45
45
|
"lodash": "^4.17.21"
|
|
46
46
|
}
|
|
47
47
|
}
|