@ikas/storefront-providers 4.0.0-alpha.63 → 4.0.0-alpha.65

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 t,__generator as e,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as o,IkasProductSearchShowStockOption as a,IkasProductListSortType as u}from"./index.js";import{IkasProductFilterFunctions as d}from"@ikas/storefront-model-functions";import{searchProducts as s,getRelatedProducts as l,getProductFilterData as c,SortByDirectionEnum as f,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}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 I(i,a){var s,l,c,f;return t(this,void 0,void 0,(function(){var t,v,p,I,T,y,g;return e(this,(function(e){switch(e.label){case 0:!function(t){var e;if((null===(e=t.pageSpecificData)||void 0===e?void 0:e.orderType)&&[o.ALL].includes(t.type))switch(t.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:t.sort=u.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:t.sort=u.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:t.sort=u.DECREASING_PRICE;break;case n.LOWEST_PRICE:t.sort=u.INCREASING_PRICE;break;case n.NEWEST:t.sort=u.LAST_ADDED;break;case n.OLDEST:t.sort=u.FIRST_ADDED;break;case n.MANUALLY:t.sort=u.FEATURED}}(i),i.isLoading=!0,t=Date.now(),i.fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,5,,6]),v=a?i.page:1,p=i.limit,!function(t){return t.type===o.ALL||t.type===o.CATEGORY}(i)||i.filters?[3,3]:[4,D(i)];case 2:e.sent(),e.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,p=200;else if(function(t){return t.type===o.DISCOUNTED}(i))v=1,p=10;else if(function(t){return t.type===o.RECOMMENDED}(i))v=1,p=10;else if(E(i))return[2];return[4,A(i,v||1,p||10,undefined)];case 4:return(I=e.sent())&&i.fetchRequestTime===t?(T=[],E(i)?[2]:(C(i)?(y=i.productListPropValue.productIds||[],T=(null==y?void 0:y.map((function(t){var e,i,n=null===(i=null===(e=I.data)||void 0===e?void 0:e.data)||void 0===i?void 0:i.find((function(e){return e.id===t.productId})),o=null==n?void 0:n.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)||(o=null==n?void 0:n.variants.find((function(t){return t.isActive}))),n&&o)return r(r({},n),{selectedVariantValues:o.variantValues})})).filter((function(t){return!!t})))||[]):T=(null===(l=null===(s=I.data)||void 0===s?void 0:s.data)||void 0===l?void 0:l.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return r(r({},t),{selectedVariantValues:(e||t.variants[0]).variantValues})})))||[],function(t,e){var r,i,n=d.isCustomValueFilter;null===(r=t.filters)||void 0===r||r.forEach((function(t){var r,i,o,a=null==e?void 0:e.find((function(e){return e.id===t.id}));a?null===(r=t.values)||void 0===r||r.forEach((function(e){var r=a.values.find((function(t){return t.id===e.id}));r?e.resultCount=r.count:n(t)?e.resultCount=null:e.resultCount=0})):n(t)?null===(i=t.values)||void 0===i||i.forEach((function(t){return t.resultCount=null})):null===(o=t.values)||void 0===o||o.forEach((function(t){return t.resultCount=0}))}));var o=null==e?void 0:e.find((function(t){return"category"===t.id}));o&&(null===(i=t.filterCategories)||void 0===i||i.forEach((function(t){var e=o.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))}(i,null===(c=I.data)||void 0===c?void 0:c.facets),i.data=T,i.count=(null===(f=I.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 g=e.sent(),console.error(g),[3,6];case 6:return[2]}}))}))}function C(t){return t.type===o.STATIC}function E(t){return t.type===o.LAST_VIEWED}function S(t){return t.type===o.SEARCH}function A(r,n,c,I){var E,A,D;return t(this,void 0,void 0,(function(){var t,T,y,g,R;return e(this,(function(e){switch(e.label){case 0:return t=[],T=[],y=d.getValueList,null===(E=r.filters)||void 0===E||E.forEach((function(e){var r=y(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&T.push({id:e.id,type:e.type,displayType:e.displayType})})),g=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(t){return t.isSelected})).map((function(t){return t.id})),R=function(t){var e,r;switch(t.sort){case u.INCREASING_PRICE:e=f.ASC,r=v.PRICE;break;case u.DECREASING_PRICE:e=f.DESC,r=v.PRICE;break;case u.FIRST_ADDED:e=f.ASC,r=v.CREATED_AT;break;case u.LAST_ADDED:e=f.DESC,r=v.CREATED_AT;break;case u.INCREASING_DISCOUNT:e=f.ASC,r=v.DISCOUNT_RATIO;break;case u.DECRASING_DISCOUNT:e=f.DESC,r=v.DISCOUNT_RATIO;break;case u.FEATURED:if(S(t))return;e=f.ASC,r=v.MANUAL_SORT;break;case u.DEFAULT:e=void 0,r=void 0}if(e&&r)return{direction:e,type:r}}(r),function(t){return t.type===o.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,s({input:{page:n,perPage:c,productIdList:C(r)?null===(D=r.productListPropValue.productIds)||void 0===D?void 0:D.map((function(t){return t.productId})):I,filterList:t,facetList:T,brandId:r.pageType===i.BRAND&&r.type!==o.SEARCH?r.filterBrandId:void 0,categoryIdList:g&&g.length?g:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),query:r.searchKeyword,order:r.type===o.SEARCH?[]:R?[R]:[],showStockOption:p.getStockPreference()||a.SHOW_ALL}})]}}))}))}function D(r){var n,o,a;return t(this,void 0,void 0,(function(){var t,u;return e(this,(function(e){switch(e.label){case 0:return[4,c({categoryId:r.filterCategoryId?r.filterCategoryId:void 0})];case 1:return t=e.sent(),r.filters=(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(a=r.filterCategories)||void 0===a?void 0:a.find((function(t){return t.id===r.filterCategoryId})))&&(u.isSelected=!0),r.filters&&r.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))}export{I as getInitial};
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 o,IkasProductSearchShowStockOption as a,IkasProductListSortType as u}from"./index.js";import{IkasProductFilterFunctions as d}from"@ikas/storefront-model-functions";import{searchProducts as s,getRelatedProducts as l,getProductFilterData as c,SortByDirectionEnum as f,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}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 I(i,a){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,p,I,T,y,g;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)&&[o.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=u.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=u.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=u.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=u.INCREASING_PRICE;break;case n.NEWEST:e.sort=u.LAST_ADDED;break;case n.OLDEST:e.sort=u.FIRST_ADDED;break;case n.MANUALLY:e.sort=u.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),v=a?i.page:1,p=i.limit,!function(e){return e.type===o.ALL||e.type===o.CATEGORY}(i)||i.filters?[3,3]:[4,D(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,p=200;else if(function(e){return e.type===o.DISCOUNTED}(i))v=1,p=10;else if(function(e){return e.type===o.RECOMMENDED}(i))v=1,p=10;else if(E(i))return[2];return[4,A(i,v||1,p||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(T=[],E(i)?[2]:(C(i)?(y=i.productListPropValue.productIds||[],T=(null==y?void 0:y.map((function(e){var t,i,n=null===(i=null===(t=I.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),o=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==o?void 0:o.isActive)||(o=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&o)return r(r({},n),{selectedVariantValues:o.variantValues})})).filter((function(e){return!!e})))||[]):T=(null===(l=null===(s=I.data)||void 0===s?void 0:s.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=d.isCustomValueFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,o,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=a.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===(o=e.values)||void 0===o||o.forEach((function(e){return e.resultCount=0}))}));var o=null==t?void 0:t.find((function(e){return"category"===e.id}));o&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=o.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})))}(i,null===(c=I.data)||void 0===c?void 0:c.facets),i.data=T,i.count=(null===(f=I.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 g=t.sent(),console.error(g),[3,6];case 6:return[2]}}))}))}function C(e){return e.type===o.STATIC}function E(e){return e.type===o.LAST_VIEWED}function S(e){return e.type===o.SEARCH}function A(r,n,c,I){var E,A,D;return e(this,void 0,void 0,(function(){var e,T,y,g,R;return t(this,(function(t){switch(t.label){case 0:return e=[],T=[],y=d.getValueList,null===(E=r.filters)||void 0===E||E.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&T.push({id:t.id,type:t.type,displayType:t.displayType})})),g=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),R=function(e){var t,r;switch(e.sort){case u.INCREASING_PRICE:t=f.ASC,r=v.PRICE;break;case u.DECREASING_PRICE:t=f.DESC,r=v.PRICE;break;case u.FIRST_ADDED:t=f.ASC,r=v.CREATED_AT;break;case u.LAST_ADDED:t=f.DESC,r=v.CREATED_AT;break;case u.INCREASING_DISCOUNT:t=f.ASC,r=v.DISCOUNT_RATIO;break;case u.DECRASING_DISCOUNT:t=f.DESC,r=v.DISCOUNT_RATIO;break;case u.FEATURED:if(S(e))return;t=f.ASC,r=v.MANUAL_SORT;break;case u.DEFAULT:t=void 0,r=void 0}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===o.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,s({input:{page:n,perPage:c,productIdList:C(r)?null===(D=r.productListPropValue.productIds)||void 0===D?void 0:D.map((function(e){return e.productId})):I,filterList:e,facetList:T,brandId:r.pageType===i.BRAND&&r.type!==o.SEARCH?r.filterBrandId:void 0,categoryIdList:g&&g.length?g:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),query:r.searchKeyword,order:r.type===o.SEARCH?[]:R?[R]:[],locale:p.getCurrentLocale(),showStockOption:p.getStockPreference()||a.SHOW_ALL}})]}}))}))}function D(r){var n,o,a;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,c({categoryId:r.filterCategoryId?r.filterCategoryId:void 0})];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==e?void 0:e.data)||void 0===o?void 0:o.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(a=r.filterCategories)||void 0===a?void 0:a.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]}}))}))}export{I as getInitial};
@@ -1 +1 @@
1
- import{__awaiter as n,__generator as t}from'./../../ext/tslib/tslib.es6.js';import{listProductOptionSet as i,searchProducts as r}from"@ikas/storefront-api";var o=function(o){return n(void 0,void 0,void 0,(function(){var n,u,a,d,e,c,s,f,v,l,p;return t(this,(function(t){switch(t.label){case 0:for(n=[],u=0,a=o;u<a.length;u++)d=a[u],null===(l=d.variants)||void 0===l||l.forEach((function(t){n.find((function(n){return n===t.productId}))||n.push(t.productId)}));return[4,r({input:{productIdList:n}})];case 1:return(e=t.sent()).isSuccess&&(c=(null===(p=e.data)||void 0===p?void 0:p.data)||[]).length?(s=c.map((function(n){return n.productOptionSetId})).filter((function(n){return!!n})),[4,i({id:{in:s}})]):[3,3];case 2:f=t.sent(),v=f.data,o.forEach((function(n){var t;null===(t=n.variants)||void 0===t||t.forEach((function(t){var i=c.find((function(n){return t.productId===n.id}));if(i){i.productOptionSet=null==v?void 0:v.find((function(n){return n.id===i.productOptionSetId}));var r=i.variants.find((function(n){return n.isActive&&t.variantId===n.id}))||i.variants[0];n.products.find((function(n){return n.id===i.id}))||(i.selectedVariantValues=r.variantValues,i.variants=i.variants.filter((function(t){var i;return null===(i=n.variants)||void 0===i?void 0:i.find((function(n){return n.variantId===t.id}))})),n.products.push(i))}}))})),t.label=3;case 3:return[2]}}))}))};export{o as populateRaffleProducts};
1
+ import{__awaiter as t,__generator as n}from'./../../ext/tslib/tslib.es6.js';import{listProductOptionSet as r,searchProducts as i}from"@ikas/storefront-api";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";var a=function(a){return t(void 0,void 0,void 0,(function(){var t,u,d,e,c,s,f,l,v,p,h;return n(this,(function(n){switch(n.label){case 0:for(t=[],u=0,d=a;u<d.length;u++)e=d[u],null===(p=e.variants)||void 0===p||p.forEach((function(n){t.find((function(t){return t===n.productId}))||t.push(n.productId)}));return[4,i({input:{productIdList:t,locale:o.getCurrentLocale()}})];case 1:return(c=n.sent()).isSuccess&&(s=(null===(h=c.data)||void 0===h?void 0:h.data)||[]).length?(f=s.map((function(t){return t.productOptionSetId})).filter((function(t){return!!t})),[4,r({id:{in:f}})]):[3,3];case 2:l=n.sent(),v=l.data,a.forEach((function(t){var n;null===(n=t.variants)||void 0===n||n.forEach((function(n){var r=s.find((function(t){return n.productId===t.id}));if(r){r.productOptionSet=null==v?void 0:v.find((function(t){return t.id===r.productOptionSetId}));var i=r.variants.find((function(t){return t.isActive&&n.variantId===t.id}))||r.variants[0];t.products.find((function(t){return t.id===r.id}))||(r.selectedVariantValues=i.variantValues,r.variants=r.variants.filter((function(n){var r;return null===(r=t.variants)||void 0===r?void 0:r.find((function(t){return t.variantId===n.id}))})),t.products.push(r))}}))})),n.label=3;case 3:return[2]}}))}))};export{a as populateRaffleProducts};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import{makeAutoObservable as a}from"mobx";import{IkasThemeJsonPageType as n,IkasRaffleMetadataTargetType as i,IkasBlogMetaDataTargetType as s,IkasHTMLMetaDataTargetType as o,IkasThemeJsonComponentPropType as u}from"@ikas/storefront-models";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{IkasProductFunctions as p}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as l}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as d}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as g}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as h}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as f}from"./prop-value/link.js";import{IkasImageListPropValueProvider as v}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as m}from"./prop-value/text.js";import{IkasColorPropValueProvider as T}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as S}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as y}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as O}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as D}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as L}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as P}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as b}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as I}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as w}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as R}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as C}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as E}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as A}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as j}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as G}from"./prop-value/raffle-list.js";import{listMerchantSettings as V,listCustomerReviewSummary as _,listProductOptionSet as F,searchProducts as B,listProductBrand as M,listCategory as k,listBlog as U,listBlogCategory as N,listStorefrontRaffle as q,listHTMLMetaData as Y,listRaffleMetaData as x,listBlogMetaData as J}from"@ikas/storefront-api";import{populateRaffleProducts as K}from"./helpers/raffle.js";var X=function(){function X(e,t,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=r,a(this)}return Object.defineProperty(X.prototype,"page",{get:function(){var e=this;if(this.pageType===n.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===n.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"nextPageData",{get:function(){var e,t,r,a,i;return{props:JSON.parse(JSON.stringify({propValues:this.pageComponentPropValues,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||n.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(a=this.page)||void 0===a?void 0:a.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,themeSettings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:c.toJSON()}))}},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"specification",{get:function(){var e,t,r=this,a=this.page;return(null==a?void 0:a.type)===n.PRODUCT?null===(e=a.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=r.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==a?void 0:a.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=r.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),X.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,V({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},X.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,r=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return r.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},X.prototype.getProductReviewSummary=function(){var r,a,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==n.PRODUCT?[3,2]:[4,_({productId:{eq:null===(r=this.pageSpecificData)||void 0===r?void 0:r.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},X.prototype.getPageSpecificData=function(){var r,a,u,l;return e(this,void 0,void 0,(function(){var d,g,h,f,v,m,T,S,y,O,D=this;return t(this,(function(L){switch(L.label){case 0:return this.pageType&&![n.BRAND,n.PRODUCT,n.CATEGORY,n.BLOG,n.BLOG_CATEGORY,n.RAFFLE_DETAIL].includes(this.pageType)?[2]:(d=this.pageParams.slug)?(g=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(n.BLOG))||(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(n.BLOG_CATEGORY))?[4,J({slug:{eq:d}})]:[3,2]):[2];case 1:return h=L.sent(),(g=(null===(u=h.data)||void 0===u?void 0:u.data)||[]).length?[3,6]:[2];case 2:return(null===(l=this.possiblePageTypes)||void 0===l?void 0:l.includes(n.RAFFLE_DETAIL))?[4,x({slug:{eq:d}})]:[3,4];case 3:return h=L.sent(),(g=h.data||[]).length?[3,6]:[2];case 4:return[4,Y({slug:{eq:d}})];case 5:if(h=L.sent(),!(g=h.data||[])||!g.length)return[2];L.label=6;case 6:if(!(f=g[0]).targetId)return[2];switch(v=function(){return e(D,void 0,void 0,(function(){var e,r,a,i,s,o,u,l,d,g,h;return t(this,(function(t){switch(t.label){case 0:return[4,B({input:{productIdList:[f.targetId],priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(g=null===(d=null==e?void 0:e.data)||void 0===d?void 0:d.data)||void 0===g?void 0:g.length)?(r=e.data.data[0]).productOptionSetId?[4,F({id:{eq:r.productOptionSetId}})]:[3,3]:[2];case 2:(a=t.sent()).isSuccess&&(null===(h=null==a?void 0:a.data)||void 0===h?void 0:h.length)&&(r.productOptionSet=a.data[0]),t.label=3;case 3:return(i=r.variants.find((function(e){return e.isActive})))?(r.selectedVariantValues=i.variantValues,s=p.getDisplayedVariantTypes,this.pageSpecificData=r,(o=s(this.pageSpecificData,r.selectedVariantValues)).length&&(u=o[0]).displayedVariantValues.length&&(l=u.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=l.variant.variantValues),this.pageType=n.PRODUCT,this.setPageMetaData(f),[2]):[2]}}))}))},m=function(){return e(D,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,M({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BRAND,this.setPageMetaData(f),[2]):[2]}}))}))},T=function(){return e(D,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,k({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},S=function(){return e(D,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,U({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BLOG,this.setPageMetaData(f),[2]):[2]}}))}))},y=function(){return e(D,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:f.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BLOG_CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},O=function(){return e(D,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],[4,K([r])]):[2];case 2:return t.sent(),this.pageSpecificData=r,this.pageType=n.RAFFLE_DETAIL,this.setPageMetaData(f),[2]}}))}))},f.targetType){case o.BRAND:return[3,7];case o.CATEGORY:return[3,9];case o.PRODUCT:return[3,11];case s.BLOG:return[3,13];case s.BLOG_CATEGORY:return[3,15];case i.RAFFLE:return[3,17]}return[3,19];case 7:return[4,m()];case 8:return[2,L.sent()];case 9:return[4,T()];case 10:return[2,L.sent()];case 11:return[4,v()];case 12:return[2,L.sent()];case 13:return[4,S()];case 14:return[2,L.sent()];case 15:return[4,y()];case 16:return[2,L.sent()];case 17:return[4,O()];case 18:return[2,L.sent()];case 19:return[3,20];case 20:return[2]}}))}))},X.prototype.getPageComponentPropValues=function(r){return e(this,void 0,void 0,(function(){var a,n,i,s=this;return t(this,(function(o){switch(o.label){case 0:return a=this.theme.components.find((function(e){return e.id===r.componentId})),n={pageComponent:r,component:a,propValues:{}},i=function(a){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=n.propValues,i=a.name,[4,this.getPageComponentPropValue(r,a)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(a.props.map(i))];case 1:return o.sent(),[2,n]}}))}))},X.prototype.getPageComponentPropValue=function(r,a){return e(this,void 0,void 0,(function(){var e,n,i,s,o,c=this;return t(this,(function(t){switch(t.label){case 0:if(n=r.propValues[a.name],i=[u.RAFFLE_LIST],null==n&&!i.includes(a.type))return[2,null];switch(a.type){case u.TEXT:return[3,1];case u.RICH_TEXT:return[3,2];case u.BOOLEAN:return[3,3];case u.IMAGE:return[3,4];case u.IMAGE_LIST:return[3,5];case u.BRAND:return[3,6];case u.BRAND_LIST:return[3,7];case u.PRODUCT_LIST:return[3,8];case u.PRODUCT_DETAIL:return[3,9];case u.PRODUCT_ATTRIBUTE:return[3,10];case u.PRODUCT_ATTRIBUTE_LIST:return[3,11];case u.CATEGORY:return[3,12];case u.CATEGORY_LIST:return[3,13];case u.LINK:case u.LIST_OF_LINK:return[3,14];case u.COLOR:return[3,15];case u.CUSTOM:return[3,16];case u.COMPONENT:case u.COMPONENT_LIST:return[3,17];case u.BLOG:return[3,19];case u.BLOG_LIST:return[3,20];case u.BLOG_CATEGORY:return[3,21];case u.BLOG_CATEGORY_LIST:return[3,22];case u.RAFFLE:return[3,23];case u.RAFFLE_LIST:return[3,24];case u.SLIDER:return[3,25]}return[3,26];case 1:return e=new m(n),[3,27];case 2:return e=new b(n),[3,27];case 3:return e=new S(n),[3,27];case 4:return e=new y(n),[3,27];case 5:return e=new v(n),[3,27];case 6:return e=new h(n),[3,27];case 7:return e=new g(n),[3,27];case 8:return e=new l(this.pageType,n,this.pageSpecificData),[3,27];case 9:return e=new d(n),[3,27];case 10:return e=new R(n),[3,27];case 11:return e=new C(n),[3,27];case 12:return e=new O(n),[3,27];case 13:return e=new D(n),[3,27];case 14:return e=new f(n,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new T(n),[3,27];case 16:return(s=this.theme.customData.find((function(e){return e.id===a.customDataId})))?(e=new L(n,s,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=n,[4,Promise.all(o.map((function(e){return c.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new I(n),[3,27];case 20:return e=new w(this.pageType,n,this.pageSpecificData),[3,27];case 21:return e=new E(n),[3,27];case 22:return e=new A(n),[3,27];case 23:return e=new j(n),[3,27];case 24:return e=new G,[3,27];case 25:return e=new P(n),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},X.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},X.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return e=[],r=[],a=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":r.push(t);break;case"RAFFLE":a.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(r,"BLOG"),this.getLinkSlugs(a,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},X.prototype.getLinkSlugs=function(a,n){return e(this,void 0,void 0,(function(){var i,s,o=this;return t(this,(function(u){switch(u.label){case 0:return i=r(a.map((function(e){return e.id}))),s=[],[4,function(){return e(o,void 0,void 0,(function(){var e,r,a,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],n){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Y({targetId:{in:i}})];case 2:return r=t.sent(),e=r.data||[],[3,8];case 3:return[4,J({targetId:{in:i}})];case 4:return a=t.sent(),e=(null===(u=a.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,x({targetId:{in:i}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()];case 1:return u.sent(),a.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},X}();export{X as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import{makeAutoObservable as a}from"mobx";import{IkasThemeJsonPageType as n,IkasRaffleMetadataTargetType as i,IkasBlogMetaDataTargetType as s,IkasHTMLMetaDataTargetType as o,IkasThemeJsonComponentPropType as u}from"@ikas/storefront-models";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{IkasProductFunctions as p}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as l}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as d}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as g}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as h}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as f}from"./prop-value/link.js";import{IkasImageListPropValueProvider as v}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as m}from"./prop-value/text.js";import{IkasColorPropValueProvider as T}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as S}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as y}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as L}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as O}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as D}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as P}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as b}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as I}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as w}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as R}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as C}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as E}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as A}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as j}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as G}from"./prop-value/raffle-list.js";import{listMerchantSettings as V,listCustomerReviewSummary as _,listProductOptionSet as F,searchProducts as B,listProductBrand as M,listCategory as k,listBlog as U,listBlogCategory as N,listStorefrontRaffle as q,listHTMLMetaData as Y,listRaffleMetaData as x,listBlogMetaData as J}from"@ikas/storefront-api";import{populateRaffleProducts as K}from"./helpers/raffle.js";var X=function(){function X(e,t,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=r,a(this)}return Object.defineProperty(X.prototype,"page",{get:function(){var e=this;if(this.pageType===n.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===n.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"nextPageData",{get:function(){var e,t,r,a,i;return{props:JSON.parse(JSON.stringify({propValues:this.pageComponentPropValues,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||n.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(a=this.page)||void 0===a?void 0:a.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,themeSettings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:c.toJSON()}))}},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"specification",{get:function(){var e,t,r=this,a=this.page;return(null==a?void 0:a.type)===n.PRODUCT?null===(e=a.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=r.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==a?void 0:a.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=r.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(X.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),X.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,V({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},X.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,r=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return r.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},X.prototype.getProductReviewSummary=function(){var r,a,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==n.PRODUCT?[3,2]:[4,_({productId:{eq:null===(r=this.pageSpecificData)||void 0===r?void 0:r.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},X.prototype.getPageSpecificData=function(){var r,a,u,l;return e(this,void 0,void 0,(function(){var d,g,h,f,v,m,T,S,y,L,O=this;return t(this,(function(D){switch(D.label){case 0:return this.pageType&&![n.BRAND,n.PRODUCT,n.CATEGORY,n.BLOG,n.BLOG_CATEGORY,n.RAFFLE_DETAIL].includes(this.pageType)?[2]:(d=this.pageParams.slug)?(g=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(n.BLOG))||(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(n.BLOG_CATEGORY))?[4,J({slug:{eq:d}})]:[3,2]):[2];case 1:return h=D.sent(),(g=(null===(u=h.data)||void 0===u?void 0:u.data)||[]).length?[3,6]:[2];case 2:return(null===(l=this.possiblePageTypes)||void 0===l?void 0:l.includes(n.RAFFLE_DETAIL))?[4,x({slug:{eq:d}})]:[3,4];case 3:return h=D.sent(),(g=h.data||[]).length?[3,6]:[2];case 4:return[4,Y({slug:{eq:d}})];case 5:if(h=D.sent(),!(g=h.data||[])||!g.length)return[2];D.label=6;case 6:if(!(f=g[0]).targetId)return[2];switch(v=function(){return e(O,void 0,void 0,(function(){var e,r,a,i,s,o,u,l,d,g,h;return t(this,(function(t){switch(t.label){case 0:return[4,B({input:{productIdList:[f.targetId],priceListId:c.getPriceListId(),salesChannelId:c.getSalesChannelId(),locale:c.getCurrentLocale()}})];case 1:return e=t.sent(),(null===(g=null===(d=null==e?void 0:e.data)||void 0===d?void 0:d.data)||void 0===g?void 0:g.length)?(r=e.data.data[0]).productOptionSetId?[4,F({id:{eq:r.productOptionSetId}})]:[3,3]:[2];case 2:(a=t.sent()).isSuccess&&(null===(h=null==a?void 0:a.data)||void 0===h?void 0:h.length)&&(r.productOptionSet=a.data[0]),t.label=3;case 3:return(i=r.variants.find((function(e){return e.isActive})))?(r.selectedVariantValues=i.variantValues,s=p.getDisplayedVariantTypes,this.pageSpecificData=r,(o=s(this.pageSpecificData,r.selectedVariantValues)).length&&(u=o[0]).displayedVariantValues.length&&(l=u.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=l.variant.variantValues),this.pageType=n.PRODUCT,this.setPageMetaData(f),[2]):[2]}}))}))},m=function(){return e(O,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,M({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BRAND,this.setPageMetaData(f),[2]):[2]}}))}))},T=function(){return e(O,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,k({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},S=function(){return e(O,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,U({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BLOG,this.setPageMetaData(f),[2]):[2]}}))}))},y=function(){return e(O,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:f.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],this.pageSpecificData=r,this.pageType=n.BLOG_CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},L=function(){return e(O,void 0,void 0,(function(){var e,r,a,i;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===i?void 0:i.length)?(r=e.data.data[0],[4,K([r])]):[2];case 2:return t.sent(),this.pageSpecificData=r,this.pageType=n.RAFFLE_DETAIL,this.setPageMetaData(f),[2]}}))}))},f.targetType){case o.BRAND:return[3,7];case o.CATEGORY:return[3,9];case o.PRODUCT:return[3,11];case s.BLOG:return[3,13];case s.BLOG_CATEGORY:return[3,15];case i.RAFFLE:return[3,17]}return[3,19];case 7:return[4,m()];case 8:return[2,D.sent()];case 9:return[4,T()];case 10:return[2,D.sent()];case 11:return[4,v()];case 12:return[2,D.sent()];case 13:return[4,S()];case 14:return[2,D.sent()];case 15:return[4,y()];case 16:return[2,D.sent()];case 17:return[4,L()];case 18:return[2,D.sent()];case 19:return[3,20];case 20:return[2]}}))}))},X.prototype.getPageComponentPropValues=function(r){return e(this,void 0,void 0,(function(){var a,n,i,s=this;return t(this,(function(o){switch(o.label){case 0:return a=this.theme.components.find((function(e){return e.id===r.componentId})),n={pageComponent:r,component:a,propValues:{}},i=function(a){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=n.propValues,i=a.name,[4,this.getPageComponentPropValue(r,a)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(a.props.map(i))];case 1:return o.sent(),[2,n]}}))}))},X.prototype.getPageComponentPropValue=function(r,a){return e(this,void 0,void 0,(function(){var e,n,i,s,o,c=this;return t(this,(function(t){switch(t.label){case 0:if(n=r.propValues[a.name],i=[u.RAFFLE_LIST],null==n&&!i.includes(a.type))return[2,null];switch(a.type){case u.TEXT:return[3,1];case u.RICH_TEXT:return[3,2];case u.BOOLEAN:return[3,3];case u.IMAGE:return[3,4];case u.IMAGE_LIST:return[3,5];case u.BRAND:return[3,6];case u.BRAND_LIST:return[3,7];case u.PRODUCT_LIST:return[3,8];case u.PRODUCT_DETAIL:return[3,9];case u.PRODUCT_ATTRIBUTE:return[3,10];case u.PRODUCT_ATTRIBUTE_LIST:return[3,11];case u.CATEGORY:return[3,12];case u.CATEGORY_LIST:return[3,13];case u.LINK:case u.LIST_OF_LINK:return[3,14];case u.COLOR:return[3,15];case u.CUSTOM:return[3,16];case u.COMPONENT:case u.COMPONENT_LIST:return[3,17];case u.BLOG:return[3,19];case u.BLOG_LIST:return[3,20];case u.BLOG_CATEGORY:return[3,21];case u.BLOG_CATEGORY_LIST:return[3,22];case u.RAFFLE:return[3,23];case u.RAFFLE_LIST:return[3,24];case u.SLIDER:return[3,25]}return[3,26];case 1:return e=new m(n),[3,27];case 2:return e=new b(n),[3,27];case 3:return e=new S(n),[3,27];case 4:return e=new y(n),[3,27];case 5:return e=new v(n),[3,27];case 6:return e=new h(n),[3,27];case 7:return e=new g(n),[3,27];case 8:return e=new l(this.pageType,n,this.pageSpecificData),[3,27];case 9:return e=new d(n),[3,27];case 10:return e=new R(n),[3,27];case 11:return e=new C(n),[3,27];case 12:return e=new L(n),[3,27];case 13:return e=new O(n),[3,27];case 14:return e=new f(n,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new T(n),[3,27];case 16:return(s=this.theme.customData.find((function(e){return e.id===a.customDataId})))?(e=new D(n,s,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=n,[4,Promise.all(o.map((function(e){return c.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new I(n),[3,27];case 20:return e=new w(this.pageType,n,this.pageSpecificData),[3,27];case 21:return e=new E(n),[3,27];case 22:return e=new A(n),[3,27];case 23:return e=new j(n),[3,27];case 24:return e=new G,[3,27];case 25:return e=new P(n),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},X.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},X.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,r,a;return t(this,(function(t){switch(t.label){case 0:return e=[],r=[],a=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":r.push(t);break;case"RAFFLE":a.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(r,"BLOG"),this.getLinkSlugs(a,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},X.prototype.getLinkSlugs=function(a,n){return e(this,void 0,void 0,(function(){var i,s,o=this;return t(this,(function(u){switch(u.label){case 0:return i=r(a.map((function(e){return e.id}))),s=[],[4,function(){return e(o,void 0,void 0,(function(){var e,r,a,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],n){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Y({targetId:{in:i}})];case 2:return r=t.sent(),e=r.data||[],[3,8];case 3:return[4,J({targetId:{in:i}})];case 4:return a=t.sent(),e=(null===(u=a.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,x({targetId:{in:i}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()];case 1:return u.sent(),a.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},X}();export{X as IkasPageDataProvider};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{searchProducts as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{IkasProductFunctions as r}from"@ikas/storefront-model-functions";var s=function(){function s(t){this.attributeListPropValue=t}return s.prototype.getValue=function(){var s,u;return t(this,void 0,void 0,(function(){var t,n,o,l,d,p,c,V=this;return i(this,(function(i){switch(i.label){case 0:return!(null===(s=this.attributeListPropValue.attributeIds)||void 0===s?void 0:s.length)||this.attributeListPropValue.usePageData||!this.attributeListPropValue.usePageData&&!this.attributeListPropValue.variantId?[2,{productDetail:null,attributeListPropValue:this.attributeListPropValue}]:[4,a({input:{productIdList:[this.attributeListPropValue.productId],priceListId:e.getPriceListId(),salesChannelId:e.getSalesChannelId()}})];case 1:return(n=i.sent()).isSuccess&&(null===(u=n.data)||void 0===u?void 0:u.data)&&(o=n.data.data,l=r.hasVariant,o.length&&((d=o[0])&&l(d)?(p=d.variants.find((function(t){return t.id===V.attributeListPropValue.variantId})))&&(d.selectedVariantValues=p.variantValues,t=d):(c=d.variants.find((function(t){return t.isActive})),d.selectedVariantValues=(c||d.variants[0]).variantValues,t=d))),[2,{productDetail:t||null,attributeListPropValue:this.attributeListPropValue}]}}))}))},s}();export{s as IkasAttributeListPropValueProvider};
1
+ import{__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{searchProducts as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{IkasProductFunctions as r}from"@ikas/storefront-model-functions";var s=function(){function s(t){this.attributeListPropValue=t}return s.prototype.getValue=function(){var s,u;return t(this,void 0,void 0,(function(){var t,n,o,l,d,c,p,V=this;return i(this,(function(i){switch(i.label){case 0:return!(null===(s=this.attributeListPropValue.attributeIds)||void 0===s?void 0:s.length)||this.attributeListPropValue.usePageData||!this.attributeListPropValue.usePageData&&!this.attributeListPropValue.variantId?[2,{productDetail:null,attributeListPropValue:this.attributeListPropValue}]:[4,a({input:{productIdList:[this.attributeListPropValue.productId],priceListId:e.getPriceListId(),salesChannelId:e.getSalesChannelId(),locale:e.getCurrentLocale()}})];case 1:return(n=i.sent()).isSuccess&&(null===(u=n.data)||void 0===u?void 0:u.data)&&(o=n.data.data,l=r.hasVariant,o.length&&((d=o[0])&&l(d)?(c=d.variants.find((function(t){return t.id===V.attributeListPropValue.variantId})))&&(d.selectedVariantValues=c.variantValues,t=d):(p=d.variants.find((function(t){return t.isActive})),d.selectedVariantValues=(p||d.variants[0]).variantValues,t=d))),[2,{productDetail:t||null,attributeListPropValue:this.attributeListPropValue}]}}))}))},s}();export{s as IkasAttributeListPropValueProvider};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as a}from'./../../ext/tslib/tslib.es6.js';import{searchProducts as i}from"@ikas/storefront-api";import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{IkasProductFunctions as r}from"@ikas/storefront-model-functions";var u=function(){function u(t){this.attributePropValue=t}return u.prototype.getValue=function(){var u,n;return t(this,void 0,void 0,(function(){var t,o,s,l,d,p,c,V=this;return a(this,(function(a){switch(a.label){case 0:return!this.attributePropValue.attributeId||(null===(u=this.attributePropValue)||void 0===u?void 0:u.usePageData)||!this.attributePropValue.usePageData&&!this.attributePropValue.variantId?[2,{productDetail:null,attributePropValue:this.attributePropValue}]:[4,i({input:{productIdList:[this.attributePropValue.productId],priceListId:e.getPriceListId(),salesChannelId:e.getSalesChannelId()}})];case 1:return(o=a.sent()).isSuccess&&(null===(n=o.data)||void 0===n?void 0:n.data)&&(s=o.data.data).length&&(l=s[0],d=r.hasVariant,l&&d(l)?(p=l.variants.find((function(t){return t.id===V.attributePropValue.variantId})))&&(l.selectedVariantValues=p.variantValues,t=l):(c=l.variants.find((function(t){return t.isActive})),l.selectedVariantValues=(c||l.variants[0]).variantValues,t=l)),[2,{productDetail:t||null,attributePropValue:this.attributePropValue}]}}))}))},u}();export{u as IkasAttributePropValueProvider};
1
+ import{__awaiter as t,__generator as a}from'./../../ext/tslib/tslib.es6.js';import{searchProducts as e}from"@ikas/storefront-api";import{IkasStorefrontConfig as r}from"@ikas/storefront-config";import{IkasProductFunctions as i}from"@ikas/storefront-model-functions";var u=function(){function u(t){this.attributePropValue=t}return u.prototype.getValue=function(){var u,n;return t(this,void 0,void 0,(function(){var t,o,s,l,d,c,p,V=this;return a(this,(function(a){switch(a.label){case 0:return!this.attributePropValue.attributeId||(null===(u=this.attributePropValue)||void 0===u?void 0:u.usePageData)||!this.attributePropValue.usePageData&&!this.attributePropValue.variantId?[2,{productDetail:null,attributePropValue:this.attributePropValue}]:[4,e({input:{productIdList:[this.attributePropValue.productId],priceListId:r.getPriceListId(),salesChannelId:r.getSalesChannelId(),locale:r.getCurrentLocale()}})];case 1:return(o=a.sent()).isSuccess&&(null===(n=o.data)||void 0===n?void 0:n.data)&&(s=o.data.data).length&&(l=s[0],d=i.hasVariant,l&&d(l)?(c=l.variants.find((function(t){return t.id===V.attributePropValue.variantId})))&&(l.selectedVariantValues=c.variantValues,t=l):(p=l.variants.find((function(t){return t.isActive})),l.selectedVariantValues=(p||l.variants[0]).variantValues,t=l)),[2,{productDetail:t||null,attributePropValue:this.attributePropValue}]}}))}))},u}();export{u as IkasAttributePropValueProvider};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{listProductOptionSet as a,searchProducts as r}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasProductFunctions as o}from"@ikas/storefront-model-functions";import{getPlaceholderProduct as u}from"../placeholders.js";var l=function(){function l(t){this.productDetailPropValue=t}return l.prototype.getValue=function(){var l,n,d;return t(this,void 0,void 0,(function(){var t,s,p,c,V,f,v,h=this;return e(this,(function(e){switch(e.label){case 0:return(null===(l=this.productDetailPropValue)||void 0===l?void 0:l.usePageData)?[2,{productDetailPropValue:this.productDetailPropValue,productDetail:null}]:this.productDetailPropValue.productId?[4,r({input:{productIdList:[this.productDetailPropValue.productId],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId()}})]:[2,null];case 1:return(t=e.sent()).isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.data)?(s=t.data.data).length?(p=s[0]).productOptionSetId?[4,a({id:{eq:p.productOptionSetId}})]:[3,3]:[3,4]:[3,5];case 2:(c=e.sent()).isSuccess&&(null===(d=c.data)||void 0===d?void 0:d.length)&&(p.productOptionSet=c.data[0]),e.label=3;case 3:return V=o.hasVariant,p&&V(p)?(f=p.variants.find((function(t){return t.id===h.productDetailPropValue.variantId})))?(p.selectedVariantValues=null==f?void 0:f.variantValues,[2,{productDetailPropValue:this.productDetailPropValue,productDetail:p}]):[2,null]:(v=p.variants.find((function(t){return t.isActive})),p.selectedVariantValues=(v||p.variants[0]).variantValues,[2,{productDetailPropValue:this.productDetailPropValue,productDetail:p}]);case 4:return[2,{productDetailPropValue:this.productDetailPropValue,productDetail:u()}];case 5:return[2,null]}}))}))},l}();export{l as IkasProductPropValueProvider};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{listProductOptionSet as a,searchProducts as r}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasProductFunctions as o}from"@ikas/storefront-model-functions";import{getPlaceholderProduct as u}from"../placeholders.js";var l=function(){function l(t){this.productDetailPropValue=t}return l.prototype.getValue=function(){var l,n,d;return t(this,void 0,void 0,(function(){var t,s,c,p,V,f,v,h=this;return e(this,(function(e){switch(e.label){case 0:return(null===(l=this.productDetailPropValue)||void 0===l?void 0:l.usePageData)?[2,{productDetailPropValue:this.productDetailPropValue,productDetail:null}]:this.productDetailPropValue.productId?[4,r({input:{productIdList:[this.productDetailPropValue.productId],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId(),locale:i.getCurrentLocale()}})]:[2,null];case 1:return(t=e.sent()).isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.data)?(s=t.data.data).length?(c=s[0]).productOptionSetId?[4,a({id:{eq:c.productOptionSetId}})]:[3,3]:[3,4]:[3,5];case 2:(p=e.sent()).isSuccess&&(null===(d=p.data)||void 0===d?void 0:d.length)&&(c.productOptionSet=p.data[0]),e.label=3;case 3:return V=o.hasVariant,c&&V(c)?(f=c.variants.find((function(t){return t.id===h.productDetailPropValue.variantId})))?(c.selectedVariantValues=null==f?void 0:f.variantValues,[2,{productDetailPropValue:this.productDetailPropValue,productDetail:c}]):[2,null]:(v=c.variants.find((function(t){return t.isActive})),c.selectedVariantValues=(v||c.variants[0]).variantValues,[2,{productDetailPropValue:this.productDetailPropValue,productDetail:c}]);case 4:return[2,{productDetailPropValue:this.productDetailPropValue,productDetail:u()}];case 5:return[2,null]}}))}))},l}();export{l as IkasProductPropValueProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "4.0.0-alpha.63",
3
+ "version": "4.0.0-alpha.65",
4
4
  "description": "Data providers for ikas storefront theme components.",
5
5
  "author": "Umut Ozan Yıldırım",
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": "^4.0.0-alpha.63",
21
- "@ikas/storefront-config": "^4.0.0-alpha.63",
22
- "@ikas/storefront-model-functions": "^4.0.0-alpha.63",
23
- "@ikas/storefront-models": "^4.0.0-alpha.63",
20
+ "@ikas/storefront-api": "^4.0.0-alpha.65",
21
+ "@ikas/storefront-config": "^4.0.0-alpha.65",
22
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.65",
23
+ "@ikas/storefront-models": "^4.0.0-alpha.65",
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": "^4.0.0-alpha.63",
42
- "@ikas/storefront-config": "^4.0.0-alpha.63",
43
- "@ikas/storefront-model-functions": "^4.0.0-alpha.63",
44
- "@ikas/storefront-models": "^4.0.0-alpha.63",
41
+ "@ikas/storefront-api": "^4.0.0-alpha.65",
42
+ "@ikas/storefront-config": "^4.0.0-alpha.65",
43
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.65",
44
+ "@ikas/storefront-models": "^4.0.0-alpha.65",
45
45
  "lodash": "^4.17.20"
46
46
  }
47
47
  }