@ikas/storefront-providers 5.0.24 → 5.0.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 n}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import i from"lodash/flatten";import{makeAutoObservable as a}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as s,IkasThemeJsonPageType as o,IkasStorefrontPopupPageFilterDataTypeEnum as u,IkasAmountType as c,IkasCampaignOfferProductApplicablePriceEnum as l,IkasCategoryConditionTypeEnum as d,IkasRaffleMetadataTargetType as p,IkasBlogMetaDataTargetType as g,IkasHTMLMetaDataTargetType as f,IkasThemeJsonComponentPropType as h}from"@ikas/storefront-models";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasProductFunctions as m,IkasProductVariantFunctions as T}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as S}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as I}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as D}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as O}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as P}from"./prop-value/link.js";import{IkasImageListPropValueProvider as C}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as y}from"./prop-value/text.js";import{IkasColorPropValueProvider as R}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as L}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as b}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as w}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as F}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as G}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as _}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as U}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as j}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as B}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as M}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as k}from"./prop-value/raffle-list.js";import{listMerchantSettings as x,listCustomerReviewSummary as Y,searchProducts as q,listCampaignOffer as J,listCustomerReviews as H,listProductOptionSet as K,listProductBrand as X,listCategory as z,listBlog as Q,listBlogCategory as $,listStorefrontRaffle as W,listHTMLMetaData as Z,listRaffleMetaData as ee,listBlogMetaData as te}from"@ikas/storefront-api";import{populateRaffleProducts as ne}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as re}from"./prop-value/video.js";var ie=function(){function ie(e,t,n,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=n,this.merchantSettings=r,a(this)}return Object.defineProperty(ie.prototype,"page",{get:function(){var e=this;if(this.pageType===o.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===o.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||o.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===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:v.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),ie.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=v.getCurrentRouting();v.getCurrentLocale(),v.getDomain();var n=v.getStorefrontId(),r=v.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=v.getStorefrontPopups(),c=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,h=!1,v=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===s.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case s.ACCOUNT:if(i)return[o.ACCOUNT,o.ORDERS,o.ORDER_DETAIL,o.FAVORITE_PRODUCTS,o.ADDRESSES,o.RAFFLE_ACCOUNT].includes(i);case s.LOGIN:return i===o.LOGIN;case s.REGISTER:return i===o.REGISTER;case s.CART:return i===o.CART;case s.CATEGORY:return i===o.CATEGORY;case s.HOME:return i===o.INDEX;case s.PRODUCT:return i===o.PRODUCT;case s.PRODUCT_BRAND:return i===o.BRAND;case s.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case s.CATEGORY:case s.PRODUCT:case s.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===u.ID_LIST&&T&&(g=S.value.includes(T),v=!0);break;case s.CUSTOM:g=!0;break;default:v=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,v=!0)}else g=!0,v=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(h=!0)}}else h=!0;g&&f&&h&&(t.isFilteredOnServerSide=v,c.push(t))})),v.init({storefrontPopups:c})},Object.defineProperty(ie.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===o.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.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(ie.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),ie.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,x({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},ie.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=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 n.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]}}))}))},ie.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==o.PRODUCT?[3,2]:[4,Y({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},ie.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var u,h,S,I,D,O,P,C,y,R,L=this;return t(this,(function(b){switch(b.label){case 0:return this.pageType&&![o.BRAND,o.PRODUCT,o.CATEGORY,o.BLOG,o.BLOG_CATEGORY,o.RAFFLE_DETAIL].includes(this.pageType)?[2]:(u=this.pageParams.slug)?(h=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(o.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(o.BLOG_CATEGORY))?[4,te({slug:{eq:u}})]:[3,2]):[2];case 1:return S=b.sent(),(h=(null===(a=S.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(o.RAFFLE_DETAIL))?[4,ee({slug:{eq:u}})]:[3,4];case 3:return S=b.sent(),(h=S.data||[]).length?[3,6]:[2];case 4:return[4,Z({slug:{eq:u}})];case 5:if(S=b.sent(),!(h=S.data||[])||!h.length)return[2];b.label=6;case 6:if(!(I=h[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var e,r,i,a,s,u,d,p,g,f,h,S,D,O,P,C,y,R,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y;return t(this,(function(t){switch(t.label){case 0:return[4,q({input:{productIdList:[I.targetId],priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(F=null===(w=null==e?void 0:e.data)||void 0===w?void 0:w.data)||void 0===F?void 0:F.length)?(r=e.data.data[0]).productOptionSetId?[4,K({id:{eq:r.productOptionSetId}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(G=null==i?void 0:i.data)||void 0===G?void 0:G.length)&&(r.productOptionSet=i.data[0]),t.label=3;case 3:return((null===(V=v.getDomain())||void 0===V?void 0:V.includes("thepurestsolutions"))||(null===(_=process.env.NEXT_PUBLIC_GQL_URL)||void 0===_?void 0:_.includes(".dev"))&&!v.getIsEditor())&&(a=r.variants.find((function(e){return e.isActive})))?(s=!!(null===(U=a.bundleSettings)||void 0===U?void 0:U.products.length),u=[r.id],s&&(null===(j=a.bundleSettings)||void 0===j||j.products.forEach((function(e){u.push(e.productId)}))),[4,H({productId:s?null:r.id,productIds:s?u:null,input:{salesChannelId:v.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:d=t.sent(),(null===(N=d.data)||void 0===N?void 0:N.data)&&d.isSuccess&&(p=d.data.data,g=!!(null===(B=a.bundleSettings)||void 0===B?void 0:B.products.length),f=[r.id],g&&(null===(M=a.bundleSettings)||void 0===M||M.products.forEach((function(e){f.push(e.productId)}))),r.customerReviews=n(n({data:p,count:p.length,limit:10,page:1,initialized:!0},g?{}:{productId:r.id}),g?{productIds:f}:{})),t.label=5;case 5:return(null===(k=r.campaignOffers)||void 0===k?void 0:k.length)?[4,J({id:{in:r.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(h=t.sent()).isSuccess&&(null===(x=h.data)||void 0===x?void 0:x.length)?(S=h.data[0],D=[],O=[],S.offers.forEach((function(e){return D.push(e.productId)})),[4,q({input:{productIdList:D,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})]):[3,8];case 7:(C=t.sent()).isSuccess&&C.data&&S.offers.forEach((function(e){var t,r,i=null===(r=null===(t=C.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return T.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===c.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===l.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&O.push({campaignOfferId:S.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}P||(P={campaignOfferId:S.id,title:e.title,description:e.description})})),r.appliedCampaignOffer=P,r.offers=O,t.label=8;case 8:return r.productGroup?[4,q({input:{productGroupId:r.productGroup.id,productGroupKey:r.productGroup.groupKey,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(y=t.sent()).isSuccess&&(null===(Y=y.data)||void 0===Y?void 0:Y.data)&&(r.productGroupItems=y.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:m.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),t.label=10;case 10:return(R=r.variants.find((function(e){return e.isActive})))?(r.selectedVariantValues=R.variantValues,L=m.getDisplayedVariantTypes,this.pageSpecificData=r,(b=L(this.pageSpecificData,r.selectedVariantValues)).length&&(E=b[0]).displayedVariantValues.length&&(A=E.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=A.variant.variantValues),this.pageType=o.PRODUCT,this.setPageMetaData(I),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,X({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BRAND,this.setPageMetaData(I),[2]):[2]}}))}))},P=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===d.PRODUCT_BRAND})))?[4,X({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(u=i.data)||void 0===u?void 0:u.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=o.CATEGORY,this.setPageMetaData(I),[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG,this.setPageMetaData(I),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:I.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG_CATEGORY,this.setPageMetaData(I),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ne([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=o.RAFFLE_DETAIL,this.setPageMetaData(I),[2]}}))}))},I.targetType){case f.BRAND:return[3,7];case f.CATEGORY:return[3,9];case f.PRODUCT:return[3,11];case g.BLOG:return[3,13];case g.BLOG_CATEGORY:return[3,15];case p.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,b.sent()];case 9:return[4,P()];case 10:return[2,b.sent()];case 11:return[4,D()];case 12:return[2,b.sent()];case 13:return[4,C()];case 14:return[2,b.sent()];case 15:return[4,y()];case 16:return[2,b.sent()];case 17:return[4,R()];case 18:return[2,b.sent()];case 19:return[3,20];case 20:return[2]}}))}))},ie.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},ie.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[h.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case h.TEXT:return[3,1];case h.RICH_TEXT:return[3,2];case h.BOOLEAN:return[3,3];case h.IMAGE:return[3,4];case h.IMAGE_LIST:return[3,5];case h.BRAND:return[3,6];case h.BRAND_LIST:return[3,7];case h.PRODUCT_LIST:return[3,8];case h.PRODUCT_DETAIL:return[3,9];case h.PRODUCT_ATTRIBUTE:return[3,10];case h.PRODUCT_ATTRIBUTE_LIST:return[3,11];case h.CATEGORY:return[3,12];case h.CATEGORY_LIST:return[3,13];case h.LINK:case h.LIST_OF_LINK:return[3,14];case h.COLOR:return[3,15];case h.CUSTOM:return[3,16];case h.COMPONENT:case h.COMPONENT_LIST:return[3,17];case h.BLOG:return[3,19];case h.BLOG_LIST:return[3,20];case h.BLOG_CATEGORY:return[3,21];case h.BLOG_CATEGORY_LIST:return[3,22];case h.RAFFLE:return[3,23];case h.RAFFLE_LIST:return[3,24];case h.SLIDER:return[3,25];case h.VIDEO:return[3,26]}return[3,27];case 1:return e=new y(a),[3,28];case 2:return e=new G(a),[3,28];case 3:return e=new L(a),[3,28];case 4:return e=new b(a),[3,28];case 5:return e=new C(a),[3,28];case 6:return e=new O(a),[3,28];case 7:return e=new D(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new S(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new I(a),[3,28];case 10:return e=new U(a),[3,28];case 11:return e=new j(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new E(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new A(a),[3,28];case 14:return e=new P(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new R(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new w(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new V(a),[3,28];case 20:return e=new _(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new N(a),[3,28];case 22:return e=new B(a),[3,28];case 23:return e=new M(a),[3,28];case 24:return e=new k,[3,28];case 25:return e=new F(a),[3,28];case 26:return e=new re(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},ie.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)},ie.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},ie.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Z({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,te({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ee({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},ie.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=i(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},ie}();export{ie as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import i from"lodash/flatten";import{makeAutoObservable as a}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as s,IkasThemeJsonPageType as o,IkasStorefrontPopupPageFilterDataTypeEnum as u,IkasAmountType as c,IkasCampaignOfferProductApplicablePriceEnum as l,IkasCategoryConditionTypeEnum as d,IkasRaffleMetadataTargetType as p,IkasBlogMetaDataTargetType as g,IkasHTMLMetaDataTargetType as f,IkasThemeJsonComponentPropType as h}from"@ikas/storefront-models";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasProductFunctions as m,IkasProductVariantFunctions as T}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as S}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as I}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as D}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as O}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as P}from"./prop-value/link.js";import{IkasImageListPropValueProvider as C}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as R}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as L}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as b}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as w}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as F}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as G}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as _}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as U}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as j}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as B}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as M}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as k}from"./prop-value/raffle-list.js";import{listMerchantSettings as x,listCustomerReviewSummary as Y,searchProducts as q,listCampaignOffer as J,listCustomerReviews as H,listProductOptionSet as K,listProductBrand as X,listCategory as z,listBlog as Q,listBlogCategory as $,listStorefrontRaffle as W,listHTMLMetaData as Z,listRaffleMetaData as ee,listBlogMetaData as te}from"@ikas/storefront-api";import{populateRaffleProducts as ne}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as re}from"./prop-value/video.js";var ie=function(){function ie(e,t,n,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=n,this.merchantSettings=r,a(this)}return Object.defineProperty(ie.prototype,"page",{get:function(){var e=this;if(this.pageType===o.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===o.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||o.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===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:v.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),ie.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=v.getCurrentRouting();v.getCurrentLocale(),v.getDomain();var n=v.getStorefrontId(),r=v.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=v.getStorefrontPopups(),c=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,h=!1,v=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===s.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case s.ACCOUNT:if(i)return[o.ACCOUNT,o.ORDERS,o.ORDER_DETAIL,o.FAVORITE_PRODUCTS,o.ADDRESSES,o.RAFFLE_ACCOUNT].includes(i);case s.LOGIN:return i===o.LOGIN;case s.REGISTER:return i===o.REGISTER;case s.CART:return i===o.CART;case s.CATEGORY:return i===o.CATEGORY;case s.HOME:return i===o.INDEX;case s.PRODUCT:return i===o.PRODUCT;case s.PRODUCT_BRAND:return i===o.BRAND;case s.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case s.CATEGORY:case s.PRODUCT:case s.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===u.ID_LIST&&T&&(g=S.value.includes(T),v=!0);break;case s.CUSTOM:g=!0;break;default:v=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,v=!0)}else g=!0,v=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(h=!0)}}else h=!0;g&&f&&h&&(t.isFilteredOnServerSide=v,c.push(t))})),v.init({storefrontPopups:c})},Object.defineProperty(ie.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===o.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.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(ie.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),ie.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,x({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},ie.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=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 n.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]}}))}))},ie.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==o.PRODUCT?[3,2]:[4,Y({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},ie.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var u,h,S,I,D,O,P,C,R,y,L=this;return t(this,(function(b){switch(b.label){case 0:return this.pageType&&![o.BRAND,o.PRODUCT,o.CATEGORY,o.BLOG,o.BLOG_CATEGORY,o.RAFFLE_DETAIL].includes(this.pageType)?[2]:(u=this.pageParams.slug)?(h=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(o.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(o.BLOG_CATEGORY))?[4,te({slug:{eq:u}})]:[3,2]):[2];case 1:return S=b.sent(),(h=(null===(a=S.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(o.RAFFLE_DETAIL))?[4,ee({slug:{eq:u}})]:[3,4];case 3:return S=b.sent(),(h=S.data||[]).length?[3,6]:[2];case 4:return[4,Z({slug:{eq:u}})];case 5:if(S=b.sent(),!(h=S.data||[])||!h.length)return[2];b.label=6;case 6:if(!(I=h[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var e,r,i,a,s,u,d,p,g,f,h,S,D,O,P,C,R,y,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y,X,z,Q,$,W,Z,ee;return t(this,(function(t){switch(t.label){case 0:return[4,q({input:{productIdList:[I.targetId],priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(B=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.data)||void 0===B?void 0:B.length)?(r=v.getCurrentRouting(),i=v.getRoutings(),a=i.find((function(e){return null===e.path})),s=null==r?void 0:r.path,(u=e.data.data[0]).productOptionSetId?[4,K({id:{eq:u.productOptionSetId}})]:[3,3]):[2];case 2:(d=t.sent()).isSuccess&&(null===(M=null==d?void 0:d.data)||void 0===M?void 0:M.length)&&(u.productOptionSet=d.data[0]),t.label=3;case 3:return((null===(k=v.getDomain())||void 0===k?void 0:k.includes("thepurestsolutions"))||(null===(x=process.env.NEXT_PUBLIC_GQL_URL)||void 0===x?void 0:x.includes(".dev"))&&!v.getIsEditor())&&(p=u.variants.find((function(e){return e.isActive})))?(g=!!(null===(Y=p.bundleSettings)||void 0===Y?void 0:Y.products.length),f=[u.id],g&&(null===(X=p.bundleSettings)||void 0===X||X.products.forEach((function(e){f.push(e.productId)}))),[4,H({productId:g?null:u.id,productIds:g?f:null,input:{salesChannelId:v.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:h=t.sent(),(null===(z=h.data)||void 0===z?void 0:z.data)&&h.isSuccess&&(S=h.data.data,D=!!(null===(Q=p.bundleSettings)||void 0===Q?void 0:Q.products.length),O=[u.id],D&&(null===($=p.bundleSettings)||void 0===$||$.products.forEach((function(e){O.push(e.productId)}))),u.customerReviews=n(n({data:S,count:S.length,limit:10,page:1,initialized:!0},D?{}:{productId:u.id}),D?{productIds:O}:{})),t.label=5;case 5:return(null===(W=u.campaignOffers)||void 0===W?void 0:W.length)?[4,J({id:{in:u.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(P=t.sent()).isSuccess&&(null===(Z=P.data)||void 0===Z?void 0:Z.length)?(C=P.data[0],R=[],y=[],C.offers.forEach((function(e){return R.push(e.productId)})),[4,q({input:{productIdList:R,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})]):[3,8];case 7:(b=t.sent()).isSuccess&&b.data&&C.offers.forEach((function(e){var t,r,i=null===(r=null===(t=b.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return T.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===c.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===l.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&y.push({campaignOfferId:C.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}L||(L={campaignOfferId:C.id,title:e.title,description:e.description})})),u.appliedCampaignOffer=L,u.offers=y,t.label=8;case 8:return u.productGroup?[4,q({input:{productGroupId:u.productGroup.id,productGroupKey:u.productGroup.groupKey,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(E=t.sent()).isSuccess&&(null===(ee=E.data)||void 0===ee?void 0:ee.data)&&(u.productGroupItems=E.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:m.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),t.label=10;case 10:return(A=u.variants.find((function(e){return e.isActive})))?(u.selectedVariantValues=A.variantValues,w=m.getDisplayedVariantTypes,this.pageSpecificData=u,(F=w(this.pageSpecificData,u.selectedVariantValues)).length&&(G=F[0]).displayedVariantValues.length&&(V=G.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=V.variant.variantValues),this.pageType=o.PRODUCT,_=I,U=a&&a.locale===(null==r?void 0:r.locale),_&&(null==_?void 0:_.translations)&&!U&&(j=null==_?void 0:_.translations.find((function(e){return e.locale===s})),_.pageTitle=(null==j?void 0:j.pageTitle)||null,_.description=(null==j?void 0:j.description)||null),this.setPageMetaData(_),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,X({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BRAND,this.setPageMetaData(I),[2]):[2]}}))}))},P=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===d.PRODUCT_BRAND})))?[4,X({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(u=i.data)||void 0===u?void 0:u.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=o.CATEGORY,this.setPageMetaData(I),[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG,this.setPageMetaData(I),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:I.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG_CATEGORY,this.setPageMetaData(I),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ne([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=o.RAFFLE_DETAIL,this.setPageMetaData(I),[2]}}))}))},I.targetType){case f.BRAND:return[3,7];case f.CATEGORY:return[3,9];case f.PRODUCT:return[3,11];case g.BLOG:return[3,13];case g.BLOG_CATEGORY:return[3,15];case p.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,b.sent()];case 9:return[4,P()];case 10:return[2,b.sent()];case 11:return[4,D()];case 12:return[2,b.sent()];case 13:return[4,C()];case 14:return[2,b.sent()];case 15:return[4,R()];case 16:return[2,b.sent()];case 17:return[4,y()];case 18:return[2,b.sent()];case 19:return[3,20];case 20:return[2]}}))}))},ie.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},ie.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[h.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case h.TEXT:return[3,1];case h.RICH_TEXT:return[3,2];case h.BOOLEAN:return[3,3];case h.IMAGE:return[3,4];case h.IMAGE_LIST:return[3,5];case h.BRAND:return[3,6];case h.BRAND_LIST:return[3,7];case h.PRODUCT_LIST:return[3,8];case h.PRODUCT_DETAIL:return[3,9];case h.PRODUCT_ATTRIBUTE:return[3,10];case h.PRODUCT_ATTRIBUTE_LIST:return[3,11];case h.CATEGORY:return[3,12];case h.CATEGORY_LIST:return[3,13];case h.LINK:case h.LIST_OF_LINK:return[3,14];case h.COLOR:return[3,15];case h.CUSTOM:return[3,16];case h.COMPONENT:case h.COMPONENT_LIST:return[3,17];case h.BLOG:return[3,19];case h.BLOG_LIST:return[3,20];case h.BLOG_CATEGORY:return[3,21];case h.BLOG_CATEGORY_LIST:return[3,22];case h.RAFFLE:return[3,23];case h.RAFFLE_LIST:return[3,24];case h.SLIDER:return[3,25];case h.VIDEO:return[3,26]}return[3,27];case 1:return e=new R(a),[3,28];case 2:return e=new G(a),[3,28];case 3:return e=new L(a),[3,28];case 4:return e=new b(a),[3,28];case 5:return e=new C(a),[3,28];case 6:return e=new O(a),[3,28];case 7:return e=new D(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new S(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new I(a),[3,28];case 10:return e=new U(a),[3,28];case 11:return e=new j(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new E(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new A(a),[3,28];case 14:return e=new P(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new y(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new w(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new V(a),[3,28];case 20:return e=new _(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new N(a),[3,28];case 22:return e=new B(a),[3,28];case 23:return e=new M(a),[3,28];case 24:return e=new k,[3,28];case 25:return e=new F(a),[3,28];case 26:return e=new re(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},ie.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)},ie.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},ie.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Z({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,te({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ee({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},ie.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=i(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},ie}();export{ie as IkasPageDataProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "5.0.24",
3
+ "version": "5.0.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": "^5.0.24",
21
- "@ikas/storefront-config": "^5.0.24",
22
- "@ikas/storefront-model-functions": "^5.0.24",
23
- "@ikas/storefront-models": "^5.0.24",
20
+ "@ikas/storefront-api": "^5.0.25",
21
+ "@ikas/storefront-config": "^5.0.25",
22
+ "@ikas/storefront-model-functions": "^5.0.25",
23
+ "@ikas/storefront-models": "^5.0.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": "^5.0.24",
42
- "@ikas/storefront-config": "^5.0.24",
43
- "@ikas/storefront-model-functions": "^5.0.24",
44
- "@ikas/storefront-models": "^5.0.24",
41
+ "@ikas/storefront-api": "^5.0.25",
42
+ "@ikas/storefront-config": "^5.0.25",
43
+ "@ikas/storefront-model-functions": "^5.0.25",
44
+ "@ikas/storefront-models": "^5.0.25",
45
45
  "lodash": "^4.17.21"
46
46
  }
47
47
  }